ChibiOS/HAL  6.1.0
hal_qspi_lld.c
Go to the documentation of this file.
1 /*
2  ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
17 /**
18  * @file hal_qspi_lld.c
19  * @brief PLATFORM QSPI subsystem low level driver source.
20  *
21  * @addtogroup QSPI
22  * @{
23  */
24 
25 #include "hal.h"
26 
27 #if (HAL_USE_QSPI == TRUE) || defined(__DOXYGEN__)
28 
29 /*===========================================================================*/
30 /* Driver local definitions. */
31 /*===========================================================================*/
32 
33 /*===========================================================================*/
34 /* Driver exported variables. */
35 /*===========================================================================*/
36 
37 /** @brief QSPID1 driver identifier.*/
38 #if (PLATFORM_QSPI_USE_QSPI1 == TRUE) || defined(__DOXYGEN__)
40 #endif
41 
42 /*===========================================================================*/
43 /* Driver local variables and types. */
44 /*===========================================================================*/
45 
46 /*===========================================================================*/
47 /* Driver local functions. */
48 /*===========================================================================*/
49 
50 /*===========================================================================*/
51 /* Driver interrupt handlers. */
52 /*===========================================================================*/
53 
54 /*===========================================================================*/
55 /* Driver exported functions. */
56 /*===========================================================================*/
57 
58 /**
59  * @brief Low level QSPI driver initialization.
60  *
61  * @notapi
62  */
63 void qspi_lld_init(void) {
64 
65 #if PLATFORM_QSPI_USE_QSPI1
66  qspiObjectInit(&QSPID1);
67 #endif
68 }
69 
70 /**
71  * @brief Configures and activates the QSPI peripheral.
72  *
73  * @param[in] qspip pointer to the @p QSPIDriver object
74  *
75  * @notapi
76  */
77 void qspi_lld_start(QSPIDriver *qspip) {
78 
79  /* If in stopped state then full initialization.*/
80  if (qspip->state == QSPI_STOP) {
81 #if PLATFORM_QSPI_USE_QSPI1
82  if (&QSPID1 == qspip) {
83  }
84 #endif
85 
86  /* Common initializations.*/
87  }
88 
89  /* QSPI setup and enable.*/
90 }
91 
92 /**
93  * @brief Deactivates the QSPI peripheral.
94  *
95  * @param[in] qspip pointer to the @p QSPIDriver object
96  *
97  * @notapi
98  */
99 void qspi_lld_stop(QSPIDriver *qspip) {
100 
101  /* If in ready state then disables QSPI.*/
102  if (qspip->state == QSPI_READY) {
103 
104  /* QSPI disable.*/
105 
106  /* Stopping involved clocks.*/
107 #if PLATFORM_QSPI_USE_QSPI1
108  if (&QSPID1 == qspip) {
109  }
110 #endif
111  }
112 }
113 
114 /**
115  * @brief Sends a command without data phase.
116  * @post At the end of the operation the configured callback is invoked.
117  *
118  * @param[in] qspip pointer to the @p QSPIDriver object
119  * @param[in] cmdp pointer to the command descriptor
120  *
121  * @notapi
122  */
123 void qspi_lld_command(QSPIDriver *qspip, const qspi_command_t *cmdp) {
124 
125  (void)qspip;
126  (void)cmdp;
127 }
128 
129 /**
130  * @brief Sends a command with data over the QSPI bus.
131  * @post At the end of the operation the configured callback is invoked.
132  *
133  * @param[in] qspip pointer to the @p QSPIDriver object
134  * @param[in] cmdp pointer to the command descriptor
135  * @param[in] n number of bytes to send
136  * @param[in] txbuf the pointer to the transmit buffer
137  *
138  * @notapi
139  */
140 void qspi_lld_send(QSPIDriver *qspip, const qspi_command_t *cmdp,
141  size_t n, const uint8_t *txbuf) {
142 
143  (void)qspip;
144  (void)cmdp;
145  (void)n;
146  (void)txbuf;
147 }
148 
149 /**
150  * @brief Sends a command then receives data over the QSPI bus.
151  * @post At the end of the operation the configured callback is invoked.
152  *
153  * @param[in] qspip pointer to the @p QSPIDriver object
154  * @param[in] cmdp pointer to the command descriptor
155  * @param[in] n number of bytes to send
156  * @param[out] rxbuf the pointer to the receive buffer
157  *
158  * @notapi
159  */
160 void qspi_lld_receive(QSPIDriver *qspip, const qspi_command_t *cmdp,
161  size_t n, uint8_t *rxbuf) {
162 
163  (void)qspip;
164  (void)cmdp;
165  (void)n;
166  (void)rxbuf;
167 }
168 
169 #if (QSPI_SUPPORTS_MEMMAP == TRUE) || defined(__DOXYGEN__)
170 /**
171  * @brief Maps in memory space a QSPI flash device.
172  * @pre The memory flash device must be initialized appropriately
173  * before mapping it in memory space.
174  *
175  * @param[in] qspip pointer to the @p QSPIDriver object
176  * @param[in] cmdp pointer to the command descriptor
177  * @param[out] addrp pointer to the memory start address of the mapped
178  * flash or @p NULL
179  *
180  * @notapi
181  */
183  const qspi_command_t *cmdp,
184  uint8_t **addrp) {
185 
186  (void)qspip;
187  (void)cmdp;
188  (void)addrp;
189 }
190 
191 /**
192  * @brief Unmaps from memory space a QSPI flash device.
193  * @post The memory flash device must be re-initialized for normal
194  * commands exchange.
195  *
196  * @param[in] qspip pointer to the @p QSPIDriver object
197  *
198  * @notapi
199  */
201 
202  (void)qspip;
203 }
204 #endif /* QSPI_SUPPORTS_MEMMAP == TRUE */
205 
206 #endif /* HAL_USE_QSPI */
207 
208 /** @} */
qspistate_t state
Driver state.
Definition: hal_qspi_lld.h:98
void qspi_lld_unmap_flash(QSPIDriver *qspip)
Unmaps from memory space a QSPI flash device.
Definition: hal_qspi_lld.c:200
void qspi_lld_receive(QSPIDriver *qspip, const qspi_command_t *cmdp, size_t n, uint8_t *rxbuf)
Sends a command then receives data over the QSPI bus.
Definition: hal_qspi_lld.c:160
void qspiObjectInit(QSPIDriver *qspip)
Initializes the standard part of a QSPIDriver structure.
Definition: hal_qspi.c:68
HAL subsystem header.
void qspi_lld_send(QSPIDriver *qspip, const qspi_command_t *cmdp, size_t n, const uint8_t *txbuf)
Sends a command with data over the QSPI bus.
Definition: hal_qspi_lld.c:140
void qspi_lld_command(QSPIDriver *qspip, const qspi_command_t *cmdp)
Sends a command without data phase.
Definition: hal_qspi_lld.c:123
void qspi_lld_init(void)
Low level QSPI driver initialization.
Definition: hal_qspi_lld.c:63
void qspi_lld_map_flash(QSPIDriver *qspip, const qspi_command_t *cmdp, uint8_t **addrp)
Maps in memory space a QSPI flash device.
Definition: hal_qspi_lld.c:182
void qspi_lld_start(QSPIDriver *qspip)
Configures and activates the QSPI peripheral.
Definition: hal_qspi_lld.c:77
Structure representing an QSPI driver.
Definition: hal_qspi_lld.h:94
void qspi_lld_stop(QSPIDriver *qspip)
Deactivates the QSPI peripheral.
Definition: hal_qspi_lld.c:99
QSPIDriver QSPID1
QSPID1 driver identifier.
Definition: hal_qspi_lld.c:39
Type of a QSPI command descriptor.
Definition: hal_qspi.h:125