Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:36

0001 /**
0002   ******************************************************************************
0003   * @file    stm32h7xx_hal_ospi.h
0004   * @author  MCD Application Team
0005   * @brief   Header file of OSPI HAL module.
0006   ******************************************************************************
0007   * @attention
0008   *
0009   * Copyright (c) 2017 STMicroelectronics.
0010   * All rights reserved.
0011   *
0012   * This software is licensed under terms that can be found in the LICENSE file
0013   * in the root directory of this software component.
0014   * If no LICENSE file comes with this software, it is provided AS-IS.
0015   *
0016   ******************************************************************************
0017   */
0018 
0019 /* Define to prevent recursive inclusion -------------------------------------*/
0020 #ifndef STM32H7xx_HAL_OSPI_H
0021 #define STM32H7xx_HAL_OSPI_H
0022 
0023 #ifdef __cplusplus
0024 extern "C" {
0025 #endif
0026 
0027 /* Includes ------------------------------------------------------------------*/
0028 #include "stm32h7xx_hal_def.h"
0029 
0030 #if defined(OCTOSPI) || defined(OCTOSPI1) || defined(OCTOSPI2)
0031 
0032 /** @addtogroup STM32H7xx_HAL_Driver
0033   * @{
0034   */
0035 
0036 /** @addtogroup OSPI
0037   * @{
0038   */
0039 
0040 /* Exported types ------------------------------------------------------------*/
0041 /** @defgroup OSPI_Exported_Types OSPI Exported Types
0042   * @ingroup RTEMSBSPsARMSTM32H7
0043   * @{
0044   */
0045 
0046 /**
0047   * @brief OSPI Init structure definition
0048   */
0049 typedef struct
0050 {
0051   uint32_t FifoThreshold;             /*!< This is the threshold used by the Peripheral to generate the interrupt
0052                                            indicating that data are available in reception or free place
0053                                            is available in transmission.
0054                                            This parameter can be a value between 1 and 32 */
0055   uint32_t DualQuad;                  /*!< It enables or not the dual-quad mode which allow to access up to
0056                                            quad mode on two different devices to increase the throughput.
0057                                            This parameter can be a value of @ref OSPI_DualQuad */
0058   uint32_t MemoryType;                /*!< It indicates the external device type connected to the OSPI.
0059                                            This parameter can be a value of @ref OSPI_MemoryType */
0060   uint32_t DeviceSize;                /*!< It defines the size of the external device connected to the OSPI,
0061                                            it corresponds to the number of address bits required to access
0062                                            the external device.
0063                                            This parameter can be a value between 1 and 32 */
0064   uint32_t ChipSelectHighTime;        /*!< It defines the minimum number of clocks which the chip select
0065                                            must remain high between commands.
0066                                            This parameter can be a value between 1 and 8 */
0067   uint32_t FreeRunningClock;          /*!< It enables or not the free running clock.
0068                                            This parameter can be a value of @ref OSPI_FreeRunningClock */
0069   uint32_t ClockMode;                 /*!< It indicates the level of clock when the chip select is released.
0070                                            This parameter can be a value of @ref OSPI_ClockMode */
0071   uint32_t WrapSize;                  /*!< It indicates the wrap-size corresponding the external device configuration.
0072                                            This parameter can be a value of @ref OSPI_WrapSize */
0073   uint32_t ClockPrescaler;            /*!< It specifies the prescaler factor used for generating
0074                                            the external clock based on the AHB clock.
0075                                            This parameter can be a value between 1 and 256 */
0076   uint32_t SampleShifting;            /*!< It allows to delay to 1/2 cycle the data sampling in order
0077                                            to take in account external signal delays.
0078                                            This parameter can be a value of @ref OSPI_SampleShifting */
0079   uint32_t DelayHoldQuarterCycle;     /*!< It allows to hold to 1/4 cycle the data.
0080                                            This parameter can be a value of @ref OSPI_DelayHoldQuarterCycle */
0081   uint32_t ChipSelectBoundary;        /*!< It enables the transaction boundary feature and
0082                                            defines the boundary of bytes to release the chip select.
0083                                            This parameter can be a value between 0 and 31 */
0084   uint32_t DelayBlockBypass;          /*!< It enables the delay block bypass, so the sampling is not affected
0085                                            by the delay block.
0086                                            This parameter can be a value of @ref OSPI_DelayBlockBypass */
0087   uint32_t MaxTran;                   /*!< It enables the communication regulation feature. The chip select is
0088                                            released every MaxTran+1 bytes when the other OctoSPI request the access
0089                                            to the bus.
0090                                            This parameter can be a value between 0 and 255 */
0091   uint32_t Refresh;                   /*!< It enables the refresh rate feature. The chip select is released every
0092                                            Refresh+1 clock cycles.
0093                                            This parameter can be a value between 0 and 0xFFFFFFFF */
0094 } OSPI_InitTypeDef;
0095 
0096 /**
0097   * @brief  HAL OSPI Handle Structure definition
0098   */
0099 #if defined (USE_HAL_OSPI_REGISTER_CALLBACKS) && (USE_HAL_OSPI_REGISTER_CALLBACKS == 1U)
0100 typedef struct __OSPI_HandleTypeDef
0101 #else
0102 typedef struct
0103 #endif /* (USE_HAL_OSPI_REGISTER_CALLBACKS) && (USE_HAL_OSPI_REGISTER_CALLBACKS == 1U) */
0104 {
0105   OCTOSPI_TypeDef            *Instance;     /*!< OSPI registers base address                      */
0106   OSPI_InitTypeDef           Init;          /*!< OSPI initialization parameters                   */
0107   uint8_t                    *pBuffPtr;     /*!< Address of the OSPI buffer for transfer          */
0108   __IO uint32_t              XferSize;      /*!< Number of data to transfer                       */
0109   __IO uint32_t              XferCount;     /*!< Counter of data transferred                      */
0110   MDMA_HandleTypeDef     *hmdma;    /*!< Handle of the MDMA channel used for the transfer  */
0111   __IO uint32_t              State;         /*!< Internal state of the OSPI HAL driver            */
0112   __IO uint32_t              ErrorCode;     /*!< Error code in case of HAL driver internal error  */
0113   uint32_t                   Timeout;       /*!< Timeout used for the OSPI external device access */
0114 #if defined (USE_HAL_OSPI_REGISTER_CALLBACKS) && (USE_HAL_OSPI_REGISTER_CALLBACKS == 1U)
0115   void (* ErrorCallback)(struct __OSPI_HandleTypeDef *hospi);
0116   void (* AbortCpltCallback)(struct __OSPI_HandleTypeDef *hospi);
0117   void (* FifoThresholdCallback)(struct __OSPI_HandleTypeDef *hospi);
0118   void (* CmdCpltCallback)(struct __OSPI_HandleTypeDef *hospi);
0119   void (* RxCpltCallback)(struct __OSPI_HandleTypeDef *hospi);
0120   void (* TxCpltCallback)(struct __OSPI_HandleTypeDef *hospi);
0121   void (* RxHalfCpltCallback)(struct __OSPI_HandleTypeDef *hospi);
0122   void (* TxHalfCpltCallback)(struct __OSPI_HandleTypeDef *hospi);
0123   void (* StatusMatchCallback)(struct __OSPI_HandleTypeDef *hospi);
0124   void (* TimeOutCallback)(struct __OSPI_HandleTypeDef *hospi);
0125 
0126   void (* MspInitCallback)(struct __OSPI_HandleTypeDef *hospi);
0127   void (* MspDeInitCallback)(struct __OSPI_HandleTypeDef *hospi);
0128 #endif /* (USE_HAL_OSPI_REGISTER_CALLBACKS) && (USE_HAL_OSPI_REGISTER_CALLBACKS == 1U) */
0129 } OSPI_HandleTypeDef;
0130 
0131 /**
0132   * @brief  HAL OSPI Regular Command Structure definition
0133   */
0134 typedef struct
0135 {
0136   uint32_t OperationType;             /*!< It indicates if the configuration applies to the common registers or
0137                                            to the registers for the write operation (these registers are only
0138                                            used for memory-mapped mode).
0139                                            This parameter can be a value of @ref OSPI_OperationType */
0140   uint32_t FlashId;                   /*!< It indicates which external device is selected for this command (it
0141                                            applies only if Dualquad is disabled in the initialization structure).
0142                                            This parameter can be a value of @ref OSPI_FlashID */
0143   uint32_t Instruction;               /*!< It contains the instruction to be sent to the device.
0144                                            This parameter can be a value between 0 and 0xFFFFFFFF */
0145   uint32_t InstructionMode;           /*!< It indicates the mode of the instruction.
0146                                            This parameter can be a value of @ref OSPI_InstructionMode */
0147   uint32_t InstructionSize;           /*!< It indicates the size of the instruction.
0148                                            This parameter can be a value of @ref OSPI_InstructionSize */
0149   uint32_t InstructionDtrMode;        /*!< It enables or not the DTR mode for the instruction phase.
0150                                            This parameter can be a value of @ref OSPI_InstructionDtrMode */
0151   uint32_t Address;                   /*!< It contains the address to be sent to the device.
0152                                            This parameter can be a value between 0 and 0xFFFFFFFF */
0153   uint32_t AddressMode;               /*!< It indicates the mode of the address.
0154                                            This parameter can be a value of @ref OSPI_AddressMode */
0155   uint32_t AddressSize;               /*!< It indicates the size of the address.
0156                                            This parameter can be a value of @ref OSPI_AddressSize */
0157   uint32_t AddressDtrMode;            /*!< It enables or not the DTR mode for the address phase.
0158                                            This parameter can be a value of @ref OSPI_AddressDtrMode */
0159   uint32_t AlternateBytes;            /*!< It contains the alternate bytes to be sent to the device.
0160                                            This parameter can be a value between 0 and 0xFFFFFFFF */
0161   uint32_t AlternateBytesMode;        /*!< It indicates the mode of the alternate bytes.
0162                                            This parameter can be a value of @ref OSPI_AlternateBytesMode */
0163   uint32_t AlternateBytesSize;        /*!< It indicates the size of the alternate bytes.
0164                                            This parameter can be a value of @ref OSPI_AlternateBytesSize */
0165   uint32_t AlternateBytesDtrMode;     /*!< It enables or not the DTR mode for the alternate bytes phase.
0166                                            This parameter can be a value of @ref OSPI_AlternateBytesDtrMode */
0167   uint32_t DataMode;                  /*!< It indicates the mode of the data.
0168                                            This parameter can be a value of @ref OSPI_DataMode */
0169   uint32_t NbData;                    /*!< It indicates the number of data transferred with this command.
0170                                            This field is only used for indirect mode.
0171                                            This parameter can be a value between 1 and 0xFFFFFFFF */
0172   uint32_t DataDtrMode;               /*!< It enables or not the DTR mode for the data phase.
0173                                            This parameter can be a value of @ref OSPI_DataDtrMode */
0174   uint32_t DummyCycles;               /*!< It indicates the number of dummy cycles inserted before data phase.
0175                                            This parameter can be a value between 0 and 31 */
0176   uint32_t DQSMode;                   /*!< It enables or not the data strobe management.
0177                                            This parameter can be a value of @ref OSPI_DQSMode */
0178   uint32_t SIOOMode;                  /*!< It enables or not the SIOO mode.
0179                                            This parameter can be a value of @ref OSPI_SIOOMode */
0180 } OSPI_RegularCmdTypeDef;
0181 
0182 /**
0183   * @brief  HAL OSPI Hyperbus Configuration Structure definition
0184   */
0185 typedef struct
0186 {
0187   uint32_t RWRecoveryTime;       /*!< It indicates the number of cycles for the device read write recovery time.
0188                                       This parameter can be a value between 0 and 255 */
0189   uint32_t AccessTime;           /*!< It indicates the number of cycles for the device access time.
0190                                       This parameter can be a value between 0 and 255 */
0191   uint32_t WriteZeroLatency;     /*!< It enables or not the latency for the write access.
0192                                       This parameter can be a value of @ref OSPI_WriteZeroLatency */
0193   uint32_t LatencyMode;          /*!< It configures the latency mode.
0194                                       This parameter can be a value of @ref OSPI_LatencyMode */
0195 } OSPI_HyperbusCfgTypeDef;
0196 
0197 /**
0198   * @brief  HAL OSPI Hyperbus Command Structure definition
0199   */
0200 typedef struct
0201 {
0202   uint32_t AddressSpace;     /*!< It indicates the address space accessed by the command.
0203                                   This parameter can be a value of @ref OSPI_AddressSpace */
0204   uint32_t Address;          /*!< It contains the address to be sent tot he device.
0205                                   This parameter can be a value between 0 and 0xFFFFFFFF */
0206   uint32_t AddressSize;      /*!< It indicates the size of the address.
0207                                   This parameter can be a value of @ref OSPI_AddressSize */
0208   uint32_t NbData;           /*!< It indicates the number of data transferred with this command.
0209                                   This field is only used for indirect mode.
0210                                   This parameter can be a value between 1 and 0xFFFFFFFF
0211                                   In case of autopolling mode, this parameter can be any value between 1 and 4 */
0212   uint32_t DQSMode;          /*!< It enables or not the data strobe management.
0213                                   This parameter can be a value of @ref OSPI_DQSMode */
0214 } OSPI_HyperbusCmdTypeDef;
0215 
0216 /**
0217   * @brief  HAL OSPI Auto Polling mode configuration structure definition
0218   */
0219 typedef struct
0220 {
0221   uint32_t Match;              /*!< Specifies the value to be compared with the masked status register to get a match.
0222                                     This parameter can be any value between 0 and 0xFFFFFFFF */
0223   uint32_t Mask;               /*!< Specifies the mask to be applied to the status bytes received.
0224                                     This parameter can be any value between 0 and 0xFFFFFFFF */
0225   uint32_t MatchMode;          /*!< Specifies the method used for determining a match.
0226                                     This parameter can be a value of @ref OSPI_MatchMode */
0227   uint32_t AutomaticStop;      /*!< Specifies if automatic polling is stopped after a match.
0228                                     This parameter can be a value of @ref OSPI_AutomaticStop */
0229   uint32_t Interval;           /*!< Specifies the number of clock cycles between two read during automatic polling phases.
0230                                     This parameter can be any value between 0 and 0xFFFF */
0231 } OSPI_AutoPollingTypeDef;
0232 
0233 /**
0234   * @brief  HAL OSPI Memory Mapped mode configuration structure definition
0235   */
0236 typedef struct
0237 {
0238   uint32_t TimeOutActivation;  /*!< Specifies if the timeout counter is enabled to release the chip select.
0239                                     This parameter can be a value of @ref OSPI_TimeOutActivation */
0240   uint32_t TimeOutPeriod;      /*!< Specifies the number of clock to wait when the FIFO is full before to release the chip select.
0241                                     This parameter can be any value between 0 and 0xFFFF */
0242 } OSPI_MemoryMappedTypeDef;
0243 
0244 /**
0245   * @brief HAL OSPI IO Manager Configuration structure definition
0246   */
0247 typedef struct
0248 {
0249   uint32_t ClkPort;                /*!< It indicates which port of the OSPI IO Manager is used for the CLK pins.
0250                                         This parameter can be a value between 1 and 8 */
0251   uint32_t DQSPort;                /*!< It indicates which port of the OSPI IO Manager is used for the DQS pin.
0252                                         This parameter can be a value between 0 and 8, 0 means that signal not used */
0253   uint32_t NCSPort;                /*!< It indicates which port of the OSPI IO Manager is used for the NCS pin.
0254                                         This parameter can be a value between 1 and 8 */
0255   uint32_t IOLowPort;              /*!< It indicates which port of the OSPI IO Manager is used for the IO[3:0] pins.
0256                                         This parameter can be a value of @ref OSPIM_IOPort */
0257   uint32_t IOHighPort;             /*!< It indicates which port of the OSPI IO Manager is used for the IO[7:4] pins.
0258                                         This parameter can be a value of @ref OSPIM_IOPort */
0259   uint32_t Req2AckTime;            /*!< It indicates the minimum switching duration (in number of clock cycles) expected
0260                                         if some signals are multiplexed in the OSPI IO Manager with the other OSPI.
0261                                         This parameter can be a value between 1 and 256 */
0262 } OSPIM_CfgTypeDef;
0263 
0264 #if defined (USE_HAL_OSPI_REGISTER_CALLBACKS) && (USE_HAL_OSPI_REGISTER_CALLBACKS == 1U)
0265 /**
0266   * @brief  HAL OSPI Callback ID enumeration definition
0267   */
0268 typedef enum
0269 {
0270   HAL_OSPI_ERROR_CB_ID          = 0x00U,  /*!< OSPI Error Callback ID            */
0271   HAL_OSPI_ABORT_CB_ID          = 0x01U,  /*!< OSPI Abort Callback ID            */
0272   HAL_OSPI_FIFO_THRESHOLD_CB_ID = 0x02U,  /*!< OSPI FIFO Threshold Callback ID   */
0273   HAL_OSPI_CMD_CPLT_CB_ID       = 0x03U,  /*!< OSPI Command Complete Callback ID */
0274   HAL_OSPI_RX_CPLT_CB_ID        = 0x04U,  /*!< OSPI Rx Complete Callback ID      */
0275   HAL_OSPI_TX_CPLT_CB_ID        = 0x05U,  /*!< OSPI Tx Complete Callback ID      */
0276   HAL_OSPI_RX_HALF_CPLT_CB_ID   = 0x06U,  /*!< OSPI Rx Half Complete Callback ID */
0277   HAL_OSPI_TX_HALF_CPLT_CB_ID   = 0x07U,  /*!< OSPI Tx Half Complete Callback ID */
0278   HAL_OSPI_STATUS_MATCH_CB_ID   = 0x08U,  /*!< OSPI Status Match Callback ID     */
0279   HAL_OSPI_TIMEOUT_CB_ID        = 0x09U,  /*!< OSPI Timeout Callback ID          */
0280 
0281   HAL_OSPI_MSP_INIT_CB_ID       = 0x0AU,  /*!< OSPI MspInit Callback ID          */
0282   HAL_OSPI_MSP_DEINIT_CB_ID     = 0x0BU   /*!< OSPI MspDeInit Callback ID        */
0283 } HAL_OSPI_CallbackIDTypeDef;
0284 
0285 /**
0286   * @brief  HAL OSPI Callback pointer definition
0287   */
0288 typedef void (*pOSPI_CallbackTypeDef)(OSPI_HandleTypeDef *hospi);
0289 #endif /* (USE_HAL_OSPI_REGISTER_CALLBACKS) && (USE_HAL_OSPI_REGISTER_CALLBACKS == 1U) */
0290 /**
0291   * @}
0292   */
0293 
0294 /* Exported constants --------------------------------------------------------*/
0295 /** @defgroup OSPI_Exported_Constants OSPI Exported Constants
0296   * @ingroup RTEMSBSPsARMSTM32H7
0297   * @{
0298   */
0299 
0300 /** @defgroup OSPI_State OSPI State
0301   * @ingroup RTEMSBSPsARMSTM32H7
0302   * @{
0303   */
0304 #define HAL_OSPI_STATE_RESET                 ((uint32_t)0x00000000U)      /*!< Initial state                                                          */
0305 #define HAL_OSPI_STATE_HYPERBUS_INIT         ((uint32_t)0x00000001U)      /*!< Initialization done in hyperbus mode but timing configuration not done */
0306 #define HAL_OSPI_STATE_READY                 ((uint32_t)0x00000002U)      /*!< Driver ready to be used                                                */
0307 #define HAL_OSPI_STATE_CMD_CFG               ((uint32_t)0x00000004U)      /*!< Command (regular or hyperbus) configured, ready for an action          */
0308 #define HAL_OSPI_STATE_READ_CMD_CFG          ((uint32_t)0x00000014U)      /*!< Read command configuration done, not the write command configuration   */
0309 #define HAL_OSPI_STATE_WRITE_CMD_CFG         ((uint32_t)0x00000024U)      /*!< Write command configuration done, not the read command configuration   */
0310 #define HAL_OSPI_STATE_BUSY_CMD              ((uint32_t)0x00000008U)      /*!< Command without data on-going                                          */
0311 #define HAL_OSPI_STATE_BUSY_TX               ((uint32_t)0x00000018U)      /*!< Indirect Tx on-going                                                   */
0312 #define HAL_OSPI_STATE_BUSY_RX               ((uint32_t)0x00000028U)      /*!< Indirect Rx on-going                                                   */
0313 #define HAL_OSPI_STATE_BUSY_AUTO_POLLING     ((uint32_t)0x00000048U)      /*!< Auto-polling on-going                                                  */
0314 #define HAL_OSPI_STATE_BUSY_MEM_MAPPED       ((uint32_t)0x00000088U)      /*!< Memory-mapped on-going                                                 */
0315 #define HAL_OSPI_STATE_ABORT                 ((uint32_t)0x00000100U)      /*!< Abort on-going                                                         */
0316 #define HAL_OSPI_STATE_ERROR                 ((uint32_t)0x00000200U)      /*!< Blocking error, driver should be re-initialized                        */
0317 /**
0318   * @}
0319   */
0320 
0321 /** @defgroup OSPI_ErrorCode OSPI Error Code
0322   * @ingroup RTEMSBSPsARMSTM32H7
0323   * @{
0324   */
0325 #define HAL_OSPI_ERROR_NONE                  ((uint32_t)0x00000000U)                                         /*!< No error                                   */
0326 #define HAL_OSPI_ERROR_TIMEOUT               ((uint32_t)0x00000001U)                                         /*!< Timeout error                              */
0327 #define HAL_OSPI_ERROR_TRANSFER              ((uint32_t)0x00000002U)                                         /*!< Transfer error                             */
0328 #define HAL_OSPI_ERROR_DMA                   ((uint32_t)0x00000004U)                                         /*!< DMA transfer error                         */
0329 #define HAL_OSPI_ERROR_INVALID_PARAM         ((uint32_t)0x00000008U)                                         /*!< Invalid parameters error                   */
0330 #define HAL_OSPI_ERROR_INVALID_SEQUENCE      ((uint32_t)0x00000010U)                                         /*!< Sequence of the state machine is incorrect */
0331 #if defined (USE_HAL_OSPI_REGISTER_CALLBACKS) && (USE_HAL_OSPI_REGISTER_CALLBACKS == 1U)
0332 #define HAL_OSPI_ERROR_INVALID_CALLBACK      ((uint32_t)0x00000020U)                                         /*!< Invalid callback error                     */
0333 #endif /* (USE_HAL_OSPI_REGISTER_CALLBACKS) && (USE_HAL_OSPI_REGISTER_CALLBACKS == 1U)*/
0334 /**
0335   * @}
0336   */
0337 
0338 /** @defgroup OSPI_DualQuad OSPI Dual-Quad
0339   * @ingroup RTEMSBSPsARMSTM32H7
0340   * @{
0341   */
0342 #define HAL_OSPI_DUALQUAD_DISABLE            ((uint32_t)0x00000000U)                                         /*!< Dual-Quad mode disabled */
0343 #define HAL_OSPI_DUALQUAD_ENABLE             ((uint32_t)OCTOSPI_CR_DQM)                                      /*!< Dual-Quad mode enabled  */
0344 /**
0345   * @}
0346   */
0347 
0348 /** @defgroup OSPI_MemoryType OSPI Memory Type
0349   * @ingroup RTEMSBSPsARMSTM32H7
0350   * @{
0351   */
0352 #define HAL_OSPI_MEMTYPE_MICRON              ((uint32_t)0x00000000U)                                         /*!< Micron mode       */
0353 #define HAL_OSPI_MEMTYPE_MACRONIX            ((uint32_t)OCTOSPI_DCR1_MTYP_0)                                 /*!< Macronix mode     */
0354 #define HAL_OSPI_MEMTYPE_APMEMORY            ((uint32_t)OCTOSPI_DCR1_MTYP_1)                                 /*!< AP Memory mode    */
0355 #define HAL_OSPI_MEMTYPE_MACRONIX_RAM        ((uint32_t)(OCTOSPI_DCR1_MTYP_1 | OCTOSPI_DCR1_MTYP_0))         /*!< Macronix RAM mode */
0356 #define HAL_OSPI_MEMTYPE_HYPERBUS            ((uint32_t)OCTOSPI_DCR1_MTYP_2)                                 /*!< Hyperbus mode     */
0357 /**
0358   * @}
0359   */
0360 
0361 /** @defgroup OSPI_FreeRunningClock OSPI Free Running Clock
0362   * @ingroup RTEMSBSPsARMSTM32H7
0363   * @{
0364   */
0365 #define HAL_OSPI_FREERUNCLK_DISABLE          ((uint32_t)0x00000000U)                                         /*!< CLK is not free running               */
0366 #define HAL_OSPI_FREERUNCLK_ENABLE           ((uint32_t)OCTOSPI_DCR1_FRCK)                                   /*!< CLK is free running (always provided) */
0367 /**
0368   * @}
0369   */
0370 
0371 /** @defgroup OSPI_ClockMode OSPI Clock Mode
0372   * @ingroup RTEMSBSPsARMSTM32H7
0373   * @{
0374   */
0375 #define HAL_OSPI_CLOCK_MODE_0                ((uint32_t)0x00000000U)                                         /*!< CLK must stay low while nCS is high  */
0376 #define HAL_OSPI_CLOCK_MODE_3                ((uint32_t)OCTOSPI_DCR1_CKMODE)                                 /*!< CLK must stay high while nCS is high */
0377 /**
0378   * @}
0379   */
0380 
0381 /** @defgroup OSPI_WrapSize OSPI Wrap-Size
0382   * @ingroup RTEMSBSPsARMSTM32H7
0383   * @{
0384   */
0385 #define HAL_OSPI_WRAP_NOT_SUPPORTED          ((uint32_t)0x00000000U)                                         /*!< wrapped reads are not supported by the memory   */
0386 #define HAL_OSPI_WRAP_16_BYTES               ((uint32_t)OCTOSPI_DCR2_WRAPSIZE_1)                             /*!< external memory supports wrap size of 16 bytes  */
0387 #define HAL_OSPI_WRAP_32_BYTES               ((uint32_t)(OCTOSPI_DCR2_WRAPSIZE_0 | OCTOSPI_DCR2_WRAPSIZE_1)) /*!< external memory supports wrap size of 32 bytes  */
0388 #define HAL_OSPI_WRAP_64_BYTES               ((uint32_t)OCTOSPI_DCR2_WRAPSIZE_2)                             /*!< external memory supports wrap size of 64 bytes  */
0389 #define HAL_OSPI_WRAP_128_BYTES              ((uint32_t)(OCTOSPI_DCR2_WRAPSIZE_0 | OCTOSPI_DCR2_WRAPSIZE_2)) /*!< external memory supports wrap size of 128 bytes */
0390 /**
0391   * @}
0392   */
0393 
0394 /** @defgroup OSPI_SampleShifting OSPI Sample Shifting
0395   * @ingroup RTEMSBSPsARMSTM32H7
0396   * @{
0397   */
0398 #define HAL_OSPI_SAMPLE_SHIFTING_NONE        ((uint32_t)0x00000000U)                                         /*!< No shift        */
0399 #define HAL_OSPI_SAMPLE_SHIFTING_HALFCYCLE   ((uint32_t)OCTOSPI_TCR_SSHIFT)                                  /*!< 1/2 cycle shift */
0400 /**
0401   * @}
0402   */
0403 
0404 /** @defgroup OSPI_DelayHoldQuarterCycle OSPI Delay Hold Quarter Cycle
0405   * @ingroup RTEMSBSPsARMSTM32H7
0406   * @{
0407   */
0408 #define HAL_OSPI_DHQC_DISABLE                ((uint32_t)0x00000000U)                                         /*!< No Delay             */
0409 #define HAL_OSPI_DHQC_ENABLE                 ((uint32_t)OCTOSPI_TCR_DHQC)                                    /*!< Delay Hold 1/4 cycle */
0410 /**
0411   * @}
0412   */
0413 
0414 /** @defgroup OSPI_DelayBlockBypass OSPI Delay Block Bypaas
0415   * @ingroup RTEMSBSPsARMSTM32H7
0416   * @{
0417   */
0418 #define HAL_OSPI_DELAY_BLOCK_USED            ((uint32_t)0x00000000U)                                         /*!< Sampling clock is delayed by the delay block */
0419 #define HAL_OSPI_DELAY_BLOCK_BYPASSED        ((uint32_t)OCTOSPI_DCR1_DLYBYP)                                 /*!< Delay block is bypassed                      */
0420 /**
0421   * @}
0422   */
0423 
0424 /** @defgroup OSPI_OperationType OSPI Operation Type
0425   * @ingroup RTEMSBSPsARMSTM32H7
0426   * @{
0427   */
0428 #define HAL_OSPI_OPTYPE_COMMON_CFG           ((uint32_t)0x00000000U)                                         /*!< Common configuration (indirect or auto-polling mode) */
0429 #define HAL_OSPI_OPTYPE_READ_CFG             ((uint32_t)0x00000001U)                                         /*!< Read configuration (memory-mapped mode)              */
0430 #define HAL_OSPI_OPTYPE_WRITE_CFG            ((uint32_t)0x00000002U)                                         /*!< Write configuration (memory-mapped mode)             */
0431 #define HAL_OSPI_OPTYPE_WRAP_CFG             ((uint32_t)0x00000003U)                                         /*!< Wrap configuration (memory-mapped mode)              */
0432 /**
0433   * @}
0434   */
0435 
0436 /** @defgroup OSPI_FlashID OSPI Flash Id
0437   * @ingroup RTEMSBSPsARMSTM32H7
0438   * @{
0439   */
0440 #define HAL_OSPI_FLASH_ID_1                  ((uint32_t)0x00000000U)                                         /*!< FLASH 1 selected */
0441 #define HAL_OSPI_FLASH_ID_2                  ((uint32_t)OCTOSPI_CR_FSEL)                                     /*!< FLASH 2 selected */
0442 /**
0443   * @}
0444   */
0445 
0446 /** @defgroup OSPI_InstructionMode OSPI Instruction Mode
0447   * @ingroup RTEMSBSPsARMSTM32H7
0448   * @{
0449   */
0450 #define HAL_OSPI_INSTRUCTION_NONE            ((uint32_t)0x00000000U)                                         /*!< No instruction               */
0451 #define HAL_OSPI_INSTRUCTION_1_LINE          ((uint32_t)OCTOSPI_CCR_IMODE_0)                                 /*!< Instruction on a single line */
0452 #define HAL_OSPI_INSTRUCTION_2_LINES         ((uint32_t)OCTOSPI_CCR_IMODE_1)                                 /*!< Instruction on two lines     */
0453 #define HAL_OSPI_INSTRUCTION_4_LINES         ((uint32_t)(OCTOSPI_CCR_IMODE_0 | OCTOSPI_CCR_IMODE_1))         /*!< Instruction on four lines    */
0454 #define HAL_OSPI_INSTRUCTION_8_LINES         ((uint32_t)OCTOSPI_CCR_IMODE_2)                                 /*!< Instruction on eight lines   */
0455 /**
0456   * @}
0457   */
0458 
0459 /** @defgroup OSPI_InstructionSize OSPI Instruction Size
0460   * @ingroup RTEMSBSPsARMSTM32H7
0461   * @{
0462   */
0463 #define HAL_OSPI_INSTRUCTION_8_BITS          ((uint32_t)0x00000000U)                                         /*!< 8-bit instruction  */
0464 #define HAL_OSPI_INSTRUCTION_16_BITS         ((uint32_t)OCTOSPI_CCR_ISIZE_0)                                 /*!< 16-bit instruction */
0465 #define HAL_OSPI_INSTRUCTION_24_BITS         ((uint32_t)OCTOSPI_CCR_ISIZE_1)                                 /*!< 24-bit instruction */
0466 #define HAL_OSPI_INSTRUCTION_32_BITS         ((uint32_t)OCTOSPI_CCR_ISIZE)                                   /*!< 32-bit instruction */
0467 /**
0468   * @}
0469   */
0470 
0471 /** @defgroup OSPI_InstructionDtrMode OSPI Instruction DTR Mode
0472   * @ingroup RTEMSBSPsARMSTM32H7
0473   * @{
0474   */
0475 #define HAL_OSPI_INSTRUCTION_DTR_DISABLE     ((uint32_t)0x00000000U)                                         /*!< DTR mode disabled for instruction phase */
0476 #define HAL_OSPI_INSTRUCTION_DTR_ENABLE      ((uint32_t)OCTOSPI_CCR_IDTR)                                    /*!< DTR mode enabled for instruction phase  */
0477 /**
0478   * @}
0479   */
0480 
0481 /** @defgroup OSPI_AddressMode OSPI Address Mode
0482   * @ingroup RTEMSBSPsARMSTM32H7
0483   * @{
0484   */
0485 #define HAL_OSPI_ADDRESS_NONE                ((uint32_t)0x00000000U)                                         /*!< No address               */
0486 #define HAL_OSPI_ADDRESS_1_LINE              ((uint32_t)OCTOSPI_CCR_ADMODE_0)                                /*!< Address on a single line */
0487 #define HAL_OSPI_ADDRESS_2_LINES             ((uint32_t)OCTOSPI_CCR_ADMODE_1)                                /*!< Address on two lines     */
0488 #define HAL_OSPI_ADDRESS_4_LINES             ((uint32_t)(OCTOSPI_CCR_ADMODE_0 | OCTOSPI_CCR_ADMODE_1))       /*!< Address on four lines    */
0489 #define HAL_OSPI_ADDRESS_8_LINES             ((uint32_t)OCTOSPI_CCR_ADMODE_2)                                /*!< Address on eight lines   */
0490 /**
0491   * @}
0492   */
0493 
0494 /** @defgroup OSPI_AddressSize OSPI Address Size
0495   * @ingroup RTEMSBSPsARMSTM32H7
0496   * @{
0497   */
0498 #define HAL_OSPI_ADDRESS_8_BITS              ((uint32_t)0x00000000U)                                         /*!< 8-bit address  */
0499 #define HAL_OSPI_ADDRESS_16_BITS             ((uint32_t)OCTOSPI_CCR_ADSIZE_0)                                /*!< 16-bit address */
0500 #define HAL_OSPI_ADDRESS_24_BITS             ((uint32_t)OCTOSPI_CCR_ADSIZE_1)                                /*!< 24-bit address */
0501 #define HAL_OSPI_ADDRESS_32_BITS             ((uint32_t)OCTOSPI_CCR_ADSIZE)                                  /*!< 32-bit address */
0502 /**
0503   * @}
0504   */
0505 
0506 /** @defgroup OSPI_AddressDtrMode OSPI Address DTR Mode
0507   * @ingroup RTEMSBSPsARMSTM32H7
0508   * @{
0509   */
0510 #define HAL_OSPI_ADDRESS_DTR_DISABLE         ((uint32_t)0x00000000U)                                         /*!< DTR mode disabled for address phase */
0511 #define HAL_OSPI_ADDRESS_DTR_ENABLE          ((uint32_t)OCTOSPI_CCR_ADDTR)                                   /*!< DTR mode enabled for address phase  */
0512 /**
0513   * @}
0514   */
0515 
0516 /** @defgroup OSPI_AlternateBytesMode OSPI Alternate Bytes Mode
0517   * @ingroup RTEMSBSPsARMSTM32H7
0518   * @{
0519   */
0520 #define HAL_OSPI_ALTERNATE_BYTES_NONE        ((uint32_t)0x00000000U)                                         /*!< No alternate bytes               */
0521 #define HAL_OSPI_ALTERNATE_BYTES_1_LINE      ((uint32_t)OCTOSPI_CCR_ABMODE_0)                                /*!< Alternate bytes on a single line */
0522 #define HAL_OSPI_ALTERNATE_BYTES_2_LINES     ((uint32_t)OCTOSPI_CCR_ABMODE_1)                                /*!< Alternate bytes on two lines     */
0523 #define HAL_OSPI_ALTERNATE_BYTES_4_LINES     ((uint32_t)(OCTOSPI_CCR_ABMODE_0 | OCTOSPI_CCR_ABMODE_1))       /*!< Alternate bytes on four lines    */
0524 #define HAL_OSPI_ALTERNATE_BYTES_8_LINES     ((uint32_t)OCTOSPI_CCR_ABMODE_2)                                /*!< Alternate bytes on eight lines   */
0525 /**
0526   * @}
0527   */
0528 
0529 /** @defgroup OSPI_AlternateBytesSize OSPI Alternate Bytes Size
0530   * @ingroup RTEMSBSPsARMSTM32H7
0531   * @{
0532   */
0533 #define HAL_OSPI_ALTERNATE_BYTES_8_BITS      ((uint32_t)0x00000000U)                                         /*!< 8-bit alternate bytes  */
0534 #define HAL_OSPI_ALTERNATE_BYTES_16_BITS     ((uint32_t)OCTOSPI_CCR_ABSIZE_0)                                /*!< 16-bit alternate bytes */
0535 #define HAL_OSPI_ALTERNATE_BYTES_24_BITS     ((uint32_t)OCTOSPI_CCR_ABSIZE_1)                                /*!< 24-bit alternate bytes */
0536 #define HAL_OSPI_ALTERNATE_BYTES_32_BITS     ((uint32_t)OCTOSPI_CCR_ABSIZE)                                  /*!< 32-bit alternate bytes */
0537 /**
0538   * @}
0539   */
0540 
0541 /** @defgroup OSPI_AlternateBytesDtrMode OSPI Alternate Bytes DTR Mode
0542   * @ingroup RTEMSBSPsARMSTM32H7
0543   * @{
0544   */
0545 #define HAL_OSPI_ALTERNATE_BYTES_DTR_DISABLE ((uint32_t)0x00000000U)                                         /*!< DTR mode disabled for alternate bytes phase */
0546 #define HAL_OSPI_ALTERNATE_BYTES_DTR_ENABLE  ((uint32_t)OCTOSPI_CCR_ABDTR)                                   /*!< DTR mode enabled for alternate bytes phase  */
0547 /**
0548   * @}
0549   */
0550 
0551 /** @defgroup OSPI_DataMode OSPI Data Mode
0552   * @ingroup RTEMSBSPsARMSTM32H7
0553   * @{
0554   */
0555 #define HAL_OSPI_DATA_NONE                   ((uint32_t)0x00000000U)                                         /*!< No data               */
0556 #define HAL_OSPI_DATA_1_LINE                 ((uint32_t)OCTOSPI_CCR_DMODE_0)                                 /*!< Data on a single line */
0557 #define HAL_OSPI_DATA_2_LINES                ((uint32_t)OCTOSPI_CCR_DMODE_1)                                 /*!< Data on two lines     */
0558 #define HAL_OSPI_DATA_4_LINES                ((uint32_t)(OCTOSPI_CCR_DMODE_0 | OCTOSPI_CCR_DMODE_1))         /*!< Data on four lines    */
0559 #define HAL_OSPI_DATA_8_LINES                ((uint32_t)OCTOSPI_CCR_DMODE_2)                                 /*!< Data on eight lines   */
0560 /**
0561   * @}
0562   */
0563 
0564 /** @defgroup OSPI_DataDtrMode OSPI Data DTR Mode
0565   * @ingroup RTEMSBSPsARMSTM32H7
0566   * @{
0567   */
0568 #define HAL_OSPI_DATA_DTR_DISABLE            ((uint32_t)0x00000000U)                                         /*!< DTR mode disabled for data phase */
0569 #define HAL_OSPI_DATA_DTR_ENABLE             ((uint32_t)OCTOSPI_CCR_DDTR)                                    /*!< DTR mode enabled for data phase  */
0570 /**
0571   * @}
0572   */
0573 
0574 /** @defgroup OSPI_DQSMode OSPI DQS Mode
0575   * @ingroup RTEMSBSPsARMSTM32H7
0576   * @{
0577   */
0578 #define HAL_OSPI_DQS_DISABLE                 ((uint32_t)0x00000000U)                                         /*!< DQS disabled */
0579 #define HAL_OSPI_DQS_ENABLE                  ((uint32_t)OCTOSPI_CCR_DQSE)                                    /*!< DQS enabled  */
0580 /**
0581   * @}
0582   */
0583 
0584 /** @defgroup OSPI_SIOOMode OSPI SIOO Mode
0585   * @ingroup RTEMSBSPsARMSTM32H7
0586   * @{
0587   */
0588 #define HAL_OSPI_SIOO_INST_EVERY_CMD         ((uint32_t)0x00000000U)                                         /*!< Send instruction on every transaction       */
0589 #define HAL_OSPI_SIOO_INST_ONLY_FIRST_CMD    ((uint32_t)OCTOSPI_CCR_SIOO)                                    /*!< Send instruction only for the first command */
0590 /**
0591   * @}
0592   */
0593 
0594 /** @defgroup OSPI_WriteZeroLatency OSPI Hyperbus Write Zero Latency Activation
0595   * @ingroup RTEMSBSPsARMSTM32H7
0596   * @{
0597   */
0598 #define HAL_OSPI_LATENCY_ON_WRITE            ((uint32_t)0x00000000U)                                         /*!< Latency on write accesses    */
0599 #define HAL_OSPI_NO_LATENCY_ON_WRITE         ((uint32_t)OCTOSPI_HLCR_WZL)                                    /*!< No latency on write accesses */
0600 /**
0601   * @}
0602   */
0603 
0604 /** @defgroup OSPI_LatencyMode OSPI Hyperbus Latency Mode
0605   * @ingroup RTEMSBSPsARMSTM32H7
0606   * @{
0607   */
0608 #define HAL_OSPI_VARIABLE_LATENCY            ((uint32_t)0x00000000U)                                         /*!< Variable initial latency */
0609 #define HAL_OSPI_FIXED_LATENCY               ((uint32_t)OCTOSPI_HLCR_LM)                                     /*!< Fixed latency            */
0610 /**
0611   * @}
0612   */
0613 
0614 /** @defgroup OSPI_AddressSpace OSPI Hyperbus Address Space
0615   * @ingroup RTEMSBSPsARMSTM32H7
0616   * @{
0617   */
0618 #define HAL_OSPI_MEMORY_ADDRESS_SPACE        ((uint32_t)0x00000000U)                                         /*!< HyperBus memory mode   */
0619 #define HAL_OSPI_REGISTER_ADDRESS_SPACE      ((uint32_t)OCTOSPI_DCR1_MTYP_0)                                 /*!< HyperBus register mode */
0620 /**
0621   * @}
0622   */
0623 
0624 /** @defgroup OSPI_MatchMode OSPI Match Mode
0625   * @ingroup RTEMSBSPsARMSTM32H7
0626   * @{
0627   */
0628 #define HAL_OSPI_MATCH_MODE_AND              ((uint32_t)0x00000000U)                                         /*!< AND match mode between unmasked bits */
0629 #define HAL_OSPI_MATCH_MODE_OR               ((uint32_t)OCTOSPI_CR_PMM)                                      /*!< OR match mode between unmasked bits  */
0630 /**
0631   * @}
0632   */
0633 
0634 /** @defgroup OSPI_AutomaticStop OSPI Automatic Stop
0635   * @ingroup RTEMSBSPsARMSTM32H7
0636   * @{
0637   */
0638 #define HAL_OSPI_AUTOMATIC_STOP_DISABLE      ((uint32_t)0x00000000U)                                         /*!< AutoPolling stops only with abort or OSPI disabling */
0639 #define HAL_OSPI_AUTOMATIC_STOP_ENABLE       ((uint32_t)OCTOSPI_CR_APMS)                                     /*!< AutoPolling stops as soon as there is a match       */
0640 /**
0641   * @}
0642   */
0643 
0644 /** @defgroup OSPI_TimeOutActivation OSPI Timeout Activation
0645   * @ingroup RTEMSBSPsARMSTM32H7
0646   * @{
0647   */
0648 #define HAL_OSPI_TIMEOUT_COUNTER_DISABLE     ((uint32_t)0x00000000U)                                         /*!< Timeout counter disabled, nCS remains active               */
0649 #define HAL_OSPI_TIMEOUT_COUNTER_ENABLE      ((uint32_t)OCTOSPI_CR_TCEN)                                     /*!< Timeout counter enabled, nCS released when timeout expires */
0650 /**
0651   * @}
0652   */
0653 
0654 /** @defgroup OSPI_Flags OSPI Flags
0655   * @ingroup RTEMSBSPsARMSTM32H7
0656   * @{
0657   */
0658 #define HAL_OSPI_FLAG_BUSY                   OCTOSPI_SR_BUSY                                                 /*!< Busy flag: operation is ongoing                                                                          */
0659 #define HAL_OSPI_FLAG_TO                     OCTOSPI_SR_TOF                                                  /*!< Timeout flag: timeout occurs in memory-mapped mode                                                       */
0660 #define HAL_OSPI_FLAG_SM                     OCTOSPI_SR_SMF                                                  /*!< Status match flag: received data matches in autopolling mode                                             */
0661 #define HAL_OSPI_FLAG_FT                     OCTOSPI_SR_FTF                                                  /*!< Fifo threshold flag: Fifo threshold reached or data left after read from memory is complete              */
0662 #define HAL_OSPI_FLAG_TC                     OCTOSPI_SR_TCF                                                  /*!< Transfer complete flag: programmed number of data have been transferred or the transfer has been aborted */
0663 #define HAL_OSPI_FLAG_TE                     OCTOSPI_SR_TEF                                                  /*!< Transfer error flag: invalid address is being accessed                                                   */
0664 /**
0665   * @}
0666   */
0667 
0668 /** @defgroup OSPI_Interrupts OSPI Interrupts
0669   * @ingroup RTEMSBSPsARMSTM32H7
0670   * @{
0671   */
0672 #define HAL_OSPI_IT_TO                       OCTOSPI_CR_TOIE                                                 /*!< Interrupt on the timeout flag           */
0673 #define HAL_OSPI_IT_SM                       OCTOSPI_CR_SMIE                                                 /*!< Interrupt on the status match flag      */
0674 #define HAL_OSPI_IT_FT                       OCTOSPI_CR_FTIE                                                 /*!< Interrupt on the fifo threshold flag    */
0675 #define HAL_OSPI_IT_TC                       OCTOSPI_CR_TCIE                                                 /*!< Interrupt on the transfer complete flag */
0676 #define HAL_OSPI_IT_TE                       OCTOSPI_CR_TEIE                                                 /*!< Interrupt on the transfer error flag    */
0677 /**
0678   * @}
0679   */
0680 
0681 /** @defgroup OSPI_Timeout_definition OSPI Timeout definition
0682   * @ingroup RTEMSBSPsARMSTM32H7
0683   * @{
0684   */
0685 #define HAL_OSPI_TIMEOUT_DEFAULT_VALUE       ((uint32_t)5000U)                                               /* 5 s */
0686 /**
0687   * @}
0688   */
0689 
0690 /** @defgroup OSPIM_IOPort OSPI IO Manager IO Port
0691   * @ingroup RTEMSBSPsARMSTM32H7
0692   * @{
0693   */
0694 #define HAL_OSPIM_IOPORT_NONE              ((uint32_t)0x00000000U)                                          /*!< IOs not used */
0695 #define HAL_OSPIM_IOPORT_1_LOW             ((uint32_t)(OCTOSPIM_PCR_IOLEN | 0x1U))                          /*!< Port 1 - IO[3:0] */
0696 #define HAL_OSPIM_IOPORT_1_HIGH            ((uint32_t)(OCTOSPIM_PCR_IOHEN | 0x1U))                          /*!< Port 1 - IO[7:4] */
0697 #define HAL_OSPIM_IOPORT_2_LOW             ((uint32_t)(OCTOSPIM_PCR_IOLEN | 0x2U))                          /*!< Port 2 - IO[3:0] */
0698 #define HAL_OSPIM_IOPORT_2_HIGH            ((uint32_t)(OCTOSPIM_PCR_IOHEN | 0x2U))                          /*!< Port 2 - IO[7:4] */
0699 #define HAL_OSPIM_IOPORT_3_LOW             ((uint32_t)(OCTOSPIM_PCR_IOLEN | 0x3U))                          /*!< Port 3 - IO[3:0] */
0700 #define HAL_OSPIM_IOPORT_3_HIGH            ((uint32_t)(OCTOSPIM_PCR_IOHEN | 0x3U))                          /*!< Port 3 - IO[7:4] */
0701 #define HAL_OSPIM_IOPORT_4_LOW             ((uint32_t)(OCTOSPIM_PCR_IOLEN | 0x4U))                          /*!< Port 4 - IO[3:0] */
0702 #define HAL_OSPIM_IOPORT_4_HIGH            ((uint32_t)(OCTOSPIM_PCR_IOHEN | 0x4U))                          /*!< Port 4 - IO[7:4] */
0703 #define HAL_OSPIM_IOPORT_5_LOW             ((uint32_t)(OCTOSPIM_PCR_IOLEN | 0x5U))                          /*!< Port 5 - IO[3:0] */
0704 #define HAL_OSPIM_IOPORT_5_HIGH            ((uint32_t)(OCTOSPIM_PCR_IOHEN | 0x5U))                          /*!< Port 5 - IO[7:4] */
0705 #define HAL_OSPIM_IOPORT_6_LOW             ((uint32_t)(OCTOSPIM_PCR_IOLEN | 0x6U))                          /*!< Port 6 - IO[3:0] */
0706 #define HAL_OSPIM_IOPORT_6_HIGH            ((uint32_t)(OCTOSPIM_PCR_IOHEN | 0x6U))                          /*!< Port 6 - IO[7:4] */
0707 #define HAL_OSPIM_IOPORT_7_LOW             ((uint32_t)(OCTOSPIM_PCR_IOLEN | 0x7U))                          /*!< Port 7 - IO[3:0] */
0708 #define HAL_OSPIM_IOPORT_7_HIGH            ((uint32_t)(OCTOSPIM_PCR_IOHEN | 0x7U))                          /*!< Port 7 - IO[7:4] */
0709 #define HAL_OSPIM_IOPORT_8_LOW             ((uint32_t)(OCTOSPIM_PCR_IOLEN | 0x8U))                          /*!< Port 8 - IO[3:0] */
0710 #define HAL_OSPIM_IOPORT_8_HIGH            ((uint32_t)(OCTOSPIM_PCR_IOHEN | 0x8U))                          /*!< Port 8 - IO[7:4] */
0711 /**
0712   * @}
0713   */
0714 /**
0715   * @}
0716   */
0717 
0718 /* Exported macros -----------------------------------------------------------*/
0719 /** @defgroup OSPI_Exported_Macros OSPI Exported Macros
0720   * @ingroup RTEMSBSPsARMSTM32H7
0721   * @{
0722   */
0723 /** @brief Reset OSPI handle state.
0724   * @param  __HANDLE__ specifies the OSPI Handle.
0725   * @retval None
0726   */
0727 #if defined (USE_HAL_OSPI_REGISTER_CALLBACKS) && (USE_HAL_OSPI_REGISTER_CALLBACKS == 1U)
0728 #define __HAL_OSPI_RESET_HANDLE_STATE(__HANDLE__)           do {                                              \
0729                                                                   (__HANDLE__)->State = HAL_OSPI_STATE_RESET; \
0730                                                                   (__HANDLE__)->MspInitCallback = NULL;       \
0731                                                                   (__HANDLE__)->MspDeInitCallback = NULL;     \
0732                                                                } while(0)
0733 #else
0734 #define __HAL_OSPI_RESET_HANDLE_STATE(__HANDLE__)           ((__HANDLE__)->State = HAL_OSPI_STATE_RESET)
0735 #endif /* (USE_HAL_OSPI_REGISTER_CALLBACKS) && (USE_HAL_OSPI_REGISTER_CALLBACKS == 1U) */
0736 
0737 /** @brief  Enable the OSPI peripheral.
0738   * @param  __HANDLE__ specifies the OSPI Handle.
0739   * @retval None
0740   */
0741 #define __HAL_OSPI_ENABLE(__HANDLE__)                       SET_BIT((__HANDLE__)->Instance->CR, OCTOSPI_CR_EN)
0742 
0743 /** @brief  Disable the OSPI peripheral.
0744   * @param  __HANDLE__ specifies the OSPI Handle.
0745   * @retval None
0746   */
0747 #define __HAL_OSPI_DISABLE(__HANDLE__)                      CLEAR_BIT((__HANDLE__)->Instance->CR, OCTOSPI_CR_EN)
0748 
0749 /** @brief  Enable the specified OSPI interrupt.
0750   * @param  __HANDLE__ specifies the OSPI Handle.
0751   * @param  __INTERRUPT__ specifies the OSPI interrupt source to enable.
0752   *          This parameter can be one of the following values:
0753   *            @arg HAL_OSPI_IT_TO: OSPI Timeout interrupt
0754   *            @arg HAL_OSPI_IT_SM: OSPI Status match interrupt
0755   *            @arg HAL_OSPI_IT_FT: OSPI FIFO threshold interrupt
0756   *            @arg HAL_OSPI_IT_TC: OSPI Transfer complete interrupt
0757   *            @arg HAL_OSPI_IT_TE: OSPI Transfer error interrupt
0758   * @retval None
0759   */
0760 #define __HAL_OSPI_ENABLE_IT(__HANDLE__, __INTERRUPT__)     SET_BIT((__HANDLE__)->Instance->CR, (__INTERRUPT__))
0761 
0762 
0763 /** @brief  Disable the specified OSPI interrupt.
0764   * @param  __HANDLE__ specifies the OSPI Handle.
0765   * @param  __INTERRUPT__ specifies the OSPI interrupt source to disable.
0766   *          This parameter can be one of the following values:
0767   *            @arg HAL_OSPI_IT_TO: OSPI Timeout interrupt
0768   *            @arg HAL_OSPI_IT_SM: OSPI Status match interrupt
0769   *            @arg HAL_OSPI_IT_FT: OSPI FIFO threshold interrupt
0770   *            @arg HAL_OSPI_IT_TC: OSPI Transfer complete interrupt
0771   *            @arg HAL_OSPI_IT_TE: OSPI Transfer error interrupt
0772   * @retval None
0773   */
0774 #define __HAL_OSPI_DISABLE_IT(__HANDLE__, __INTERRUPT__)    CLEAR_BIT((__HANDLE__)->Instance->CR, (__INTERRUPT__))
0775 
0776 /** @brief  Check whether the specified OSPI interrupt source is enabled or not.
0777   * @param  __HANDLE__ specifies the OSPI Handle.
0778   * @param  __INTERRUPT__ specifies the OSPI interrupt source to check.
0779   *          This parameter can be one of the following values:
0780   *            @arg HAL_OSPI_IT_TO: OSPI Timeout interrupt
0781   *            @arg HAL_OSPI_IT_SM: OSPI Status match interrupt
0782   *            @arg HAL_OSPI_IT_FT: OSPI FIFO threshold interrupt
0783   *            @arg HAL_OSPI_IT_TC: OSPI Transfer complete interrupt
0784   *            @arg HAL_OSPI_IT_TE: OSPI Transfer error interrupt
0785   * @retval The new state of __INTERRUPT__ (TRUE or FALSE).
0786   */
0787 #define __HAL_OSPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (READ_BIT((__HANDLE__)->Instance->CR, (__INTERRUPT__))\
0788                                                              == (__INTERRUPT__))
0789 
0790 /**
0791   * @brief  Check whether the selected OSPI flag is set or not.
0792   * @param  __HANDLE__ specifies the OSPI Handle.
0793   * @param  __FLAG__ specifies the OSPI flag to check.
0794   *          This parameter can be one of the following values:
0795   *            @arg HAL_OSPI_FLAG_BUSY: OSPI Busy flag
0796   *            @arg HAL_OSPI_FLAG_TO:   OSPI Timeout flag
0797   *            @arg HAL_OSPI_FLAG_SM:   OSPI Status match flag
0798   *            @arg HAL_OSPI_FLAG_FT:   OSPI FIFO threshold flag
0799   *            @arg HAL_OSPI_FLAG_TC:   OSPI Transfer complete flag
0800   *            @arg HAL_OSPI_FLAG_TE:   OSPI Transfer error flag
0801   * @retval None
0802   */
0803 #define __HAL_OSPI_GET_FLAG(__HANDLE__, __FLAG__)           ((READ_BIT((__HANDLE__)->Instance->SR, (__FLAG__)) \
0804                                                               != 0U) ? SET : RESET)
0805 
0806 /** @brief  Clears the specified OSPI's flag status.
0807   * @param  __HANDLE__ specifies the OSPI Handle.
0808   * @param  __FLAG__ specifies the OSPI clear register flag that needs to be set
0809   *          This parameter can be one of the following values:
0810   *            @arg HAL_OSPI_FLAG_TO:   OSPI Timeout flag
0811   *            @arg HAL_OSPI_FLAG_SM:   OSPI Status match flag
0812   *            @arg HAL_OSPI_FLAG_TC:   OSPI Transfer complete flag
0813   *            @arg HAL_OSPI_FLAG_TE:   OSPI Transfer error flag
0814   * @retval None
0815   */
0816 #define __HAL_OSPI_CLEAR_FLAG(__HANDLE__, __FLAG__)         WRITE_REG((__HANDLE__)->Instance->FCR, (__FLAG__))
0817 
0818 /**
0819   * @}
0820   */
0821 
0822 /* Exported functions --------------------------------------------------------*/
0823 /** @addtogroup OSPI_Exported_Functions
0824   * @{
0825   */
0826 
0827 /* Initialization/de-initialization functions  ********************************/
0828 /** @addtogroup OSPI_Exported_Functions_Group1
0829   * @{
0830   */
0831 HAL_StatusTypeDef     HAL_OSPI_Init(OSPI_HandleTypeDef *hospi);
0832 void                  HAL_OSPI_MspInit(OSPI_HandleTypeDef *hospi);
0833 HAL_StatusTypeDef     HAL_OSPI_DeInit(OSPI_HandleTypeDef *hospi);
0834 void                  HAL_OSPI_MspDeInit(OSPI_HandleTypeDef *hospi);
0835 
0836 /**
0837   * @}
0838   */
0839 
0840 /* IO operation functions *****************************************************/
0841 /** @addtogroup OSPI_Exported_Functions_Group2
0842   * @{
0843   */
0844 /* OSPI IRQ handler function */
0845 void                  HAL_OSPI_IRQHandler(OSPI_HandleTypeDef *hospi);
0846 
0847 /* OSPI command configuration functions */
0848 HAL_StatusTypeDef     HAL_OSPI_Command(OSPI_HandleTypeDef *hospi, OSPI_RegularCmdTypeDef *cmd, uint32_t Timeout);
0849 HAL_StatusTypeDef     HAL_OSPI_Command_IT(OSPI_HandleTypeDef *hospi, OSPI_RegularCmdTypeDef *cmd);
0850 HAL_StatusTypeDef     HAL_OSPI_HyperbusCfg(OSPI_HandleTypeDef *hospi, OSPI_HyperbusCfgTypeDef *cfg, uint32_t Timeout);
0851 HAL_StatusTypeDef     HAL_OSPI_HyperbusCmd(OSPI_HandleTypeDef *hospi, OSPI_HyperbusCmdTypeDef *cmd, uint32_t Timeout);
0852 
0853 /* OSPI indirect mode functions */
0854 HAL_StatusTypeDef     HAL_OSPI_Transmit(OSPI_HandleTypeDef *hospi, uint8_t *pData, uint32_t Timeout);
0855 HAL_StatusTypeDef     HAL_OSPI_Receive(OSPI_HandleTypeDef *hospi, uint8_t *pData, uint32_t Timeout);
0856 HAL_StatusTypeDef     HAL_OSPI_Transmit_IT(OSPI_HandleTypeDef *hospi, uint8_t *pData);
0857 HAL_StatusTypeDef     HAL_OSPI_Receive_IT(OSPI_HandleTypeDef *hospi, uint8_t *pData);
0858 HAL_StatusTypeDef     HAL_OSPI_Transmit_DMA(OSPI_HandleTypeDef *hospi, uint8_t *pData);
0859 HAL_StatusTypeDef     HAL_OSPI_Receive_DMA(OSPI_HandleTypeDef *hospi, uint8_t *pData);
0860 
0861 /* OSPI status flag polling mode functions */
0862 HAL_StatusTypeDef     HAL_OSPI_AutoPolling(OSPI_HandleTypeDef *hospi, OSPI_AutoPollingTypeDef *cfg, uint32_t Timeout);
0863 HAL_StatusTypeDef     HAL_OSPI_AutoPolling_IT(OSPI_HandleTypeDef *hospi, OSPI_AutoPollingTypeDef *cfg);
0864 
0865 /* OSPI memory-mapped mode functions */
0866 HAL_StatusTypeDef     HAL_OSPI_MemoryMapped(OSPI_HandleTypeDef *hospi, OSPI_MemoryMappedTypeDef *cfg);
0867 
0868 /* Callback functions in non-blocking modes ***********************************/
0869 void                  HAL_OSPI_ErrorCallback(OSPI_HandleTypeDef *hospi);
0870 void                  HAL_OSPI_AbortCpltCallback(OSPI_HandleTypeDef *hospi);
0871 void                  HAL_OSPI_FifoThresholdCallback(OSPI_HandleTypeDef *hospi);
0872 
0873 /* OSPI indirect mode functions */
0874 void                  HAL_OSPI_CmdCpltCallback(OSPI_HandleTypeDef *hospi);
0875 void                  HAL_OSPI_RxCpltCallback(OSPI_HandleTypeDef *hospi);
0876 void                  HAL_OSPI_TxCpltCallback(OSPI_HandleTypeDef *hospi);
0877 void                  HAL_OSPI_RxHalfCpltCallback(OSPI_HandleTypeDef *hospi);
0878 void                  HAL_OSPI_TxHalfCpltCallback(OSPI_HandleTypeDef *hospi);
0879 
0880 /* OSPI status flag polling mode functions */
0881 void                  HAL_OSPI_StatusMatchCallback(OSPI_HandleTypeDef *hospi);
0882 
0883 /* OSPI memory-mapped mode functions */
0884 void                  HAL_OSPI_TimeOutCallback(OSPI_HandleTypeDef *hospi);
0885 
0886 #if defined (USE_HAL_OSPI_REGISTER_CALLBACKS) && (USE_HAL_OSPI_REGISTER_CALLBACKS == 1U)
0887 /* OSPI callback registering/unregistering */
0888 HAL_StatusTypeDef     HAL_OSPI_RegisterCallback(OSPI_HandleTypeDef *hospi, HAL_OSPI_CallbackIDTypeDef CallbackID,
0889                                                 pOSPI_CallbackTypeDef pCallback);
0890 HAL_StatusTypeDef     HAL_OSPI_UnRegisterCallback(OSPI_HandleTypeDef *hospi, HAL_OSPI_CallbackIDTypeDef CallbackID);
0891 #endif /* (USE_HAL_OSPI_REGISTER_CALLBACKS) && (USE_HAL_OSPI_REGISTER_CALLBACKS == 1U) */
0892 /**
0893   * @}
0894   */
0895 
0896 /* Peripheral Control and State functions  ************************************/
0897 /** @addtogroup OSPI_Exported_Functions_Group3
0898   * @{
0899   */
0900 HAL_StatusTypeDef     HAL_OSPI_Abort(OSPI_HandleTypeDef *hospi);
0901 HAL_StatusTypeDef     HAL_OSPI_Abort_IT(OSPI_HandleTypeDef *hospi);
0902 HAL_StatusTypeDef     HAL_OSPI_SetFifoThreshold(OSPI_HandleTypeDef *hospi, uint32_t Threshold);
0903 uint32_t              HAL_OSPI_GetFifoThreshold(const OSPI_HandleTypeDef *hospi);
0904 HAL_StatusTypeDef     HAL_OSPI_SetTimeout(OSPI_HandleTypeDef *hospi, uint32_t Timeout);
0905 uint32_t              HAL_OSPI_GetError(const OSPI_HandleTypeDef *hospi);
0906 uint32_t              HAL_OSPI_GetState(const OSPI_HandleTypeDef *hospi);
0907 
0908 /**
0909   * @}
0910   */
0911 
0912 /* OSPI IO Manager configuration function  ************************************/
0913 /** @addtogroup OSPI_Exported_Functions_Group4
0914   * @{
0915   */
0916 HAL_StatusTypeDef     HAL_OSPIM_Config(OSPI_HandleTypeDef *hospi, OSPIM_CfgTypeDef *cfg, uint32_t Timeout);
0917 
0918 /**
0919   * @}
0920   */
0921 
0922 /**
0923   * @}
0924   */
0925 /* End of exported functions -------------------------------------------------*/
0926 
0927 /* Private macros ------------------------------------------------------------*/
0928 /**
0929   @cond 0
0930   */
0931 #define IS_OSPI_FIFO_THRESHOLD(THRESHOLD)  (((THRESHOLD) >= 1U) && ((THRESHOLD) <= 32U))
0932 
0933 #define IS_OSPI_DUALQUAD_MODE(MODE)        (((MODE) == HAL_OSPI_DUALQUAD_DISABLE) || \
0934                                             ((MODE) == HAL_OSPI_DUALQUAD_ENABLE))
0935 
0936 #define IS_OSPI_MEMORY_TYPE(TYPE)          (((TYPE) == HAL_OSPI_MEMTYPE_MICRON)       || \
0937                                             ((TYPE) == HAL_OSPI_MEMTYPE_MACRONIX)     || \
0938                                             ((TYPE) == HAL_OSPI_MEMTYPE_APMEMORY)     || \
0939                                             ((TYPE) == HAL_OSPI_MEMTYPE_MACRONIX_RAM) || \
0940                                             ((TYPE) == HAL_OSPI_MEMTYPE_HYPERBUS))
0941 
0942 #define IS_OSPI_DEVICE_SIZE(SIZE)          (((SIZE) >= 1U) && ((SIZE) <= 32U))
0943 
0944 #define IS_OSPI_CS_HIGH_TIME(TIME)         (((TIME) >= 1U) && ((TIME) <= 8U))
0945 
0946 #define IS_OSPI_FREE_RUN_CLK(CLK)          (((CLK) == HAL_OSPI_FREERUNCLK_DISABLE) || \
0947                                             ((CLK) == HAL_OSPI_FREERUNCLK_ENABLE))
0948 
0949 #define IS_OSPI_CLOCK_MODE(MODE)           (((MODE) == HAL_OSPI_CLOCK_MODE_0) || \
0950                                             ((MODE) == HAL_OSPI_CLOCK_MODE_3))
0951 
0952 #define IS_OSPI_WRAP_SIZE(SIZE)            (((SIZE) == HAL_OSPI_WRAP_NOT_SUPPORTED) || \
0953                                             ((SIZE) == HAL_OSPI_WRAP_16_BYTES)      || \
0954                                             ((SIZE) == HAL_OSPI_WRAP_32_BYTES)      || \
0955                                             ((SIZE) == HAL_OSPI_WRAP_64_BYTES)      || \
0956                                             ((SIZE) == HAL_OSPI_WRAP_128_BYTES))
0957 
0958 #define IS_OSPI_CLK_PRESCALER(PRESCALER)   (((PRESCALER) >= 1U) && ((PRESCALER) <= 256U))
0959 
0960 #define IS_OSPI_SAMPLE_SHIFTING(CYCLE)     (((CYCLE) == HAL_OSPI_SAMPLE_SHIFTING_NONE)      || \
0961                                             ((CYCLE) == HAL_OSPI_SAMPLE_SHIFTING_HALFCYCLE))
0962 
0963 #define IS_OSPI_DHQC(CYCLE)                (((CYCLE) == HAL_OSPI_DHQC_DISABLE) || \
0964                                             ((CYCLE) == HAL_OSPI_DHQC_ENABLE))
0965 
0966 #define IS_OSPI_OPERATION_TYPE(TYPE)       (((TYPE) == HAL_OSPI_OPTYPE_COMMON_CFG) || \
0967                                             ((TYPE) == HAL_OSPI_OPTYPE_READ_CFG)   || \
0968                                             ((TYPE) == HAL_OSPI_OPTYPE_WRITE_CFG)  || \
0969                                             ((TYPE) == HAL_OSPI_OPTYPE_WRAP_CFG))
0970 
0971 #define IS_OSPI_FLASH_ID(FLASHID)          (((FLASHID) == HAL_OSPI_FLASH_ID_1) || \
0972                                             ((FLASHID) == HAL_OSPI_FLASH_ID_2))
0973 
0974 #define IS_OSPI_INSTRUCTION_MODE(MODE)     (((MODE) == HAL_OSPI_INSTRUCTION_NONE)    || \
0975                                             ((MODE) == HAL_OSPI_INSTRUCTION_1_LINE)  || \
0976                                             ((MODE) == HAL_OSPI_INSTRUCTION_2_LINES) || \
0977                                             ((MODE) == HAL_OSPI_INSTRUCTION_4_LINES) || \
0978                                             ((MODE) == HAL_OSPI_INSTRUCTION_8_LINES))
0979 
0980 #define IS_OSPI_INSTRUCTION_SIZE(SIZE)     (((SIZE) == HAL_OSPI_INSTRUCTION_8_BITS)  || \
0981                                             ((SIZE) == HAL_OSPI_INSTRUCTION_16_BITS) || \
0982                                             ((SIZE) == HAL_OSPI_INSTRUCTION_24_BITS) || \
0983                                             ((SIZE) == HAL_OSPI_INSTRUCTION_32_BITS))
0984 
0985 #define IS_OSPI_INSTRUCTION_DTR_MODE(MODE) (((MODE) == HAL_OSPI_INSTRUCTION_DTR_DISABLE) || \
0986                                             ((MODE) == HAL_OSPI_INSTRUCTION_DTR_ENABLE))
0987 
0988 #define IS_OSPI_ADDRESS_MODE(MODE)         (((MODE) == HAL_OSPI_ADDRESS_NONE)    || \
0989                                             ((MODE) == HAL_OSPI_ADDRESS_1_LINE)  || \
0990                                             ((MODE) == HAL_OSPI_ADDRESS_2_LINES) || \
0991                                             ((MODE) == HAL_OSPI_ADDRESS_4_LINES) || \
0992                                             ((MODE) == HAL_OSPI_ADDRESS_8_LINES))
0993 
0994 #define IS_OSPI_ADDRESS_SIZE(SIZE)         (((SIZE) == HAL_OSPI_ADDRESS_8_BITS)  || \
0995                                             ((SIZE) == HAL_OSPI_ADDRESS_16_BITS) || \
0996                                             ((SIZE) == HAL_OSPI_ADDRESS_24_BITS) || \
0997                                             ((SIZE) == HAL_OSPI_ADDRESS_32_BITS))
0998 
0999 #define IS_OSPI_ADDRESS_DTR_MODE(MODE)     (((MODE) == HAL_OSPI_ADDRESS_DTR_DISABLE) || \
1000                                             ((MODE) == HAL_OSPI_ADDRESS_DTR_ENABLE))
1001 
1002 #define IS_OSPI_ALT_BYTES_MODE(MODE)       (((MODE) == HAL_OSPI_ALTERNATE_BYTES_NONE)    || \
1003                                             ((MODE) == HAL_OSPI_ALTERNATE_BYTES_1_LINE)  || \
1004                                             ((MODE) == HAL_OSPI_ALTERNATE_BYTES_2_LINES) || \
1005                                             ((MODE) == HAL_OSPI_ALTERNATE_BYTES_4_LINES) || \
1006                                             ((MODE) == HAL_OSPI_ALTERNATE_BYTES_8_LINES))
1007 
1008 #define IS_OSPI_ALT_BYTES_SIZE(SIZE)       (((SIZE) == HAL_OSPI_ALTERNATE_BYTES_8_BITS)  || \
1009                                             ((SIZE) == HAL_OSPI_ALTERNATE_BYTES_16_BITS) || \
1010                                             ((SIZE) == HAL_OSPI_ALTERNATE_BYTES_24_BITS) || \
1011                                             ((SIZE) == HAL_OSPI_ALTERNATE_BYTES_32_BITS))
1012 
1013 #define IS_OSPI_ALT_BYTES_DTR_MODE(MODE)   (((MODE) == HAL_OSPI_ALTERNATE_BYTES_DTR_DISABLE) || \
1014                                             ((MODE) == HAL_OSPI_ALTERNATE_BYTES_DTR_ENABLE))
1015 
1016 #define IS_OSPI_DATA_MODE(MODE)            (((MODE) == HAL_OSPI_DATA_NONE)    || \
1017                                             ((MODE) == HAL_OSPI_DATA_1_LINE)  || \
1018                                             ((MODE) == HAL_OSPI_DATA_2_LINES) || \
1019                                             ((MODE) == HAL_OSPI_DATA_4_LINES) || \
1020                                             ((MODE) == HAL_OSPI_DATA_8_LINES))
1021 
1022 #define IS_OSPI_NUMBER_DATA(NUMBER)        ((NUMBER) >= 1U)
1023 
1024 #define IS_OSPI_DATA_DTR_MODE(MODE)        (((MODE) == HAL_OSPI_DATA_DTR_DISABLE) || \
1025                                             ((MODE) == HAL_OSPI_DATA_DTR_ENABLE))
1026 
1027 #define IS_OSPI_DUMMY_CYCLES(NUMBER)       ((NUMBER) <= 31U)
1028 
1029 #define IS_OSPI_DQS_MODE(MODE)             (((MODE) == HAL_OSPI_DQS_DISABLE) || \
1030                                             ((MODE) == HAL_OSPI_DQS_ENABLE))
1031 
1032 #define IS_OSPI_SIOO_MODE(MODE)            (((MODE) == HAL_OSPI_SIOO_INST_EVERY_CMD) || \
1033                                             ((MODE) == HAL_OSPI_SIOO_INST_ONLY_FIRST_CMD))
1034 
1035 #define IS_OSPI_RW_RECOVERY_TIME(NUMBER)   ((NUMBER) <= 255U)
1036 
1037 #define IS_OSPI_ACCESS_TIME(NUMBER)        ((NUMBER) <= 255U)
1038 
1039 #define IS_OSPI_WRITE_ZERO_LATENCY(MODE)   (((MODE) == HAL_OSPI_LATENCY_ON_WRITE) || \
1040                                             ((MODE) == HAL_OSPI_NO_LATENCY_ON_WRITE))
1041 
1042 #define IS_OSPI_LATENCY_MODE(MODE)         (((MODE) == HAL_OSPI_VARIABLE_LATENCY) || \
1043                                             ((MODE) == HAL_OSPI_FIXED_LATENCY))
1044 
1045 #define IS_OSPI_ADDRESS_SPACE(SPACE)       (((SPACE) == HAL_OSPI_MEMORY_ADDRESS_SPACE) || \
1046                                             ((SPACE) == HAL_OSPI_REGISTER_ADDRESS_SPACE))
1047 
1048 #define IS_OSPI_MATCH_MODE(MODE)           (((MODE) == HAL_OSPI_MATCH_MODE_AND) || \
1049                                             ((MODE) == HAL_OSPI_MATCH_MODE_OR))
1050 
1051 #define IS_OSPI_AUTOMATIC_STOP(MODE)       (((MODE) == HAL_OSPI_AUTOMATIC_STOP_ENABLE) || \
1052                                             ((MODE) == HAL_OSPI_AUTOMATIC_STOP_DISABLE))
1053 
1054 #define IS_OSPI_INTERVAL(INTERVAL)         ((INTERVAL) <= 0xFFFFU)
1055 
1056 #define IS_OSPI_STATUS_BYTES_SIZE(SIZE)    (((SIZE) >= 1U) && ((SIZE) <= 4U))
1057 
1058 #define IS_OSPI_TIMEOUT_ACTIVATION(MODE)   (((MODE) == HAL_OSPI_TIMEOUT_COUNTER_DISABLE) || \
1059                                             ((MODE) == HAL_OSPI_TIMEOUT_COUNTER_ENABLE))
1060 
1061 #define IS_OSPI_TIMEOUT_PERIOD(PERIOD)     ((PERIOD) <= 0xFFFFU)
1062 
1063 #define IS_OSPI_CS_BOUNDARY(BOUNDARY)      ((BOUNDARY) <= 31U)
1064 
1065 #define IS_OSPI_DLYBYP(MODE)               (((MODE) == HAL_OSPI_DELAY_BLOCK_USED) || \
1066                                             ((MODE) == HAL_OSPI_DELAY_BLOCK_BYPASSED))
1067 
1068 #define IS_OSPI_MAXTRAN(NB_BYTES)          ((NB_BYTES) <= 255U)
1069 
1070 #define IS_OSPIM_PORT(NUMBER)              (((NUMBER) >= 1U) && ((NUMBER) <= 8U))
1071 
1072 #define IS_OSPIM_DQS_PORT(NUMBER)          ((NUMBER) <= 8U)
1073 
1074 #define IS_OSPIM_IO_PORT(PORT)             (((PORT) == HAL_OSPIM_IOPORT_NONE)  || \
1075                                             ((PORT) == HAL_OSPIM_IOPORT_1_LOW)  || \
1076                                             ((PORT) == HAL_OSPIM_IOPORT_1_HIGH) || \
1077                                             ((PORT) == HAL_OSPIM_IOPORT_2_LOW)  || \
1078                                             ((PORT) == HAL_OSPIM_IOPORT_2_HIGH) || \
1079                                             ((PORT) == HAL_OSPIM_IOPORT_3_LOW)  || \
1080                                             ((PORT) == HAL_OSPIM_IOPORT_3_HIGH) || \
1081                                             ((PORT) == HAL_OSPIM_IOPORT_4_LOW)  || \
1082                                             ((PORT) == HAL_OSPIM_IOPORT_4_HIGH) || \
1083                                             ((PORT) == HAL_OSPIM_IOPORT_5_LOW)  || \
1084                                             ((PORT) == HAL_OSPIM_IOPORT_5_HIGH) || \
1085                                             ((PORT) == HAL_OSPIM_IOPORT_6_LOW)  || \
1086                                             ((PORT) == HAL_OSPIM_IOPORT_6_HIGH) || \
1087                                             ((PORT) == HAL_OSPIM_IOPORT_7_LOW)  || \
1088                                             ((PORT) == HAL_OSPIM_IOPORT_7_HIGH) || \
1089                                             ((PORT) == HAL_OSPIM_IOPORT_8_LOW)  || \
1090                                             ((PORT) == HAL_OSPIM_IOPORT_8_HIGH))
1091 
1092 #define IS_OSPIM_REQ2ACKTIME(TIME)          (((TIME) >= 1U) && ((TIME) <= 256U))
1093 /**
1094   @endcond
1095   */
1096 
1097 /* End of private macros -----------------------------------------------------*/
1098 
1099 /**
1100   * @}
1101   */
1102 
1103 /**
1104   * @}
1105   */
1106 
1107 #endif /* OCTOSPI || OCTOSPI1 || OCTOSPI2 */
1108 
1109 #ifdef __cplusplus
1110 }
1111 #endif
1112 
1113 #endif /* STM32H7xx_HAL_OSPI_H */