gr55xx_hal_qspi.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file gr55xx_hal_qspi.h
5  * @author BLE Driver Team
6  * @brief Header file containing functions prototypes of QSPI HAL library.
7  *
8  ****************************************************************************************
9  * @attention
10  #####Copyright (c) 2019 GOODIX
11  All rights reserved.
12 
13  Redistribution and use in source and binary forms, with or without
14  modification, are permitted provided that the following conditions are met:
15  * Redistributions of source code must retain the above copyright
16  notice, this list of conditions and the following disclaimer.
17  * Redistributions in binary form must reproduce the above copyright
18  notice, this list of conditions and the following disclaimer in the
19  documentation and/or other materials provided with the distribution.
20  * Neither the name of GOODIX nor the names of its contributors may be used
21  to endorse or promote products derived from this software without
22  specific prior written permission.
23 
24  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  POSSIBILITY OF SUCH DAMAGE.
35  ****************************************************************************************
36  */
37 
38 /** @addtogroup PERIPHERAL Peripheral Driver
39  * @{
40  */
41 
42 /** @addtogroup HAL_DRIVER HAL Driver
43  * @{
44  */
45 
46 /** @defgroup HAL_QSPI QSPI
47  * @brief QSPI HAL module driver.
48  * @{
49  */
50 
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55xx_HAL_QSPI_H__
53 #define __GR55xx_HAL_QSPI_H__
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx_ll_spi.h"
61 #include "gr55xx_hal_def.h"
62 
63 /* Exported types ------------------------------------------------------------*/
64 /** @addtogroup HAL_QSPI_ENUMERATIONS Enumerations
65  * @{
66  */
67 
68 /** @defgroup HAL_QSPI_state HAL QSPI state
69  * @{
70  */
71 
72 /**
73  * @brief HAL QSPI State Enumerations definition
74  */
75 typedef enum
76 {
77  HAL_QSPI_STATE_RESET = 0x00, /**< Peripheral not initialized */
78  HAL_QSPI_STATE_READY = 0x01, /**< Peripheral initialized and ready for use */
79  HAL_QSPI_STATE_BUSY = 0x02, /**< Peripheral in indirect mode and busy */
80  HAL_QSPI_STATE_BUSY_INDIRECT_TX = 0x12, /**< Peripheral in indirect mode with transmission ongoing */
81  HAL_QSPI_STATE_BUSY_INDIRECT_RX = 0x22, /**< Peripheral in indirect mode with reception ongoing */
82  HAL_QSPI_STATE_ABORT = 0x08, /**< Peripheral with abort request ongoing */
83  HAL_QSPI_STATE_ERROR = 0x04 /**< Peripheral in error */
84 
86 
87 /** @} */
88 
89 /** @} */
90 
91 /** @addtogroup HAL_QSPI_STRUCTURES Structures
92  * @{
93  */
94 
95 /** @defgroup QSPI_Configuration QSPI Configuration
96  * @{
97  */
98 
99 /**
100  * @brief QSPI init Structure definition
101  */
102 typedef struct _qspi_init_t
103 {
104  uint32_t clock_prescaler; /**< Specifies the prescaler factor for generating clock based on the AHB clock.
105  This parameter can be a number between 0 and 0xFFFF */
106 
107  uint32_t clock_mode; /**< Specifies the Clock Mode. It indicates the level that clock takes between commands.
108  This parameter can be a value of @ref QSPI_Clock_Mode */
109 
110  uint32_t rx_sample_delay; /**< Specifies the RX sample delay. It is used to delay the sample of the RX input port.
111  This parameter can be a number between 0 and 0x7 */
113 /** @} */
114 
115 /** @defgroup QSPI_handle QSPI handle
116  * @{
117  */
118 
119 /**
120  * @brief QSPI handle Structure definition
121  */
122 typedef struct _qspi_handle
123 {
124  ssi_regs_t *p_instance; /**< QSPI registers base address */
125 
126  qspi_init_t init; /**< QSPI communication parameters */
127 
128  uint8_t *p_tx_buffer; /**< Pointer to QSPI Tx transfer Buffer */
129 
130  __IO uint32_t tx_xfer_size; /**< QSPI Tx Transfer size */
131 
132  __IO uint32_t tx_xfer_count; /**< QSPI Tx Transfer Counter */
133 
134  uint8_t *p_rx_buffer; /**< Pointer to QSPI Rx transfer Buffer */
135 
136  __IO uint32_t rx_xfer_size; /**< QSPI Rx Transfer size */
137 
138  __IO uint32_t rx_xfer_count; /**< QSPI Rx Transfer Counter */
139 
140  void (*write_fifo)(struct _qspi_handle *p_qspi); /**< Pointer to QSPI Tx transfer FIFO write function */
141 
142  void (*read_fifo)(struct _qspi_handle *p_qspi); /**< Pointer to QSPI Rx transfer FIFO read function */
143 
144  dma_handle_t *p_dma; /**< QSPI Rx/Tx DMA Handle parameters */
145 
146  __IO hal_lock_t lock; /**< Locking object */
147 
148  __IO hal_qspi_state_t state; /**< QSPI communication state */
149 
150  __IO uint32_t error_code; /**< QSPI Error code */
151 
152  uint32_t timeout; /**< Timeout for the QSPI memory access */
153 
154  uint32_t retention[9]; /**< DMA important register information. */
156 /** @} */
157 
158 /** @defgroup QSPI_Command QSPI command
159  * @{
160  */
161 
162 /**
163  * @brief QSPI command Structure definition
164  */
165 typedef struct _qspi_command_t
166 {
167  uint32_t instruction; /**< Specifies the Instruction to be sent.
168  This parameter can be a value (8-bit) between 0x00 and 0xFF. */
169 
170  uint32_t address; /**< Specifies the Address to be sent (Size from 1 to 4 bytes according AddressSize).
171  This parameter can be a value (32-bits) between 0x0 and 0xFFFFFFFF. */
172 
173  uint32_t instruction_size; /**< Specifies the Instruction Size.
174  This parameter can be a value of @ref QSPI_Instruction_Size. */
175 
176  uint32_t address_size; /**< Specifies the Address Size.
177  This parameter can be a value of @ref QSPI_Address_Size. */
178 
179  uint32_t dummy_cycles; /**< Specifies the Number of Dummy Cycles.
180  This parameter can be a number between 0 and 31. */
181 
182  uint32_t data_size; /**< Specifies the QSPI address width.
183  This parameter can be a value of @ref QSPI_Data_Size. */
184 
185  uint32_t instruction_address_mode; /**< Specifies the Instruction and Address Mode.
186  This parameter can be a value of @ref QSPI_Inst_Addr_Mode. */
187 
188  uint32_t data_mode; /**< Specifies the Data Mode (used for dummy cycles and data phases).
189  This parameter can be a value of @ref QSPI_Data_Mode. */
190 
191  uint32_t length; /**< Specifies the number of data to transfer. (This is the number of bytes).
192  This parameter can be any value between 0 and 0xFFFFFFFF (0 means undefined length
193  until end of memory). */
194 
196 /** @} */
197 
198 /** @} */
199 
200 /** @addtogroup HAL_QSPI_CALLBACK_STRUCTURES Callback Structures
201  * @{
202  */
203 
204 /** @defgroup HAL_QSPI_Callback Callback
205  * @{
206  */
207 
208 /**
209  * @brief HAL_QSPI Callback function definition
210  */
211 
212 typedef struct _hal_qspi_callback
213 {
214  void (*qspi_msp_init)(qspi_handle_t *p_qspi); /**< QSPI init MSP callback */
215  void (*qspi_msp_deinit)(qspi_handle_t *p_qspi); /**< QSPI de-init MSP callback */
216  void (*qspi_error_callback)(qspi_handle_t *p_qspi); /**< QSPI error callback */
217  void (*qspi_abort_cplt_callback)(qspi_handle_t *p_qspi); /**< QSPI abort complete callback */
218  void (*qspi_fifo_threshold_callback)(qspi_handle_t *p_qspi); /**< QSPI FIFO threshold callback */
219  void (*qspi_rx_cplt_callback)(qspi_handle_t *p_qspi); /**< QSPI rx transfer completed callback */
220  void (*qspi_tx_cplt_callback)(qspi_handle_t *p_qspi); /**< QSPI tx transfer completed callback */
222 
223 /** @} */
224 
225 /** @} */
226 
227 /**
228  * @defgroup HAL_QSPI_MACRO Defines
229  * @{
230  */
231 
232 /* Exported constants --------------------------------------------------------*/
233 /** @defgroup QSPI_Exported_Constants QSPI Exported Constants
234  * @{
235  */
236 
237 /** @defgroup QSPI_Error_Code QSPI Error Code
238  * @{
239  */
240 #define HAL_QSPI_ERROR_NONE ((uint32_t)0x00000000) /**< No error */
241 #define HAL_QSPI_ERROR_TIMEOUT ((uint32_t)0x00000001) /**< Timeout error */
242 #define HAL_QSPI_ERROR_TRANSFER ((uint32_t)0x00000002) /**< Transfer error */
243 #define HAL_QSPI_ERROR_DMA ((uint32_t)0x00000004) /**< DMA transfer error */
244 #define HAL_QSPI_ERROR_INVALID_PARAM ((uint32_t)0x00000008) /**< Invalid parameter error */
245 /** @} */
246 
247 /** @defgroup QSPI_Clock_Mode QSPI Clock Mode
248  * @{
249  */
250 #define QSPI_CLOCK_MODE_0 (LL_SSI_SCPOL_LOW | LL_SSI_SCPHA_1EDGE) /**< Inactive state of CLK is low;
251  CLK toggles at the start of the first data bit */
252 #define QSPI_CLOCK_MODE_1 (LL_SSI_SCPOL_LOW | LL_SSI_SCPHA_2EDGE) /**< Inactive state of CLK is low;
253  CLK toggles in the middle of the first data bit */
254 #define QSPI_CLOCK_MODE_2 (LL_SSI_SCPOL_HIGH | LL_SSI_SCPHA_1EDGE) /**< Inactive state of CLK is high;
255  CLK toggles at the start of the first data bit */
256 #define QSPI_CLOCK_MODE_3 (LL_SSI_SCPOL_HIGH | LL_SSI_SCPHA_2EDGE) /**< Inactive state of CLK is high;
257  CLK toggles in the middle of the first data bit */
258 /** @} */
259 
260 /** @defgroup QSPI_Data_Mode QSPI Data Mode
261  * @{
262  */
263 #define QSPI_DATA_MODE_SPI LL_SSI_FRF_SPI /**< Standard SPI Frame Format */
264 #define QSPI_DATA_MODE_DUALSPI LL_SSI_FRF_DUALSPI /**< Dual SPI Frame Format */
265 #define QSPI_DATA_MODE_QUADSPI LL_SSI_FRF_QUADSPI /**< Quad SPI Frame Format */
266 /** @} */
267 
268 /** @defgroup QSPI_Instruction_Size QSPI Instruction Size
269  * @{
270  */
271 #define QSPI_INSTSIZE_00_BITS LL_SSI_INSTSIZE_0BIT /**< 0-bit (No Instruction) */
272 #define QSPI_INSTSIZE_04_BITS LL_SSI_INSTSIZE_4BIT /**< 4-bit Instruction */
273 #define QSPI_INSTSIZE_08_BITS LL_SSI_INSTSIZE_8BIT /**< 8-bit Instruction */
274 #define QSPI_INSTSIZE_16_BITS LL_SSI_INSTSIZE_16BIT /**< 16-bit Instruction */
275 /** @} */
276 
277 /** @defgroup QSPI_Address_Size QSPI Address Size
278  * @{
279  */
280 #define QSPI_ADDRSIZE_00_BITS LL_SSI_ADDRSIZE_0BIT /**< 0-bit address */
281 #define QSPI_ADDRSIZE_04_BITS LL_SSI_ADDRSIZE_4BIT /**< 4-bit address */
282 #define QSPI_ADDRSIZE_08_BITS LL_SSI_ADDRSIZE_8BIT /**< 8-bit address */
283 #define QSPI_ADDRSIZE_12_BITS LL_SSI_ADDRSIZE_12BIT /**< 12-bit address */
284 #define QSPI_ADDRSIZE_16_BITS LL_SSI_ADDRSIZE_16BIT /**< 16-bit address */
285 #define QSPI_ADDRSIZE_20_BITS LL_SSI_ADDRSIZE_20BIT /**< 20-bit address */
286 #define QSPI_ADDRSIZE_24_BITS LL_SSI_ADDRSIZE_24BIT /**< 24-bit address */
287 #define QSPI_ADDRSIZE_28_BITS LL_SSI_ADDRSIZE_28BIT /**< 28-bit address */
288 #define QSPI_ADDRSIZE_32_BITS LL_SSI_ADDRSIZE_32BIT /**< 32-bit address */
289 /** @} */
290 
291 /** @defgroup QSPI_Data_Size Data Width
292  * @{
293  */
294 #define QSPI_DATASIZE_04_BITS LL_SSI_DATASIZE_4BIT /**< Data length for SPI transfer: 4 bits */
295 #define QSPI_DATASIZE_05_BITS LL_SSI_DATASIZE_5BIT /**< Data length for SPI transfer: 5 bits */
296 #define QSPI_DATASIZE_06_BITS LL_SSI_DATASIZE_6BIT /**< Data length for SPI transfer: 6 bits */
297 #define QSPI_DATASIZE_07_BITS LL_SSI_DATASIZE_7BIT /**< Data length for SPI transfer: 7 bits */
298 #define QSPI_DATASIZE_08_BITS LL_SSI_DATASIZE_8BIT /**< Data length for SPI transfer: 8 bits */
299 #define QSPI_DATASIZE_09_BITS LL_SSI_DATASIZE_9BIT /**< Data length for SPI transfer: 9 bits */
300 #define QSPI_DATASIZE_10_BITS LL_SSI_DATASIZE_10BIT /**< Data length for SPI transfer: 10 bits */
301 #define QSPI_DATASIZE_11_BITS LL_SSI_DATASIZE_11BIT /**< Data length for SPI transfer: 11 bits */
302 #define QSPI_DATASIZE_12_BITS LL_SSI_DATASIZE_12BIT /**< Data length for SPI transfer: 12 bits */
303 #define QSPI_DATASIZE_13_BITS LL_SSI_DATASIZE_13BIT /**< Data length for SPI transfer: 13 bits */
304 #define QSPI_DATASIZE_14_BITS LL_SSI_DATASIZE_14BIT /**< Data length for SPI transfer: 14 bits */
305 #define QSPI_DATASIZE_15_BITS LL_SSI_DATASIZE_15BIT /**< Data length for SPI transfer: 15 bits */
306 #define QSPI_DATASIZE_16_BITS LL_SSI_DATASIZE_16BIT /**< Data length for SPI transfer: 16 bits */
307 #define QSPI_DATASIZE_17_BITS LL_SSI_DATASIZE_17BIT /**< Data length for SPI transfer: 17 bits */
308 #define QSPI_DATASIZE_18_BITS LL_SSI_DATASIZE_18BIT /**< Data length for SPI transfer: 18 bits */
309 #define QSPI_DATASIZE_19_BITS LL_SSI_DATASIZE_19BIT /**< Data length for SPI transfer: 19 bits */
310 #define QSPI_DATASIZE_20_BITS LL_SSI_DATASIZE_20BIT /**< Data length for SPI transfer: 20 bits */
311 #define QSPI_DATASIZE_21_BITS LL_SSI_DATASIZE_21BIT /**< Data length for SPI transfer: 21 bits */
312 #define QSPI_DATASIZE_22_BITS LL_SSI_DATASIZE_22BIT /**< Data length for SPI transfer: 22 bits */
313 #define QSPI_DATASIZE_23_BITS LL_SSI_DATASIZE_23BIT /**< Data length for SPI transfer: 23 bits */
314 #define QSPI_DATASIZE_24_BITS LL_SSI_DATASIZE_24BIT /**< Data length for SPI transfer: 24 bits */
315 #define QSPI_DATASIZE_25_BITS LL_SSI_DATASIZE_25BIT /**< Data length for SPI transfer: 25 bits */
316 #define QSPI_DATASIZE_26_BITS LL_SSI_DATASIZE_26BIT /**< Data length for SPI transfer: 26 bits */
317 #define QSPI_DATASIZE_27_BITS LL_SSI_DATASIZE_27BIT /**< Data length for SPI transfer: 27 bits */
318 #define QSPI_DATASIZE_28_BITS LL_SSI_DATASIZE_28BIT /**< Data length for SPI transfer: 28 bits */
319 #define QSPI_DATASIZE_29_BITS LL_SSI_DATASIZE_29BIT /**< Data length for SPI transfer: 29 bits */
320 #define QSPI_DATASIZE_30_BITS LL_SSI_DATASIZE_30BIT /**< Data length for SPI transfer: 30 bits */
321 #define QSPI_DATASIZE_31_BITS LL_SSI_DATASIZE_31BIT /**< Data length for SPI transfer: 31 bits */
322 #define QSPI_DATASIZE_32_BITS LL_SSI_DATASIZE_32BIT /**< Data length for SPI transfer: 32 bits */
323 
324 /** @} */
325 
326 
327 /** @defgroup QSPI_Inst_Addr_Mode QSPI Instruction and Address Mode
328  * @{
329  */
330 #define QSPI_INST_ADDR_ALL_IN_SPI LL_SSI_INST_ADDR_ALL_IN_SPI /**< Instruction and address are sent in SPI mode */
331 #define QSPI_INST_IN_SPI_ADDR_IN_SPIFRF LL_SSI_INST_IN_SPI_ADDR_IN_SPIFRF /**< Instruction is sent in SPI mode, and address is sent in Daul/Quad SPI mode */
332 #define QSPI_INST_ADDR_ALL_IN_SPIFRF LL_SSI_INST_ADDR_ALL_IN_SPIFRF /**< Instruction and address are sent in Daul/Quad SPI mode */
333 /** @} */
334 
335 /** @defgroup QSPI_Flags QSPI Flags
336  * @{
337  */
338 #define QSPI_FLAG_DCOL LL_SSI_SR_DCOL /**< Data collision error flag */
339 #define QSPI_FLAG_TXE LL_SSI_SR_TXE /**< Transmission error flag */
340 #define QSPI_FLAG_RFF LL_SSI_SR_RFF /**< Rx FIFO full flag */
341 #define QSPI_FLAG_RFNE LL_SSI_SR_RFNE /**< Rx FIFO not empty flag */
342 #define QSPI_FLAG_TFE LL_SSI_SR_TFE /**< Tx FIFO empty flag */
343 #define QSPI_FLAG_TFNF LL_SSI_SR_TFNF /**< Tx FIFO not full flag */
344 #define QSPI_FLAG_BUSY LL_SSI_SR_BUSY /**< Busy flag */
345 /** @} */
346 
347 /** @defgroup QSPI_Interrupts QSPI Interrupts
348  * @{
349  */
350 #define QSPI_IT_MST LL_SSI_IS_MST /**< Multi-Master Contention Interrupt flag */
351 #define QSPI_IT_RXF LL_SSI_IS_RXF /**< Receive FIFO Full Interrupt flag */
352 #define QSPI_IT_RXO LL_SSI_IS_RXO /**< Receive FIFO Overflow Interrupt flag */
353 #define QSPI_IT_RXU LL_SSI_IS_RXU /**< Receive FIFO Underflow Interrupt flag */
354 #define QSPI_IT_TXO LL_SSI_IS_TXO /**< Transmit FIFO Overflow Interrupt flag */
355 #define QSPI_IT_TXE LL_SSI_IS_TXE /**< Transmit FIFO Empty Interrupt flag */
356 /** @} */
357 
358 /** @defgroup QSPI_Timeout_definition QSPI Timeout_definition
359  * @{
360  */
361 #define HAL_QSPI_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000) /**< 5s */
362 /** @} */
363 
364 /** @} */
365 
366 /* Exported macro ------------------------------------------------------------*/
367 /** @defgroup QSPI_Exported_Macros QSPI Exported Macros
368  * @{
369  */
370 
371 /** @brief Reset QSPI handle states.
372  * @param __HANDLE__ QSPI handle.
373  * @retval None
374  */
375 #define __HAL_QSPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_QSPI_STATE_RESET)
376 
377 /** @brief Enable the specified QSPI peripheral.
378  * @param __HANDLE__ Specifies the QSPI Handle.
379  * @retval None
380  */
381 #define __HAL_QSPI_ENABLE(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->SSI_EN, SSI_SSIEN_EN)
382 
383 /** @brief Disable the specified QSPI peripheral.
384  * @param __HANDLE__ Specifies the QSPI Handle.
385  * @retval None
386  */
387 #define __HAL_QSPI_DISABLE(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->SSI_EN, SSI_SSIEN_EN)
388 
389 /** @brief Enable the QSPI DMA TX Request.
390  * @param __HANDLE__ Specifies the QSPI Handle.
391  * @retval None
392  */
393 #define __HAL_QSPI_ENABLE_DMATX(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->DMAC, SSI_DMAC_TDMAE)
394 
395 /** @brief Enable the QSPI DMA RX Request.
396  * @param __HANDLE__ Specifies the QSPI Handle.
397  * @retval None
398  */
399 #define __HAL_QSPI_ENABLE_DMARX(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->DMAC, SSI_DMAC_RDMAE)
400 
401 /** @brief Disable the QSPI DMA TX Request.
402  * @param __HANDLE__ Specifies the QSPI Handle.
403  * @retval None
404  */
405 #define __HAL_QSPI_DISABLE_DMATX(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->DMAC, SSI_DMAC_TDMAE)
406 
407 /** @brief Disable the QSPI DMA RX Request.
408  * @param __HANDLE__ Specifies the QSPI Handle.
409  * @retval None
410  */
411 #define __HAL_QSPI_DISABLE_DMARX(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->DMAC, SSI_DMAC_RDMAE)
412 
413 /** @brief Enable the specified QSPI interrupts.
414  * @param __HANDLE__ Specifies the QSPI Handle.
415  * @param __INTERRUPT__ Specifies the interrupt source to enable.
416  * This parameter can be one of the following values:
417  * @arg @ref QSPI_IT_MST Multi-Master Contention Interrupt enable
418  * @arg @ref QSPI_IT_RXF Receive FIFO Full Interrupt enable
419  * @arg @ref QSPI_IT_RXO Receive FIFO Overflow Interrupt enable
420  * @arg @ref QSPI_IT_RXU Receive FIFO Underflow Interrupt enable
421  * @arg @ref QSPI_IT_TXO Transmit FIFO Overflow Interrupt enable
422  * @arg @ref QSPI_IT_TXE Transmit FIFO Empty Interrupt enable
423  * @retval None
424  */
425 #define __HAL_QSPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BITS((__HANDLE__)->p_instance->INTMASK, (__INTERRUPT__))
426 
427 /** @brief Disable the specified QSPI interrupts.
428  * @param __HANDLE__ Specifies the QSPI handle.
429  * @param __INTERRUPT__ Specifies the interrupt source to disable.
430  * This parameter can be one of the following values:
431  * @arg @ref QSPI_IT_MST Multi-Master Contention Interrupt enable
432  * @arg @ref QSPI_IT_RXF Receive FIFO Full Interrupt enable
433  * @arg @ref QSPI_IT_RXO Receive FIFO Overflow Interrupt enable
434  * @arg @ref QSPI_IT_RXU Receive FIFO Underflow Interrupt enable
435  * @arg @ref QSPI_IT_TXO Transmit FIFO Overflow Interrupt enable
436  * @arg @ref QSPI_IT_TXE Transmit FIFO Empty Interrupt enable
437  * @retval None
438  */
439 #define __HAL_QSPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BITS((__HANDLE__)->p_instance->INTMASK, (__INTERRUPT__))
440 
441 /** @brief Check whether the specified QSPI interrupt source is enabled or not.
442  * @param __HANDLE__ Specifies the QSPI Handle.
443  * @param __INTERRUPT__ Specifies the interrupt source to check.
444  * This parameter can be one of the following values:
445  * @arg @ref QSPI_IT_MST Multi-Master Contention Interrupt enable
446  * @arg @ref QSPI_IT_RXF Receive FIFO Full Interrupt enable
447  * @arg @ref QSPI_IT_RXO Receive FIFO Overflow Interrupt enable
448  * @arg @ref QSPI_IT_RXU Receive FIFO Underflow Interrupt enable
449  * @arg @ref QSPI_IT_TXO Transmit FIFO Overflow Interrupt enable
450  * @arg @ref QSPI_IT_TXE Transmit FIFO Empty Interrupt enable
451  * @retval The new state of __IT__ (TRUE or FALSE).
452  */
453 #define __HAL_QSPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (READ_BITS((__HANDLE__)->p_instance->INTSTAT, (__INTERRUPT__)) == (__INTERRUPT__))
454 
455 /** @brief Check whether the specified QSPI flag is set or not.
456  * @param __HANDLE__ Specifies the QSPI Handle.
457  * @param __FLAG__ Specifies the flag to check.
458  * This parameter can be one of the following values:
459  * @arg @ref QSPI_FLAG_DCOL Data collision error flag
460  * @arg @ref QSPI_FLAG_TXE Transmission error flag
461  * @arg @ref QSPI_FLAG_RFF Rx FIFO full flag
462  * @arg @ref QSPI_FLAG_RFNE Rx FIFO not empty flag
463  * @arg @ref QSPI_FLAG_TFE Tx FIFO empty flag
464  * @arg @ref QSPI_FLAG_TFNF Tx FIFO not full flag
465  * @arg @ref QSPI_FLAG_BUSY Busy flag
466  * @retval The new state of __FLAG__ (TRUE or FALSE).
467  */
468 #define __HAL_QSPI_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BITS((__HANDLE__)->p_instance->STAT, (__FLAG__)) != 0) ? SET : RESET)
469 
470 /** @brief Clear the specified QSPI flag.
471  * @param __HANDLE__ Specifies the QSPI Handle.
472  * @param __FLAG__ Specifies the flag to clear.
473  * This parameter can be one of the following values:
474  * @arg @ref QSPI_FLAG_DCOL Data collision error flag
475  * @arg @ref QSPI_FLAG_TXE Transmission error flag
476  * @arg @ref QSPI_FLAG_RFF Rx FIFO full flag
477  * @arg @ref QSPI_FLAG_RFNE Rx FIFO not empty flag
478  * @arg @ref QSPI_FLAG_TFE Tx FIFO empty flag
479  * @arg @ref QSPI_FLAG_TFNF Tx FIFO not full flag
480  * @arg @ref QSPI_FLAG_BUSY Busy flag
481  * @retval None
482  */
483 #define __HAL_QSPI_CLEAR_FLAG(__HANDLE__, __FLAG__) READ_BITS((__HANDLE__)->p_instance->STAT, (__FLAG__))
484 
485 /** @} */
486 
487 /* Private macros ------------------------------------------------------------*/
488 /** @defgroup QSPI_Private_Macro QSPI Private Macros
489  * @{
490  */
491 
492 /** @brief Check if QSPI Clock Prescaler is valid.
493  * @param __PRESCALER__ QSPI Clock Prescaler.
494  * @retval SET (__PRESCALER__ is valid) or RESET (__PRESCALER__ is invalid)
495  */
496 #define IS_QSPI_CLOCK_PRESCALER(__PRESCALER__) ((__PRESCALER__) <= 0xFFFF)
497 
498 /** @brief Check if QSPI FIFO Threshold is valid.
499  * @param __THR__ QSPI FIFO Threshold.
500  * @retval SET (__THR__ is valid) or RESET (__THR__ is invalid)
501  */
502 #define IS_QSPI_FIFO_THRESHOLD(__THR__) (((__THR__) >= 0) && ((__THR__) <= 7))
503 
504 /** @brief Check if QSPI Clock Mode is valid.
505  * @param __CLKMODE__ QSPI Clock Mode.
506  * @retval SET (__CLKMODE__ is valid) or RESET (__CLKMODE__ is invalid)
507  */
508 #define IS_QSPI_CLOCK_MODE(__CLKMODE__) (((__CLKMODE__) == QSPI_CLOCK_MODE_0) || \
509  ((__CLKMODE__) == QSPI_CLOCK_MODE_1) || \
510  ((__CLKMODE__) == QSPI_CLOCK_MODE_2) || \
511  ((__CLKMODE__) == QSPI_CLOCK_MODE_3))
512 
513 /** @brief Check if QSPI Instruction Size is valid.
514  * @param __INST_SIZE__ QSPI Instruction Size.
515  * @retval SET (__INST_SIZE__ is valid) or RESET (__INST_SIZE__ is invalid)
516  */
517 #define IS_QSPI_INSTRUCTION_SIZE(__INST_SIZE__) (((__INST_SIZE__) == QSPI_INSTSIZE_00_BITS) || \
518  ((__INST_SIZE__) == QSPI_INSTSIZE_04_BITS) || \
519  ((__INST_SIZE__) == QSPI_INSTSIZE_08_BITS) || \
520  ((__INST_SIZE__) == QSPI_INSTSIZE_16_BITS))
521 
522 /** @brief Check if QSPI Address Size is valid.
523  * @param __ADDR_SIZE__ QSPI Address Size .
524  * @retval SET (__ADDR_SIZE__ is valid) or RESET (__ADDR_SIZE__ is invalid)
525  */
526 #define IS_QSPI_ADDRESS_SIZE(__ADDR_SIZE__) (((__ADDR_SIZE__) == QSPI_ADDRSIZE_00_BITS) || \
527  ((__ADDR_SIZE__) == QSPI_ADDRSIZE_04_BITS) || \
528  ((__ADDR_SIZE__) == QSPI_ADDRSIZE_08_BITS) || \
529  ((__ADDR_SIZE__) == QSPI_ADDRSIZE_12_BITS) || \
530  ((__ADDR_SIZE__) == QSPI_ADDRSIZE_16_BITS) || \
531  ((__ADDR_SIZE__) == QSPI_ADDRSIZE_20_BITS) || \
532  ((__ADDR_SIZE__) == QSPI_ADDRSIZE_24_BITS) || \
533  ((__ADDR_SIZE__) == QSPI_ADDRSIZE_28_BITS) || \
534  ((__ADDR_SIZE__) == QSPI_ADDRSIZE_32_BITS))
535 
536 /** @brief Check if QSPI Dummy Cycle is valid.
537  * @param __DCY__ QSPI Dummy Cycle.
538  * @retval SET (__DCY__ is valid) or RESET (__DCY__ is invalid)
539  */
540 #define IS_QSPI_DUMMY_CYCLES(__DCY__) ((__DCY__) <= 31)
541 
542 /** @brief Check if QSPI Instruction and Address Mode is valid.
543  * @param __MODE__ QSPI Instruction and Address Mode.
544  * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
545  */
546 #define IS_QSPI_INSTADDR_MODE(__MODE__) (((__MODE__) == QSPI_INST_ADDR_ALL_IN_SPI) || \
547  ((__MODE__) == QSPI_INST_IN_SPI_ADDR_IN_SPIFRF) || \
548  ((__MODE__) == QSPI_INST_ADDR_ALL_IN_SPIFRF))
549 
550 /** @brief Check if QSPI Data Mode is valid.
551  * @param __MODE__ QSPI Data Mode.
552  * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
553  */
554 #define IS_QSPI_DATA_MODE(__MODE__) (((__MODE__) == QSPI_DATA_MODE_SPI) || \
555  ((__MODE__) == QSPI_DATA_MODE_DUALSPI) || \
556  ((__MODE__) == QSPI_DATA_MODE_QUADSPI))
557 
558 /** @} */
559 
560 /** @} */
561 
562 
563 /* Exported functions --------------------------------------------------------*/
564 /** @addtogroup HAL_QSPI_DRIVER_FUNCTIONS Functions
565  * @{
566  */
567 
568 /** @defgroup QSPI_Exported_Functions_Group1 Initialization and de-initialization functions
569  * @brief Initialization and de-initialization functions
570  *
571 @verbatim
572  ===============================================================================
573  ##### Initialization and de-initialization functions #####
574  ===============================================================================
575  [..] This subsection provides a set of functions allowing to initialize and
576  de-initialize the QSPIx peripheral:
577 
578  (+) User must implement hal_qspi_msp_init() function in which he configures
579  all related peripherals resources (GPIO, DMA, IT and NVIC ).
580 
581  (+) Call the function hal_qspi_init() to configure the selected device with
582  the selected configuration:
583  (++) Clock Prescaler
584  (++) Clock Mode
585 
586  (+) Call the function hal_qspi_deinit() to restore the default configuration
587  of the selected QSPIx peripheral.
588 
589 @endverbatim
590  * @{
591  */
592 
593 /**
594  ****************************************************************************************
595  * @brief Initialize the QSPI according to the specified parameters
596  * in the qspi_init_t and initialize the associated handle.
597  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
598  * @retval ::HAL_OK: Operation is OK.
599  * @retval ::HAL_ERROR: Parameter error or operation not supported.
600  * @retval ::HAL_BUSY: Driver is busy.
601  * @retval ::HAL_TIMEOUT: Timeout occurred.
602  ****************************************************************************************
603  */
605 
606 /**
607  ****************************************************************************************
608  * @brief De-initialize the QSPI peripheral.
609  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
610  * @retval ::HAL_OK: Operation is OK.
611  * @retval ::HAL_ERROR: Parameter error or operation not supported.
612  * @retval ::HAL_BUSY: Driver is busy.
613  * @retval ::HAL_TIMEOUT: Timeout occurred.
614  ****************************************************************************************
615  */
617 
618 /**
619  ****************************************************************************************
620  * @brief Initialize the QSPI MSP.
621  * @note This function should not be modified. When the callback is needed,
622  * the hal_qspi_msp_deinit can be implemented in the user file.
623  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
624  ****************************************************************************************
625  */
627 
628 /**
629  ****************************************************************************************
630  * @brief De-initialize the QSPI MSP.
631  * @note This function should not be modified. When the callback is needed,
632  * the hal_qspi_msp_deinit can be implemented in the user file.
633  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
634  ****************************************************************************************
635  */
637 
638 /** @} */
639 
640 /** @defgroup QSPI_Exported_Functions_Group2 IO operation functions
641  * @brief Data transfers functions
642  *
643 @verbatim
644  ==============================================================================
645  ##### IO operation functions #####
646  ===============================================================================
647  [..]
648  This subsection provides a set of functions allowing to manage the QSPI
649  data transfers.
650 
651  [..] The QSPI supports master and slave mode:
652 
653  (#) There are two modes of transfer:
654  (++) Blocking mode: The communication is performed in polling mode.
655  The HAL status of all data processing is returned by the same function
656  after finishing transfer.
657  (++) No-Blocking mode: The communication is performed using Interrupts.
658  or DMA, These APIs return the HAL status.
659  The end of the data processing will be indicated through the
660  dedicated QSPI IRQ when using Interrupt mode or the DMA IRQ when
661  using DMA mode.
662  The hal_qspi_tx_cplt_callback(), hal_qspi_rx_cplt_callback() and hal_qspi_txrx_cplt_callback() user callbacks
663  will be executed respectively at the end of the transmit or Receive process.
664  The hal_qspi_error_callback() user callback will be executed when a communication error is detected
665 
666  (#) APIs provided for these 2 transfer modes (Blocking mode or Non blocking mode using either Interrupt or DMA)
667  exist for 1 Line (simplex) and 2 Lines (full duplex) modes.
668 
669 @endverbatim
670  * @{
671  */
672 
673 /**
674  ****************************************************************************************
675  * @brief Transmit an amount of data with the specified instruction and address in blocking mode.
676  * @note This function is used only in Indirect Write Mode. Dummy cycles in command will be ignored.
677  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
678  * @param[in] p_cmd: Pointer to a qspi_command_t structure that contains the instruction and address for data transfer.
679  * @param[in] p_data: Pointer to data buffer
680  * @param[in] timeout: Timeout duration
681  * @retval ::HAL_OK: Operation is OK.
682  * @retval ::HAL_ERROR: Parameter error or operation not supported.
683  * @retval ::HAL_BUSY: Driver is busy.
684  * @retval ::HAL_TIMEOUT: Timeout occurred.
685  ****************************************************************************************
686  */
687 hal_status_t hal_qspi_command_transmit(qspi_handle_t *p_qspi, qspi_command_t *p_cmd, uint8_t *p_data, uint32_t timeout);
688 
689 /**
690  ****************************************************************************************
691  * @brief Receive an amount of data with the specified instruction, address and dummy cycles in blocking mode.
692  * @note This function is used only in Indirect Read Mode.
693  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
694  * @param[in] p_cmd: Pointer to a qspi_command_t structure that contains the instruction and address for data transfer.
695  * @param[out] p_data: Pointer to data buffer
696  * @param[in] timeout: Timeout duration
697  * @retval ::HAL_OK: Operation is OK.
698  * @retval ::HAL_ERROR: Parameter error or operation not supported.
699  * @retval ::HAL_BUSY: Driver is busy.
700  * @retval ::HAL_TIMEOUT: Timeout occurred.
701  ****************************************************************************************
702  */
703 hal_status_t hal_qspi_command_receive(qspi_handle_t *p_qspi, qspi_command_t *p_cmd, uint8_t *p_data, uint32_t timeout);
704 
705 /**
706  ****************************************************************************************
707  * @brief Transmit only instruction in blocking mode.
708  * @note This function is used only in Indirect Write Mode.
709  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
710  * @param[in] p_cmd: Pointer to a qspi_command_t structure that contains the instruction and address for data transfer.
711  * @param[in] timeout: Timeout duration
712  * @retval ::HAL_OK: Operation is OK.
713  * @retval ::HAL_ERROR: Parameter error or operation not supported.
714  * @retval ::HAL_BUSY: Driver is busy.
715  * @retval ::HAL_TIMEOUT: Timeout occurred.
716  ****************************************************************************************
717  */
718 hal_status_t hal_qspi_command(qspi_handle_t *p_qspi, qspi_command_t *p_cmd, uint32_t timeout);
719 
720 /**
721  ****************************************************************************************
722  * @brief Transmit an amount of data in blocking mode with standard SPI.
723  * @note This function is used only in Indirect Write Mode.
724  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
725  * @param[in] p_data: Pointer to data buffer
726  * @param[in] length: Amount of data to be sent in bytes
727  * @param[in] timeout: Timeout duration
728  * @retval ::HAL_OK: Operation is OK.
729  * @retval ::HAL_ERROR: Parameter error or operation not supported.
730  * @retval ::HAL_BUSY: Driver is busy.
731  * @retval ::HAL_TIMEOUT: Timeout occurred.
732  ****************************************************************************************
733  */
734 hal_status_t hal_qspi_transmit(qspi_handle_t *p_qspi, uint8_t *p_data, uint32_t length, uint32_t timeout);
735 
736 /**
737  ****************************************************************************************
738  * @brief Receive an amount of data in blocking mode with standard SPI.
739  * @note This function is used only in Indirect Read Mode.
740  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
741  * @param[out] p_data: Pointer to data buffer
742  * @param[in] length: Amount of data to be received in bytes
743  * @param[in] timeout: Timeout duration
744  * @retval ::HAL_OK: Operation is OK.
745  * @retval ::HAL_ERROR: Parameter error or operation not supported.
746  * @retval ::HAL_BUSY: Driver is busy.
747  * @retval ::HAL_TIMEOUT: Timeout occurred.
748  ****************************************************************************************
749  */
750 hal_status_t hal_qspi_receive(qspi_handle_t *p_qspi, uint8_t *p_data, uint32_t length, uint32_t timeout);
751 
752 /**
753  ****************************************************************************************
754  * @brief Transmit an amount of data with the specified instruction and address in non-blocking mode with Interrupt.
755  * @note This function is used only in Indirect Write Mode. Dummy cycles in command will be ignored.
756  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
757  * @param[in] p_cmd: Pointer to a qspi_command_t structure that contains the instruction and address for data transfer.
758  * @param[in] p_data: Pointer to data buffer
759  * @retval ::HAL_OK: Operation is OK.
760  * @retval ::HAL_ERROR: Parameter error or operation not supported.
761  * @retval ::HAL_BUSY: Driver is busy.
762  * @retval ::HAL_TIMEOUT: Timeout occurred.
763  ****************************************************************************************
764  */
766 
767 /**
768  ****************************************************************************************
769  * @brief Receive an amount of data with the specified instruction, address and dummy cycles in non-blocking mode with Interrupt.
770  * @note This function is used only in Indirect Read Mode.
771  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
772  * @param[in] p_cmd: Pointer to a qspi_command_t structure that contains the instruction and address for data transfer.
773  * @param[out] p_data: Pointer to data buffer
774  * @retval ::HAL_OK: Operation is OK.
775  * @retval ::HAL_ERROR: Parameter error or operation not supported.
776  * @retval ::HAL_BUSY: Driver is busy.
777  * @retval ::HAL_TIMEOUT: Timeout occurred.
778  ****************************************************************************************
779  */
781 
782 /**
783  ****************************************************************************************
784  * @brief Transmit instruction in non-blocking mode with Interrupt.
785  * @note This function is used only in Indirect Write Mode.
786  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
787  * @param[in] p_cmd: Pointer to a qspi_command_t structure that contains the instruction and address for data transfer.
788  * @retval ::HAL_OK: Operation is OK.
789  * @retval ::HAL_ERROR: Parameter error or operation not supported.
790  * @retval ::HAL_BUSY: Driver is busy.
791  * @retval ::HAL_TIMEOUT: Timeout occurred.
792  ****************************************************************************************
793  */
795 
796 /**
797  ****************************************************************************************
798  * @brief Transmit an amount of data in non-blocking mode at standard SPI with Interrupt.
799  * @note This function is used only in Indirect Write Mode.
800  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
801  * @param[in] p_data: Pointer to data buffer
802  * @param[in] length: Amount of data to be sent in bytes
803  * @retval ::HAL_OK: Operation is OK.
804  * @retval ::HAL_ERROR: Parameter error or operation not supported.
805  * @retval ::HAL_BUSY: Driver is busy.
806  * @retval ::HAL_TIMEOUT: Timeout occurred.
807  ****************************************************************************************
808  */
809 hal_status_t hal_qspi_transmit_it(qspi_handle_t *p_qspi, uint8_t *p_data, uint32_t length);
810 
811 /**
812  ****************************************************************************************
813  * @brief Receive an amount of data in non-blocking mode at standard SPI with Interrupt.
814  * @note This function is used only in Indirect Read Mode.
815  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
816  * @param[out] p_data: Pointer to data buffer
817  * @param[in] length: Amount of data to be received in bytes
818  * @retval ::HAL_OK: Operation is OK.
819  * @retval ::HAL_ERROR: Parameter error or operation not supported.
820  * @retval ::HAL_BUSY: Driver is busy.
821  * @retval ::HAL_TIMEOUT: Timeout occurred.
822  ****************************************************************************************
823  */
824 hal_status_t hal_qspi_receive_it(qspi_handle_t *p_qspi, uint8_t *p_data, uint32_t length);
825 
826 /**
827  ****************************************************************************************
828  * @brief Transmit an amount of data with the specified instruction and address in non-blocking mode with DMA .
829  * @note This function is used only in Indirect Write Mode. Dummy cycles in command will be ignored.
830  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
831  * @param[in] p_cmd: Pointer to a qspi_command_t structure that contains the instruction and address for data transfer.
832  * @param[in] p_data: Pointer to data buffer
833  * @retval ::HAL_OK: Operation is OK.
834  * @retval ::HAL_ERROR: Parameter error or operation not supported.
835  * @retval ::HAL_BUSY: Driver is busy.
836  * @retval ::HAL_TIMEOUT: Timeout occurred.
837  ****************************************************************************************
838  */
840 
841 /**
842  ****************************************************************************************
843  * @brief Receive an amount of data with the specified instruction, address and dummy cycles in non-blocking mode with DMA .
844  * @note This function is used only in Indirect Read Mode.
845  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
846  * @param[in] p_cmd: Pointer to a qspi_command_t structure that contains the instruction and address for data transfer.
847  * @param[out] p_data: Pointer to data buffer
848  * @retval ::HAL_OK: Operation is OK.
849  * @retval ::HAL_ERROR: Parameter error or operation not supported.
850  * @retval ::HAL_BUSY: Driver is busy.
851  * @retval ::HAL_TIMEOUT: Timeout occurred.
852  ****************************************************************************************
853  */
855 
856 /**
857  ****************************************************************************************
858  * @brief Transmit instruction in non-blocking mode with DMA.
859  * @note This function is used only in Indirect Write Mode.
860  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
861  * @param[in] p_cmd: Pointer to a qspi_command_t structure that contains the instruction and address for data transfer.
862  * @retval ::HAL_OK: Operation is OK.
863  * @retval ::HAL_ERROR: Parameter error or operation not supported.
864  * @retval ::HAL_BUSY: Driver is busy.
865  * @retval ::HAL_TIMEOUT: Timeout occurred.
866  ****************************************************************************************
867  */
869 
870 /**
871  ****************************************************************************************
872  * @brief Transmit an amount of data in non-blocking mode at standard SPI with DMA.
873  * @note This function is used only in Indirect Write Mode.
874  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
875  * @param[in] p_data: Pointer to data buffer
876  * @param[in] length: Amount of data to be sent in bytes, ranging between 0 and 4095.
877  * @retval ::HAL_OK: Operation is OK.
878  * @retval ::HAL_ERROR: Parameter error or operation not supported.
879  * @retval ::HAL_BUSY: Driver is busy.
880  * @retval ::HAL_TIMEOUT: Timeout occurred.
881  ****************************************************************************************
882  */
883 hal_status_t hal_qspi_transmit_dma(qspi_handle_t *p_qspi, uint8_t *p_data, uint32_t length);
884 
885 /**
886  ****************************************************************************************
887  * @brief Receive an amount of data in non-blocking mode at standard SPI with DMA.
888  * @note This function is used only in Indirect Read Mode.
889  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
890  * @param[out] p_data: Pointer to data buffer
891  * @param[in] length: Amount of data to be received in bytes
892  * @retval ::HAL_OK: Operation is OK.
893  * @retval ::HAL_ERROR: Parameter error or operation not supported.
894  * @retval ::HAL_BUSY: Driver is busy.
895  * @retval ::HAL_TIMEOUT: Timeout occurred.
896  ****************************************************************************************
897  */
898 hal_status_t hal_qspi_receive_dma(qspi_handle_t *p_qspi, uint8_t *p_data, uint32_t length);
899 
900 /**
901  ****************************************************************************************
902  * @brief Abort the current transmission.
903  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
904  * @retval ::HAL_OK: Operation is OK.
905  * @retval ::HAL_ERROR: Parameter error or operation not supported.
906  * @retval ::HAL_BUSY: Driver is busy.
907  * @retval ::HAL_TIMEOUT: Timeout occurred.
908  ****************************************************************************************
909  */
911 
912 /**
913  ****************************************************************************************
914  * @brief Abort the current transmission (non-blocking function)
915  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
916  * @retval ::HAL_OK: Operation is OK.
917  * @retval ::HAL_ERROR: Parameter error or operation not supported.
918  * @retval ::HAL_BUSY: Driver is busy.
919  * @retval ::HAL_TIMEOUT: Timeout occurred.
920  ****************************************************************************************
921  */
923 
924 /** @} */
925 
926 /** @addtogroup QSPI_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
927  * @brief IRQ Handler and Callbacks functions
928  * @{
929  */
930 
931 /**
932  ****************************************************************************************
933  * @brief Handle QSPI interrupt request.
934  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
935  ****************************************************************************************
936  */
938 
939 /**
940  ****************************************************************************************
941  * @brief Tx Transfer completed callback.
942  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
943  ****************************************************************************************
944  */
946 
947 /**
948  ****************************************************************************************
949  * @brief Rx Transfer completed callback.
950  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
951  ****************************************************************************************
952  */
954 
955 /**
956  ****************************************************************************************
957  * @brief QSPI error callback.
958  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
959  ****************************************************************************************
960  */
962 
963 /**
964  ****************************************************************************************
965  * @brief QSPI Abort Complete callback.
966  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
967  ****************************************************************************************
968  */
970 
971 /**
972  ****************************************************************************************
973  * @brief FIFO Threshold callback.
974  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
975  ****************************************************************************************
976  */
978 
979 /** @} */
980 
981 /** @defgroup QSPI_Exported_Functions_Group3 Peripheral State and Errors functions
982  * @brief QSPI control functions
983  *
984 @verbatim
985  ===============================================================================
986  ##### Peripheral State and Errors functions #####
987  ===============================================================================
988  [..]
989  This subsection provides a set of functions allowing to control the QSPI.
990  (+) hal_qspi_get_state() API can be helpful to check in run-time the state of the QSPI peripheral.
991  (+) hal_qspi_get_error() check in run-time Errors occurring during communication.
992  (+) hal_qspi_set_timeout() set the timeout during internal process.
993  (+) hal_qspi_set_tx_fifo_threshold() set the TX FIFO Threshold.
994  (+) hal_qspi_set_rx_fifo_threshold() set the RX FIFO Threshold.
995  (+) hal_qspi_get_tx_fifo_threshold() get the TX FIFO Threshold.
996  (+) hal_qspi_get_rx_fifo_threshold() get the RX FIFO Threshold.
997 @endverbatim
998  * @{
999  */
1000 
1001 /**
1002  ****************************************************************************************
1003  * @brief Return the QSPI handle state.
1004  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
1005  * @retval ::HAL_QSPI_STATE_RESET: Peripheral not initialized.
1006  * @retval ::HAL_QSPI_STATE_READY: Peripheral initialized and ready for use.
1007  * @retval ::HAL_QSPI_STATE_BUSY: Peripheral in indirect mode and busy.
1008  * @retval ::HAL_QSPI_STATE_BUSY_INDIRECT_TX: Peripheral in indirect mode with transmission ongoing.
1009  * @retval ::HAL_QSPI_STATE_BUSY_INDIRECT_RX: Peripheral in indirect mode with reception ongoing.
1010  * @retval ::HAL_QSPI_STATE_ABORT: Peripheral with abort request ongoing.
1011  * @retval ::HAL_QSPI_STATE_ERROR: Peripheral in error.
1012  ****************************************************************************************
1013  */
1015 
1016 /**
1017  ****************************************************************************************
1018  * @brief Return the QSPI error code.
1019  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
1020  * @return QSPI error code in bitmap format
1021  ****************************************************************************************
1022  */
1024 
1025 /**
1026  ****************************************************************************************
1027  * @brief Set the QSPI internal process timeout value.
1028  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
1029  * @param[in] timeout: Internal process timeout value.
1030  * @retval ::HAL_OK: Operation is OK.
1031  * @retval ::HAL_ERROR: Parameter error or operation not supported.
1032  * @retval ::HAL_BUSY: Driver is busy.
1033  * @retval ::HAL_TIMEOUT: Timeout occurred.
1034  ****************************************************************************************
1035  */
1036 void hal_qspi_set_timeout(qspi_handle_t *p_qspi, uint32_t timeout);
1037 
1038 /**
1039  ****************************************************************************************
1040  * @brief Set the TX FIFO threshold.
1041  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
1042  * @param[in] threshold: TX FIFO threshold value ranging between 0x0U and 0x7U.
1043  * @retval ::HAL_OK: Operation is OK.
1044  * @retval ::HAL_ERROR: Parameter error or operation not supported.
1045  * @retval ::HAL_BUSY: Driver is busy.
1046  * @retval ::HAL_TIMEOUT: Timeout occurred.
1047  ****************************************************************************************
1048  */
1050 
1051 /**
1052  ****************************************************************************************
1053  * @brief Set the RX FIFO threshold.
1054  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
1055  * @param[in] threshold: RX FIFO threshold value ranging between 0x0U and 0x7U.
1056  * @retval ::HAL_OK: Operation is OK.
1057  * @retval ::HAL_ERROR: Parameter error or operation not supported.
1058  * @retval ::HAL_BUSY: Driver is busy.
1059  * @retval ::HAL_TIMEOUT: Timeout occurred.
1060  ****************************************************************************************
1061  */
1063 
1064 /**
1065  ****************************************************************************************
1066  * @brief Get the TX FIFO threshold.
1067  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
1068  * @return TX FIFO threshold
1069  ****************************************************************************************
1070  */
1072 
1073 /**
1074  ****************************************************************************************
1075  * @brief Get the RX FIFO threshold.
1076  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration information for the specified QSPI module.
1077  * @return RX FIFO threshold
1078  ****************************************************************************************
1079  */
1081 
1082 /**
1083  ****************************************************************************************
1084  * @brief Suspend some registers related to QSPI configuration before sleep.
1085  * @param[in] p_qspi: Pointer to a QSPIhandle which contains the configuration
1086  * information for the specified QSPI module.
1087  * @retval ::HAL_OK: Operation is OK.
1088  * @retval ::HAL_ERROR: Parameter error or operation not supported.
1089  * @retval ::HAL_BUSY: Driver is busy.
1090  * @retval ::HAL_TIMEOUT: Timeout occurred.
1091  ****************************************************************************************
1092  */
1094 
1095 /**
1096  ****************************************************************************************
1097  * @brief Restore some registers related to QSPI configuration after sleep.
1098  * This function must be used in conjunction with the hal_qspi_suspend_reg().
1099  * @param[in] p_qspi: Pointer to a QSPI handle which contains the configuration
1100  * information for the specified QSPI module.
1101  * @retval ::HAL_OK: Operation is OK.
1102  * @retval ::HAL_ERROR: Parameter error or operation not supported.
1103  * @retval ::HAL_BUSY: Driver is busy.
1104  * @retval ::HAL_TIMEOUT: Timeout occurred.
1105  ****************************************************************************************
1106  */
1108 
1109 /** @} */
1110 
1111 /** @} */
1112 
1113 #ifdef __cplusplus
1114 }
1115 #endif
1116 
1117 #endif /* __GR55xx_HAL_QSPI_H__ */
1118 
1119 /** @} */
1120 
1121 /** @} */
1122 
1123 /** @} */
_hal_qspi_callback::qspi_msp_deinit
void(* qspi_msp_deinit)(qspi_handle_t *p_qspi)
Definition: gr55xx_hal_qspi.h:215
_qspi_handle::tx_xfer_size
__IO uint32_t tx_xfer_size
Definition: gr55xx_hal_qspi.h:130
_qspi_command_t::instruction_size
uint32_t instruction_size
Definition: gr55xx_hal_qspi.h:173
_qspi_handle::timeout
uint32_t timeout
Definition: gr55xx_hal_qspi.h:152
hal_lock_t
hal_lock_t
HAL Lock structures definition.
Definition: gr55xx_hal_def.h:81
hal_qspi_fifo_threshold_callback
void hal_qspi_fifo_threshold_callback(qspi_handle_t *p_qspi)
FIFO Threshold callback.
_hal_qspi_callback::qspi_rx_cplt_callback
void(* qspi_rx_cplt_callback)(qspi_handle_t *p_qspi)
Definition: gr55xx_hal_qspi.h:219
_qspi_command_t::data_size
uint32_t data_size
Definition: gr55xx_hal_qspi.h:182
hal_qspi_set_rx_fifo_threshold
hal_status_t hal_qspi_set_rx_fifo_threshold(qspi_handle_t *p_qspi, uint32_t threshold)
Set the RX FIFO threshold.
hal_qspi_get_rx_fifo_threshold
uint32_t hal_qspi_get_rx_fifo_threshold(qspi_handle_t *p_qspi)
Get the RX FIFO threshold.
hal_qspi_transmit_dma
hal_status_t hal_qspi_transmit_dma(qspi_handle_t *p_qspi, uint8_t *p_data, uint32_t length)
Transmit an amount of data in non-blocking mode at standard SPI with DMA.
hal_qspi_command_receive
hal_status_t hal_qspi_command_receive(qspi_handle_t *p_qspi, qspi_command_t *p_cmd, uint8_t *p_data, uint32_t timeout)
Receive an amount of data with the specified instruction, address and dummy cycles in blocking mode.
_qspi_command_t::instruction_address_mode
uint32_t instruction_address_mode
Definition: gr55xx_hal_qspi.h:185
HAL_QSPI_STATE_ABORT
@ HAL_QSPI_STATE_ABORT
Definition: gr55xx_hal_qspi.h:82
_hal_qspi_callback::qspi_fifo_threshold_callback
void(* qspi_fifo_threshold_callback)(qspi_handle_t *p_qspi)
Definition: gr55xx_hal_qspi.h:218
_qspi_command_t::length
uint32_t length
Definition: gr55xx_hal_qspi.h:191
_qspi_handle::rx_xfer_size
__IO uint32_t rx_xfer_size
Definition: gr55xx_hal_qspi.h:136
_qspi_handle::state
__IO hal_qspi_state_t state
Definition: gr55xx_hal_qspi.h:148
hal_qspi_set_tx_fifo_threshold
hal_status_t hal_qspi_set_tx_fifo_threshold(qspi_handle_t *p_qspi, uint32_t threshold)
Set the TX FIFO threshold.
_hal_qspi_callback::qspi_error_callback
void(* qspi_error_callback)(qspi_handle_t *p_qspi)
Definition: gr55xx_hal_qspi.h:216
_qspi_handle::rx_xfer_count
__IO uint32_t rx_xfer_count
Definition: gr55xx_hal_qspi.h:138
hal_qspi_deinit
hal_status_t hal_qspi_deinit(qspi_handle_t *p_qspi)
De-initialize the QSPI peripheral.
_qspi_handle::p_tx_buffer
uint8_t * p_tx_buffer
Definition: gr55xx_hal_qspi.h:128
_qspi_init_t
QSPI init Structure definition.
Definition: gr55xx_hal_qspi.h:103
hal_qspi_msp_init
void hal_qspi_msp_init(qspi_handle_t *p_qspi)
Initialize the QSPI MSP.
hal_qspi_receive
hal_status_t hal_qspi_receive(qspi_handle_t *p_qspi, uint8_t *p_data, uint32_t length, uint32_t timeout)
Receive an amount of data in blocking mode with standard SPI.
HAL_QSPI_STATE_RESET
@ HAL_QSPI_STATE_RESET
Definition: gr55xx_hal_qspi.h:77
_qspi_command_t
QSPI command Structure definition.
Definition: gr55xx_hal_qspi.h:166
HAL_QSPI_STATE_READY
@ HAL_QSPI_STATE_READY
Definition: gr55xx_hal_qspi.h:78
_qspi_handle::p_instance
ssi_regs_t * p_instance
Definition: gr55xx_hal_qspi.h:124
_qspi_handle::write_fifo
void(* write_fifo)(struct _qspi_handle *p_qspi)
Definition: gr55xx_hal_qspi.h:140
hal_qspi_init
hal_status_t hal_qspi_init(qspi_handle_t *p_qspi)
Initialize the QSPI according to the specified parameters in the qspi_init_t and initialize the assoc...
_qspi_command_t::address_size
uint32_t address_size
Definition: gr55xx_hal_qspi.h:176
hal_qspi_msp_deinit
void hal_qspi_msp_deinit(qspi_handle_t *p_qspi)
De-initialize the QSPI MSP.
hal_qspi_command_transmit_it
hal_status_t hal_qspi_command_transmit_it(qspi_handle_t *p_qspi, qspi_command_t *p_cmd, uint8_t *p_data)
Transmit an amount of data with the specified instruction and address in non-blocking mode with Inter...
hal_qspi_suspend_reg
hal_status_t hal_qspi_suspend_reg(qspi_handle_t *p_qspi)
Suspend some registers related to QSPI configuration before sleep.
hal_qspi_tx_cplt_callback
void hal_qspi_tx_cplt_callback(qspi_handle_t *p_qspi)
Tx Transfer completed callback.
hal_qspi_command_receive_dma
hal_status_t hal_qspi_command_receive_dma(qspi_handle_t *p_qspi, qspi_command_t *p_cmd, uint8_t *p_data)
Receive an amount of data with the specified instruction, address and dummy cycles in non-blocking mo...
hal_qspi_abort_cplt_callback
void hal_qspi_abort_cplt_callback(qspi_handle_t *p_qspi)
QSPI Abort Complete callback.
hal_qspi_command_transmit
hal_status_t hal_qspi_command_transmit(qspi_handle_t *p_qspi, qspi_command_t *p_cmd, uint8_t *p_data, uint32_t timeout)
Transmit an amount of data with the specified instruction and address in blocking mode.
_hal_qspi_callback::qspi_tx_cplt_callback
void(* qspi_tx_cplt_callback)(qspi_handle_t *p_qspi)
Definition: gr55xx_hal_qspi.h:220
_qspi_handle::p_dma
dma_handle_t * p_dma
Definition: gr55xx_hal_qspi.h:144
HAL_QSPI_STATE_ERROR
@ HAL_QSPI_STATE_ERROR
Definition: gr55xx_hal_qspi.h:83
_qspi_command_t::dummy_cycles
uint32_t dummy_cycles
Definition: gr55xx_hal_qspi.h:179
hal_qspi_irq_handler
void hal_qspi_irq_handler(qspi_handle_t *p_qspi)
Handle QSPI interrupt request.
hal_qspi_abort
hal_status_t hal_qspi_abort(qspi_handle_t *p_qspi)
Abort the current transmission.
hal_qspi_receive_it
hal_status_t hal_qspi_receive_it(qspi_handle_t *p_qspi, uint8_t *p_data, uint32_t length)
Receive an amount of data in non-blocking mode at standard SPI with Interrupt.
_hal_qspi_callback
HAL_QSPI Callback function definition.
Definition: gr55xx_hal_qspi.h:213
hal_qspi_rx_cplt_callback
void hal_qspi_rx_cplt_callback(qspi_handle_t *p_qspi)
Rx Transfer completed callback.
gr55xx_ll_spi.h
Header file containing functions prototypes of SPI LL library.
hal_qspi_abort_it
hal_status_t hal_qspi_abort_it(qspi_handle_t *p_qspi)
Abort the current transmission (non-blocking function)
qspi_command_t
struct _qspi_command_t qspi_command_t
QSPI command Structure definition.
HAL_QSPI_STATE_BUSY_INDIRECT_RX
@ HAL_QSPI_STATE_BUSY_INDIRECT_RX
Definition: gr55xx_hal_qspi.h:81
_hal_qspi_callback::qspi_abort_cplt_callback
void(* qspi_abort_cplt_callback)(qspi_handle_t *p_qspi)
Definition: gr55xx_hal_qspi.h:217
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr55xx_hal_def.h:70
hal_qspi_command
hal_status_t hal_qspi_command(qspi_handle_t *p_qspi, qspi_command_t *p_cmd, uint32_t timeout)
Transmit only instruction in blocking mode.
_qspi_init_t::clock_prescaler
uint32_t clock_prescaler
Definition: gr55xx_hal_qspi.h:104
_qspi_handle::read_fifo
void(* read_fifo)(struct _qspi_handle *p_qspi)
Definition: gr55xx_hal_qspi.h:142
hal_qspi_receive_dma
hal_status_t hal_qspi_receive_dma(qspi_handle_t *p_qspi, uint8_t *p_data, uint32_t length)
Receive an amount of data in non-blocking mode at standard SPI with DMA.
_qspi_handle::error_code
__IO uint32_t error_code
Definition: gr55xx_hal_qspi.h:150
hal_qspi_resume_reg
hal_status_t hal_qspi_resume_reg(qspi_handle_t *p_qspi)
Restore some registers related to QSPI configuration after sleep. This function must be used in conju...
hal_qspi_command_receive_it
hal_status_t hal_qspi_command_receive_it(qspi_handle_t *p_qspi, qspi_command_t *p_cmd, uint8_t *p_data)
Receive an amount of data with the specified instruction, address and dummy cycles in non-blocking mo...
_qspi_handle::init
qspi_init_t init
Definition: gr55xx_hal_qspi.h:126
_qspi_handle::lock
__IO hal_lock_t lock
Definition: gr55xx_hal_qspi.h:146
_qspi_command_t::instruction
uint32_t instruction
Definition: gr55xx_hal_qspi.h:167
_qspi_handle::tx_xfer_count
__IO uint32_t tx_xfer_count
Definition: gr55xx_hal_qspi.h:132
HAL_QSPI_STATE_BUSY_INDIRECT_TX
@ HAL_QSPI_STATE_BUSY_INDIRECT_TX
Definition: gr55xx_hal_qspi.h:80
hal_qspi_get_tx_fifo_threshold
uint32_t hal_qspi_get_tx_fifo_threshold(qspi_handle_t *p_qspi)
Get the TX FIFO threshold.
hal_qspi_command_transmit_dma
hal_status_t hal_qspi_command_transmit_dma(qspi_handle_t *p_qspi, qspi_command_t *p_cmd, uint8_t *p_data)
Transmit an amount of data with the specified instruction and address in non-blocking mode with DMA .
hal_qspi_set_timeout
void hal_qspi_set_timeout(qspi_handle_t *p_qspi, uint32_t timeout)
Set the QSPI internal process timeout value.
qspi_handle_t
struct _qspi_handle qspi_handle_t
QSPI handle Structure definition.
hal_qspi_command_it
hal_status_t hal_qspi_command_it(qspi_handle_t *p_qspi, qspi_command_t *p_cmd)
Transmit instruction in non-blocking mode with Interrupt.
_qspi_command_t::data_mode
uint32_t data_mode
Definition: gr55xx_hal_qspi.h:188
HAL_QSPI_STATE_BUSY
@ HAL_QSPI_STATE_BUSY
Definition: gr55xx_hal_qspi.h:79
qspi_init_t
struct _qspi_init_t qspi_init_t
QSPI init Structure definition.
hal_qspi_transmit
hal_status_t hal_qspi_transmit(qspi_handle_t *p_qspi, uint8_t *p_data, uint32_t length, uint32_t timeout)
Transmit an amount of data in blocking mode with standard SPI.
hal_qspi_callback_t
struct _hal_qspi_callback hal_qspi_callback_t
HAL_QSPI Callback function definition.
hal_qspi_state_t
hal_qspi_state_t
HAL QSPI State Enumerations definition.
Definition: gr55xx_hal_qspi.h:76
hal_qspi_get_state
hal_qspi_state_t hal_qspi_get_state(qspi_handle_t *p_qspi)
Return the QSPI handle state.
_qspi_handle::retention
uint32_t retention[9]
Definition: gr55xx_hal_qspi.h:154
_hal_qspi_callback::qspi_msp_init
void(* qspi_msp_init)(qspi_handle_t *p_qspi)
Definition: gr55xx_hal_qspi.h:214
hal_qspi_command_dma
hal_status_t hal_qspi_command_dma(qspi_handle_t *p_qspi, qspi_command_t *p_cmd)
Transmit instruction in non-blocking mode with DMA.
_qspi_handle::p_rx_buffer
uint8_t * p_rx_buffer
Definition: gr55xx_hal_qspi.h:134
_qspi_handle
QSPI handle Structure definition.
Definition: gr55xx_hal_qspi.h:123
_qspi_command_t::address
uint32_t address
Definition: gr55xx_hal_qspi.h:170
_dma_handle
DMA handle Structure definition.
Definition: gr55xx_hal_dma.h:179
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
hal_qspi_get_error
uint32_t hal_qspi_get_error(qspi_handle_t *p_qspi)
Return the QSPI error code.
_qspi_init_t::clock_mode
uint32_t clock_mode
Definition: gr55xx_hal_qspi.h:107
hal_qspi_error_callback
void hal_qspi_error_callback(qspi_handle_t *p_qspi)
QSPI error callback.
hal_qspi_transmit_it
hal_status_t hal_qspi_transmit_it(qspi_handle_t *p_qspi, uint8_t *p_data, uint32_t length)
Transmit an amount of data in non-blocking mode at standard SPI with Interrupt.
_qspi_init_t::rx_sample_delay
uint32_t rx_sample_delay
Definition: gr55xx_hal_qspi.h:110