2 ******************************************************************************
\r
3 * @file stm32l4xx_hal_qspi.h
\r
4 * @author MCD Application Team
\r
5 * @brief Header file of QSPI HAL module.
\r
6 ******************************************************************************
\r
9 * <h2><center>© Copyright (c) 2017 STMicroelectronics.
\r
10 * All rights reserved.</center></h2>
\r
12 * This software component is licensed by ST under BSD 3-Clause license,
\r
13 * the "License"; You may not use this file except in compliance with the
\r
14 * License. You may obtain a copy of the License at:
\r
15 * opensource.org/licenses/BSD-3-Clause
\r
17 ******************************************************************************
\r
20 /* Define to prevent recursive inclusion -------------------------------------*/
\r
21 #ifndef STM32L4xx_HAL_QSPI_H
\r
22 #define STM32L4xx_HAL_QSPI_H
\r
28 /* Includes ------------------------------------------------------------------*/
\r
29 #include "stm32l4xx_hal_def.h"
\r
31 #if defined(QUADSPI)
\r
33 /** @addtogroup STM32L4xx_HAL_Driver
\r
37 /** @addtogroup QSPI
\r
41 /* Exported types ------------------------------------------------------------*/
\r
42 /** @defgroup QSPI_Exported_Types QSPI Exported Types
\r
47 * @brief QSPI Init structure definition
\r
51 uint32_t ClockPrescaler; /* Specifies the prescaler factor for generating clock based on the AHB clock.
\r
52 This parameter can be a number between 0 and 255 */
\r
53 uint32_t FifoThreshold; /* Specifies the threshold number of bytes in the FIFO (used only in indirect mode)
\r
54 This parameter can be a value between 1 and 16 */
\r
55 uint32_t SampleShifting; /* Specifies the Sample Shift. The data is sampled 1/2 clock cycle delay later to
\r
56 take in account external signal delays. (It should be QSPI_SAMPLE_SHIFTING_NONE in DDR mode)
\r
57 This parameter can be a value of @ref QSPI_SampleShifting */
\r
58 uint32_t FlashSize; /* Specifies the Flash Size. FlashSize+1 is effectively the number of address bits
\r
59 required to address the flash memory. The flash capacity can be up to 4GB
\r
60 (addressed using 32 bits) in indirect mode, but the addressable space in
\r
61 memory-mapped mode is limited to 256MB
\r
62 This parameter can be a number between 0 and 31 */
\r
63 uint32_t ChipSelectHighTime; /* Specifies the Chip Select High Time. ChipSelectHighTime+1 defines the minimum number
\r
64 of clock cycles which the chip select must remain high between commands.
\r
65 This parameter can be a value of @ref QSPI_ChipSelectHighTime */
\r
66 uint32_t ClockMode; /* Specifies the Clock Mode. It indicates the level that clock takes between commands.
\r
67 This parameter can be a value of @ref QSPI_ClockMode */
\r
68 #if defined(QUADSPI_CR_DFM)
\r
69 uint32_t FlashID; /* Specifies the Flash which will be used,
\r
70 This parameter can be a value of @ref QSPI_Flash_Select */
\r
71 uint32_t DualFlash; /* Specifies the Dual Flash Mode State
\r
72 This parameter can be a value of @ref QSPI_DualFlash_Mode */
\r
77 * @brief HAL QSPI State structures definition
\r
81 HAL_QSPI_STATE_RESET = 0x00U, /*!< Peripheral not initialized */
\r
82 HAL_QSPI_STATE_READY = 0x01U, /*!< Peripheral initialized and ready for use */
\r
83 HAL_QSPI_STATE_BUSY = 0x02U, /*!< Peripheral in indirect mode and busy */
\r
84 HAL_QSPI_STATE_BUSY_INDIRECT_TX = 0x12U, /*!< Peripheral in indirect mode with transmission ongoing */
\r
85 HAL_QSPI_STATE_BUSY_INDIRECT_RX = 0x22U, /*!< Peripheral in indirect mode with reception ongoing */
\r
86 HAL_QSPI_STATE_BUSY_AUTO_POLLING = 0x42U, /*!< Peripheral in auto polling mode ongoing */
\r
87 HAL_QSPI_STATE_BUSY_MEM_MAPPED = 0x82U, /*!< Peripheral in memory mapped mode ongoing */
\r
88 HAL_QSPI_STATE_ABORT = 0x08U, /*!< Peripheral with abort request ongoing */
\r
89 HAL_QSPI_STATE_ERROR = 0x04U /*!< Peripheral in error */
\r
90 }HAL_QSPI_StateTypeDef;
\r
93 * @brief QSPI Handle Structure definition
\r
95 #if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
\r
96 typedef struct __QSPI_HandleTypeDef
\r
101 QUADSPI_TypeDef *Instance; /* QSPI registers base address */
\r
102 QSPI_InitTypeDef Init; /* QSPI communication parameters */
\r
103 uint8_t *pTxBuffPtr; /* Pointer to QSPI Tx transfer Buffer */
\r
104 __IO uint32_t TxXferSize; /* QSPI Tx Transfer size */
\r
105 __IO uint32_t TxXferCount; /* QSPI Tx Transfer Counter */
\r
106 uint8_t *pRxBuffPtr; /* Pointer to QSPI Rx transfer Buffer */
\r
107 __IO uint32_t RxXferSize; /* QSPI Rx Transfer size */
\r
108 __IO uint32_t RxXferCount; /* QSPI Rx Transfer Counter */
\r
109 DMA_HandleTypeDef *hdma; /* QSPI Rx/Tx DMA Handle parameters */
\r
110 __IO HAL_LockTypeDef Lock; /* Locking object */
\r
111 __IO HAL_QSPI_StateTypeDef State; /* QSPI communication state */
\r
112 __IO uint32_t ErrorCode; /* QSPI Error code */
\r
113 uint32_t Timeout; /* Timeout for the QSPI memory access */
\r
114 #if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
\r
115 void (* ErrorCallback) (struct __QSPI_HandleTypeDef *hqspi);
\r
116 void (* AbortCpltCallback) (struct __QSPI_HandleTypeDef *hqspi);
\r
117 void (* FifoThresholdCallback)(struct __QSPI_HandleTypeDef *hqspi);
\r
118 void (* CmdCpltCallback) (struct __QSPI_HandleTypeDef *hqspi);
\r
119 void (* RxCpltCallback) (struct __QSPI_HandleTypeDef *hqspi);
\r
120 void (* TxCpltCallback) (struct __QSPI_HandleTypeDef *hqspi);
\r
121 void (* RxHalfCpltCallback) (struct __QSPI_HandleTypeDef *hqspi);
\r
122 void (* TxHalfCpltCallback) (struct __QSPI_HandleTypeDef *hqspi);
\r
123 void (* StatusMatchCallback) (struct __QSPI_HandleTypeDef *hqspi);
\r
124 void (* TimeOutCallback) (struct __QSPI_HandleTypeDef *hqspi);
\r
126 void (* MspInitCallback) (struct __QSPI_HandleTypeDef *hqspi);
\r
127 void (* MspDeInitCallback) (struct __QSPI_HandleTypeDef *hqspi);
\r
129 }QSPI_HandleTypeDef;
\r
132 * @brief QSPI Command structure definition
\r
136 uint32_t Instruction; /* Specifies the Instruction to be sent
\r
137 This parameter can be a value (8-bit) between 0x00 and 0xFF */
\r
138 uint32_t Address; /* Specifies the Address to be sent (Size from 1 to 4 bytes according AddressSize)
\r
139 This parameter can be a value (32-bits) between 0x0 and 0xFFFFFFFF */
\r
140 uint32_t AlternateBytes; /* Specifies the Alternate Bytes to be sent (Size from 1 to 4 bytes according AlternateBytesSize)
\r
141 This parameter can be a value (32-bits) between 0x0 and 0xFFFFFFFF */
\r
142 uint32_t AddressSize; /* Specifies the Address Size
\r
143 This parameter can be a value of @ref QSPI_AddressSize */
\r
144 uint32_t AlternateBytesSize; /* Specifies the Alternate Bytes Size
\r
145 This parameter can be a value of @ref QSPI_AlternateBytesSize */
\r
146 uint32_t DummyCycles; /* Specifies the Number of Dummy Cycles.
\r
147 This parameter can be a number between 0 and 31 */
\r
148 uint32_t InstructionMode; /* Specifies the Instruction Mode
\r
149 This parameter can be a value of @ref QSPI_InstructionMode */
\r
150 uint32_t AddressMode; /* Specifies the Address Mode
\r
151 This parameter can be a value of @ref QSPI_AddressMode */
\r
152 uint32_t AlternateByteMode; /* Specifies the Alternate Bytes Mode
\r
153 This parameter can be a value of @ref QSPI_AlternateBytesMode */
\r
154 uint32_t DataMode; /* Specifies the Data Mode (used for dummy cycles and data phases)
\r
155 This parameter can be a value of @ref QSPI_DataMode */
\r
156 uint32_t NbData; /* Specifies the number of data to transfer. (This is the number of bytes)
\r
157 This parameter can be any value between 0 and 0xFFFFFFFF (0 means undefined length
\r
158 until end of memory)*/
\r
159 uint32_t DdrMode; /* Specifies the double data rate mode for address, alternate byte and data phase
\r
160 This parameter can be a value of @ref QSPI_DdrMode */
\r
161 uint32_t DdrHoldHalfCycle; /* Specifies if the DDR hold is enabled. When enabled it delays the data
\r
162 output by one half of system clock in DDR mode.
\r
163 Not available on all devices.
\r
164 This parameter can be a value of @ref QSPI_DdrHoldHalfCycle */
\r
165 uint32_t SIOOMode; /* Specifies the send instruction only once mode
\r
166 This parameter can be a value of @ref QSPI_SIOOMode */
\r
167 }QSPI_CommandTypeDef;
\r
170 * @brief QSPI Auto Polling mode configuration structure definition
\r
174 uint32_t Match; /* Specifies the value to be compared with the masked status register to get a match.
\r
175 This parameter can be any value between 0 and 0xFFFFFFFF */
\r
176 uint32_t Mask; /* Specifies the mask to be applied to the status bytes received.
\r
177 This parameter can be any value between 0 and 0xFFFFFFFF */
\r
178 uint32_t Interval; /* Specifies the number of clock cycles between two read during automatic polling phases.
\r
179 This parameter can be any value between 0 and 0xFFFF */
\r
180 uint32_t StatusBytesSize; /* Specifies the size of the status bytes received.
\r
181 This parameter can be any value between 1 and 4 */
\r
182 uint32_t MatchMode; /* Specifies the method used for determining a match.
\r
183 This parameter can be a value of @ref QSPI_MatchMode */
\r
184 uint32_t AutomaticStop; /* Specifies if automatic polling is stopped after a match.
\r
185 This parameter can be a value of @ref QSPI_AutomaticStop */
\r
186 }QSPI_AutoPollingTypeDef;
\r
189 * @brief QSPI Memory Mapped mode configuration structure definition
\r
193 uint32_t TimeOutPeriod; /* Specifies the number of clock to wait when the FIFO is full before to release the chip select.
\r
194 This parameter can be any value between 0 and 0xFFFF */
\r
195 uint32_t TimeOutActivation; /* Specifies if the timeout counter is enabled to release the chip select.
\r
196 This parameter can be a value of @ref QSPI_TimeOutActivation */
\r
197 }QSPI_MemoryMappedTypeDef;
\r
199 #if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
\r
201 * @brief HAL QSPI Callback ID enumeration definition
\r
205 HAL_QSPI_ERROR_CB_ID = 0x00U, /*!< QSPI Error Callback ID */
\r
206 HAL_QSPI_ABORT_CB_ID = 0x01U, /*!< QSPI Abort Callback ID */
\r
207 HAL_QSPI_FIFO_THRESHOLD_CB_ID = 0x02U, /*!< QSPI FIFO Threshold Callback ID */
\r
208 HAL_QSPI_CMD_CPLT_CB_ID = 0x03U, /*!< QSPI Command Complete Callback ID */
\r
209 HAL_QSPI_RX_CPLT_CB_ID = 0x04U, /*!< QSPI Rx Complete Callback ID */
\r
210 HAL_QSPI_TX_CPLT_CB_ID = 0x05U, /*!< QSPI Tx Complete Callback ID */
\r
211 HAL_QSPI_RX_HALF_CPLT_CB_ID = 0x06U, /*!< QSPI Rx Half Complete Callback ID */
\r
212 HAL_QSPI_TX_HALF_CPLT_CB_ID = 0x07U, /*!< QSPI Tx Half Complete Callback ID */
\r
213 HAL_QSPI_STATUS_MATCH_CB_ID = 0x08U, /*!< QSPI Status Match Callback ID */
\r
214 HAL_QSPI_TIMEOUT_CB_ID = 0x09U, /*!< QSPI Timeout Callback ID */
\r
216 HAL_QSPI_MSP_INIT_CB_ID = 0x0AU, /*!< QSPI MspInit Callback ID */
\r
217 HAL_QSPI_MSP_DEINIT_CB_ID = 0x0B0 /*!< QSPI MspDeInit Callback ID */
\r
218 }HAL_QSPI_CallbackIDTypeDef;
\r
221 * @brief HAL QSPI Callback pointer definition
\r
223 typedef void (*pQSPI_CallbackTypeDef)(QSPI_HandleTypeDef *hqspi);
\r
229 /* Exported constants --------------------------------------------------------*/
\r
230 /** @defgroup QSPI_Exported_Constants QSPI Exported Constants
\r
234 /** @defgroup QSPI_ErrorCode QSPI Error Code
\r
237 #define HAL_QSPI_ERROR_NONE 0x00000000U /*!< No error */
\r
238 #define HAL_QSPI_ERROR_TIMEOUT 0x00000001U /*!< Timeout error */
\r
239 #define HAL_QSPI_ERROR_TRANSFER 0x00000002U /*!< Transfer error */
\r
240 #define HAL_QSPI_ERROR_DMA 0x00000004U /*!< DMA transfer error */
\r
241 #define HAL_QSPI_ERROR_INVALID_PARAM 0x00000008U /*!< Invalid parameters error */
\r
242 #if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
\r
243 #define HAL_QSPI_ERROR_INVALID_CALLBACK 0x00000010U /*!< Invalid callback error */
\r
249 /** @defgroup QSPI_SampleShifting QSPI Sample Shifting
\r
252 #define QSPI_SAMPLE_SHIFTING_NONE 0x00000000U /*!<No clock cycle shift to sample data*/
\r
253 #define QSPI_SAMPLE_SHIFTING_HALFCYCLE ((uint32_t)QUADSPI_CR_SSHIFT) /*!<1/2 clock cycle shift to sample data*/
\r
258 /** @defgroup QSPI_ChipSelectHighTime QSPI ChipSelect High Time
\r
261 #define QSPI_CS_HIGH_TIME_1_CYCLE 0x00000000U /*!<nCS stay high for at least 1 clock cycle between commands*/
\r
262 #define QSPI_CS_HIGH_TIME_2_CYCLE ((uint32_t)QUADSPI_DCR_CSHT_0) /*!<nCS stay high for at least 2 clock cycles between commands*/
\r
263 #define QSPI_CS_HIGH_TIME_3_CYCLE ((uint32_t)QUADSPI_DCR_CSHT_1) /*!<nCS stay high for at least 3 clock cycles between commands*/
\r
264 #define QSPI_CS_HIGH_TIME_4_CYCLE ((uint32_t)QUADSPI_DCR_CSHT_0 | QUADSPI_DCR_CSHT_1) /*!<nCS stay high for at least 4 clock cycles between commands*/
\r
265 #define QSPI_CS_HIGH_TIME_5_CYCLE ((uint32_t)QUADSPI_DCR_CSHT_2) /*!<nCS stay high for at least 5 clock cycles between commands*/
\r
266 #define QSPI_CS_HIGH_TIME_6_CYCLE ((uint32_t)QUADSPI_DCR_CSHT_2 | QUADSPI_DCR_CSHT_0) /*!<nCS stay high for at least 6 clock cycles between commands*/
\r
267 #define QSPI_CS_HIGH_TIME_7_CYCLE ((uint32_t)QUADSPI_DCR_CSHT_2 | QUADSPI_DCR_CSHT_1) /*!<nCS stay high for at least 7 clock cycles between commands*/
\r
268 #define QSPI_CS_HIGH_TIME_8_CYCLE ((uint32_t)QUADSPI_DCR_CSHT) /*!<nCS stay high for at least 8 clock cycles between commands*/
\r
273 /** @defgroup QSPI_ClockMode QSPI Clock Mode
\r
276 #define QSPI_CLOCK_MODE_0 0x00000000U /*!<Clk stays low while nCS is released*/
\r
277 #define QSPI_CLOCK_MODE_3 ((uint32_t)QUADSPI_DCR_CKMODE) /*!<Clk goes high while nCS is released*/
\r
282 #if defined(QUADSPI_CR_DFM)
\r
283 /** @defgroup QSPI_Flash_Select QSPI Flash Select
\r
286 #define QSPI_FLASH_ID_1 0x00000000U /*!<FLASH 1 selected*/
\r
287 #define QSPI_FLASH_ID_2 ((uint32_t)QUADSPI_CR_FSEL) /*!<FLASH 2 selected*/
\r
292 /** @defgroup QSPI_DualFlash_Mode QSPI Dual Flash Mode
\r
295 #define QSPI_DUALFLASH_ENABLE ((uint32_t)QUADSPI_CR_DFM) /*!<Dual-flash mode enabled*/
\r
296 #define QSPI_DUALFLASH_DISABLE 0x00000000U /*!<Dual-flash mode disabled*/
\r
302 /** @defgroup QSPI_AddressSize QSPI Address Size
\r
305 #define QSPI_ADDRESS_8_BITS 0x00000000U /*!<8-bit address*/
\r
306 #define QSPI_ADDRESS_16_BITS ((uint32_t)QUADSPI_CCR_ADSIZE_0) /*!<16-bit address*/
\r
307 #define QSPI_ADDRESS_24_BITS ((uint32_t)QUADSPI_CCR_ADSIZE_1) /*!<24-bit address*/
\r
308 #define QSPI_ADDRESS_32_BITS ((uint32_t)QUADSPI_CCR_ADSIZE) /*!<32-bit address*/
\r
313 /** @defgroup QSPI_AlternateBytesSize QSPI Alternate Bytes Size
\r
316 #define QSPI_ALTERNATE_BYTES_8_BITS 0x00000000U /*!<8-bit alternate bytes*/
\r
317 #define QSPI_ALTERNATE_BYTES_16_BITS ((uint32_t)QUADSPI_CCR_ABSIZE_0) /*!<16-bit alternate bytes*/
\r
318 #define QSPI_ALTERNATE_BYTES_24_BITS ((uint32_t)QUADSPI_CCR_ABSIZE_1) /*!<24-bit alternate bytes*/
\r
319 #define QSPI_ALTERNATE_BYTES_32_BITS ((uint32_t)QUADSPI_CCR_ABSIZE) /*!<32-bit alternate bytes*/
\r
324 /** @defgroup QSPI_InstructionMode QSPI Instruction Mode
\r
327 #define QSPI_INSTRUCTION_NONE 0x00000000U /*!<No instruction*/
\r
328 #define QSPI_INSTRUCTION_1_LINE ((uint32_t)QUADSPI_CCR_IMODE_0) /*!<Instruction on a single line*/
\r
329 #define QSPI_INSTRUCTION_2_LINES ((uint32_t)QUADSPI_CCR_IMODE_1) /*!<Instruction on two lines*/
\r
330 #define QSPI_INSTRUCTION_4_LINES ((uint32_t)QUADSPI_CCR_IMODE) /*!<Instruction on four lines*/
\r
335 /** @defgroup QSPI_AddressMode QSPI Address Mode
\r
338 #define QSPI_ADDRESS_NONE 0x00000000U /*!<No address*/
\r
339 #define QSPI_ADDRESS_1_LINE ((uint32_t)QUADSPI_CCR_ADMODE_0) /*!<Address on a single line*/
\r
340 #define QSPI_ADDRESS_2_LINES ((uint32_t)QUADSPI_CCR_ADMODE_1) /*!<Address on two lines*/
\r
341 #define QSPI_ADDRESS_4_LINES ((uint32_t)QUADSPI_CCR_ADMODE) /*!<Address on four lines*/
\r
346 /** @defgroup QSPI_AlternateBytesMode QSPI Alternate Bytes Mode
\r
349 #define QSPI_ALTERNATE_BYTES_NONE 0x00000000U /*!<No alternate bytes*/
\r
350 #define QSPI_ALTERNATE_BYTES_1_LINE ((uint32_t)QUADSPI_CCR_ABMODE_0) /*!<Alternate bytes on a single line*/
\r
351 #define QSPI_ALTERNATE_BYTES_2_LINES ((uint32_t)QUADSPI_CCR_ABMODE_1) /*!<Alternate bytes on two lines*/
\r
352 #define QSPI_ALTERNATE_BYTES_4_LINES ((uint32_t)QUADSPI_CCR_ABMODE) /*!<Alternate bytes on four lines*/
\r
357 /** @defgroup QSPI_DataMode QSPI Data Mode
\r
360 #define QSPI_DATA_NONE 0x00000000U /*!<No data*/
\r
361 #define QSPI_DATA_1_LINE ((uint32_t)QUADSPI_CCR_DMODE_0) /*!<Data on a single line*/
\r
362 #define QSPI_DATA_2_LINES ((uint32_t)QUADSPI_CCR_DMODE_1) /*!<Data on two lines*/
\r
363 #define QSPI_DATA_4_LINES ((uint32_t)QUADSPI_CCR_DMODE) /*!<Data on four lines*/
\r
368 /** @defgroup QSPI_DdrMode QSPI DDR Mode
\r
371 #define QSPI_DDR_MODE_DISABLE 0x00000000U /*!<Double data rate mode disabled*/
\r
372 #define QSPI_DDR_MODE_ENABLE ((uint32_t)QUADSPI_CCR_DDRM) /*!<Double data rate mode enabled*/
\r
377 /** @defgroup QSPI_DdrHoldHalfCycle QSPI DDR Data Output Delay
\r
380 #define QSPI_DDR_HHC_ANALOG_DELAY 0x00000000U /*!<Delay the data output using analog delay in DDR mode*/
\r
381 #if defined(QUADSPI_CCR_DHHC)
\r
382 #define QSPI_DDR_HHC_HALF_CLK_DELAY ((uint32_t)QUADSPI_CCR_DHHC) /*!<Delay the data output by one half of system clock in DDR mode*/
\r
388 /** @defgroup QSPI_SIOOMode QSPI Send Instruction Mode
\r
391 #define QSPI_SIOO_INST_EVERY_CMD 0x00000000U /*!<Send instruction on every transaction*/
\r
392 #define QSPI_SIOO_INST_ONLY_FIRST_CMD ((uint32_t)QUADSPI_CCR_SIOO) /*!<Send instruction only for the first command*/
\r
397 /** @defgroup QSPI_MatchMode QSPI Match Mode
\r
400 #define QSPI_MATCH_MODE_AND 0x00000000U /*!<AND match mode between unmasked bits*/
\r
401 #define QSPI_MATCH_MODE_OR ((uint32_t)QUADSPI_CR_PMM) /*!<OR match mode between unmasked bits*/
\r
406 /** @defgroup QSPI_AutomaticStop QSPI Automatic Stop
\r
409 #define QSPI_AUTOMATIC_STOP_DISABLE 0x00000000U /*!<AutoPolling stops only with abort or QSPI disabling*/
\r
410 #define QSPI_AUTOMATIC_STOP_ENABLE ((uint32_t)QUADSPI_CR_APMS) /*!<AutoPolling stops as soon as there is a match*/
\r
415 /** @defgroup QSPI_TimeOutActivation QSPI Timeout Activation
\r
418 #define QSPI_TIMEOUT_COUNTER_DISABLE 0x00000000U /*!<Timeout counter disabled, nCS remains active*/
\r
419 #define QSPI_TIMEOUT_COUNTER_ENABLE ((uint32_t)QUADSPI_CR_TCEN) /*!<Timeout counter enabled, nCS released when timeout expires*/
\r
424 /** @defgroup QSPI_Flags QSPI Flags
\r
427 #define QSPI_FLAG_BUSY QUADSPI_SR_BUSY /*!<Busy flag: operation is ongoing*/
\r
428 #define QSPI_FLAG_TO QUADSPI_SR_TOF /*!<Timeout flag: timeout occurs in memory-mapped mode*/
\r
429 #define QSPI_FLAG_SM QUADSPI_SR_SMF /*!<Status match flag: received data matches in autopolling mode*/
\r
430 #define QSPI_FLAG_FT QUADSPI_SR_FTF /*!<Fifo threshold flag: Fifo threshold reached or data left after read from memory is complete*/
\r
431 #define QSPI_FLAG_TC QUADSPI_SR_TCF /*!<Transfer complete flag: programmed number of data have been transferred or the transfer has been aborted*/
\r
432 #define QSPI_FLAG_TE QUADSPI_SR_TEF /*!<Transfer error flag: invalid address is being accessed*/
\r
437 /** @defgroup QSPI_Interrupts QSPI Interrupts
\r
440 #define QSPI_IT_TO QUADSPI_CR_TOIE /*!<Interrupt on the timeout flag*/
\r
441 #define QSPI_IT_SM QUADSPI_CR_SMIE /*!<Interrupt on the status match flag*/
\r
442 #define QSPI_IT_FT QUADSPI_CR_FTIE /*!<Interrupt on the fifo threshold flag*/
\r
443 #define QSPI_IT_TC QUADSPI_CR_TCIE /*!<Interrupt on the transfer complete flag*/
\r
444 #define QSPI_IT_TE QUADSPI_CR_TEIE /*!<Interrupt on the transfer error flag*/
\r
449 /** @defgroup QSPI_Timeout_definition QSPI Timeout definition
\r
450 * @brief QSPI Timeout definition
\r
453 #define HAL_QSPI_TIMEOUT_DEFAULT_VALUE 5000U /* 5 s */
\r
462 /* Exported macros -----------------------------------------------------------*/
\r
463 /** @defgroup QSPI_Exported_Macros QSPI Exported Macros
\r
466 /** @brief Reset QSPI handle state.
\r
467 * @param __HANDLE__ : QSPI handle.
\r
470 #if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
\r
471 #define __HAL_QSPI_RESET_HANDLE_STATE(__HANDLE__) do { \
\r
472 (__HANDLE__)->State = HAL_QSPI_STATE_RESET; \
\r
473 (__HANDLE__)->MspInitCallback = NULL; \
\r
474 (__HANDLE__)->MspDeInitCallback = NULL; \
\r
477 #define __HAL_QSPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_QSPI_STATE_RESET)
\r
480 /** @brief Enable the QSPI peripheral.
\r
481 * @param __HANDLE__ : specifies the QSPI Handle.
\r
484 #define __HAL_QSPI_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR, QUADSPI_CR_EN)
\r
486 /** @brief Disable the QSPI peripheral.
\r
487 * @param __HANDLE__ : specifies the QSPI Handle.
\r
490 #define __HAL_QSPI_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR, QUADSPI_CR_EN)
\r
492 /** @brief Enable the specified QSPI interrupt.
\r
493 * @param __HANDLE__ : specifies the QSPI Handle.
\r
494 * @param __INTERRUPT__ : specifies the QSPI interrupt source to enable.
\r
495 * This parameter can be one of the following values:
\r
496 * @arg QSPI_IT_TO: QSPI Timeout interrupt
\r
497 * @arg QSPI_IT_SM: QSPI Status match interrupt
\r
498 * @arg QSPI_IT_FT: QSPI FIFO threshold interrupt
\r
499 * @arg QSPI_IT_TC: QSPI Transfer complete interrupt
\r
500 * @arg QSPI_IT_TE: QSPI Transfer error interrupt
\r
503 #define __HAL_QSPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CR, (__INTERRUPT__))
\r
506 /** @brief Disable the specified QSPI interrupt.
\r
507 * @param __HANDLE__ : specifies the QSPI Handle.
\r
508 * @param __INTERRUPT__ : specifies the QSPI interrupt source to disable.
\r
509 * This parameter can be one of the following values:
\r
510 * @arg QSPI_IT_TO: QSPI Timeout interrupt
\r
511 * @arg QSPI_IT_SM: QSPI Status match interrupt
\r
512 * @arg QSPI_IT_FT: QSPI FIFO threshold interrupt
\r
513 * @arg QSPI_IT_TC: QSPI Transfer complete interrupt
\r
514 * @arg QSPI_IT_TE: QSPI Transfer error interrupt
\r
517 #define __HAL_QSPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CR, (__INTERRUPT__))
\r
519 /** @brief Check whether the specified QSPI interrupt source is enabled or not.
\r
520 * @param __HANDLE__ : specifies the QSPI Handle.
\r
521 * @param __INTERRUPT__ : specifies the QSPI interrupt source to check.
\r
522 * This parameter can be one of the following values:
\r
523 * @arg QSPI_IT_TO: QSPI Timeout interrupt
\r
524 * @arg QSPI_IT_SM: QSPI Status match interrupt
\r
525 * @arg QSPI_IT_FT: QSPI FIFO threshold interrupt
\r
526 * @arg QSPI_IT_TC: QSPI Transfer complete interrupt
\r
527 * @arg QSPI_IT_TE: QSPI Transfer error interrupt
\r
528 * @retval The new state of __INTERRUPT__ (TRUE or FALSE).
\r
530 #define __HAL_QSPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (READ_BIT((__HANDLE__)->Instance->CR, (__INTERRUPT__)) == (__INTERRUPT__))
\r
533 * @brief Check whether the selected QSPI flag is set or not.
\r
534 * @param __HANDLE__ : specifies the QSPI Handle.
\r
535 * @param __FLAG__ : specifies the QSPI flag to check.
\r
536 * This parameter can be one of the following values:
\r
537 * @arg QSPI_FLAG_BUSY: QSPI Busy flag
\r
538 * @arg QSPI_FLAG_TO: QSPI Timeout flag
\r
539 * @arg QSPI_FLAG_SM: QSPI Status match flag
\r
540 * @arg QSPI_FLAG_FT: QSPI FIFO threshold flag
\r
541 * @arg QSPI_FLAG_TC: QSPI Transfer complete flag
\r
542 * @arg QSPI_FLAG_TE: QSPI Transfer error flag
\r
545 #define __HAL_QSPI_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BIT((__HANDLE__)->Instance->SR, (__FLAG__)) != 0U) ? SET : RESET)
\r
547 /** @brief Clears the specified QSPI's flag status.
\r
548 * @param __HANDLE__ : specifies the QSPI Handle.
\r
549 * @param __FLAG__ : specifies the QSPI clear register flag that needs to be set
\r
550 * This parameter can be one of the following values:
\r
551 * @arg QSPI_FLAG_TO: QSPI Timeout flag
\r
552 * @arg QSPI_FLAG_SM: QSPI Status match flag
\r
553 * @arg QSPI_FLAG_TC: QSPI Transfer complete flag
\r
554 * @arg QSPI_FLAG_TE: QSPI Transfer error flag
\r
557 #define __HAL_QSPI_CLEAR_FLAG(__HANDLE__, __FLAG__) WRITE_REG((__HANDLE__)->Instance->FCR, (__FLAG__))
\r
562 /* Exported functions --------------------------------------------------------*/
\r
563 /** @addtogroup QSPI_Exported_Functions
\r
567 /** @addtogroup QSPI_Exported_Functions_Group1
\r
570 /* Initialization/de-initialization functions ********************************/
\r
571 HAL_StatusTypeDef HAL_QSPI_Init (QSPI_HandleTypeDef *hqspi);
\r
572 HAL_StatusTypeDef HAL_QSPI_DeInit (QSPI_HandleTypeDef *hqspi);
\r
573 void HAL_QSPI_MspInit (QSPI_HandleTypeDef *hqspi);
\r
574 void HAL_QSPI_MspDeInit(QSPI_HandleTypeDef *hqspi);
\r
579 /** @addtogroup QSPI_Exported_Functions_Group2
\r
582 /* IO operation functions *****************************************************/
\r
583 /* QSPI IRQ handler method */
\r
584 void HAL_QSPI_IRQHandler(QSPI_HandleTypeDef *hqspi);
\r
586 /* QSPI indirect mode */
\r
587 HAL_StatusTypeDef HAL_QSPI_Command (QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd, uint32_t Timeout);
\r
588 HAL_StatusTypeDef HAL_QSPI_Transmit (QSPI_HandleTypeDef *hqspi, uint8_t *pData, uint32_t Timeout);
\r
589 HAL_StatusTypeDef HAL_QSPI_Receive (QSPI_HandleTypeDef *hqspi, uint8_t *pData, uint32_t Timeout);
\r
590 HAL_StatusTypeDef HAL_QSPI_Command_IT (QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd);
\r
591 HAL_StatusTypeDef HAL_QSPI_Transmit_IT (QSPI_HandleTypeDef *hqspi, uint8_t *pData);
\r
592 HAL_StatusTypeDef HAL_QSPI_Receive_IT (QSPI_HandleTypeDef *hqspi, uint8_t *pData);
\r
593 HAL_StatusTypeDef HAL_QSPI_Transmit_DMA (QSPI_HandleTypeDef *hqspi, uint8_t *pData);
\r
594 HAL_StatusTypeDef HAL_QSPI_Receive_DMA (QSPI_HandleTypeDef *hqspi, uint8_t *pData);
\r
596 /* QSPI status flag polling mode */
\r
597 HAL_StatusTypeDef HAL_QSPI_AutoPolling (QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd, QSPI_AutoPollingTypeDef *cfg, uint32_t Timeout);
\r
598 HAL_StatusTypeDef HAL_QSPI_AutoPolling_IT(QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd, QSPI_AutoPollingTypeDef *cfg);
\r
600 /* QSPI memory-mapped mode */
\r
601 HAL_StatusTypeDef HAL_QSPI_MemoryMapped(QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd, QSPI_MemoryMappedTypeDef *cfg);
\r
603 /* Callback functions in non-blocking modes ***********************************/
\r
604 void HAL_QSPI_ErrorCallback (QSPI_HandleTypeDef *hqspi);
\r
605 void HAL_QSPI_AbortCpltCallback (QSPI_HandleTypeDef *hqspi);
\r
606 void HAL_QSPI_FifoThresholdCallback(QSPI_HandleTypeDef *hqspi);
\r
608 /* QSPI indirect mode */
\r
609 void HAL_QSPI_CmdCpltCallback (QSPI_HandleTypeDef *hqspi);
\r
610 void HAL_QSPI_RxCpltCallback (QSPI_HandleTypeDef *hqspi);
\r
611 void HAL_QSPI_TxCpltCallback (QSPI_HandleTypeDef *hqspi);
\r
612 void HAL_QSPI_RxHalfCpltCallback (QSPI_HandleTypeDef *hqspi);
\r
613 void HAL_QSPI_TxHalfCpltCallback (QSPI_HandleTypeDef *hqspi);
\r
615 /* QSPI status flag polling mode */
\r
616 void HAL_QSPI_StatusMatchCallback (QSPI_HandleTypeDef *hqspi);
\r
618 /* QSPI memory-mapped mode */
\r
619 void HAL_QSPI_TimeOutCallback (QSPI_HandleTypeDef *hqspi);
\r
621 #if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
\r
622 /* QSPI callback registering/unregistering */
\r
623 HAL_StatusTypeDef HAL_QSPI_RegisterCallback (QSPI_HandleTypeDef *hqspi, HAL_QSPI_CallbackIDTypeDef CallbackId, pQSPI_CallbackTypeDef pCallback);
\r
624 HAL_StatusTypeDef HAL_QSPI_UnRegisterCallback (QSPI_HandleTypeDef *hqspi, HAL_QSPI_CallbackIDTypeDef CallbackId);
\r
630 /** @addtogroup QSPI_Exported_Functions_Group3
\r
633 /* Peripheral Control and State functions ************************************/
\r
634 HAL_QSPI_StateTypeDef HAL_QSPI_GetState (QSPI_HandleTypeDef *hqspi);
\r
635 uint32_t HAL_QSPI_GetError (QSPI_HandleTypeDef *hqspi);
\r
636 HAL_StatusTypeDef HAL_QSPI_Abort (QSPI_HandleTypeDef *hqspi);
\r
637 HAL_StatusTypeDef HAL_QSPI_Abort_IT (QSPI_HandleTypeDef *hqspi);
\r
638 void HAL_QSPI_SetTimeout (QSPI_HandleTypeDef *hqspi, uint32_t Timeout);
\r
639 HAL_StatusTypeDef HAL_QSPI_SetFifoThreshold(QSPI_HandleTypeDef *hqspi, uint32_t Threshold);
\r
640 uint32_t HAL_QSPI_GetFifoThreshold(QSPI_HandleTypeDef *hqspi);
\r
641 #if defined(QUADSPI_CR_DFM)
\r
642 HAL_StatusTypeDef HAL_QSPI_SetFlashID (QSPI_HandleTypeDef *hqspi, uint32_t FlashID);
\r
651 /* End of exported functions -------------------------------------------------*/
\r
653 /* Private macros ------------------------------------------------------------*/
\r
654 /** @defgroup QSPI_Private_Macros QSPI Private Macros
\r
657 #define IS_QSPI_CLOCK_PRESCALER(PRESCALER) ((PRESCALER) <= 0xFFU)
\r
659 #define IS_QSPI_FIFO_THRESHOLD(THR) (((THR) > 0U) && ((THR) <= 16U))
\r
661 #define IS_QSPI_SSHIFT(SSHIFT) (((SSHIFT) == QSPI_SAMPLE_SHIFTING_NONE) || \
\r
662 ((SSHIFT) == QSPI_SAMPLE_SHIFTING_HALFCYCLE))
\r
664 #define IS_QSPI_FLASH_SIZE(FSIZE) (((FSIZE) <= 31U))
\r
666 #define IS_QSPI_CS_HIGH_TIME(CSHTIME) (((CSHTIME) == QSPI_CS_HIGH_TIME_1_CYCLE) || \
\r
667 ((CSHTIME) == QSPI_CS_HIGH_TIME_2_CYCLE) || \
\r
668 ((CSHTIME) == QSPI_CS_HIGH_TIME_3_CYCLE) || \
\r
669 ((CSHTIME) == QSPI_CS_HIGH_TIME_4_CYCLE) || \
\r
670 ((CSHTIME) == QSPI_CS_HIGH_TIME_5_CYCLE) || \
\r
671 ((CSHTIME) == QSPI_CS_HIGH_TIME_6_CYCLE) || \
\r
672 ((CSHTIME) == QSPI_CS_HIGH_TIME_7_CYCLE) || \
\r
673 ((CSHTIME) == QSPI_CS_HIGH_TIME_8_CYCLE))
\r
675 #define IS_QSPI_CLOCK_MODE(CLKMODE) (((CLKMODE) == QSPI_CLOCK_MODE_0) || \
\r
676 ((CLKMODE) == QSPI_CLOCK_MODE_3))
\r
678 #if defined(QUADSPI_CR_DFM)
\r
679 #define IS_QSPI_FLASH_ID(FLASH_ID) (((FLASH_ID) == QSPI_FLASH_ID_1) || \
\r
680 ((FLASH_ID) == QSPI_FLASH_ID_2))
\r
682 #define IS_QSPI_DUAL_FLASH_MODE(MODE) (((MODE) == QSPI_DUALFLASH_ENABLE) || \
\r
683 ((MODE) == QSPI_DUALFLASH_DISABLE))
\r
686 #define IS_QSPI_INSTRUCTION(INSTRUCTION) ((INSTRUCTION) <= 0xFFU)
\r
688 #define IS_QSPI_ADDRESS_SIZE(ADDR_SIZE) (((ADDR_SIZE) == QSPI_ADDRESS_8_BITS) || \
\r
689 ((ADDR_SIZE) == QSPI_ADDRESS_16_BITS) || \
\r
690 ((ADDR_SIZE) == QSPI_ADDRESS_24_BITS) || \
\r
691 ((ADDR_SIZE) == QSPI_ADDRESS_32_BITS))
\r
693 #define IS_QSPI_ALTERNATE_BYTES_SIZE(SIZE) (((SIZE) == QSPI_ALTERNATE_BYTES_8_BITS) || \
\r
694 ((SIZE) == QSPI_ALTERNATE_BYTES_16_BITS) || \
\r
695 ((SIZE) == QSPI_ALTERNATE_BYTES_24_BITS) || \
\r
696 ((SIZE) == QSPI_ALTERNATE_BYTES_32_BITS))
\r
698 #define IS_QSPI_DUMMY_CYCLES(DCY) ((DCY) <= 31U)
\r
700 #define IS_QSPI_INSTRUCTION_MODE(MODE) (((MODE) == QSPI_INSTRUCTION_NONE) || \
\r
701 ((MODE) == QSPI_INSTRUCTION_1_LINE) || \
\r
702 ((MODE) == QSPI_INSTRUCTION_2_LINES) || \
\r
703 ((MODE) == QSPI_INSTRUCTION_4_LINES))
\r
705 #define IS_QSPI_ADDRESS_MODE(MODE) (((MODE) == QSPI_ADDRESS_NONE) || \
\r
706 ((MODE) == QSPI_ADDRESS_1_LINE) || \
\r
707 ((MODE) == QSPI_ADDRESS_2_LINES) || \
\r
708 ((MODE) == QSPI_ADDRESS_4_LINES))
\r
710 #define IS_QSPI_ALTERNATE_BYTES_MODE(MODE) (((MODE) == QSPI_ALTERNATE_BYTES_NONE) || \
\r
711 ((MODE) == QSPI_ALTERNATE_BYTES_1_LINE) || \
\r
712 ((MODE) == QSPI_ALTERNATE_BYTES_2_LINES) || \
\r
713 ((MODE) == QSPI_ALTERNATE_BYTES_4_LINES))
\r
715 #define IS_QSPI_DATA_MODE(MODE) (((MODE) == QSPI_DATA_NONE) || \
\r
716 ((MODE) == QSPI_DATA_1_LINE) || \
\r
717 ((MODE) == QSPI_DATA_2_LINES) || \
\r
718 ((MODE) == QSPI_DATA_4_LINES))
\r
720 #define IS_QSPI_DDR_MODE(DDR_MODE) (((DDR_MODE) == QSPI_DDR_MODE_DISABLE) || \
\r
721 ((DDR_MODE) == QSPI_DDR_MODE_ENABLE))
\r
723 #if defined(QUADSPI_CCR_DHHC)
\r
724 #define IS_QSPI_DDR_HHC(DDR_HHC) (((DDR_HHC) == QSPI_DDR_HHC_ANALOG_DELAY) || \
\r
725 ((DDR_HHC) == QSPI_DDR_HHC_HALF_CLK_DELAY))
\r
728 #define IS_QSPI_DDR_HHC(DDR_HHC) (((DDR_HHC) == QSPI_DDR_HHC_ANALOG_DELAY))
\r
731 #define IS_QSPI_SIOO_MODE(SIOO_MODE) (((SIOO_MODE) == QSPI_SIOO_INST_EVERY_CMD) || \
\r
732 ((SIOO_MODE) == QSPI_SIOO_INST_ONLY_FIRST_CMD))
\r
734 #define IS_QSPI_INTERVAL(INTERVAL) ((INTERVAL) <= QUADSPI_PIR_INTERVAL)
\r
736 #define IS_QSPI_STATUS_BYTES_SIZE(SIZE) (((SIZE) >= 1U) && ((SIZE) <= 4U))
\r
738 #define IS_QSPI_MATCH_MODE(MODE) (((MODE) == QSPI_MATCH_MODE_AND) || \
\r
739 ((MODE) == QSPI_MATCH_MODE_OR))
\r
741 #define IS_QSPI_AUTOMATIC_STOP(APMS) (((APMS) == QSPI_AUTOMATIC_STOP_DISABLE) || \
\r
742 ((APMS) == QSPI_AUTOMATIC_STOP_ENABLE))
\r
744 #define IS_QSPI_TIMEOUT_ACTIVATION(TCEN) (((TCEN) == QSPI_TIMEOUT_COUNTER_DISABLE) || \
\r
745 ((TCEN) == QSPI_TIMEOUT_COUNTER_ENABLE))
\r
747 #define IS_QSPI_TIMEOUT_PERIOD(PERIOD) ((PERIOD) <= 0xFFFFU)
\r
751 /* End of private macros -----------------------------------------------------*/
\r
761 #endif /* defined(QUADSPI) || defined(QUADSPI1) || defined(QUADSPI2) */
\r
767 #endif /* STM32L4xx_HAL_QSPI_H */
\r
769 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r