20#ifndef STM32H7xx_HAL_QSPI_H
21#define STM32H7xx_HAL_QSPI_H
51 uint32_t ClockPrescaler;
53 uint32_t FifoThreshold;
55 uint32_t SampleShifting;
63 uint32_t ChipSelectHighTime;
79 HAL_QSPI_STATE_RESET = 0x00U,
80 HAL_QSPI_STATE_READY = 0x01U,
81 HAL_QSPI_STATE_BUSY = 0x02U,
82 HAL_QSPI_STATE_BUSY_INDIRECT_TX = 0x12U,
83 HAL_QSPI_STATE_BUSY_INDIRECT_RX = 0x22U,
84 HAL_QSPI_STATE_BUSY_AUTO_POLLING = 0x42U,
85 HAL_QSPI_STATE_BUSY_MEM_MAPPED = 0x82U,
86 HAL_QSPI_STATE_ABORT = 0x08U,
87 HAL_QSPI_STATE_ERROR = 0x04U
88}HAL_QSPI_StateTypeDef;
93#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
94typedef struct __QSPI_HandleTypeDef
100 QSPI_InitTypeDef Init;
102 __IO uint32_t TxXferSize;
103 __IO uint32_t TxXferCount;
105 __IO uint32_t RxXferSize;
106 __IO uint32_t RxXferCount;
109 __IO HAL_QSPI_StateTypeDef State;
110 __IO uint32_t ErrorCode;
112#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
113 void (* ErrorCallback) (
struct __QSPI_HandleTypeDef *hqspi);
114 void (* AbortCpltCallback) (
struct __QSPI_HandleTypeDef *hqspi);
115 void (* FifoThresholdCallback)(
struct __QSPI_HandleTypeDef *hqspi);
116 void (* CmdCpltCallback) (
struct __QSPI_HandleTypeDef *hqspi);
117 void (* RxCpltCallback) (
struct __QSPI_HandleTypeDef *hqspi);
118 void (* TxCpltCallback) (
struct __QSPI_HandleTypeDef *hqspi);
119 void (* StatusMatchCallback) (
struct __QSPI_HandleTypeDef *hqspi);
120 void (* TimeOutCallback) (
struct __QSPI_HandleTypeDef *hqspi);
122 void (* MspInitCallback) (
struct __QSPI_HandleTypeDef *hqspi);
123 void (* MspDeInitCallback) (
struct __QSPI_HandleTypeDef *hqspi);
132 uint32_t Instruction;
136 uint32_t AlternateBytes;
138 uint32_t AddressSize;
140 uint32_t AlternateBytesSize;
142 uint32_t DummyCycles;
144 uint32_t InstructionMode;
146 uint32_t AddressMode;
148 uint32_t AlternateByteMode;
157 uint32_t DdrHoldHalfCycle;
175 uint32_t StatusBytesSize;
179 uint32_t AutomaticStop;
181}QSPI_AutoPollingTypeDef;
188 uint32_t TimeOutPeriod;
190 uint32_t TimeOutActivation;
192}QSPI_MemoryMappedTypeDef;
194#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
200 HAL_QSPI_ERROR_CB_ID = 0x00U,
201 HAL_QSPI_ABORT_CB_ID = 0x01U,
202 HAL_QSPI_FIFO_THRESHOLD_CB_ID = 0x02U,
203 HAL_QSPI_CMD_CPLT_CB_ID = 0x03U,
204 HAL_QSPI_RX_CPLT_CB_ID = 0x04U,
205 HAL_QSPI_TX_CPLT_CB_ID = 0x05U,
206 HAL_QSPI_STATUS_MATCH_CB_ID = 0x08U,
207 HAL_QSPI_TIMEOUT_CB_ID = 0x09U,
209 HAL_QSPI_MSP_INIT_CB_ID = 0x0AU,
210 HAL_QSPI_MSP_DEINIT_CB_ID = 0x0B0
211}HAL_QSPI_CallbackIDTypeDef;
216typedef void (*pQSPI_CallbackTypeDef)(QSPI_HandleTypeDef *hqspi);
232#define HAL_QSPI_ERROR_NONE 0x00000000U
233#define HAL_QSPI_ERROR_TIMEOUT 0x00000001U
234#define HAL_QSPI_ERROR_TRANSFER 0x00000002U
235#define HAL_QSPI_ERROR_DMA 0x00000004U
236#define HAL_QSPI_ERROR_INVALID_PARAM 0x00000008U
237#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
238#define HAL_QSPI_ERROR_INVALID_CALLBACK 0x00000010U
248#define QSPI_SAMPLE_SHIFTING_NONE 0x00000000U
249#define QSPI_SAMPLE_SHIFTING_HALFCYCLE ((uint32_t)QUADSPI_CR_SSHIFT)
258#define QSPI_CS_HIGH_TIME_1_CYCLE 0x00000000U
259#define QSPI_CS_HIGH_TIME_2_CYCLE ((uint32_t)QUADSPI_DCR_CSHT_0)
260#define QSPI_CS_HIGH_TIME_3_CYCLE ((uint32_t)QUADSPI_DCR_CSHT_1)
261#define QSPI_CS_HIGH_TIME_4_CYCLE ((uint32_t)QUADSPI_DCR_CSHT_0 | QUADSPI_DCR_CSHT_1)
262#define QSPI_CS_HIGH_TIME_5_CYCLE ((uint32_t)QUADSPI_DCR_CSHT_2)
263#define QSPI_CS_HIGH_TIME_6_CYCLE ((uint32_t)QUADSPI_DCR_CSHT_2 | QUADSPI_DCR_CSHT_0)
264#define QSPI_CS_HIGH_TIME_7_CYCLE ((uint32_t)QUADSPI_DCR_CSHT_2 | QUADSPI_DCR_CSHT_1)
265#define QSPI_CS_HIGH_TIME_8_CYCLE ((uint32_t)QUADSPI_DCR_CSHT)
274#define QSPI_CLOCK_MODE_0 0x00000000U
275#define QSPI_CLOCK_MODE_3 ((uint32_t)QUADSPI_DCR_CKMODE)
284#define QSPI_FLASH_ID_1 0x00000000U
285#define QSPI_FLASH_ID_2 ((uint32_t)QUADSPI_CR_FSEL)
294#define QSPI_DUALFLASH_ENABLE ((uint32_t)QUADSPI_CR_DFM)
295#define QSPI_DUALFLASH_DISABLE 0x00000000U
304#define QSPI_ADDRESS_8_BITS 0x00000000U
305#define QSPI_ADDRESS_16_BITS ((uint32_t)QUADSPI_CCR_ADSIZE_0)
306#define QSPI_ADDRESS_24_BITS ((uint32_t)QUADSPI_CCR_ADSIZE_1)
307#define QSPI_ADDRESS_32_BITS ((uint32_t)QUADSPI_CCR_ADSIZE)
316#define QSPI_ALTERNATE_BYTES_8_BITS 0x00000000U
317#define QSPI_ALTERNATE_BYTES_16_BITS ((uint32_t)QUADSPI_CCR_ABSIZE_0)
318#define QSPI_ALTERNATE_BYTES_24_BITS ((uint32_t)QUADSPI_CCR_ABSIZE_1)
319#define QSPI_ALTERNATE_BYTES_32_BITS ((uint32_t)QUADSPI_CCR_ABSIZE)
328#define QSPI_INSTRUCTION_NONE 0x00000000U
329#define QSPI_INSTRUCTION_1_LINE ((uint32_t)QUADSPI_CCR_IMODE_0)
330#define QSPI_INSTRUCTION_2_LINES ((uint32_t)QUADSPI_CCR_IMODE_1)
331#define QSPI_INSTRUCTION_4_LINES ((uint32_t)QUADSPI_CCR_IMODE)
340#define QSPI_ADDRESS_NONE 0x00000000U
341#define QSPI_ADDRESS_1_LINE ((uint32_t)QUADSPI_CCR_ADMODE_0)
342#define QSPI_ADDRESS_2_LINES ((uint32_t)QUADSPI_CCR_ADMODE_1)
343#define QSPI_ADDRESS_4_LINES ((uint32_t)QUADSPI_CCR_ADMODE)
352#define QSPI_ALTERNATE_BYTES_NONE 0x00000000U
353#define QSPI_ALTERNATE_BYTES_1_LINE ((uint32_t)QUADSPI_CCR_ABMODE_0)
354#define QSPI_ALTERNATE_BYTES_2_LINES ((uint32_t)QUADSPI_CCR_ABMODE_1)
355#define QSPI_ALTERNATE_BYTES_4_LINES ((uint32_t)QUADSPI_CCR_ABMODE)
364#define QSPI_DATA_NONE 0x00000000U
365#define QSPI_DATA_1_LINE ((uint32_t)QUADSPI_CCR_DMODE_0)
366#define QSPI_DATA_2_LINES ((uint32_t)QUADSPI_CCR_DMODE_1)
367#define QSPI_DATA_4_LINES ((uint32_t)QUADSPI_CCR_DMODE)
376#define QSPI_DDR_MODE_DISABLE 0x00000000U
377#define QSPI_DDR_MODE_ENABLE ((uint32_t)QUADSPI_CCR_DDRM)
386#define QSPI_DDR_HHC_ANALOG_DELAY 0x00000000U
387#define QSPI_DDR_HHC_HALF_CLK_DELAY ((uint32_t)QUADSPI_CCR_DHHC)
396#define QSPI_SIOO_INST_EVERY_CMD 0x00000000U
397#define QSPI_SIOO_INST_ONLY_FIRST_CMD ((uint32_t)QUADSPI_CCR_SIOO)
406#define QSPI_MATCH_MODE_AND 0x00000000U
407#define QSPI_MATCH_MODE_OR ((uint32_t)QUADSPI_CR_PMM)
416#define QSPI_AUTOMATIC_STOP_DISABLE 0x00000000U
417#define QSPI_AUTOMATIC_STOP_ENABLE ((uint32_t)QUADSPI_CR_APMS)
426#define QSPI_TIMEOUT_COUNTER_DISABLE 0x00000000U
427#define QSPI_TIMEOUT_COUNTER_ENABLE ((uint32_t)QUADSPI_CR_TCEN)
436#define QSPI_FLAG_BUSY QUADSPI_SR_BUSY
437#define QSPI_FLAG_TO QUADSPI_SR_TOF
438#define QSPI_FLAG_SM QUADSPI_SR_SMF
439#define QSPI_FLAG_FT QUADSPI_SR_FTF
440#define QSPI_FLAG_TC QUADSPI_SR_TCF
441#define QSPI_FLAG_TE QUADSPI_SR_TEF
450#define QSPI_IT_TO QUADSPI_CR_TOIE
451#define QSPI_IT_SM QUADSPI_CR_SMIE
452#define QSPI_IT_FT QUADSPI_CR_FTIE
453#define QSPI_IT_TC QUADSPI_CR_TCIE
454#define QSPI_IT_TE QUADSPI_CR_TEIE
464#define HAL_QSPI_TIMEOUT_DEFAULT_VALUE 5000U
482#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
483#define __HAL_QSPI_RESET_HANDLE_STATE(__HANDLE__) do { \
484 (__HANDLE__)->State = HAL_QSPI_STATE_RESET; \
485 (__HANDLE__)->MspInitCallback = NULL; \
486 (__HANDLE__)->MspDeInitCallback = NULL; \
489#define __HAL_QSPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_QSPI_STATE_RESET)
496#define __HAL_QSPI_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR, QUADSPI_CR_EN)
502#define __HAL_QSPI_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR, QUADSPI_CR_EN)
515#define __HAL_QSPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CR, (__INTERRUPT__))
529#define __HAL_QSPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CR, (__INTERRUPT__))
542#define __HAL_QSPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (READ_BIT((__HANDLE__)->Instance->CR, (__INTERRUPT__)) == (__INTERRUPT__))
557#define __HAL_QSPI_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BIT((__HANDLE__)->Instance->SR, (__FLAG__)) != 0U) ? SET : RESET)
569#define __HAL_QSPI_CLEAR_FLAG(__HANDLE__, __FLAG__) WRITE_REG((__HANDLE__)->Instance->FCR, (__FLAG__))
585void HAL_QSPI_MspInit (QSPI_HandleTypeDef *hqspi);
586void HAL_QSPI_MspDeInit(QSPI_HandleTypeDef *hqspi);
596void HAL_QSPI_IRQHandler(QSPI_HandleTypeDef *hqspi);
599HAL_StatusTypeDef HAL_QSPI_Command (QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd, uint32_t Timeout);
600HAL_StatusTypeDef HAL_QSPI_Transmit (QSPI_HandleTypeDef *hqspi, uint8_t *pData, uint32_t Timeout);
601HAL_StatusTypeDef HAL_QSPI_Receive (QSPI_HandleTypeDef *hqspi, uint8_t *pData, uint32_t Timeout);
602HAL_StatusTypeDef HAL_QSPI_Command_IT (QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd);
603HAL_StatusTypeDef HAL_QSPI_Transmit_IT (QSPI_HandleTypeDef *hqspi, uint8_t *pData);
604HAL_StatusTypeDef HAL_QSPI_Receive_IT (QSPI_HandleTypeDef *hqspi, uint8_t *pData);
605HAL_StatusTypeDef HAL_QSPI_Transmit_DMA (QSPI_HandleTypeDef *hqspi, uint8_t *pData);
606HAL_StatusTypeDef HAL_QSPI_Receive_DMA (QSPI_HandleTypeDef *hqspi, uint8_t *pData);
609HAL_StatusTypeDef HAL_QSPI_AutoPolling (QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd, QSPI_AutoPollingTypeDef *cfg, uint32_t Timeout);
610HAL_StatusTypeDef HAL_QSPI_AutoPolling_IT(QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd, QSPI_AutoPollingTypeDef *cfg);
613HAL_StatusTypeDef HAL_QSPI_MemoryMapped(QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd, QSPI_MemoryMappedTypeDef *cfg);
616void HAL_QSPI_ErrorCallback (QSPI_HandleTypeDef *hqspi);
617void HAL_QSPI_AbortCpltCallback (QSPI_HandleTypeDef *hqspi);
618void HAL_QSPI_FifoThresholdCallback(QSPI_HandleTypeDef *hqspi);
621void HAL_QSPI_CmdCpltCallback (QSPI_HandleTypeDef *hqspi);
622void HAL_QSPI_RxCpltCallback (QSPI_HandleTypeDef *hqspi);
623void HAL_QSPI_TxCpltCallback (QSPI_HandleTypeDef *hqspi);
626void HAL_QSPI_StatusMatchCallback (QSPI_HandleTypeDef *hqspi);
629void HAL_QSPI_TimeOutCallback (QSPI_HandleTypeDef *hqspi);
631#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
633HAL_StatusTypeDef HAL_QSPI_RegisterCallback (QSPI_HandleTypeDef *hqspi, HAL_QSPI_CallbackIDTypeDef CallbackId, pQSPI_CallbackTypeDef pCallback);
634HAL_StatusTypeDef HAL_QSPI_UnRegisterCallback (QSPI_HandleTypeDef *hqspi, HAL_QSPI_CallbackIDTypeDef CallbackId);
644HAL_QSPI_StateTypeDef HAL_QSPI_GetState (
const QSPI_HandleTypeDef *hqspi);
645uint32_t HAL_QSPI_GetError (
const QSPI_HandleTypeDef *hqspi);
648void HAL_QSPI_SetTimeout (QSPI_HandleTypeDef *hqspi, uint32_t Timeout);
649HAL_StatusTypeDef HAL_QSPI_SetFifoThreshold(QSPI_HandleTypeDef *hqspi, uint32_t Threshold);
650uint32_t HAL_QSPI_GetFifoThreshold(
const QSPI_HandleTypeDef *hqspi);
651HAL_StatusTypeDef HAL_QSPI_SetFlashID (QSPI_HandleTypeDef *hqspi, uint32_t FlashID);
666#define IS_QSPI_CLOCK_PRESCALER(PRESCALER) ((PRESCALER) <= 0xFFU)
668#define IS_QSPI_FIFO_THRESHOLD(THR) (((THR) > 0U) && ((THR) <= 32U))
670#define IS_QSPI_SSHIFT(SSHIFT) (((SSHIFT) == QSPI_SAMPLE_SHIFTING_NONE) || \
671 ((SSHIFT) == QSPI_SAMPLE_SHIFTING_HALFCYCLE))
673#define IS_QSPI_FLASH_SIZE(FSIZE) (((FSIZE) <= 31U))
675#define IS_QSPI_CS_HIGH_TIME(CSHTIME) (((CSHTIME) == QSPI_CS_HIGH_TIME_1_CYCLE) || \
676 ((CSHTIME) == QSPI_CS_HIGH_TIME_2_CYCLE) || \
677 ((CSHTIME) == QSPI_CS_HIGH_TIME_3_CYCLE) || \
678 ((CSHTIME) == QSPI_CS_HIGH_TIME_4_CYCLE) || \
679 ((CSHTIME) == QSPI_CS_HIGH_TIME_5_CYCLE) || \
680 ((CSHTIME) == QSPI_CS_HIGH_TIME_6_CYCLE) || \
681 ((CSHTIME) == QSPI_CS_HIGH_TIME_7_CYCLE) || \
682 ((CSHTIME) == QSPI_CS_HIGH_TIME_8_CYCLE))
684#define IS_QSPI_CLOCK_MODE(CLKMODE) (((CLKMODE) == QSPI_CLOCK_MODE_0) || \
685 ((CLKMODE) == QSPI_CLOCK_MODE_3))
687#define IS_QSPI_FLASH_ID(FLASH_ID) (((FLASH_ID) == QSPI_FLASH_ID_1) || \
688 ((FLASH_ID) == QSPI_FLASH_ID_2))
690#define IS_QSPI_DUAL_FLASH_MODE(MODE) (((MODE) == QSPI_DUALFLASH_ENABLE) || \
691 ((MODE) == QSPI_DUALFLASH_DISABLE))
693#define IS_QSPI_INSTRUCTION(INSTRUCTION) ((INSTRUCTION) <= 0xFFU)
695#define IS_QSPI_ADDRESS_SIZE(ADDR_SIZE) (((ADDR_SIZE) == QSPI_ADDRESS_8_BITS) || \
696 ((ADDR_SIZE) == QSPI_ADDRESS_16_BITS) || \
697 ((ADDR_SIZE) == QSPI_ADDRESS_24_BITS) || \
698 ((ADDR_SIZE) == QSPI_ADDRESS_32_BITS))
700#define IS_QSPI_ALTERNATE_BYTES_SIZE(SIZE) (((SIZE) == QSPI_ALTERNATE_BYTES_8_BITS) || \
701 ((SIZE) == QSPI_ALTERNATE_BYTES_16_BITS) || \
702 ((SIZE) == QSPI_ALTERNATE_BYTES_24_BITS) || \
703 ((SIZE) == QSPI_ALTERNATE_BYTES_32_BITS))
705#define IS_QSPI_DUMMY_CYCLES(DCY) ((DCY) <= 31U)
707#define IS_QSPI_INSTRUCTION_MODE(MODE) (((MODE) == QSPI_INSTRUCTION_NONE) || \
708 ((MODE) == QSPI_INSTRUCTION_1_LINE) || \
709 ((MODE) == QSPI_INSTRUCTION_2_LINES) || \
710 ((MODE) == QSPI_INSTRUCTION_4_LINES))
712#define IS_QSPI_ADDRESS_MODE(MODE) (((MODE) == QSPI_ADDRESS_NONE) || \
713 ((MODE) == QSPI_ADDRESS_1_LINE) || \
714 ((MODE) == QSPI_ADDRESS_2_LINES) || \
715 ((MODE) == QSPI_ADDRESS_4_LINES))
717#define IS_QSPI_ALTERNATE_BYTES_MODE(MODE) (((MODE) == QSPI_ALTERNATE_BYTES_NONE) || \
718 ((MODE) == QSPI_ALTERNATE_BYTES_1_LINE) || \
719 ((MODE) == QSPI_ALTERNATE_BYTES_2_LINES) || \
720 ((MODE) == QSPI_ALTERNATE_BYTES_4_LINES))
722#define IS_QSPI_DATA_MODE(MODE) (((MODE) == QSPI_DATA_NONE) || \
723 ((MODE) == QSPI_DATA_1_LINE) || \
724 ((MODE) == QSPI_DATA_2_LINES) || \
725 ((MODE) == QSPI_DATA_4_LINES))
727#define IS_QSPI_DDR_MODE(DDR_MODE) (((DDR_MODE) == QSPI_DDR_MODE_DISABLE) || \
728 ((DDR_MODE) == QSPI_DDR_MODE_ENABLE))
730#define IS_QSPI_DDR_HHC(DDR_HHC) (((DDR_HHC) == QSPI_DDR_HHC_ANALOG_DELAY) || \
731 ((DDR_HHC) == QSPI_DDR_HHC_HALF_CLK_DELAY))
733#define IS_QSPI_SIOO_MODE(SIOO_MODE) (((SIOO_MODE) == QSPI_SIOO_INST_EVERY_CMD) || \
734 ((SIOO_MODE) == QSPI_SIOO_INST_ONLY_FIRST_CMD))
736#define IS_QSPI_INTERVAL(INTERVAL) ((INTERVAL) <= QUADSPI_PIR_INTERVAL)
738#define IS_QSPI_STATUS_BYTES_SIZE(SIZE) (((SIZE) >= 1U) && ((SIZE) <= 4U))
740#define IS_QSPI_MATCH_MODE(MODE) (((MODE) == QSPI_MATCH_MODE_AND) || \
741 ((MODE) == QSPI_MATCH_MODE_OR))
743#define IS_QSPI_AUTOMATIC_STOP(APMS) (((APMS) == QSPI_AUTOMATIC_STOP_DISABLE) || \
744 ((APMS) == QSPI_AUTOMATIC_STOP_ENABLE))
746#define IS_QSPI_TIMEOUT_ACTIVATION(TCEN) (((TCEN) == QSPI_TIMEOUT_COUNTER_DISABLE) || \
747 ((TCEN) == QSPI_TIMEOUT_COUNTER_ENABLE))
749#define IS_QSPI_TIMEOUT_PERIOD(PERIOD) ((PERIOD) <= 0xFFFFU)
#define __IO
Definition: core_cm4.h:239
This file contains HAL common defines, enumeration, macros and structures definitions.
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32h7xx_hal_def.h:47
HAL_LockTypeDef
HAL Lock structures definition.
Definition: stm32h7xx_hal_def.h:58
QUAD Serial Peripheral Interface.
Definition: stm32h742xx.h:1414
MDMA handle Structure definition.
Definition: stm32h7xx_hal_mdma.h:204