TUKS MCU Introductory course / TUKS-COURSE-TIMER
Committer:
elmot
Date:
Fri Feb 24 21:13:56 2017 +0000
Revision:
1:d0dfbce63a89
Ready-to-copy

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elmot 1:d0dfbce63a89 1 /**
elmot 1:d0dfbce63a89 2 ******************************************************************************
elmot 1:d0dfbce63a89 3 * @file stm32l4xx_hal_qspi.h
elmot 1:d0dfbce63a89 4 * @author MCD Application Team
elmot 1:d0dfbce63a89 5 * @version V1.5.1
elmot 1:d0dfbce63a89 6 * @date 31-May-2016
elmot 1:d0dfbce63a89 7 * @brief Header file of QSPI HAL module.
elmot 1:d0dfbce63a89 8 ******************************************************************************
elmot 1:d0dfbce63a89 9 * @attention
elmot 1:d0dfbce63a89 10 *
elmot 1:d0dfbce63a89 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
elmot 1:d0dfbce63a89 12 *
elmot 1:d0dfbce63a89 13 * Redistribution and use in source and binary forms, with or without modification,
elmot 1:d0dfbce63a89 14 * are permitted provided that the following conditions are met:
elmot 1:d0dfbce63a89 15 * 1. Redistributions of source code must retain the above copyright notice,
elmot 1:d0dfbce63a89 16 * this list of conditions and the following disclaimer.
elmot 1:d0dfbce63a89 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
elmot 1:d0dfbce63a89 18 * this list of conditions and the following disclaimer in the documentation
elmot 1:d0dfbce63a89 19 * and/or other materials provided with the distribution.
elmot 1:d0dfbce63a89 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
elmot 1:d0dfbce63a89 21 * may be used to endorse or promote products derived from this software
elmot 1:d0dfbce63a89 22 * without specific prior written permission.
elmot 1:d0dfbce63a89 23 *
elmot 1:d0dfbce63a89 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
elmot 1:d0dfbce63a89 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
elmot 1:d0dfbce63a89 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
elmot 1:d0dfbce63a89 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
elmot 1:d0dfbce63a89 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
elmot 1:d0dfbce63a89 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
elmot 1:d0dfbce63a89 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
elmot 1:d0dfbce63a89 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
elmot 1:d0dfbce63a89 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
elmot 1:d0dfbce63a89 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
elmot 1:d0dfbce63a89 34 *
elmot 1:d0dfbce63a89 35 ******************************************************************************
elmot 1:d0dfbce63a89 36 */
elmot 1:d0dfbce63a89 37
elmot 1:d0dfbce63a89 38 /* Define to prevent recursive inclusion -------------------------------------*/
elmot 1:d0dfbce63a89 39 #ifndef __STM32L4xx_HAL_QSPI_H
elmot 1:d0dfbce63a89 40 #define __STM32L4xx_HAL_QSPI_H
elmot 1:d0dfbce63a89 41
elmot 1:d0dfbce63a89 42 #ifdef __cplusplus
elmot 1:d0dfbce63a89 43 extern "C" {
elmot 1:d0dfbce63a89 44 #endif
elmot 1:d0dfbce63a89 45
elmot 1:d0dfbce63a89 46 /* Includes ------------------------------------------------------------------*/
elmot 1:d0dfbce63a89 47 #include "stm32l4xx_hal_def.h"
elmot 1:d0dfbce63a89 48
elmot 1:d0dfbce63a89 49 /** @addtogroup STM32L4xx_HAL_Driver
elmot 1:d0dfbce63a89 50 * @{
elmot 1:d0dfbce63a89 51 */
elmot 1:d0dfbce63a89 52
elmot 1:d0dfbce63a89 53 /** @addtogroup QSPI
elmot 1:d0dfbce63a89 54 * @{
elmot 1:d0dfbce63a89 55 */
elmot 1:d0dfbce63a89 56
elmot 1:d0dfbce63a89 57 /* Exported types ------------------------------------------------------------*/
elmot 1:d0dfbce63a89 58 /** @defgroup QSPI_Exported_Types QSPI Exported Types
elmot 1:d0dfbce63a89 59 * @{
elmot 1:d0dfbce63a89 60 */
elmot 1:d0dfbce63a89 61
elmot 1:d0dfbce63a89 62 /**
elmot 1:d0dfbce63a89 63 * @brief QSPI Init structure definition
elmot 1:d0dfbce63a89 64 */
elmot 1:d0dfbce63a89 65 typedef struct
elmot 1:d0dfbce63a89 66 {
elmot 1:d0dfbce63a89 67 uint32_t ClockPrescaler; /* Specifies the prescaler factor for generating clock based on the AHB clock.
elmot 1:d0dfbce63a89 68 This parameter can be a number between 0 and 255 */
elmot 1:d0dfbce63a89 69 uint32_t FifoThreshold; /* Specifies the threshold number of bytes in the FIFO (used only in indirect mode)
elmot 1:d0dfbce63a89 70 This parameter can be a value between 1 and 16 */
elmot 1:d0dfbce63a89 71 uint32_t SampleShifting; /* Specifies the Sample Shift. The data is sampled 1/2 clock cycle delay later to
elmot 1:d0dfbce63a89 72 take in account external signal delays. (It should be QSPI_SAMPLE_SHIFTING_NONE in DDR mode)
elmot 1:d0dfbce63a89 73 This parameter can be a value of @ref QSPI_SampleShifting */
elmot 1:d0dfbce63a89 74 uint32_t FlashSize; /* Specifies the Flash Size. FlashSize+1 is effectively the number of address bits
elmot 1:d0dfbce63a89 75 required to address the flash memory. The flash capacity can be up to 4GB
elmot 1:d0dfbce63a89 76 (addressed using 32 bits) in indirect mode, but the addressable space in
elmot 1:d0dfbce63a89 77 memory-mapped mode is limited to 256MB
elmot 1:d0dfbce63a89 78 This parameter can be a number between 0 and 31 */
elmot 1:d0dfbce63a89 79 uint32_t ChipSelectHighTime; /* Specifies the Chip Select High Time. ChipSelectHighTime+1 defines the minimum number
elmot 1:d0dfbce63a89 80 of clock cycles which the chip select must remain high between commands.
elmot 1:d0dfbce63a89 81 This parameter can be a value of @ref QSPI_ChipSelectHighTime */
elmot 1:d0dfbce63a89 82 uint32_t ClockMode; /* Specifies the Clock Mode. It indicates the level that clock takes between commands.
elmot 1:d0dfbce63a89 83 This parameter can be a value of @ref QSPI_ClockMode */
elmot 1:d0dfbce63a89 84 #if defined(STM32L431xx) || defined(STM32L432xx) || defined(STM32L433xx) || defined(STM32L442xx) || defined(STM32L443xx)
elmot 1:d0dfbce63a89 85 uint32_t FlashID; /* Specifies the Flash which will be used,
elmot 1:d0dfbce63a89 86 This parameter can be a value of @ref QSPI_Flash_Select */
elmot 1:d0dfbce63a89 87 uint32_t DualFlash; /* Specifies the Dual Flash Mode State
elmot 1:d0dfbce63a89 88 This parameter can be a value of @ref QSPI_DualFlash_Mode */
elmot 1:d0dfbce63a89 89 #endif
elmot 1:d0dfbce63a89 90 }QSPI_InitTypeDef;
elmot 1:d0dfbce63a89 91
elmot 1:d0dfbce63a89 92 /**
elmot 1:d0dfbce63a89 93 * @brief HAL QSPI State structures definition
elmot 1:d0dfbce63a89 94 */
elmot 1:d0dfbce63a89 95 typedef enum
elmot 1:d0dfbce63a89 96 {
elmot 1:d0dfbce63a89 97 HAL_QSPI_STATE_RESET = 0x00, /*!< Peripheral not initialized */
elmot 1:d0dfbce63a89 98 HAL_QSPI_STATE_READY = 0x01, /*!< Peripheral initialized and ready for use */
elmot 1:d0dfbce63a89 99 HAL_QSPI_STATE_BUSY = 0x02, /*!< Peripheral in indirect mode and busy */
elmot 1:d0dfbce63a89 100 HAL_QSPI_STATE_BUSY_INDIRECT_TX = 0x12, /*!< Peripheral in indirect mode with transmission ongoing */
elmot 1:d0dfbce63a89 101 HAL_QSPI_STATE_BUSY_INDIRECT_RX = 0x22, /*!< Peripheral in indirect mode with reception ongoing */
elmot 1:d0dfbce63a89 102 HAL_QSPI_STATE_BUSY_AUTO_POLLING = 0x42, /*!< Peripheral in auto polling mode ongoing */
elmot 1:d0dfbce63a89 103 HAL_QSPI_STATE_BUSY_MEM_MAPPED = 0x82, /*!< Peripheral in memory mapped mode ongoing */
elmot 1:d0dfbce63a89 104 HAL_QSPI_STATE_ABORT = 0x08, /*!< Peripheral with abort request ongoing */
elmot 1:d0dfbce63a89 105 HAL_QSPI_STATE_ERROR = 0x04 /*!< Peripheral in error */
elmot 1:d0dfbce63a89 106 }HAL_QSPI_StateTypeDef;
elmot 1:d0dfbce63a89 107
elmot 1:d0dfbce63a89 108 /**
elmot 1:d0dfbce63a89 109 * @brief QSPI Handle Structure definition
elmot 1:d0dfbce63a89 110 */
elmot 1:d0dfbce63a89 111 typedef struct
elmot 1:d0dfbce63a89 112 {
elmot 1:d0dfbce63a89 113 QUADSPI_TypeDef *Instance; /* QSPI registers base address */
elmot 1:d0dfbce63a89 114 QSPI_InitTypeDef Init; /* QSPI communication parameters */
elmot 1:d0dfbce63a89 115 uint8_t *pTxBuffPtr; /* Pointer to QSPI Tx transfer Buffer */
elmot 1:d0dfbce63a89 116 __IO uint16_t TxXferSize; /* QSPI Tx Transfer size */
elmot 1:d0dfbce63a89 117 __IO uint16_t TxXferCount; /* QSPI Tx Transfer Counter */
elmot 1:d0dfbce63a89 118 uint8_t *pRxBuffPtr; /* Pointer to QSPI Rx transfer Buffer */
elmot 1:d0dfbce63a89 119 __IO uint16_t RxXferSize; /* QSPI Rx Transfer size */
elmot 1:d0dfbce63a89 120 __IO uint16_t RxXferCount; /* QSPI Rx Transfer Counter */
elmot 1:d0dfbce63a89 121 DMA_HandleTypeDef *hdma; /* QSPI Rx/Tx DMA Handle parameters */
elmot 1:d0dfbce63a89 122 __IO HAL_LockTypeDef Lock; /* Locking object */
elmot 1:d0dfbce63a89 123 __IO HAL_QSPI_StateTypeDef State; /* QSPI communication state */
elmot 1:d0dfbce63a89 124 __IO uint32_t ErrorCode; /* QSPI Error code */
elmot 1:d0dfbce63a89 125 uint32_t Timeout; /* Timeout for the QSPI memory access */
elmot 1:d0dfbce63a89 126 }QSPI_HandleTypeDef;
elmot 1:d0dfbce63a89 127
elmot 1:d0dfbce63a89 128 /**
elmot 1:d0dfbce63a89 129 * @brief QSPI Command structure definition
elmot 1:d0dfbce63a89 130 */
elmot 1:d0dfbce63a89 131 typedef struct
elmot 1:d0dfbce63a89 132 {
elmot 1:d0dfbce63a89 133 uint32_t Instruction; /* Specifies the Instruction to be sent
elmot 1:d0dfbce63a89 134 This parameter can be a value (8-bit) between 0x00 and 0xFF */
elmot 1:d0dfbce63a89 135 uint32_t Address; /* Specifies the Address to be sent (Size from 1 to 4 bytes according AddressSize)
elmot 1:d0dfbce63a89 136 This parameter can be a value (32-bits) between 0x0 and 0xFFFFFFFF */
elmot 1:d0dfbce63a89 137 uint32_t AlternateBytes; /* Specifies the Alternate Bytes to be sent (Size from 1 to 4 bytes according AlternateBytesSize)
elmot 1:d0dfbce63a89 138 This parameter can be a value (32-bits) between 0x0 and 0xFFFFFFFF */
elmot 1:d0dfbce63a89 139 uint32_t AddressSize; /* Specifies the Address Size
elmot 1:d0dfbce63a89 140 This parameter can be a value of @ref QSPI_AddressSize */
elmot 1:d0dfbce63a89 141 uint32_t AlternateBytesSize; /* Specifies the Alternate Bytes Size
elmot 1:d0dfbce63a89 142 This parameter can be a value of @ref QSPI_AlternateBytesSize */
elmot 1:d0dfbce63a89 143 uint32_t DummyCycles; /* Specifies the Number of Dummy Cycles.
elmot 1:d0dfbce63a89 144 This parameter can be a number between 0 and 31 */
elmot 1:d0dfbce63a89 145 uint32_t InstructionMode; /* Specifies the Instruction Mode
elmot 1:d0dfbce63a89 146 This parameter can be a value of @ref QSPI_InstructionMode */
elmot 1:d0dfbce63a89 147 uint32_t AddressMode; /* Specifies the Address Mode
elmot 1:d0dfbce63a89 148 This parameter can be a value of @ref QSPI_AddressMode */
elmot 1:d0dfbce63a89 149 uint32_t AlternateByteMode; /* Specifies the Alternate Bytes Mode
elmot 1:d0dfbce63a89 150 This parameter can be a value of @ref QSPI_AlternateBytesMode */
elmot 1:d0dfbce63a89 151 uint32_t DataMode; /* Specifies the Data Mode (used for dummy cycles and data phases)
elmot 1:d0dfbce63a89 152 This parameter can be a value of @ref QSPI_DataMode */
elmot 1:d0dfbce63a89 153 uint32_t NbData; /* Specifies the number of data to transfer. (This is the number of bytes)
elmot 1:d0dfbce63a89 154 This parameter can be any value between 0 and 0xFFFFFFFF (0 means undefined length
elmot 1:d0dfbce63a89 155 until end of memory)*/
elmot 1:d0dfbce63a89 156 uint32_t DdrMode; /* Specifies the double data rate mode for address, alternate byte and data phase
elmot 1:d0dfbce63a89 157 This parameter can be a value of @ref QSPI_DdrMode */
elmot 1:d0dfbce63a89 158 uint32_t DdrHoldHalfCycle; /* Specifies the DDR hold half cycle. It delays the data output by one half of
elmot 1:d0dfbce63a89 159 system clock in DDR mode. Not available on STM32L4x6 devices but in future devices.
elmot 1:d0dfbce63a89 160 This parameter can be a value of @ref QSPI_DdrHoldHalfCycle */
elmot 1:d0dfbce63a89 161 uint32_t SIOOMode; /* Specifies the send instruction only once mode
elmot 1:d0dfbce63a89 162 This parameter can be a value of @ref QSPI_SIOOMode */
elmot 1:d0dfbce63a89 163 }QSPI_CommandTypeDef;
elmot 1:d0dfbce63a89 164
elmot 1:d0dfbce63a89 165 /**
elmot 1:d0dfbce63a89 166 * @brief QSPI Auto Polling mode configuration structure definition
elmot 1:d0dfbce63a89 167 */
elmot 1:d0dfbce63a89 168 typedef struct
elmot 1:d0dfbce63a89 169 {
elmot 1:d0dfbce63a89 170 uint32_t Match; /* Specifies the value to be compared with the masked status register to get a match.
elmot 1:d0dfbce63a89 171 This parameter can be any value between 0 and 0xFFFFFFFF */
elmot 1:d0dfbce63a89 172 uint32_t Mask; /* Specifies the mask to be applied to the status bytes received.
elmot 1:d0dfbce63a89 173 This parameter can be any value between 0 and 0xFFFFFFFF */
elmot 1:d0dfbce63a89 174 uint32_t Interval; /* Specifies the number of clock cycles between two read during automatic polling phases.
elmot 1:d0dfbce63a89 175 This parameter can be any value between 0 and 0xFFFF */
elmot 1:d0dfbce63a89 176 uint32_t StatusBytesSize; /* Specifies the size of the status bytes received.
elmot 1:d0dfbce63a89 177 This parameter can be any value between 1 and 4 */
elmot 1:d0dfbce63a89 178 uint32_t MatchMode; /* Specifies the method used for determining a match.
elmot 1:d0dfbce63a89 179 This parameter can be a value of @ref QSPI_MatchMode */
elmot 1:d0dfbce63a89 180 uint32_t AutomaticStop; /* Specifies if automatic polling is stopped after a match.
elmot 1:d0dfbce63a89 181 This parameter can be a value of @ref QSPI_AutomaticStop */
elmot 1:d0dfbce63a89 182 }QSPI_AutoPollingTypeDef;
elmot 1:d0dfbce63a89 183
elmot 1:d0dfbce63a89 184 /**
elmot 1:d0dfbce63a89 185 * @brief QSPI Memory Mapped mode configuration structure definition
elmot 1:d0dfbce63a89 186 */
elmot 1:d0dfbce63a89 187 typedef struct
elmot 1:d0dfbce63a89 188 {
elmot 1:d0dfbce63a89 189 uint32_t TimeOutPeriod; /* Specifies the number of clock to wait when the FIFO is full before to release the chip select.
elmot 1:d0dfbce63a89 190 This parameter can be any value between 0 and 0xFFFF */
elmot 1:d0dfbce63a89 191 uint32_t TimeOutActivation; /* Specifies if the timeout counter is enabled to release the chip select.
elmot 1:d0dfbce63a89 192 This parameter can be a value of @ref QSPI_TimeOutActivation */
elmot 1:d0dfbce63a89 193 }QSPI_MemoryMappedTypeDef;
elmot 1:d0dfbce63a89 194
elmot 1:d0dfbce63a89 195 /**
elmot 1:d0dfbce63a89 196 * @}
elmot 1:d0dfbce63a89 197 */
elmot 1:d0dfbce63a89 198
elmot 1:d0dfbce63a89 199 /* Exported constants --------------------------------------------------------*/
elmot 1:d0dfbce63a89 200 /** @defgroup QSPI_Exported_Constants QSPI Exported Constants
elmot 1:d0dfbce63a89 201 * @{
elmot 1:d0dfbce63a89 202 */
elmot 1:d0dfbce63a89 203
elmot 1:d0dfbce63a89 204 /** @defgroup QSPI_ErrorCode QSPI Error Code
elmot 1:d0dfbce63a89 205 * @{
elmot 1:d0dfbce63a89 206 */
elmot 1:d0dfbce63a89 207 #define HAL_QSPI_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */
elmot 1:d0dfbce63a89 208 #define HAL_QSPI_ERROR_TIMEOUT ((uint32_t)0x00000001) /*!< Timeout error */
elmot 1:d0dfbce63a89 209 #define HAL_QSPI_ERROR_TRANSFER ((uint32_t)0x00000002) /*!< Transfer error */
elmot 1:d0dfbce63a89 210 #define HAL_QSPI_ERROR_DMA ((uint32_t)0x00000004) /*!< DMA transfer error */
elmot 1:d0dfbce63a89 211 #define HAL_QSPI_ERROR_INVALID_PARAM ((uint32_t)0x00000008) /*!< Invalid parameters error */
elmot 1:d0dfbce63a89 212 /**
elmot 1:d0dfbce63a89 213 * @}
elmot 1:d0dfbce63a89 214 */
elmot 1:d0dfbce63a89 215
elmot 1:d0dfbce63a89 216 /** @defgroup QSPI_SampleShifting QSPI Sample Shifting
elmot 1:d0dfbce63a89 217 * @{
elmot 1:d0dfbce63a89 218 */
elmot 1:d0dfbce63a89 219 #define QSPI_SAMPLE_SHIFTING_NONE ((uint32_t)0x00000000) /*!<No clock cycle shift to sample data*/
elmot 1:d0dfbce63a89 220 #define QSPI_SAMPLE_SHIFTING_HALFCYCLE ((uint32_t)QUADSPI_CR_SSHIFT) /*!<1/2 clock cycle shift to sample data*/
elmot 1:d0dfbce63a89 221 /**
elmot 1:d0dfbce63a89 222 * @}
elmot 1:d0dfbce63a89 223 */
elmot 1:d0dfbce63a89 224
elmot 1:d0dfbce63a89 225 /** @defgroup QSPI_ChipSelectHighTime QSPI ChipSelect High Time
elmot 1:d0dfbce63a89 226 * @{
elmot 1:d0dfbce63a89 227 */
elmot 1:d0dfbce63a89 228 #define QSPI_CS_HIGH_TIME_1_CYCLE ((uint32_t)0x00000000) /*!<nCS stay high for at least 1 clock cycle between commands*/
elmot 1:d0dfbce63a89 229 #define QSPI_CS_HIGH_TIME_2_CYCLE ((uint32_t)QUADSPI_DCR_CSHT_0) /*!<nCS stay high for at least 2 clock cycles between commands*/
elmot 1:d0dfbce63a89 230 #define QSPI_CS_HIGH_TIME_3_CYCLE ((uint32_t)QUADSPI_DCR_CSHT_1) /*!<nCS stay high for at least 3 clock cycles between commands*/
elmot 1:d0dfbce63a89 231 #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*/
elmot 1:d0dfbce63a89 232 #define QSPI_CS_HIGH_TIME_5_CYCLE ((uint32_t)QUADSPI_DCR_CSHT_2) /*!<nCS stay high for at least 5 clock cycles between commands*/
elmot 1:d0dfbce63a89 233 #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*/
elmot 1:d0dfbce63a89 234 #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*/
elmot 1:d0dfbce63a89 235 #define QSPI_CS_HIGH_TIME_8_CYCLE ((uint32_t)QUADSPI_DCR_CSHT) /*!<nCS stay high for at least 8 clock cycles between commands*/
elmot 1:d0dfbce63a89 236 /**
elmot 1:d0dfbce63a89 237 * @}
elmot 1:d0dfbce63a89 238 */
elmot 1:d0dfbce63a89 239
elmot 1:d0dfbce63a89 240 /** @defgroup QSPI_ClockMode QSPI Clock Mode
elmot 1:d0dfbce63a89 241 * @{
elmot 1:d0dfbce63a89 242 */
elmot 1:d0dfbce63a89 243 #define QSPI_CLOCK_MODE_0 ((uint32_t)0x00000000) /*!<Clk stays low while nCS is released*/
elmot 1:d0dfbce63a89 244 #define QSPI_CLOCK_MODE_3 ((uint32_t)QUADSPI_DCR_CKMODE) /*!<Clk goes high while nCS is released*/
elmot 1:d0dfbce63a89 245 /**
elmot 1:d0dfbce63a89 246 * @}
elmot 1:d0dfbce63a89 247 */
elmot 1:d0dfbce63a89 248
elmot 1:d0dfbce63a89 249 #if defined(STM32L431xx) || defined(STM32L432xx) || defined(STM32L433xx) || defined(STM32L442xx) || defined(STM32L443xx)
elmot 1:d0dfbce63a89 250 /** @defgroup QSPI_Flash_Select QSPI Flash Select
elmot 1:d0dfbce63a89 251 * @{
elmot 1:d0dfbce63a89 252 */
elmot 1:d0dfbce63a89 253 #define QSPI_FLASH_ID_1 ((uint32_t)0x00000000) /*!<FLASH 1 selected*/
elmot 1:d0dfbce63a89 254 #define QSPI_FLASH_ID_2 ((uint32_t)QUADSPI_CR_FSEL) /*!<FLASH 2 selected*/
elmot 1:d0dfbce63a89 255 /**
elmot 1:d0dfbce63a89 256 * @}
elmot 1:d0dfbce63a89 257 */
elmot 1:d0dfbce63a89 258
elmot 1:d0dfbce63a89 259 /** @defgroup QSPI_DualFlash_Mode QSPI Dual Flash Mode
elmot 1:d0dfbce63a89 260 * @{
elmot 1:d0dfbce63a89 261 */
elmot 1:d0dfbce63a89 262 #define QSPI_DUALFLASH_ENABLE ((uint32_t)QUADSPI_CR_DFM) /*!<Dual-flash mode enabled*/
elmot 1:d0dfbce63a89 263 #define QSPI_DUALFLASH_DISABLE ((uint32_t)0x00000000) /*!<Dual-flash mode disabled*/
elmot 1:d0dfbce63a89 264 /**
elmot 1:d0dfbce63a89 265 * @}
elmot 1:d0dfbce63a89 266 */
elmot 1:d0dfbce63a89 267 #endif
elmot 1:d0dfbce63a89 268
elmot 1:d0dfbce63a89 269 /** @defgroup QSPI_AddressSize QSPI Address Size
elmot 1:d0dfbce63a89 270 * @{
elmot 1:d0dfbce63a89 271 */
elmot 1:d0dfbce63a89 272 #define QSPI_ADDRESS_8_BITS ((uint32_t)0x00000000) /*!<8-bit address*/
elmot 1:d0dfbce63a89 273 #define QSPI_ADDRESS_16_BITS ((uint32_t)QUADSPI_CCR_ADSIZE_0) /*!<16-bit address*/
elmot 1:d0dfbce63a89 274 #define QSPI_ADDRESS_24_BITS ((uint32_t)QUADSPI_CCR_ADSIZE_1) /*!<24-bit address*/
elmot 1:d0dfbce63a89 275 #define QSPI_ADDRESS_32_BITS ((uint32_t)QUADSPI_CCR_ADSIZE) /*!<32-bit address*/
elmot 1:d0dfbce63a89 276 /**
elmot 1:d0dfbce63a89 277 * @}
elmot 1:d0dfbce63a89 278 */
elmot 1:d0dfbce63a89 279
elmot 1:d0dfbce63a89 280 /** @defgroup QSPI_AlternateBytesSize QSPI Alternate Bytes Size
elmot 1:d0dfbce63a89 281 * @{
elmot 1:d0dfbce63a89 282 */
elmot 1:d0dfbce63a89 283 #define QSPI_ALTERNATE_BYTES_8_BITS ((uint32_t)0x00000000) /*!<8-bit alternate bytes*/
elmot 1:d0dfbce63a89 284 #define QSPI_ALTERNATE_BYTES_16_BITS ((uint32_t)QUADSPI_CCR_ABSIZE_0) /*!<16-bit alternate bytes*/
elmot 1:d0dfbce63a89 285 #define QSPI_ALTERNATE_BYTES_24_BITS ((uint32_t)QUADSPI_CCR_ABSIZE_1) /*!<24-bit alternate bytes*/
elmot 1:d0dfbce63a89 286 #define QSPI_ALTERNATE_BYTES_32_BITS ((uint32_t)QUADSPI_CCR_ABSIZE) /*!<32-bit alternate bytes*/
elmot 1:d0dfbce63a89 287 /**
elmot 1:d0dfbce63a89 288 * @}
elmot 1:d0dfbce63a89 289 */
elmot 1:d0dfbce63a89 290
elmot 1:d0dfbce63a89 291 /** @defgroup QSPI_InstructionMode QSPI Instruction Mode
elmot 1:d0dfbce63a89 292 * @{
elmot 1:d0dfbce63a89 293 */
elmot 1:d0dfbce63a89 294 #define QSPI_INSTRUCTION_NONE ((uint32_t)0x00000000) /*!<No instruction*/
elmot 1:d0dfbce63a89 295 #define QSPI_INSTRUCTION_1_LINE ((uint32_t)QUADSPI_CCR_IMODE_0) /*!<Instruction on a single line*/
elmot 1:d0dfbce63a89 296 #define QSPI_INSTRUCTION_2_LINES ((uint32_t)QUADSPI_CCR_IMODE_1) /*!<Instruction on two lines*/
elmot 1:d0dfbce63a89 297 #define QSPI_INSTRUCTION_4_LINES ((uint32_t)QUADSPI_CCR_IMODE) /*!<Instruction on four lines*/
elmot 1:d0dfbce63a89 298 /**
elmot 1:d0dfbce63a89 299 * @}
elmot 1:d0dfbce63a89 300 */
elmot 1:d0dfbce63a89 301
elmot 1:d0dfbce63a89 302 /** @defgroup QSPI_AddressMode QSPI Address Mode
elmot 1:d0dfbce63a89 303 * @{
elmot 1:d0dfbce63a89 304 */
elmot 1:d0dfbce63a89 305 #define QSPI_ADDRESS_NONE ((uint32_t)0x00000000) /*!<No address*/
elmot 1:d0dfbce63a89 306 #define QSPI_ADDRESS_1_LINE ((uint32_t)QUADSPI_CCR_ADMODE_0) /*!<Address on a single line*/
elmot 1:d0dfbce63a89 307 #define QSPI_ADDRESS_2_LINES ((uint32_t)QUADSPI_CCR_ADMODE_1) /*!<Address on two lines*/
elmot 1:d0dfbce63a89 308 #define QSPI_ADDRESS_4_LINES ((uint32_t)QUADSPI_CCR_ADMODE) /*!<Address on four lines*/
elmot 1:d0dfbce63a89 309 /**
elmot 1:d0dfbce63a89 310 * @}
elmot 1:d0dfbce63a89 311 */
elmot 1:d0dfbce63a89 312
elmot 1:d0dfbce63a89 313 /** @defgroup QSPI_AlternateBytesMode QSPI Alternate Bytes Mode
elmot 1:d0dfbce63a89 314 * @{
elmot 1:d0dfbce63a89 315 */
elmot 1:d0dfbce63a89 316 #define QSPI_ALTERNATE_BYTES_NONE ((uint32_t)0x00000000) /*!<No alternate bytes*/
elmot 1:d0dfbce63a89 317 #define QSPI_ALTERNATE_BYTES_1_LINE ((uint32_t)QUADSPI_CCR_ABMODE_0) /*!<Alternate bytes on a single line*/
elmot 1:d0dfbce63a89 318 #define QSPI_ALTERNATE_BYTES_2_LINES ((uint32_t)QUADSPI_CCR_ABMODE_1) /*!<Alternate bytes on two lines*/
elmot 1:d0dfbce63a89 319 #define QSPI_ALTERNATE_BYTES_4_LINES ((uint32_t)QUADSPI_CCR_ABMODE) /*!<Alternate bytes on four lines*/
elmot 1:d0dfbce63a89 320 /**
elmot 1:d0dfbce63a89 321 * @}
elmot 1:d0dfbce63a89 322 */
elmot 1:d0dfbce63a89 323
elmot 1:d0dfbce63a89 324 /** @defgroup QSPI_DataMode QSPI Data Mode
elmot 1:d0dfbce63a89 325 * @{
elmot 1:d0dfbce63a89 326 */
elmot 1:d0dfbce63a89 327 #define QSPI_DATA_NONE ((uint32_t)0X00000000) /*!<No data*/
elmot 1:d0dfbce63a89 328 #define QSPI_DATA_1_LINE ((uint32_t)QUADSPI_CCR_DMODE_0) /*!<Data on a single line*/
elmot 1:d0dfbce63a89 329 #define QSPI_DATA_2_LINES ((uint32_t)QUADSPI_CCR_DMODE_1) /*!<Data on two lines*/
elmot 1:d0dfbce63a89 330 #define QSPI_DATA_4_LINES ((uint32_t)QUADSPI_CCR_DMODE) /*!<Data on four lines*/
elmot 1:d0dfbce63a89 331 /**
elmot 1:d0dfbce63a89 332 * @}
elmot 1:d0dfbce63a89 333 */
elmot 1:d0dfbce63a89 334
elmot 1:d0dfbce63a89 335 /** @defgroup QSPI_DdrMode QSPI DDR Mode
elmot 1:d0dfbce63a89 336 * @{
elmot 1:d0dfbce63a89 337 */
elmot 1:d0dfbce63a89 338 #define QSPI_DDR_MODE_DISABLE ((uint32_t)0x00000000) /*!<Double data rate mode disabled*/
elmot 1:d0dfbce63a89 339 #define QSPI_DDR_MODE_ENABLE ((uint32_t)QUADSPI_CCR_DDRM) /*!<Double data rate mode enabled*/
elmot 1:d0dfbce63a89 340 /**
elmot 1:d0dfbce63a89 341 * @}
elmot 1:d0dfbce63a89 342 */
elmot 1:d0dfbce63a89 343
elmot 1:d0dfbce63a89 344 /** @defgroup QSPI_DdrHoldHalfCycle QSPI DDR Data Output Delay
elmot 1:d0dfbce63a89 345 * @{
elmot 1:d0dfbce63a89 346 */
elmot 1:d0dfbce63a89 347 #define QSPI_DDR_HHC_ANALOG_DELAY ((uint32_t)0x00000000) /*!<Delay the data output using analog delay in DDR mode*/
elmot 1:d0dfbce63a89 348 #if defined(STM32L431xx) || defined(STM32L432xx) || defined(STM32L433xx) || defined(STM32L442xx) || defined(STM32L443xx)
elmot 1:d0dfbce63a89 349 #define QSPI_DDR_HHC_HALF_CLK_DELAY ((uint32_t)QUADSPI_CCR_DHHC) /*!<Delay the data output by 1/2 clock cycle in DDR mode*/
elmot 1:d0dfbce63a89 350 #endif
elmot 1:d0dfbce63a89 351 /**
elmot 1:d0dfbce63a89 352 * @}
elmot 1:d0dfbce63a89 353 */
elmot 1:d0dfbce63a89 354
elmot 1:d0dfbce63a89 355 /** @defgroup QSPI_SIOOMode QSPI Send Instruction Mode
elmot 1:d0dfbce63a89 356 * @{
elmot 1:d0dfbce63a89 357 */
elmot 1:d0dfbce63a89 358 #define QSPI_SIOO_INST_EVERY_CMD ((uint32_t)0x00000000) /*!<Send instruction on every transaction*/
elmot 1:d0dfbce63a89 359 #define QSPI_SIOO_INST_ONLY_FIRST_CMD ((uint32_t)QUADSPI_CCR_SIOO) /*!<Send instruction only for the first command*/
elmot 1:d0dfbce63a89 360 /**
elmot 1:d0dfbce63a89 361 * @}
elmot 1:d0dfbce63a89 362 */
elmot 1:d0dfbce63a89 363
elmot 1:d0dfbce63a89 364 /** @defgroup QSPI_MatchMode QSPI Match Mode
elmot 1:d0dfbce63a89 365 * @{
elmot 1:d0dfbce63a89 366 */
elmot 1:d0dfbce63a89 367 #define QSPI_MATCH_MODE_AND ((uint32_t)0x00000000) /*!<AND match mode between unmasked bits*/
elmot 1:d0dfbce63a89 368 #define QSPI_MATCH_MODE_OR ((uint32_t)QUADSPI_CR_PMM) /*!<OR match mode between unmasked bits*/
elmot 1:d0dfbce63a89 369 /**
elmot 1:d0dfbce63a89 370 * @}
elmot 1:d0dfbce63a89 371 */
elmot 1:d0dfbce63a89 372
elmot 1:d0dfbce63a89 373 /** @defgroup QSPI_AutomaticStop QSPI Automatic Stop
elmot 1:d0dfbce63a89 374 * @{
elmot 1:d0dfbce63a89 375 */
elmot 1:d0dfbce63a89 376 #define QSPI_AUTOMATIC_STOP_DISABLE ((uint32_t)0x00000000) /*!<AutoPolling stops only with abort or QSPI disabling*/
elmot 1:d0dfbce63a89 377 #define QSPI_AUTOMATIC_STOP_ENABLE ((uint32_t)QUADSPI_CR_APMS) /*!<AutoPolling stops as soon as there is a match*/
elmot 1:d0dfbce63a89 378 /**
elmot 1:d0dfbce63a89 379 * @}
elmot 1:d0dfbce63a89 380 */
elmot 1:d0dfbce63a89 381
elmot 1:d0dfbce63a89 382 /** @defgroup QSPI_TimeOutActivation QSPI Timeout Activation
elmot 1:d0dfbce63a89 383 * @{
elmot 1:d0dfbce63a89 384 */
elmot 1:d0dfbce63a89 385 #define QSPI_TIMEOUT_COUNTER_DISABLE ((uint32_t)0x00000000) /*!<Timeout counter disabled, nCS remains active*/
elmot 1:d0dfbce63a89 386 #define QSPI_TIMEOUT_COUNTER_ENABLE ((uint32_t)QUADSPI_CR_TCEN) /*!<Timeout counter enabled, nCS released when timeout expires*/
elmot 1:d0dfbce63a89 387 /**
elmot 1:d0dfbce63a89 388 * @}
elmot 1:d0dfbce63a89 389 */
elmot 1:d0dfbce63a89 390
elmot 1:d0dfbce63a89 391 /** @defgroup QSPI_Flags QSPI Flags
elmot 1:d0dfbce63a89 392 * @{
elmot 1:d0dfbce63a89 393 */
elmot 1:d0dfbce63a89 394 #define QSPI_FLAG_BUSY QUADSPI_SR_BUSY /*!<Busy flag: operation is ongoing*/
elmot 1:d0dfbce63a89 395 #define QSPI_FLAG_TO QUADSPI_SR_TOF /*!<Timeout flag: timeout occurs in memory-mapped mode*/
elmot 1:d0dfbce63a89 396 #define QSPI_FLAG_SM QUADSPI_SR_SMF /*!<Status match flag: received data matches in autopolling mode*/
elmot 1:d0dfbce63a89 397 #define QSPI_FLAG_FT QUADSPI_SR_FTF /*!<Fifo threshold flag: Fifo threshold reached or data left after read from memory is complete*/
elmot 1:d0dfbce63a89 398 #define QSPI_FLAG_TC QUADSPI_SR_TCF /*!<Transfer complete flag: programmed number of data have been transferred or the transfer has been aborted*/
elmot 1:d0dfbce63a89 399 #define QSPI_FLAG_TE QUADSPI_SR_TEF /*!<Transfer error flag: invalid address is being accessed*/
elmot 1:d0dfbce63a89 400 /**
elmot 1:d0dfbce63a89 401 * @}
elmot 1:d0dfbce63a89 402 */
elmot 1:d0dfbce63a89 403
elmot 1:d0dfbce63a89 404 /** @defgroup QSPI_Interrupts QSPI Interrupts
elmot 1:d0dfbce63a89 405 * @{
elmot 1:d0dfbce63a89 406 */
elmot 1:d0dfbce63a89 407 #define QSPI_IT_TO QUADSPI_CR_TOIE /*!<Interrupt on the timeout flag*/
elmot 1:d0dfbce63a89 408 #define QSPI_IT_SM QUADSPI_CR_SMIE /*!<Interrupt on the status match flag*/
elmot 1:d0dfbce63a89 409 #define QSPI_IT_FT QUADSPI_CR_FTIE /*!<Interrupt on the fifo threshold flag*/
elmot 1:d0dfbce63a89 410 #define QSPI_IT_TC QUADSPI_CR_TCIE /*!<Interrupt on the transfer complete flag*/
elmot 1:d0dfbce63a89 411 #define QSPI_IT_TE QUADSPI_CR_TEIE /*!<Interrupt on the transfer error flag*/
elmot 1:d0dfbce63a89 412 /**
elmot 1:d0dfbce63a89 413 * @}
elmot 1:d0dfbce63a89 414 */
elmot 1:d0dfbce63a89 415
elmot 1:d0dfbce63a89 416 /** @defgroup QSPI_Timeout_definition QSPI Timeout definition
elmot 1:d0dfbce63a89 417 * @brief QSPI Timeout definition
elmot 1:d0dfbce63a89 418 * @{
elmot 1:d0dfbce63a89 419 */
elmot 1:d0dfbce63a89 420 #define HAL_QPSI_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000)/* 5 s */
elmot 1:d0dfbce63a89 421 /**
elmot 1:d0dfbce63a89 422 * @}
elmot 1:d0dfbce63a89 423 */
elmot 1:d0dfbce63a89 424
elmot 1:d0dfbce63a89 425 /**
elmot 1:d0dfbce63a89 426 * @}
elmot 1:d0dfbce63a89 427 */
elmot 1:d0dfbce63a89 428
elmot 1:d0dfbce63a89 429 /* Exported macros -----------------------------------------------------------*/
elmot 1:d0dfbce63a89 430 /** @defgroup QSPI_Exported_Macros QSPI Exported Macros
elmot 1:d0dfbce63a89 431 * @{
elmot 1:d0dfbce63a89 432 */
elmot 1:d0dfbce63a89 433 /** @brief Reset QSPI handle state.
elmot 1:d0dfbce63a89 434 * @param __HANDLE__: QSPI handle.
elmot 1:d0dfbce63a89 435 * @retval None
elmot 1:d0dfbce63a89 436 */
elmot 1:d0dfbce63a89 437 #define __HAL_QSPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_QSPI_STATE_RESET)
elmot 1:d0dfbce63a89 438
elmot 1:d0dfbce63a89 439 /** @brief Enable the QSPI peripheral.
elmot 1:d0dfbce63a89 440 * @param __HANDLE__: specifies the QSPI Handle.
elmot 1:d0dfbce63a89 441 * @retval None
elmot 1:d0dfbce63a89 442 */
elmot 1:d0dfbce63a89 443 #define __HAL_QSPI_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR, QUADSPI_CR_EN)
elmot 1:d0dfbce63a89 444
elmot 1:d0dfbce63a89 445 /** @brief Disable the QSPI peripheral.
elmot 1:d0dfbce63a89 446 * @param __HANDLE__: specifies the QSPI Handle.
elmot 1:d0dfbce63a89 447 * @retval None
elmot 1:d0dfbce63a89 448 */
elmot 1:d0dfbce63a89 449 #define __HAL_QSPI_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR, QUADSPI_CR_EN)
elmot 1:d0dfbce63a89 450
elmot 1:d0dfbce63a89 451 /** @brief Enable the specified QSPI interrupt.
elmot 1:d0dfbce63a89 452 * @param __HANDLE__: specifies the QSPI Handle.
elmot 1:d0dfbce63a89 453 * @param __INTERRUPT__: specifies the QSPI interrupt source to enable.
elmot 1:d0dfbce63a89 454 * This parameter can be one of the following values:
elmot 1:d0dfbce63a89 455 * @arg QSPI_IT_TO: QSPI Timeout interrupt
elmot 1:d0dfbce63a89 456 * @arg QSPI_IT_SM: QSPI Status match interrupt
elmot 1:d0dfbce63a89 457 * @arg QSPI_IT_FT: QSPI FIFO threshold interrupt
elmot 1:d0dfbce63a89 458 * @arg QSPI_IT_TC: QSPI Transfer complete interrupt
elmot 1:d0dfbce63a89 459 * @arg QSPI_IT_TE: QSPI Transfer error interrupt
elmot 1:d0dfbce63a89 460 * @retval None
elmot 1:d0dfbce63a89 461 */
elmot 1:d0dfbce63a89 462 #define __HAL_QSPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CR, (__INTERRUPT__))
elmot 1:d0dfbce63a89 463
elmot 1:d0dfbce63a89 464
elmot 1:d0dfbce63a89 465 /** @brief Disable the specified QSPI interrupt.
elmot 1:d0dfbce63a89 466 * @param __HANDLE__: specifies the QSPI Handle.
elmot 1:d0dfbce63a89 467 * @param __INTERRUPT__: specifies the QSPI interrupt source to disable.
elmot 1:d0dfbce63a89 468 * This parameter can be one of the following values:
elmot 1:d0dfbce63a89 469 * @arg QSPI_IT_TO: QSPI Timeout interrupt
elmot 1:d0dfbce63a89 470 * @arg QSPI_IT_SM: QSPI Status match interrupt
elmot 1:d0dfbce63a89 471 * @arg QSPI_IT_FT: QSPI FIFO threshold interrupt
elmot 1:d0dfbce63a89 472 * @arg QSPI_IT_TC: QSPI Transfer complete interrupt
elmot 1:d0dfbce63a89 473 * @arg QSPI_IT_TE: QSPI Transfer error interrupt
elmot 1:d0dfbce63a89 474 * @retval None
elmot 1:d0dfbce63a89 475 */
elmot 1:d0dfbce63a89 476 #define __HAL_QSPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CR, (__INTERRUPT__))
elmot 1:d0dfbce63a89 477
elmot 1:d0dfbce63a89 478 /** @brief Check whether the specified QSPI interrupt source is enabled or not.
elmot 1:d0dfbce63a89 479 * @param __HANDLE__: specifies the QSPI Handle.
elmot 1:d0dfbce63a89 480 * @param __INTERRUPT__: specifies the QSPI interrupt source to check.
elmot 1:d0dfbce63a89 481 * This parameter can be one of the following values:
elmot 1:d0dfbce63a89 482 * @arg QSPI_IT_TO: QSPI Timeout interrupt
elmot 1:d0dfbce63a89 483 * @arg QSPI_IT_SM: QSPI Status match interrupt
elmot 1:d0dfbce63a89 484 * @arg QSPI_IT_FT: QSPI FIFO threshold interrupt
elmot 1:d0dfbce63a89 485 * @arg QSPI_IT_TC: QSPI Transfer complete interrupt
elmot 1:d0dfbce63a89 486 * @arg QSPI_IT_TE: QSPI Transfer error interrupt
elmot 1:d0dfbce63a89 487 * @retval The new state of __INTERRUPT__ (TRUE or FALSE).
elmot 1:d0dfbce63a89 488 */
elmot 1:d0dfbce63a89 489 #define __HAL_QSPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (READ_BIT((__HANDLE__)->Instance->CR, (__INTERRUPT__)) == (__INTERRUPT__))
elmot 1:d0dfbce63a89 490
elmot 1:d0dfbce63a89 491 /**
elmot 1:d0dfbce63a89 492 * @brief Check whether the selected QSPI flag is set or not.
elmot 1:d0dfbce63a89 493 * @param __HANDLE__: specifies the QSPI Handle.
elmot 1:d0dfbce63a89 494 * @param __FLAG__: specifies the QSPI flag to check.
elmot 1:d0dfbce63a89 495 * This parameter can be one of the following values:
elmot 1:d0dfbce63a89 496 * @arg QSPI_FLAG_BUSY: QSPI Busy flag
elmot 1:d0dfbce63a89 497 * @arg QSPI_FLAG_TO: QSPI Timeout flag
elmot 1:d0dfbce63a89 498 * @arg QSPI_FLAG_SM: QSPI Status match flag
elmot 1:d0dfbce63a89 499 * @arg QSPI_FLAG_FT: QSPI FIFO threshold flag
elmot 1:d0dfbce63a89 500 * @arg QSPI_FLAG_TC: QSPI Transfer complete flag
elmot 1:d0dfbce63a89 501 * @arg QSPI_FLAG_TE: QSPI Transfer error flag
elmot 1:d0dfbce63a89 502 * @retval None
elmot 1:d0dfbce63a89 503 */
elmot 1:d0dfbce63a89 504 #define __HAL_QSPI_GET_FLAG(__HANDLE__, __FLAG__) (READ_BIT((__HANDLE__)->Instance->SR, (__FLAG__)) != 0)
elmot 1:d0dfbce63a89 505
elmot 1:d0dfbce63a89 506 /** @brief Clears the specified QSPI's flag status.
elmot 1:d0dfbce63a89 507 * @param __HANDLE__: specifies the QSPI Handle.
elmot 1:d0dfbce63a89 508 * @param __FLAG__: specifies the QSPI clear register flag that needs to be set
elmot 1:d0dfbce63a89 509 * This parameter can be one of the following values:
elmot 1:d0dfbce63a89 510 * @arg QSPI_FLAG_TO: QSPI Timeout flag
elmot 1:d0dfbce63a89 511 * @arg QSPI_FLAG_SM: QSPI Status match flag
elmot 1:d0dfbce63a89 512 * @arg QSPI_FLAG_TC: QSPI Transfer complete flag
elmot 1:d0dfbce63a89 513 * @arg QSPI_FLAG_TE: QSPI Transfer error flag
elmot 1:d0dfbce63a89 514 * @retval None
elmot 1:d0dfbce63a89 515 */
elmot 1:d0dfbce63a89 516 #define __HAL_QSPI_CLEAR_FLAG(__HANDLE__, __FLAG__) WRITE_REG((__HANDLE__)->Instance->FCR, (__FLAG__))
elmot 1:d0dfbce63a89 517 /**
elmot 1:d0dfbce63a89 518 * @}
elmot 1:d0dfbce63a89 519 */
elmot 1:d0dfbce63a89 520
elmot 1:d0dfbce63a89 521 /* Exported functions --------------------------------------------------------*/
elmot 1:d0dfbce63a89 522 /** @addtogroup QSPI_Exported_Functions
elmot 1:d0dfbce63a89 523 * @{
elmot 1:d0dfbce63a89 524 */
elmot 1:d0dfbce63a89 525 /* Initialization/de-initialization functions ********************************/
elmot 1:d0dfbce63a89 526 HAL_StatusTypeDef HAL_QSPI_Init (QSPI_HandleTypeDef *hqspi);
elmot 1:d0dfbce63a89 527 HAL_StatusTypeDef HAL_QSPI_DeInit (QSPI_HandleTypeDef *hqspi);
elmot 1:d0dfbce63a89 528 void HAL_QSPI_MspInit (QSPI_HandleTypeDef *hqspi);
elmot 1:d0dfbce63a89 529 void HAL_QSPI_MspDeInit(QSPI_HandleTypeDef *hqspi);
elmot 1:d0dfbce63a89 530
elmot 1:d0dfbce63a89 531 /* IO operation functions *****************************************************/
elmot 1:d0dfbce63a89 532 /* QSPI IRQ handler method */
elmot 1:d0dfbce63a89 533 void HAL_QSPI_IRQHandler(QSPI_HandleTypeDef *hqspi);
elmot 1:d0dfbce63a89 534
elmot 1:d0dfbce63a89 535 /* QSPI indirect mode */
elmot 1:d0dfbce63a89 536 HAL_StatusTypeDef HAL_QSPI_Command (QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd, uint32_t Timeout);
elmot 1:d0dfbce63a89 537 HAL_StatusTypeDef HAL_QSPI_Transmit (QSPI_HandleTypeDef *hqspi, uint8_t *pData, uint32_t Timeout);
elmot 1:d0dfbce63a89 538 HAL_StatusTypeDef HAL_QSPI_Receive (QSPI_HandleTypeDef *hqspi, uint8_t *pData, uint32_t Timeout);
elmot 1:d0dfbce63a89 539 HAL_StatusTypeDef HAL_QSPI_Command_IT (QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd);
elmot 1:d0dfbce63a89 540 HAL_StatusTypeDef HAL_QSPI_Transmit_IT (QSPI_HandleTypeDef *hqspi, uint8_t *pData);
elmot 1:d0dfbce63a89 541 HAL_StatusTypeDef HAL_QSPI_Receive_IT (QSPI_HandleTypeDef *hqspi, uint8_t *pData);
elmot 1:d0dfbce63a89 542 HAL_StatusTypeDef HAL_QSPI_Transmit_DMA (QSPI_HandleTypeDef *hqspi, uint8_t *pData);
elmot 1:d0dfbce63a89 543 HAL_StatusTypeDef HAL_QSPI_Receive_DMA (QSPI_HandleTypeDef *hqspi, uint8_t *pData);
elmot 1:d0dfbce63a89 544
elmot 1:d0dfbce63a89 545 /* QSPI status flag polling mode */
elmot 1:d0dfbce63a89 546 HAL_StatusTypeDef HAL_QSPI_AutoPolling (QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd, QSPI_AutoPollingTypeDef *cfg, uint32_t Timeout);
elmot 1:d0dfbce63a89 547 HAL_StatusTypeDef HAL_QSPI_AutoPolling_IT(QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd, QSPI_AutoPollingTypeDef *cfg);
elmot 1:d0dfbce63a89 548
elmot 1:d0dfbce63a89 549 /* QSPI memory-mapped mode */
elmot 1:d0dfbce63a89 550 HAL_StatusTypeDef HAL_QSPI_MemoryMapped(QSPI_HandleTypeDef *hqspi, QSPI_CommandTypeDef *cmd, QSPI_MemoryMappedTypeDef *cfg);
elmot 1:d0dfbce63a89 551
elmot 1:d0dfbce63a89 552 /* Callback functions in non-blocking modes ***********************************/
elmot 1:d0dfbce63a89 553 void HAL_QSPI_ErrorCallback (QSPI_HandleTypeDef *hqspi);
elmot 1:d0dfbce63a89 554 void HAL_QSPI_AbortCpltCallback (QSPI_HandleTypeDef *hqspi);
elmot 1:d0dfbce63a89 555 void HAL_QSPI_FifoThresholdCallback(QSPI_HandleTypeDef *hqspi);
elmot 1:d0dfbce63a89 556
elmot 1:d0dfbce63a89 557 /* QSPI indirect mode */
elmot 1:d0dfbce63a89 558 void HAL_QSPI_CmdCpltCallback (QSPI_HandleTypeDef *hqspi);
elmot 1:d0dfbce63a89 559 void HAL_QSPI_RxCpltCallback (QSPI_HandleTypeDef *hqspi);
elmot 1:d0dfbce63a89 560 void HAL_QSPI_TxCpltCallback (QSPI_HandleTypeDef *hqspi);
elmot 1:d0dfbce63a89 561 void HAL_QSPI_RxHalfCpltCallback (QSPI_HandleTypeDef *hqspi);
elmot 1:d0dfbce63a89 562 void HAL_QSPI_TxHalfCpltCallback (QSPI_HandleTypeDef *hqspi);
elmot 1:d0dfbce63a89 563
elmot 1:d0dfbce63a89 564 /* QSPI status flag polling mode */
elmot 1:d0dfbce63a89 565 void HAL_QSPI_StatusMatchCallback (QSPI_HandleTypeDef *hqspi);
elmot 1:d0dfbce63a89 566
elmot 1:d0dfbce63a89 567 /* QSPI memory-mapped mode */
elmot 1:d0dfbce63a89 568 void HAL_QSPI_TimeOutCallback (QSPI_HandleTypeDef *hqspi);
elmot 1:d0dfbce63a89 569
elmot 1:d0dfbce63a89 570 /* Peripheral Control and State functions ************************************/
elmot 1:d0dfbce63a89 571 HAL_QSPI_StateTypeDef HAL_QSPI_GetState (QSPI_HandleTypeDef *hqspi);
elmot 1:d0dfbce63a89 572 uint32_t HAL_QSPI_GetError (QSPI_HandleTypeDef *hqspi);
elmot 1:d0dfbce63a89 573 HAL_StatusTypeDef HAL_QSPI_Abort (QSPI_HandleTypeDef *hqspi);
elmot 1:d0dfbce63a89 574 HAL_StatusTypeDef HAL_QSPI_Abort_IT (QSPI_HandleTypeDef *hqspi);
elmot 1:d0dfbce63a89 575 void HAL_QSPI_SetTimeout (QSPI_HandleTypeDef *hqspi, uint32_t Timeout);
elmot 1:d0dfbce63a89 576 HAL_StatusTypeDef HAL_QSPI_SetFifoThreshold(QSPI_HandleTypeDef *hqspi, uint32_t Threshold);
elmot 1:d0dfbce63a89 577 uint32_t HAL_QSPI_GetFifoThreshold(QSPI_HandleTypeDef *hqspi);
elmot 1:d0dfbce63a89 578 /**
elmot 1:d0dfbce63a89 579 * @}
elmot 1:d0dfbce63a89 580 */
elmot 1:d0dfbce63a89 581 /* End of exported functions -------------------------------------------------*/
elmot 1:d0dfbce63a89 582
elmot 1:d0dfbce63a89 583 /* Private macros ------------------------------------------------------------*/
elmot 1:d0dfbce63a89 584 /** @defgroup QSPI_Private_Macros QSPI Private Macros
elmot 1:d0dfbce63a89 585 * @{
elmot 1:d0dfbce63a89 586 */
elmot 1:d0dfbce63a89 587 #define IS_QSPI_CLOCK_PRESCALER(PRESCALER) ((PRESCALER) <= 0xFF)
elmot 1:d0dfbce63a89 588
elmot 1:d0dfbce63a89 589 #define IS_QSPI_FIFO_THRESHOLD(THR) (((THR) > 0) && ((THR) <= 16))
elmot 1:d0dfbce63a89 590
elmot 1:d0dfbce63a89 591 #define IS_QSPI_SSHIFT(SSHIFT) (((SSHIFT) == QSPI_SAMPLE_SHIFTING_NONE) || \
elmot 1:d0dfbce63a89 592 ((SSHIFT) == QSPI_SAMPLE_SHIFTING_HALFCYCLE))
elmot 1:d0dfbce63a89 593
elmot 1:d0dfbce63a89 594 #define IS_QSPI_FLASH_SIZE(FSIZE) (((FSIZE) <= 31))
elmot 1:d0dfbce63a89 595
elmot 1:d0dfbce63a89 596 #define IS_QSPI_CS_HIGH_TIME(CSHTIME) (((CSHTIME) == QSPI_CS_HIGH_TIME_1_CYCLE) || \
elmot 1:d0dfbce63a89 597 ((CSHTIME) == QSPI_CS_HIGH_TIME_2_CYCLE) || \
elmot 1:d0dfbce63a89 598 ((CSHTIME) == QSPI_CS_HIGH_TIME_3_CYCLE) || \
elmot 1:d0dfbce63a89 599 ((CSHTIME) == QSPI_CS_HIGH_TIME_4_CYCLE) || \
elmot 1:d0dfbce63a89 600 ((CSHTIME) == QSPI_CS_HIGH_TIME_5_CYCLE) || \
elmot 1:d0dfbce63a89 601 ((CSHTIME) == QSPI_CS_HIGH_TIME_6_CYCLE) || \
elmot 1:d0dfbce63a89 602 ((CSHTIME) == QSPI_CS_HIGH_TIME_7_CYCLE) || \
elmot 1:d0dfbce63a89 603 ((CSHTIME) == QSPI_CS_HIGH_TIME_8_CYCLE))
elmot 1:d0dfbce63a89 604
elmot 1:d0dfbce63a89 605 #define IS_QSPI_CLOCK_MODE(CLKMODE) (((CLKMODE) == QSPI_CLOCK_MODE_0) || \
elmot 1:d0dfbce63a89 606 ((CLKMODE) == QSPI_CLOCK_MODE_3))
elmot 1:d0dfbce63a89 607
elmot 1:d0dfbce63a89 608 #if defined(STM32L431xx) || defined(STM32L432xx) || defined(STM32L433xx) || defined(STM32L442xx) || defined(STM32L443xx)
elmot 1:d0dfbce63a89 609 #define IS_QSPI_FLASH_ID(FLASH) (((FLASH) == QSPI_FLASH_ID_1) || \
elmot 1:d0dfbce63a89 610 ((FLASH) == QSPI_FLASH_ID_2))
elmot 1:d0dfbce63a89 611
elmot 1:d0dfbce63a89 612 #define IS_QSPI_DUAL_FLASH_MODE(MODE) (((MODE) == QSPI_DUALFLASH_ENABLE) || \
elmot 1:d0dfbce63a89 613 ((MODE) == QSPI_DUALFLASH_DISABLE))
elmot 1:d0dfbce63a89 614 #endif
elmot 1:d0dfbce63a89 615
elmot 1:d0dfbce63a89 616 #define IS_QSPI_INSTRUCTION(INSTRUCTION) ((INSTRUCTION) <= 0xFF)
elmot 1:d0dfbce63a89 617
elmot 1:d0dfbce63a89 618 #define IS_QSPI_ADDRESS_SIZE(ADDR_SIZE) (((ADDR_SIZE) == QSPI_ADDRESS_8_BITS) || \
elmot 1:d0dfbce63a89 619 ((ADDR_SIZE) == QSPI_ADDRESS_16_BITS) || \
elmot 1:d0dfbce63a89 620 ((ADDR_SIZE) == QSPI_ADDRESS_24_BITS) || \
elmot 1:d0dfbce63a89 621 ((ADDR_SIZE) == QSPI_ADDRESS_32_BITS))
elmot 1:d0dfbce63a89 622
elmot 1:d0dfbce63a89 623 #define IS_QSPI_ALTERNATE_BYTES_SIZE(SIZE) (((SIZE) == QSPI_ALTERNATE_BYTES_8_BITS) || \
elmot 1:d0dfbce63a89 624 ((SIZE) == QSPI_ALTERNATE_BYTES_16_BITS) || \
elmot 1:d0dfbce63a89 625 ((SIZE) == QSPI_ALTERNATE_BYTES_24_BITS) || \
elmot 1:d0dfbce63a89 626 ((SIZE) == QSPI_ALTERNATE_BYTES_32_BITS))
elmot 1:d0dfbce63a89 627
elmot 1:d0dfbce63a89 628 #define IS_QSPI_DUMMY_CYCLES(DCY) ((DCY) <= 31)
elmot 1:d0dfbce63a89 629
elmot 1:d0dfbce63a89 630 #define IS_QSPI_INSTRUCTION_MODE(MODE) (((MODE) == QSPI_INSTRUCTION_NONE) || \
elmot 1:d0dfbce63a89 631 ((MODE) == QSPI_INSTRUCTION_1_LINE) || \
elmot 1:d0dfbce63a89 632 ((MODE) == QSPI_INSTRUCTION_2_LINES) || \
elmot 1:d0dfbce63a89 633 ((MODE) == QSPI_INSTRUCTION_4_LINES))
elmot 1:d0dfbce63a89 634
elmot 1:d0dfbce63a89 635 #define IS_QSPI_ADDRESS_MODE(MODE) (((MODE) == QSPI_ADDRESS_NONE) || \
elmot 1:d0dfbce63a89 636 ((MODE) == QSPI_ADDRESS_1_LINE) || \
elmot 1:d0dfbce63a89 637 ((MODE) == QSPI_ADDRESS_2_LINES) || \
elmot 1:d0dfbce63a89 638 ((MODE) == QSPI_ADDRESS_4_LINES))
elmot 1:d0dfbce63a89 639
elmot 1:d0dfbce63a89 640 #define IS_QSPI_ALTERNATE_BYTES_MODE(MODE) (((MODE) == QSPI_ALTERNATE_BYTES_NONE) || \
elmot 1:d0dfbce63a89 641 ((MODE) == QSPI_ALTERNATE_BYTES_1_LINE) || \
elmot 1:d0dfbce63a89 642 ((MODE) == QSPI_ALTERNATE_BYTES_2_LINES) || \
elmot 1:d0dfbce63a89 643 ((MODE) == QSPI_ALTERNATE_BYTES_4_LINES))
elmot 1:d0dfbce63a89 644
elmot 1:d0dfbce63a89 645 #define IS_QSPI_DATA_MODE(MODE) (((MODE) == QSPI_DATA_NONE) || \
elmot 1:d0dfbce63a89 646 ((MODE) == QSPI_DATA_1_LINE) || \
elmot 1:d0dfbce63a89 647 ((MODE) == QSPI_DATA_2_LINES) || \
elmot 1:d0dfbce63a89 648 ((MODE) == QSPI_DATA_4_LINES))
elmot 1:d0dfbce63a89 649
elmot 1:d0dfbce63a89 650 #define IS_QSPI_DDR_MODE(DDR_MODE) (((DDR_MODE) == QSPI_DDR_MODE_DISABLE) || \
elmot 1:d0dfbce63a89 651 ((DDR_MODE) == QSPI_DDR_MODE_ENABLE))
elmot 1:d0dfbce63a89 652
elmot 1:d0dfbce63a89 653 #if defined(STM32L431xx) || defined(STM32L432xx) || defined(STM32L433xx) || defined(STM32L442xx) || defined(STM32L443xx)
elmot 1:d0dfbce63a89 654 #define IS_QSPI_DDR_HHC(DDR_HHC) (((DDR_HHC) == QSPI_DDR_HHC_ANALOG_DELAY) || \
elmot 1:d0dfbce63a89 655 ((DDR_HHC) == QSPI_DDR_HHC_HALF_CLK_DELAY))
elmot 1:d0dfbce63a89 656 #else
elmot 1:d0dfbce63a89 657 #define IS_QSPI_DDR_HHC(DDR_HHC) (((DDR_HHC) == QSPI_DDR_HHC_ANALOG_DELAY))
elmot 1:d0dfbce63a89 658 #endif
elmot 1:d0dfbce63a89 659
elmot 1:d0dfbce63a89 660 #define IS_QSPI_SIOO_MODE(SIOO_MODE) (((SIOO_MODE) == QSPI_SIOO_INST_EVERY_CMD) || \
elmot 1:d0dfbce63a89 661 ((SIOO_MODE) == QSPI_SIOO_INST_ONLY_FIRST_CMD))
elmot 1:d0dfbce63a89 662
elmot 1:d0dfbce63a89 663 #define IS_QSPI_INTERVAL(INTERVAL) ((INTERVAL) <= QUADSPI_PIR_INTERVAL)
elmot 1:d0dfbce63a89 664
elmot 1:d0dfbce63a89 665 #define IS_QSPI_STATUS_BYTES_SIZE(SIZE) (((SIZE) >= 1) && ((SIZE) <= 4))
elmot 1:d0dfbce63a89 666
elmot 1:d0dfbce63a89 667 #define IS_QSPI_MATCH_MODE(MODE) (((MODE) == QSPI_MATCH_MODE_AND) || \
elmot 1:d0dfbce63a89 668 ((MODE) == QSPI_MATCH_MODE_OR))
elmot 1:d0dfbce63a89 669
elmot 1:d0dfbce63a89 670 #define IS_QSPI_AUTOMATIC_STOP(APMS) (((APMS) == QSPI_AUTOMATIC_STOP_DISABLE) || \
elmot 1:d0dfbce63a89 671 ((APMS) == QSPI_AUTOMATIC_STOP_ENABLE))
elmot 1:d0dfbce63a89 672
elmot 1:d0dfbce63a89 673 #define IS_QSPI_TIMEOUT_ACTIVATION(TCEN) (((TCEN) == QSPI_TIMEOUT_COUNTER_DISABLE) || \
elmot 1:d0dfbce63a89 674 ((TCEN) == QSPI_TIMEOUT_COUNTER_ENABLE))
elmot 1:d0dfbce63a89 675
elmot 1:d0dfbce63a89 676 #define IS_QSPI_TIMEOUT_PERIOD(PERIOD) ((PERIOD) <= 0xFFFF)
elmot 1:d0dfbce63a89 677 /**
elmot 1:d0dfbce63a89 678 * @}
elmot 1:d0dfbce63a89 679 */
elmot 1:d0dfbce63a89 680 /* End of private macros -----------------------------------------------------*/
elmot 1:d0dfbce63a89 681
elmot 1:d0dfbce63a89 682 /**
elmot 1:d0dfbce63a89 683 * @}
elmot 1:d0dfbce63a89 684 */
elmot 1:d0dfbce63a89 685
elmot 1:d0dfbce63a89 686 /**
elmot 1:d0dfbce63a89 687 * @}
elmot 1:d0dfbce63a89 688 */
elmot 1:d0dfbce63a89 689
elmot 1:d0dfbce63a89 690 #ifdef __cplusplus
elmot 1:d0dfbce63a89 691 }
elmot 1:d0dfbce63a89 692 #endif
elmot 1:d0dfbce63a89 693
elmot 1:d0dfbce63a89 694 #endif /* __STM32L4xx_HAL_QSPI_H */
elmot 1:d0dfbce63a89 695
elmot 1:d0dfbce63a89 696 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/