Back to home page

LXR

 
 

    


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

0001 /**
0002   ******************************************************************************
0003   * @file    stm32h7xx_ll_sdmmc.h
0004   * @author  MCD Application Team
0005   * @brief   Header file of SDMMC 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_LL_SDMMC_H
0021 #define STM32H7xx_LL_SDMMC_H
0022 
0023 #ifdef __cplusplus
0024 extern "C" {
0025 #endif
0026 
0027 /* Includes ------------------------------------------------------------------*/
0028 #include "stm32h7xx_hal_def.h"
0029 
0030 /** @addtogroup STM32H7xx_Driver
0031   * @{
0032   */
0033 
0034 /** @addtogroup SDMMC_LL
0035   * @{
0036   */
0037 
0038 /* Exported types ------------------------------------------------------------*/
0039 /** @defgroup SDMMC_LL_Exported_Types SDMMC_LL Exported Types
0040   * @ingroup RTEMSBSPsARMSTM32H7
0041   * @{
0042   */
0043 
0044 /**
0045   * @brief  SDMMC Configuration Structure definition
0046   */
0047 typedef struct
0048 {
0049   uint32_t ClockEdge;            /*!< Specifies the SDMMC_CCK clock transition on which Data and Command change.
0050                                       This parameter can be a value of @ref SDMMC_LL_Clock_Edge                 */
0051 
0052   uint32_t ClockPowerSave;       /*!< Specifies whether SDMMC Clock output is enabled or
0053                                       disabled when the bus is idle.
0054                                       This parameter can be a value of @ref SDMMC_LL_Clock_Power_Save           */
0055 
0056   uint32_t BusWide;              /*!< Specifies the SDMMC bus width.
0057                                       This parameter can be a value of @ref SDMMC_LL_Bus_Wide                   */
0058 
0059   uint32_t HardwareFlowControl;  /*!< Specifies whether the SDMMC hardware flow control is enabled or disabled.
0060                                       This parameter can be a value of @ref SDMMC_LL_Hardware_Flow_Control      */
0061 
0062   uint32_t ClockDiv;             /*!< Specifies the clock frequency of the SDMMC controller.
0063                                       This parameter can be a value between Min_Data = 0 and Max_Data = 1023   */
0064 
0065 #if (USE_SD_TRANSCEIVER != 0U)
0066   uint32_t TranceiverPresent;    /*!< Specifies if there is a 1V8 Transceiver/Switcher.
0067                                       This parameter can be a value of @ref SDMMC_LL_TRANSCEIVER_PRESENT       */
0068 #endif /* USE_SD_TRANSCEIVER */
0069 } SDMMC_InitTypeDef;
0070 
0071 
0072 /**
0073   * @brief  SDMMC Command Control structure
0074   */
0075 typedef struct
0076 {
0077   uint32_t Argument;            /*!< Specifies the SDMMC command argument which is sent
0078                                      to a card as part of a command message. If a command
0079                                      contains an argument, it must be loaded into this register
0080                                      before writing the command to the command register.              */
0081 
0082   uint32_t CmdIndex;            /*!< Specifies the SDMMC command index. It must be Min_Data = 0 and
0083                                      Max_Data = 64                                                    */
0084 
0085   uint32_t Response;            /*!< Specifies the SDMMC response type.
0086                                      This parameter can be a value of @ref SDMMC_LL_Response_Type         */
0087 
0088   uint32_t WaitForInterrupt;    /*!< Specifies whether SDMMC wait for interrupt request is
0089                                      enabled or disabled.
0090                                      This parameter can be a value of @ref SDMMC_LL_Wait_Interrupt_State  */
0091 
0092   uint32_t CPSM;                /*!< Specifies whether SDMMC Command path state machine (CPSM)
0093                                      is enabled or disabled.
0094                                      This parameter can be a value of @ref SDMMC_LL_CPSM_State            */
0095 } SDMMC_CmdInitTypeDef;
0096 
0097 
0098 /**
0099   * @brief  SDMMC Data Control structure
0100   */
0101 typedef struct
0102 {
0103   uint32_t DataTimeOut;         /*!< Specifies the data timeout period in card bus clock periods.  */
0104 
0105   uint32_t DataLength;          /*!< Specifies the number of data bytes to be transferred.         */
0106 
0107   uint32_t DataBlockSize;       /*!< Specifies the data block size for block transfer.
0108                                      This parameter can be a value of @ref SDMMC_LL_Data_Block_Size    */
0109 
0110   uint32_t TransferDir;         /*!< Specifies the data transfer direction, whether the transfer
0111                                      is a read or write.
0112                                      This parameter can be a value of @ref SDMMC_LL_Transfer_Direction */
0113 
0114   uint32_t TransferMode;        /*!< Specifies whether data transfer is in stream or block mode.
0115                                      This parameter can be a value of @ref SDMMC_LL_Transfer_Type      */
0116 
0117   uint32_t DPSM;                /*!< Specifies whether SDMMC Data path state machine (DPSM)
0118                                      is enabled or disabled.
0119                                      This parameter can be a value of @ref SDMMC_LL_DPSM_State         */
0120 } SDMMC_DataInitTypeDef;
0121 
0122 /**
0123   * @}
0124   */
0125 
0126 /* Exported constants --------------------------------------------------------*/
0127 /** @defgroup SDMMC_LL_Exported_Constants SDMMC_LL Exported Constants
0128   * @ingroup RTEMSBSPsARMSTM32H7
0129   * @{
0130   */
0131 #define SDMMC_ERROR_NONE                     ((uint32_t)0x00000000U)   /*!< No error                                                      */
0132 #define SDMMC_ERROR_CMD_CRC_FAIL             ((uint32_t)0x00000001U)   /*!< Command response received (but CRC check failed)              */
0133 #define SDMMC_ERROR_DATA_CRC_FAIL            ((uint32_t)0x00000002U)   /*!< Data block sent/received (CRC check failed)                   */
0134 #define SDMMC_ERROR_CMD_RSP_TIMEOUT          ((uint32_t)0x00000004U)   /*!< Command response timeout                                      */
0135 #define SDMMC_ERROR_DATA_TIMEOUT             ((uint32_t)0x00000008U)   /*!< Data timeout                                                  */
0136 #define SDMMC_ERROR_TX_UNDERRUN              ((uint32_t)0x00000010U)   /*!< Transmit FIFO underrun                                        */
0137 #define SDMMC_ERROR_RX_OVERRUN               ((uint32_t)0x00000020U)   /*!< Receive FIFO overrun                                          */
0138 #define SDMMC_ERROR_ADDR_MISALIGNED          ((uint32_t)0x00000040U)   /*!< Misaligned address                                            */
0139 #define SDMMC_ERROR_BLOCK_LEN_ERR            ((uint32_t)0x00000080U)   /*!< Transferred block length is not allowed for the card or the number of transferred bytes does not match the block length   */
0140 #define SDMMC_ERROR_ERASE_SEQ_ERR            ((uint32_t)0x00000100U)   /*!< An error in the sequence of erase command occurs              */
0141 #define SDMMC_ERROR_BAD_ERASE_PARAM          ((uint32_t)0x00000200U)   /*!< An invalid selection for erase groups                         */
0142 #define SDMMC_ERROR_WRITE_PROT_VIOLATION     ((uint32_t)0x00000400U)   /*!< Attempt to program a write protect block                      */
0143 #define SDMMC_ERROR_LOCK_UNLOCK_FAILED       ((uint32_t)0x00000800U)   /*!< Sequence or password error has been detected in unlock command or if there was an attempt to access a locked card    */
0144 #define SDMMC_ERROR_COM_CRC_FAILED           ((uint32_t)0x00001000U)   /*!< CRC check of the previous command failed                      */
0145 #define SDMMC_ERROR_ILLEGAL_CMD              ((uint32_t)0x00002000U)   /*!< Command is not legal for the card state                       */
0146 #define SDMMC_ERROR_CARD_ECC_FAILED          ((uint32_t)0x00004000U)   /*!< Card internal ECC was applied but failed to correct the data  */
0147 #define SDMMC_ERROR_CC_ERR                   ((uint32_t)0x00008000U)   /*!< Internal card controller error                                */
0148 #define SDMMC_ERROR_GENERAL_UNKNOWN_ERR      ((uint32_t)0x00010000U)   /*!< General or unknown error                                      */
0149 #define SDMMC_ERROR_STREAM_READ_UNDERRUN     ((uint32_t)0x00020000U)   /*!< The card could not sustain data reading in stream rmode       */
0150 #define SDMMC_ERROR_STREAM_WRITE_OVERRUN     ((uint32_t)0x00040000U)   /*!< The card could not sustain data programming in stream mode    */
0151 #define SDMMC_ERROR_CID_CSD_OVERWRITE        ((uint32_t)0x00080000U)   /*!< CID/CSD overwrite error                                       */
0152 #define SDMMC_ERROR_WP_ERASE_SKIP            ((uint32_t)0x00100000U)   /*!< Only partial address space was erased                         */
0153 #define SDMMC_ERROR_CARD_ECC_DISABLED        ((uint32_t)0x00200000U)   /*!< Command has been executed without using internal ECC          */
0154 #define SDMMC_ERROR_ERASE_RESET              ((uint32_t)0x00400000U)   /*!< Erase sequence was cleared before executing because an out of erase sequence command was received                        */
0155 #define SDMMC_ERROR_AKE_SEQ_ERR              ((uint32_t)0x00800000U)   /*!< Error in sequence of authentication                           */
0156 #define SDMMC_ERROR_INVALID_VOLTRANGE        ((uint32_t)0x01000000U)   /*!< Error in case of invalid voltage range                        */
0157 #define SDMMC_ERROR_ADDR_OUT_OF_RANGE        ((uint32_t)0x02000000U)   /*!< Error when addressed block is out of range                    */
0158 #define SDMMC_ERROR_REQUEST_NOT_APPLICABLE   ((uint32_t)0x04000000U)   /*!< Error when command request is not applicable                  */
0159 #define SDMMC_ERROR_INVALID_PARAMETER        ((uint32_t)0x08000000U)   /*!< the used parameter is not valid                               */
0160 #define SDMMC_ERROR_UNSUPPORTED_FEATURE      ((uint32_t)0x10000000U)   /*!< Error when feature is not insupported                         */
0161 #define SDMMC_ERROR_BUSY                     ((uint32_t)0x20000000U)   /*!< Error when transfer process is busy                           */
0162 #define SDMMC_ERROR_DMA                      ((uint32_t)0x40000000U)   /*!< Error while DMA transfer                                      */
0163 #define SDMMC_ERROR_TIMEOUT                  ((uint32_t)0x80000000U)   /*!< Timeout error                                                 */
0164 
0165 /**
0166   * @brief SDMMC Commands Index
0167   */
0168 #define SDMMC_CMD_GO_IDLE_STATE                       ((uint8_t)0U)   /*!< Resets the SD memory card.                                                               */
0169 #define SDMMC_CMD_SEND_OP_COND                        ((uint8_t)1U)   /*!< Sends host capacity support information and activates the card's initialization process. */
0170 #define SDMMC_CMD_ALL_SEND_CID                        ((uint8_t)2U)   /*!< Asks any card connected to the host to send the CID numbers on the CMD line.             */
0171 #define SDMMC_CMD_SET_REL_ADDR                        ((uint8_t)3U)   /*!< Asks the card to publish a new relative address (RCA).                                   */
0172 #define SDMMC_CMD_SET_DSR                             ((uint8_t)4U)   /*!< Programs the DSR of all cards.                                                           */
0173 #define SDMMC_CMD_SDMMC_SEN_OP_COND                   ((uint8_t)5U)   /*!< Sends host capacity support information (HCS) and asks the accessed card to send its operating condition register (OCR) content in the response on the CMD line.*/
0174 #define SDMMC_CMD_HS_SWITCH                           ((uint8_t)6U)   /*!< Checks switchable function (mode 0) and switch card function (mode 1).                   */
0175 #define SDMMC_CMD_SEL_DESEL_CARD                      ((uint8_t)7U)   /*!< Selects the card by its own relative address and gets deselected by any other address    */
0176 #define SDMMC_CMD_HS_SEND_EXT_CSD                     ((uint8_t)8U)   /*!< Sends SD Memory Card interface condition, which includes host supply voltage information  and asks the card whether card supports voltage.                      */
0177 #define SDMMC_CMD_SEND_CSD                            ((uint8_t)9U)   /*!< Addressed card sends its card specific data (CSD) on the CMD line.                       */
0178 #define SDMMC_CMD_SEND_CID                            ((uint8_t)10U)  /*!< Addressed card sends its card identification (CID) on the CMD line.                      */
0179 #define SDMMC_CMD_VOLTAGE_SWITCH                      ((uint8_t)11U)  /*!< SD card Voltage switch to 1.8V mode.                                                     */
0180 #define SDMMC_CMD_STOP_TRANSMISSION                   ((uint8_t)12U)  /*!< Forces the card to stop transmission.                                                    */
0181 #define SDMMC_CMD_SEND_STATUS                         ((uint8_t)13U)  /*!< Addressed card sends its status register.                                                */
0182 #define SDMMC_CMD_HS_BUSTEST_READ                     ((uint8_t)14U)  /*!< Reserved                                                                                 */
0183 #define SDMMC_CMD_GO_INACTIVE_STATE                   ((uint8_t)15U)  /*!< Sends an addressed card into the inactive state.                                         */
0184 #define SDMMC_CMD_SET_BLOCKLEN                        ((uint8_t)16U)  /*!< Sets the block length (in bytes for SDSC) for all following block commands (read, write, lock). Default block length is fixed to 512 Bytes. Not effective        */
0185 /*!< for SDHS and SDXC.                                                                       */
0186 #define SDMMC_CMD_READ_SINGLE_BLOCK                   ((uint8_t)17U)  /*!< Reads single block of size selected by SET_BLOCKLEN in case of SDSC, and a block of fixed 512 bytes in case of SDHC and SDXC.                                    */
0187 #define SDMMC_CMD_READ_MULT_BLOCK                     ((uint8_t)18U)  /*!< Continuously transfers data blocks from card to host until interrupted by  STOP_TRANSMISSION command.                                                            */
0188 #define SDMMC_CMD_HS_BUSTEST_WRITE                    ((uint8_t)19U)  /*!< 64 bytes tuning pattern is sent for SDR50 and SDR104.                                    */
0189 #define SDMMC_CMD_WRITE_DAT_UNTIL_STOP                ((uint8_t)20U)  /*!< Speed class control command.                                                             */
0190 #define SDMMC_CMD_SET_BLOCK_COUNT                     ((uint8_t)23U)  /*!< Specify block count for CMD18 and CMD25.                                                 */
0191 #define SDMMC_CMD_WRITE_SINGLE_BLOCK                  ((uint8_t)24U)  /*!< Writes single block of size selected by SET_BLOCKLEN in case of SDSC, and a block of fixed 512 bytes in case of SDHC and SDXC.                                   */
0192 #define SDMMC_CMD_WRITE_MULT_BLOCK                    ((uint8_t)25U)  /*!< Continuously writes blocks of data until a STOP_TRANSMISSION follows.                    */
0193 #define SDMMC_CMD_PROG_CID                            ((uint8_t)26U)  /*!< Reserved for manufacturers.                                                              */
0194 #define SDMMC_CMD_PROG_CSD                            ((uint8_t)27U)  /*!< Programming of the programmable bits of the CSD.                                         */
0195 #define SDMMC_CMD_SET_WRITE_PROT                      ((uint8_t)28U)  /*!< Sets the write protection bit of the addressed group.                                    */
0196 #define SDMMC_CMD_CLR_WRITE_PROT                      ((uint8_t)29U)  /*!< Clears the write protection bit of the addressed group.                                  */
0197 #define SDMMC_CMD_SEND_WRITE_PROT                     ((uint8_t)30U)  /*!< Asks the card to send the status of the write protection bits.                           */
0198 #define SDMMC_CMD_SD_ERASE_GRP_START                  ((uint8_t)32U)  /*!< Sets the address of the first write block to be erased. (For SD card only).              */
0199 #define SDMMC_CMD_SD_ERASE_GRP_END                    ((uint8_t)33U)  /*!< Sets the address of the last write block of the continuous range to be erased.           */
0200 #define SDMMC_CMD_ERASE_GRP_START                     ((uint8_t)35U)  /*!< Sets the address of the first write block to be erased. Reserved for each command system set by switch function command (CMD6).                                  */
0201 #define SDMMC_CMD_ERASE_GRP_END                       ((uint8_t)36U)  /*!< Sets the address of the last write block of the continuous range to be erased. Reserved for each command system set by switch function command (CMD6).           */
0202 #define SDMMC_CMD_ERASE                               ((uint8_t)38U)  /*!< Reserved for SD security applications.                                                   */
0203 #define SDMMC_CMD_FAST_IO                             ((uint8_t)39U)  /*!< SD card doesn't support it (Reserved).                                                   */
0204 #define SDMMC_CMD_GO_IRQ_STATE                        ((uint8_t)40U)  /*!< SD card doesn't support it (Reserved).                                                   */
0205 #define SDMMC_CMD_LOCK_UNLOCK                         ((uint8_t)42U)  /*!< Sets/resets the password or lock/unlock the card. The size of the data block is set by the SET_BLOCK_LEN command.                                                */
0206 #define SDMMC_CMD_APP_CMD                             ((uint8_t)55U)  /*!< Indicates to the card that the next command is an application specific command rather than a standard command.                                                   */
0207 #define SDMMC_CMD_GEN_CMD                             ((uint8_t)56U)  /*!< Used either to transfer a data block to the card or to get a data block from the card for general purpose/application specific commands.                         */
0208 #define SDMMC_CMD_NO_CMD                              ((uint8_t)64U)  /*!< No command                                                                               */
0209 
0210 /**
0211   * @brief Following commands are SD Card Specific commands.
0212   *        SDMMC_APP_CMD should be sent before sending these commands.
0213   */
0214 #define SDMMC_CMD_APP_SD_SET_BUSWIDTH                 ((uint8_t)6U)   /*!< (ACMD6) Defines the data bus width to be used for data transfer. The allowed data bus widths are given in SCR register.                                                   */
0215 #define SDMMC_CMD_SD_APP_STATUS                       ((uint8_t)13U)  /*!< (ACMD13) Sends the SD status.                                                            */
0216 #define SDMMC_CMD_SD_APP_SEND_NUM_WRITE_BLOCKS        ((uint8_t)22U)  /*!< (ACMD22) Sends the number of the written (without errors) write blocks. Responds with 32bit+CRC data block.                                                               */
0217 #define SDMMC_CMD_SD_APP_OP_COND                      ((uint8_t)41U)  /*!< (ACMD41) Sends host capacity support information (HCS) and asks the accessed card to send its operating condition register (OCR) content in the response on the CMD line. */
0218 #define SDMMC_CMD_SD_APP_SET_CLR_CARD_DETECT          ((uint8_t)42U)  /*!< (ACMD42) Connect/Disconnect the 50 KOhm pull-up resistor on CD/DAT3 (pin 1) of the card  */
0219 #define SDMMC_CMD_SD_APP_SEND_SCR                     ((uint8_t)51U)  /*!< Reads the SD Configuration Register (SCR).                                               */
0220 #define SDMMC_CMD_SDMMC_RW_DIRECT                     ((uint8_t)52U)  /*!< For SD I/O card only, reserved for security specification.                               */
0221 #define SDMMC_CMD_SDMMC_RW_EXTENDED                   ((uint8_t)53U)  /*!< For SD I/O card only, reserved for security specification.                               */
0222 
0223 /**
0224   * @brief Following commands are MMC Specific commands.
0225   */
0226 #define SDMMC_CMD_MMC_SLEEP_AWAKE                     ((uint8_t)5U)   /*!< Toggle the device between Sleep state and Standby state.                                 */
0227 
0228 /**
0229   * @brief Following commands are SD Card Specific security commands.
0230   *        SDMMC_CMD_APP_CMD should be sent before sending these commands.
0231   */
0232 #define SDMMC_CMD_SD_APP_GET_MKB                      ((uint8_t)43U)
0233 #define SDMMC_CMD_SD_APP_GET_MID                      ((uint8_t)44U)
0234 #define SDMMC_CMD_SD_APP_SET_CER_RN1                  ((uint8_t)45U)
0235 #define SDMMC_CMD_SD_APP_GET_CER_RN2                  ((uint8_t)46U)
0236 #define SDMMC_CMD_SD_APP_SET_CER_RES2                 ((uint8_t)47U)
0237 #define SDMMC_CMD_SD_APP_GET_CER_RES1                 ((uint8_t)48U)
0238 #define SDMMC_CMD_SD_APP_SECURE_READ_MULTIPLE_BLOCK   ((uint8_t)18U)
0239 #define SDMMC_CMD_SD_APP_SECURE_WRITE_MULTIPLE_BLOCK  ((uint8_t)25U)
0240 #define SDMMC_CMD_SD_APP_SECURE_ERASE                 ((uint8_t)38U)
0241 #define SDMMC_CMD_SD_APP_CHANGE_SECURE_AREA           ((uint8_t)49U)
0242 #define SDMMC_CMD_SD_APP_SECURE_WRITE_MKB             ((uint8_t)48U)
0243 
0244 /**
0245   * @brief  Masks for errors Card Status R1 (OCR Register)
0246   */
0247 #define SDMMC_OCR_ADDR_OUT_OF_RANGE        ((uint32_t)0x80000000U)
0248 #define SDMMC_OCR_ADDR_MISALIGNED          ((uint32_t)0x40000000U)
0249 #define SDMMC_OCR_BLOCK_LEN_ERR            ((uint32_t)0x20000000U)
0250 #define SDMMC_OCR_ERASE_SEQ_ERR            ((uint32_t)0x10000000U)
0251 #define SDMMC_OCR_BAD_ERASE_PARAM          ((uint32_t)0x08000000U)
0252 #define SDMMC_OCR_WRITE_PROT_VIOLATION     ((uint32_t)0x04000000U)
0253 #define SDMMC_OCR_LOCK_UNLOCK_FAILED       ((uint32_t)0x01000000U)
0254 #define SDMMC_OCR_COM_CRC_FAILED           ((uint32_t)0x00800000U)
0255 #define SDMMC_OCR_ILLEGAL_CMD              ((uint32_t)0x00400000U)
0256 #define SDMMC_OCR_CARD_ECC_FAILED          ((uint32_t)0x00200000U)
0257 #define SDMMC_OCR_CC_ERROR                 ((uint32_t)0x00100000U)
0258 #define SDMMC_OCR_GENERAL_UNKNOWN_ERROR    ((uint32_t)0x00080000U)
0259 #define SDMMC_OCR_STREAM_READ_UNDERRUN     ((uint32_t)0x00040000U)
0260 #define SDMMC_OCR_STREAM_WRITE_OVERRUN     ((uint32_t)0x00020000U)
0261 #define SDMMC_OCR_CID_CSD_OVERWRITE        ((uint32_t)0x00010000U)
0262 #define SDMMC_OCR_WP_ERASE_SKIP            ((uint32_t)0x00008000U)
0263 #define SDMMC_OCR_CARD_ECC_DISABLED        ((uint32_t)0x00004000U)
0264 #define SDMMC_OCR_ERASE_RESET              ((uint32_t)0x00002000U)
0265 #define SDMMC_OCR_AKE_SEQ_ERROR            ((uint32_t)0x00000008U)
0266 #define SDMMC_OCR_ERRORBITS                ((uint32_t)0xFDFFE008U)
0267 
0268 /**
0269   * @brief  Masks for R6 Response
0270   */
0271 #define SDMMC_R6_GENERAL_UNKNOWN_ERROR     ((uint32_t)0x00002000U)
0272 #define SDMMC_R6_ILLEGAL_CMD               ((uint32_t)0x00004000U)
0273 #define SDMMC_R6_COM_CRC_FAILED            ((uint32_t)0x00008000U)
0274 
0275 #define SDMMC_VOLTAGE_WINDOW_SD            ((uint32_t)0x80100000U)
0276 #define SDMMC_HIGH_CAPACITY                ((uint32_t)0x40000000U)
0277 #define SDMMC_STD_CAPACITY                 ((uint32_t)0x00000000U)
0278 #define SDMMC_CHECK_PATTERN                ((uint32_t)0x000001AAU)
0279 #define SD_SWITCH_1_8V_CAPACITY            ((uint32_t)0x01000000U)
0280 #define SDMMC_DDR50_SWITCH_PATTERN         ((uint32_t)0x80FFFF04U)
0281 #define SDMMC_SDR104_SWITCH_PATTERN        ((uint32_t)0x80FF1F03U)
0282 #define SDMMC_SDR50_SWITCH_PATTERN         ((uint32_t)0x80FF1F02U)
0283 #define SDMMC_SDR25_SWITCH_PATTERN         ((uint32_t)0x80FFFF01U)
0284 #define SDMMC_SDR12_SWITCH_PATTERN         ((uint32_t)0x80FFFF00U)
0285 
0286 #define SDMMC_MAX_VOLT_TRIAL               ((uint32_t)0x0000FFFFU)
0287 
0288 #define SDMMC_MAX_TRIAL                    ((uint32_t)0x0000FFFFU)
0289 
0290 #define SDMMC_ALLZERO                      ((uint32_t)0x00000000U)
0291 
0292 #define SDMMC_WIDE_BUS_SUPPORT             ((uint32_t)0x00040000U)
0293 #define SDMMC_SINGLE_BUS_SUPPORT           ((uint32_t)0x00010000U)
0294 #define SDMMC_CARD_LOCKED                  ((uint32_t)0x02000000U)
0295 
0296 #ifndef SDMMC_DATATIMEOUT
0297 #define SDMMC_DATATIMEOUT                  ((uint32_t)0xFFFFFFFFU)
0298 #endif /* SDMMC_DATATIMEOUT */
0299 #define SDMMC_0TO7BITS                     ((uint32_t)0x000000FFU)
0300 #define SDMMC_8TO15BITS                    ((uint32_t)0x0000FF00U)
0301 #define SDMMC_16TO23BITS                   ((uint32_t)0x00FF0000U)
0302 #define SDMMC_24TO31BITS                   ((uint32_t)0xFF000000U)
0303 #define SDMMC_MAX_DATA_LENGTH              ((uint32_t)0x01FFFFFFU)
0304 
0305 #define SDMMC_HALFFIFO                     ((uint32_t)0x00000008U)
0306 #define SDMMC_HALFFIFOBYTES                ((uint32_t)0x00000020U)
0307 
0308 /**
0309   * @brief  Command Class supported
0310   */
0311 #define SDMMC_CCCC_ERASE                   ((uint32_t)0x00000020U)
0312 
0313 #define SDMMC_CMDTIMEOUT                   ((uint32_t)5000U)        /* Command send and response timeout     */
0314 #define SDMMC_MAXERASETIMEOUT              ((uint32_t)63000U)       /* Max erase Timeout 63 s                */
0315 #define SDMMC_STOPTRANSFERTIMEOUT          ((uint32_t)100000000U)   /* Timeout for STOP TRANSMISSION command */
0316 
0317 /** @defgroup SDMMC_LL_Clock_Edge Clock Edge
0318   * @ingroup RTEMSBSPsARMSTM32H7
0319   * @{
0320   */
0321 #define SDMMC_CLOCK_EDGE_RISING               ((uint32_t)0x00000000U)
0322 #define SDMMC_CLOCK_EDGE_FALLING              SDMMC_CLKCR_NEGEDGE
0323 
0324 #define IS_SDMMC_CLOCK_EDGE(EDGE) (((EDGE) == SDMMC_CLOCK_EDGE_RISING) || \
0325                                    ((EDGE) == SDMMC_CLOCK_EDGE_FALLING))
0326 /**
0327   * @}
0328   */
0329 
0330 /** @defgroup SDMMC_LL_Clock_Power_Save Clock Power Saving
0331   * @ingroup RTEMSBSPsARMSTM32H7
0332   * @{
0333   */
0334 #define SDMMC_CLOCK_POWER_SAVE_DISABLE         ((uint32_t)0x00000000U)
0335 #define SDMMC_CLOCK_POWER_SAVE_ENABLE          SDMMC_CLKCR_PWRSAV
0336 
0337 #define IS_SDMMC_CLOCK_POWER_SAVE(SAVE) (((SAVE) == SDMMC_CLOCK_POWER_SAVE_DISABLE) || \
0338                                          ((SAVE) == SDMMC_CLOCK_POWER_SAVE_ENABLE))
0339 /**
0340   * @}
0341   */
0342 
0343 /** @defgroup SDMMC_LL_Bus_Wide Bus Width
0344   * @ingroup RTEMSBSPsARMSTM32H7
0345   * @{
0346   */
0347 #define SDMMC_BUS_WIDE_1B                      ((uint32_t)0x00000000U)
0348 #define SDMMC_BUS_WIDE_4B                      SDMMC_CLKCR_WIDBUS_0
0349 #define SDMMC_BUS_WIDE_8B                      SDMMC_CLKCR_WIDBUS_1
0350 
0351 #define IS_SDMMC_BUS_WIDE(WIDE) (((WIDE) == SDMMC_BUS_WIDE_1B) || \
0352                                  ((WIDE) == SDMMC_BUS_WIDE_4B) || \
0353                                  ((WIDE) == SDMMC_BUS_WIDE_8B))
0354 /**
0355   * @}
0356   */
0357 
0358 /** @defgroup SDMMC_LL_Speed_Mode
0359   * @ingroup RTEMSBSPsARMSTM32H7
0360   * @{
0361   */
0362 #define SDMMC_SPEED_MODE_AUTO                  ((uint32_t)0x00000000U)
0363 #define SDMMC_SPEED_MODE_DEFAULT               ((uint32_t)0x00000001U)
0364 #define SDMMC_SPEED_MODE_HIGH                  ((uint32_t)0x00000002U)
0365 #define SDMMC_SPEED_MODE_ULTRA                 ((uint32_t)0x00000003U)
0366 #define SDMMC_SPEED_MODE_ULTRA_SDR104          SDMMC_SPEED_MODE_ULTRA
0367 #define SDMMC_SPEED_MODE_DDR                   ((uint32_t)0x00000004U)
0368 #define SDMMC_SPEED_MODE_ULTRA_SDR50           ((uint32_t)0x00000005U)
0369 
0370 #define IS_SDMMC_SPEED_MODE(MODE) (((MODE) == SDMMC_SPEED_MODE_AUTO)         || \
0371                                    ((MODE) == SDMMC_SPEED_MODE_DEFAULT)      || \
0372                                    ((MODE) == SDMMC_SPEED_MODE_HIGH)         || \
0373                                    ((MODE) == SDMMC_SPEED_MODE_ULTRA)        || \
0374                                    ((MODE) == SDMMC_SPEED_MODE_ULTRA_SDR50)  || \
0375                                    ((MODE) == SDMMC_SPEED_MODE_DDR))
0376 
0377 /**
0378   * @}
0379   */
0380 
0381 /** @defgroup SDMMC_LL_Hardware_Flow_Control Hardware Flow Control
0382   * @ingroup RTEMSBSPsARMSTM32H7
0383   * @{
0384   */
0385 #define SDMMC_HARDWARE_FLOW_CONTROL_DISABLE    ((uint32_t)0x00000000U)
0386 #define SDMMC_HARDWARE_FLOW_CONTROL_ENABLE     SDMMC_CLKCR_HWFC_EN
0387 
0388 #define IS_SDMMC_HARDWARE_FLOW_CONTROL(CONTROL) (((CONTROL) == SDMMC_HARDWARE_FLOW_CONTROL_DISABLE) || \
0389                                                  ((CONTROL) == SDMMC_HARDWARE_FLOW_CONTROL_ENABLE))
0390 /**
0391   * @}
0392   */
0393 
0394 /** @defgroup SDMMC_LL_Clock_Division Clock Division
0395   * @ingroup RTEMSBSPsARMSTM32H7
0396   * @{
0397   */
0398 /* SDMMC_CK frequency = SDMMCCLK / [2 * CLKDIV] */
0399 #define IS_SDMMC_CLKDIV(DIV)   ((DIV) < 0x400U)
0400 /**
0401   * @}
0402   */
0403 
0404 /** @defgroup SDMMC_LL_TRANSCEIVER_PRESENT Transceiver Present
0405   * @ingroup RTEMSBSPsARMSTM32H7
0406   * @{
0407   */
0408 #define SDMMC_TRANSCEIVER_UNKNOWN             ((uint32_t)0x00000000U)
0409 #define SDMMC_TRANSCEIVER_NOT_PRESENT         ((uint32_t)0x00000001U)
0410 #define SDMMC_TRANSCEIVER_PRESENT             ((uint32_t)0x00000002U)
0411 
0412 /**
0413   * @}
0414   */
0415 
0416 /** @defgroup SDMMC_LL_Command_Index Command Index
0417   * @ingroup RTEMSBSPsARMSTM32H7
0418   * @{
0419   */
0420 #define IS_SDMMC_CMD_INDEX(INDEX)            ((INDEX) < 0x40U)
0421 /**
0422   * @}
0423   */
0424 
0425 /** @defgroup SDMMC_LL_Response_Type Response Type
0426   * @ingroup RTEMSBSPsARMSTM32H7
0427   * @{
0428   */
0429 #define SDMMC_RESPONSE_NO                    ((uint32_t)0x00000000U)
0430 #define SDMMC_RESPONSE_SHORT                 SDMMC_CMD_WAITRESP_0
0431 #define SDMMC_RESPONSE_LONG                  SDMMC_CMD_WAITRESP
0432 
0433 #define IS_SDMMC_RESPONSE(RESPONSE) (((RESPONSE) == SDMMC_RESPONSE_NO)    || \
0434                                      ((RESPONSE) == SDMMC_RESPONSE_SHORT) || \
0435                                      ((RESPONSE) == SDMMC_RESPONSE_LONG))
0436 /**
0437   * @}
0438   */
0439 
0440 /** @defgroup SDMMC_LL_Wait_Interrupt_State Wait Interrupt
0441   * @ingroup RTEMSBSPsARMSTM32H7
0442   * @{
0443   */
0444 #define SDMMC_WAIT_NO                        ((uint32_t)0x00000000U)
0445 #define SDMMC_WAIT_IT                        SDMMC_CMD_WAITINT
0446 #define SDMMC_WAIT_PEND                      SDMMC_CMD_WAITPEND
0447 
0448 #define IS_SDMMC_WAIT(WAIT) (((WAIT) == SDMMC_WAIT_NO) || \
0449                              ((WAIT) == SDMMC_WAIT_IT) || \
0450                              ((WAIT) == SDMMC_WAIT_PEND))
0451 /**
0452   * @}
0453   */
0454 
0455 /** @defgroup SDMMC_LL_CPSM_State CPSM State
0456   * @ingroup RTEMSBSPsARMSTM32H7
0457   * @{
0458   */
0459 #define SDMMC_CPSM_DISABLE                   ((uint32_t)0x00000000U)
0460 #define SDMMC_CPSM_ENABLE                    SDMMC_CMD_CPSMEN
0461 
0462 #define IS_SDMMC_CPSM(CPSM) (((CPSM) == SDMMC_CPSM_DISABLE) || \
0463                              ((CPSM) == SDMMC_CPSM_ENABLE))
0464 /**
0465   * @}
0466   */
0467 
0468 /** @defgroup SDMMC_LL_Response_Registers Response Register
0469   * @ingroup RTEMSBSPsARMSTM32H7
0470   * @{
0471   */
0472 #define SDMMC_RESP1                          ((uint32_t)0x00000000U)
0473 #define SDMMC_RESP2                          ((uint32_t)0x00000004U)
0474 #define SDMMC_RESP3                          ((uint32_t)0x00000008U)
0475 #define SDMMC_RESP4                          ((uint32_t)0x0000000CU)
0476 
0477 #define IS_SDMMC_RESP(RESP) (((RESP) == SDMMC_RESP1) || \
0478                              ((RESP) == SDMMC_RESP2) || \
0479                              ((RESP) == SDMMC_RESP3) || \
0480                              ((RESP) == SDMMC_RESP4))
0481 
0482 /** @defgroup SDMMC_Internal_DMA_Mode  SDMMC Internal DMA Mode
0483   * @ingroup RTEMSBSPsARMSTM32H7
0484   * @{
0485   */
0486 #define SDMMC_DISABLE_IDMA              ((uint32_t)0x00000000)
0487 #define SDMMC_ENABLE_IDMA_SINGLE_BUFF   (SDMMC_IDMA_IDMAEN)
0488 #define SDMMC_ENABLE_IDMA_DOUBLE_BUFF0  (SDMMC_IDMA_IDMAEN | SDMMC_IDMA_IDMABMODE)
0489 #define SDMMC_ENABLE_IDMA_DOUBLE_BUFF1  (SDMMC_IDMA_IDMAEN | SDMMC_IDMA_IDMABMODE | SDMMC_IDMA_IDMABACT)
0490 
0491 /**
0492   * @}
0493   */
0494 
0495 /** @defgroup SDMMC_LL_Data_Length Data Length
0496   * @ingroup RTEMSBSPsARMSTM32H7
0497   * @{
0498   */
0499 #define IS_SDMMC_DATA_LENGTH(LENGTH) ((LENGTH) <= 0x01FFFFFFU)
0500 /**
0501   * @}
0502   */
0503 
0504 /** @defgroup SDMMC_LL_Data_Block_Size  Data Block Size
0505   * @ingroup RTEMSBSPsARMSTM32H7
0506   * @{
0507   */
0508 #define SDMMC_DATABLOCK_SIZE_1B               ((uint32_t)0x00000000U)
0509 #define SDMMC_DATABLOCK_SIZE_2B               SDMMC_DCTRL_DBLOCKSIZE_0
0510 #define SDMMC_DATABLOCK_SIZE_4B               SDMMC_DCTRL_DBLOCKSIZE_1
0511 #define SDMMC_DATABLOCK_SIZE_8B               (SDMMC_DCTRL_DBLOCKSIZE_0|SDMMC_DCTRL_DBLOCKSIZE_1)
0512 #define SDMMC_DATABLOCK_SIZE_16B              SDMMC_DCTRL_DBLOCKSIZE_2
0513 #define SDMMC_DATABLOCK_SIZE_32B              (SDMMC_DCTRL_DBLOCKSIZE_0|SDMMC_DCTRL_DBLOCKSIZE_2)
0514 #define SDMMC_DATABLOCK_SIZE_64B              (SDMMC_DCTRL_DBLOCKSIZE_1|SDMMC_DCTRL_DBLOCKSIZE_2)
0515 #define SDMMC_DATABLOCK_SIZE_128B             (SDMMC_DCTRL_DBLOCKSIZE_0| \
0516                                                SDMMC_DCTRL_DBLOCKSIZE_1|SDMMC_DCTRL_DBLOCKSIZE_2)
0517 #define SDMMC_DATABLOCK_SIZE_256B             SDMMC_DCTRL_DBLOCKSIZE_3
0518 #define SDMMC_DATABLOCK_SIZE_512B             (SDMMC_DCTRL_DBLOCKSIZE_0|SDMMC_DCTRL_DBLOCKSIZE_3)
0519 #define SDMMC_DATABLOCK_SIZE_1024B            (SDMMC_DCTRL_DBLOCKSIZE_1|SDMMC_DCTRL_DBLOCKSIZE_3)
0520 #define SDMMC_DATABLOCK_SIZE_2048B            (SDMMC_DCTRL_DBLOCKSIZE_0| \
0521                                                SDMMC_DCTRL_DBLOCKSIZE_1|SDMMC_DCTRL_DBLOCKSIZE_3)
0522 #define SDMMC_DATABLOCK_SIZE_4096B            (SDMMC_DCTRL_DBLOCKSIZE_2|SDMMC_DCTRL_DBLOCKSIZE_3)
0523 #define SDMMC_DATABLOCK_SIZE_8192B            (SDMMC_DCTRL_DBLOCKSIZE_0| \
0524                                                SDMMC_DCTRL_DBLOCKSIZE_2|SDMMC_DCTRL_DBLOCKSIZE_3)
0525 #define SDMMC_DATABLOCK_SIZE_16384B           (SDMMC_DCTRL_DBLOCKSIZE_1| \
0526                                                SDMMC_DCTRL_DBLOCKSIZE_2|SDMMC_DCTRL_DBLOCKSIZE_3)
0527 
0528 #define IS_SDMMC_BLOCK_SIZE(SIZE) (((SIZE) == SDMMC_DATABLOCK_SIZE_1B)    || \
0529                                    ((SIZE) == SDMMC_DATABLOCK_SIZE_2B)    || \
0530                                    ((SIZE) == SDMMC_DATABLOCK_SIZE_4B)    || \
0531                                    ((SIZE) == SDMMC_DATABLOCK_SIZE_8B)    || \
0532                                    ((SIZE) == SDMMC_DATABLOCK_SIZE_16B)   || \
0533                                    ((SIZE) == SDMMC_DATABLOCK_SIZE_32B)   || \
0534                                    ((SIZE) == SDMMC_DATABLOCK_SIZE_64B)   || \
0535                                    ((SIZE) == SDMMC_DATABLOCK_SIZE_128B)  || \
0536                                    ((SIZE) == SDMMC_DATABLOCK_SIZE_256B)  || \
0537                                    ((SIZE) == SDMMC_DATABLOCK_SIZE_512B)  || \
0538                                    ((SIZE) == SDMMC_DATABLOCK_SIZE_1024B) || \
0539                                    ((SIZE) == SDMMC_DATABLOCK_SIZE_2048B) || \
0540                                    ((SIZE) == SDMMC_DATABLOCK_SIZE_4096B) || \
0541                                    ((SIZE) == SDMMC_DATABLOCK_SIZE_8192B) || \
0542                                    ((SIZE) == SDMMC_DATABLOCK_SIZE_16384B))
0543 /**
0544   * @}
0545   */
0546 
0547 /** @defgroup SDMMC_LL_Transfer_Direction Transfer Direction
0548   * @ingroup RTEMSBSPsARMSTM32H7
0549   * @{
0550   */
0551 #define SDMMC_TRANSFER_DIR_TO_CARD            ((uint32_t)0x00000000U)
0552 #define SDMMC_TRANSFER_DIR_TO_SDMMC            SDMMC_DCTRL_DTDIR
0553 
0554 #define IS_SDMMC_TRANSFER_DIR(DIR) (((DIR) == SDMMC_TRANSFER_DIR_TO_CARD) || \
0555                                     ((DIR) == SDMMC_TRANSFER_DIR_TO_SDMMC))
0556 /**
0557   * @}
0558   */
0559 
0560 /** @defgroup SDMMC_LL_Transfer_Type Transfer Type
0561   * @ingroup RTEMSBSPsARMSTM32H7
0562   * @{
0563   */
0564 #define SDMMC_TRANSFER_MODE_BLOCK             ((uint32_t)0x00000000U)
0565 #define SDMMC_TRANSFER_MODE_STREAM            SDMMC_DCTRL_DTMODE_1
0566 
0567 #define IS_SDMMC_TRANSFER_MODE(MODE) (((MODE) == SDMMC_TRANSFER_MODE_BLOCK) || \
0568                                       ((MODE) == SDMMC_TRANSFER_MODE_STREAM))
0569 /**
0570   * @}
0571   */
0572 
0573 /** @defgroup SDMMC_LL_DPSM_State DPSM State
0574   * @ingroup RTEMSBSPsARMSTM32H7
0575   * @{
0576   */
0577 #define SDMMC_DPSM_DISABLE                    ((uint32_t)0x00000000U)
0578 #define SDMMC_DPSM_ENABLE                     SDMMC_DCTRL_DTEN
0579 
0580 #define IS_SDMMC_DPSM(DPSM) (((DPSM) == SDMMC_DPSM_DISABLE) ||\
0581                              ((DPSM) == SDMMC_DPSM_ENABLE))
0582 /**
0583   * @}
0584   */
0585 
0586 /** @defgroup SDMMC_LL_Read_Wait_Mode Read Wait Mode
0587   * @ingroup RTEMSBSPsARMSTM32H7
0588   * @{
0589   */
0590 #define SDMMC_READ_WAIT_MODE_DATA2                ((uint32_t)0x00000000U)
0591 #define SDMMC_READ_WAIT_MODE_CLK                  (SDMMC_DCTRL_RWMOD)
0592 
0593 #define IS_SDMMC_READWAIT_MODE(MODE) (((MODE) == SDMMC_READ_WAIT_MODE_CLK) || \
0594                                       ((MODE) == SDMMC_READ_WAIT_MODE_DATA2))
0595 /**
0596   * @}
0597   */
0598 
0599 /** @defgroup SDMMC_LL_Interrupt_sources Interrupt Sources
0600   * @ingroup RTEMSBSPsARMSTM32H7
0601   * @{
0602   */
0603 #define SDMMC_IT_CCRCFAIL                  SDMMC_MASK_CCRCFAILIE
0604 #define SDMMC_IT_DCRCFAIL                  SDMMC_MASK_DCRCFAILIE
0605 #define SDMMC_IT_CTIMEOUT                  SDMMC_MASK_CTIMEOUTIE
0606 #define SDMMC_IT_DTIMEOUT                  SDMMC_MASK_DTIMEOUTIE
0607 #define SDMMC_IT_TXUNDERR                  SDMMC_MASK_TXUNDERRIE
0608 #define SDMMC_IT_RXOVERR                   SDMMC_MASK_RXOVERRIE
0609 #define SDMMC_IT_CMDREND                   SDMMC_MASK_CMDRENDIE
0610 #define SDMMC_IT_CMDSENT                   SDMMC_MASK_CMDSENTIE
0611 #define SDMMC_IT_DATAEND                   SDMMC_MASK_DATAENDIE
0612 #define SDMMC_IT_DHOLD                     SDMMC_MASK_DHOLDIE
0613 #define SDMMC_IT_DBCKEND                   SDMMC_MASK_DBCKENDIE
0614 #define SDMMC_IT_DABORT                    SDMMC_MASK_DABORTIE
0615 #define SDMMC_IT_TXFIFOHE                  SDMMC_MASK_TXFIFOHEIE
0616 #define SDMMC_IT_RXFIFOHF                  SDMMC_MASK_RXFIFOHFIE
0617 #define SDMMC_IT_RXFIFOF                   SDMMC_MASK_RXFIFOFIE
0618 #define SDMMC_IT_TXFIFOE                   SDMMC_MASK_TXFIFOEIE
0619 #define SDMMC_IT_BUSYD0END                 SDMMC_MASK_BUSYD0ENDIE
0620 #define SDMMC_IT_SDIOIT                    SDMMC_MASK_SDIOITIE
0621 #define SDMMC_IT_ACKFAIL                   SDMMC_MASK_ACKFAILIE
0622 #define SDMMC_IT_ACKTIMEOUT                SDMMC_MASK_ACKTIMEOUTIE
0623 #define SDMMC_IT_VSWEND                    SDMMC_MASK_VSWENDIE
0624 #define SDMMC_IT_CKSTOP                    SDMMC_MASK_CKSTOPIE
0625 #define SDMMC_IT_IDMABTC                   SDMMC_MASK_IDMABTCIE
0626 /**
0627   * @}
0628   */
0629 
0630 /** @defgroup SDMMC_LL_Flags Flags
0631   * @ingroup RTEMSBSPsARMSTM32H7
0632   * @{
0633   */
0634 #define SDMMC_FLAG_CCRCFAIL                  SDMMC_STA_CCRCFAIL
0635 #define SDMMC_FLAG_DCRCFAIL                  SDMMC_STA_DCRCFAIL
0636 #define SDMMC_FLAG_CTIMEOUT                  SDMMC_STA_CTIMEOUT
0637 #define SDMMC_FLAG_DTIMEOUT                  SDMMC_STA_DTIMEOUT
0638 #define SDMMC_FLAG_TXUNDERR                  SDMMC_STA_TXUNDERR
0639 #define SDMMC_FLAG_RXOVERR                   SDMMC_STA_RXOVERR
0640 #define SDMMC_FLAG_CMDREND                   SDMMC_STA_CMDREND
0641 #define SDMMC_FLAG_CMDSENT                   SDMMC_STA_CMDSENT
0642 #define SDMMC_FLAG_DATAEND                   SDMMC_STA_DATAEND
0643 #define SDMMC_FLAG_DHOLD                     SDMMC_STA_DHOLD
0644 #define SDMMC_FLAG_DBCKEND                   SDMMC_STA_DBCKEND
0645 #define SDMMC_FLAG_DABORT                    SDMMC_STA_DABORT
0646 #define SDMMC_FLAG_DPSMACT                   SDMMC_STA_DPSMACT
0647 #define SDMMC_FLAG_CMDACT                    SDMMC_STA_CPSMACT
0648 #define SDMMC_FLAG_TXFIFOHE                  SDMMC_STA_TXFIFOHE
0649 #define SDMMC_FLAG_RXFIFOHF                  SDMMC_STA_RXFIFOHF
0650 #define SDMMC_FLAG_TXFIFOF                   SDMMC_STA_TXFIFOF
0651 #define SDMMC_FLAG_RXFIFOF                   SDMMC_STA_RXFIFOF
0652 #define SDMMC_FLAG_TXFIFOE                   SDMMC_STA_TXFIFOE
0653 #define SDMMC_FLAG_RXFIFOE                   SDMMC_STA_RXFIFOE
0654 #define SDMMC_FLAG_BUSYD0                    SDMMC_STA_BUSYD0
0655 #define SDMMC_FLAG_BUSYD0END                 SDMMC_STA_BUSYD0END
0656 #define SDMMC_FLAG_SDIOIT                    SDMMC_STA_SDIOIT
0657 #define SDMMC_FLAG_ACKFAIL                   SDMMC_STA_ACKFAIL
0658 #define SDMMC_FLAG_ACKTIMEOUT                SDMMC_STA_ACKTIMEOUT
0659 #define SDMMC_FLAG_VSWEND                    SDMMC_STA_VSWEND
0660 #define SDMMC_FLAG_CKSTOP                    SDMMC_STA_CKSTOP
0661 #define SDMMC_FLAG_IDMATE                    SDMMC_STA_IDMATE
0662 #define SDMMC_FLAG_IDMABTC                   SDMMC_STA_IDMABTC
0663 
0664 #define SDMMC_STATIC_FLAGS             ((uint32_t)(SDMMC_FLAG_CCRCFAIL   | SDMMC_FLAG_DCRCFAIL | SDMMC_FLAG_CTIMEOUT |\
0665                                                    SDMMC_FLAG_DTIMEOUT   | SDMMC_FLAG_TXUNDERR | SDMMC_FLAG_RXOVERR  |\
0666                                                    SDMMC_FLAG_CMDREND    | SDMMC_FLAG_CMDSENT  | SDMMC_FLAG_DATAEND  |\
0667                                                    SDMMC_FLAG_DHOLD      | SDMMC_FLAG_DBCKEND  | SDMMC_FLAG_DABORT   |\
0668                                                    SDMMC_FLAG_BUSYD0END  | SDMMC_FLAG_SDIOIT   | SDMMC_FLAG_ACKFAIL  |\
0669                                                    SDMMC_FLAG_ACKTIMEOUT | SDMMC_FLAG_VSWEND   | SDMMC_FLAG_CKSTOP   |\
0670                                                    SDMMC_FLAG_IDMATE     | SDMMC_FLAG_IDMABTC))
0671 
0672 #define SDMMC_STATIC_CMD_FLAGS         ((uint32_t)(SDMMC_FLAG_CCRCFAIL | SDMMC_FLAG_CTIMEOUT  | SDMMC_FLAG_CMDREND   |\
0673                                                    SDMMC_FLAG_CMDSENT  | SDMMC_FLAG_BUSYD0END))
0674 
0675 #define SDMMC_STATIC_DATA_FLAGS        ((uint32_t)(SDMMC_FLAG_DCRCFAIL | SDMMC_FLAG_DTIMEOUT | SDMMC_FLAG_TXUNDERR   |\
0676                                                    SDMMC_FLAG_RXOVERR  | SDMMC_FLAG_DATAEND  | SDMMC_FLAG_DHOLD      |\
0677                                                    SDMMC_FLAG_DBCKEND  | SDMMC_FLAG_DABORT   | SDMMC_FLAG_IDMATE     |\
0678                                                    SDMMC_FLAG_IDMABTC))
0679 /**
0680   * @}
0681   */
0682 
0683 /**
0684   * @}
0685   */
0686 
0687 /* Exported macro ------------------------------------------------------------*/
0688 /** @defgroup SDMMC_LL_Exported_macros SDMMC_LL Exported Macros
0689   * @ingroup RTEMSBSPsARMSTM32H7
0690   * @{
0691   */
0692 
0693 /** @defgroup SDMMC_LL_Register Bits And Addresses Definitions
0694   * @ingroup RTEMSBSPsARMSTM32H7
0695   * @brief SDMMC_LL registers bit address in the alias region
0696   * @{
0697   */
0698 /* ---------------------- SDMMC registers bit mask --------------------------- */
0699 /* --- CLKCR Register ---*/
0700 /* CLKCR register clear mask */
0701 #define CLKCR_CLEAR_MASK         ((uint32_t)(SDMMC_CLKCR_CLKDIV  | SDMMC_CLKCR_PWRSAV |\
0702                                              SDMMC_CLKCR_WIDBUS |\
0703                                              SDMMC_CLKCR_NEGEDGE | SDMMC_CLKCR_HWFC_EN |\
0704                                              SDMMC_CLKCR_DDR | SDMMC_CLKCR_BUSSPEED |\
0705                                              SDMMC_CLKCR_SELCLKRX))
0706 
0707 /* --- DCTRL Register ---*/
0708 /* SDMMC DCTRL Clear Mask */
0709 #define DCTRL_CLEAR_MASK         ((uint32_t)(SDMMC_DCTRL_DTEN    | SDMMC_DCTRL_DTDIR |\
0710                                              SDMMC_DCTRL_DTMODE  | SDMMC_DCTRL_DBLOCKSIZE))
0711 
0712 /* --- CMD Register ---*/
0713 /* CMD Register clear mask */
0714 #define CMD_CLEAR_MASK           ((uint32_t)(SDMMC_CMD_CMDINDEX | SDMMC_CMD_WAITRESP |\
0715                                              SDMMC_CMD_WAITINT  | SDMMC_CMD_WAITPEND |\
0716                                              SDMMC_CMD_CPSMEN   | SDMMC_CMD_CMDSUSPEND))
0717 
0718 /* SDMMC Initialization Frequency (400KHz max) for Peripheral CLK 200MHz*/
0719 #define SDMMC_INIT_CLK_DIV ((uint8_t)0xFA)
0720 
0721 /* SDMMC Default Speed Frequency (25Mhz max) for Peripheral CLK 200MHz*/
0722 #define SDMMC_NSPEED_CLK_DIV ((uint8_t)0x4)
0723 
0724 /* SDMMC High Speed Frequency (50Mhz max) for Peripheral CLK 200MHz*/
0725 #define SDMMC_HSPEED_CLK_DIV ((uint8_t)0x2)
0726 /**
0727   * @}
0728   */
0729 
0730 /** @defgroup SDMMC_LL_Interrupt_Clock Interrupt And Clock Configuration
0731   * @ingroup RTEMSBSPsARMSTM32H7
0732   *  @brief macros to handle interrupts and specific clock configurations
0733   * @{
0734   */
0735 
0736 /**
0737   * @brief  Enable the SDMMC device interrupt.
0738   * @param  __INSTANCE__ Pointer to SDMMC register base
0739   * @param  __INTERRUPT__ specifies the SDMMC interrupt sources to be enabled.
0740   *         This parameter can be one or a combination of the following values:
0741   *            @arg SDMMC_IT_CCRCFAIL:   Command response received (CRC check failed) interrupt
0742   *            @arg SDMMC_IT_DCRCFAIL:   Data block sent/received (CRC check failed) interrupt
0743   *            @arg SDMMC_IT_CTIMEOUT:   Command response timeout interrupt
0744   *            @arg SDMMC_IT_DTIMEOUT:   Data timeout interrupt
0745   *            @arg SDMMC_IT_TXUNDERR:   Transmit FIFO underrun error interrupt
0746   *            @arg SDMMC_IT_RXOVERR:    Received FIFO overrun error interrupt
0747   *            @arg SDMMC_IT_CMDREND:    Command response received (CRC check passed) interrupt
0748   *            @arg SDMMC_IT_CMDSENT:    Command sent (no response required) interrupt
0749   *            @arg SDMMC_IT_DATAEND:    Data end (data counter, DATACOUNT, is zero) interrupt
0750   *            @arg SDMMC_IT_DHOLD:      Data transfer Hold interrupt
0751   *            @arg SDMMC_IT_DBCKEND:    Data block sent/received (CRC check passed) interrupt
0752   *            @arg SDMMC_IT_DABORT:     Data transfer aborted by CMD12 interrupt
0753   *            @arg SDMMC_IT_TXFIFOHE:   Transmit FIFO Half Empty interrupt
0754   *            @arg SDMMC_IT_RXFIFOHF:   Receive FIFO Half Full interrupt
0755   *            @arg SDMMC_IT_RXFIFOF:    Receive FIFO full interrupt
0756   *            @arg SDMMC_IT_TXFIFOE:    Transmit FIFO empty interrupt
0757   *            @arg SDMMC_IT_BUSYD0END:  End of SDMMC_D0 Busy following a CMD response detected interrupt
0758   *            @arg SDMMC_IT_SDIOIT:     SDIO interrupt received interrupt
0759   *            @arg SDMMC_IT_ACKFAIL:    Boot Acknowledgment received interrupt
0760   *            @arg SDMMC_IT_ACKTIMEOUT: Boot Acknowledgment timeout interrupt
0761   *            @arg SDMMC_IT_VSWEND:     Voltage switch critical timing section completion interrupt
0762   *            @arg SDMMC_IT_CKSTOP:     SDMMC_CK stopped in Voltage switch procedure interrupt
0763   *            @arg SDMMC_IT_IDMABTC:    IDMA buffer transfer complete interrupt
0764   * @retval None
0765   */
0766 #define __SDMMC_ENABLE_IT(__INSTANCE__, __INTERRUPT__)  ((__INSTANCE__)->MASK |= (__INTERRUPT__))
0767 
0768 /**
0769   * @brief  Disable the SDMMC device interrupt.
0770   * @param  __INSTANCE__ Pointer to SDMMC register base
0771   * @param  __INTERRUPT__ specifies the SDMMC interrupt sources to be disabled.
0772   *          This parameter can be one or a combination of the following values:
0773   *            @arg SDMMC_IT_CCRCFAIL:   Command response received (CRC check failed) interrupt
0774   *            @arg SDMMC_IT_DCRCFAIL:   Data block sent/received (CRC check failed) interrupt
0775   *            @arg SDMMC_IT_CTIMEOUT:   Command response timeout interrupt
0776   *            @arg SDMMC_IT_DTIMEOUT:   Data timeout interrupt
0777   *            @arg SDMMC_IT_TXUNDERR:   Transmit FIFO underrun error interrupt
0778   *            @arg SDMMC_IT_RXOVERR:    Received FIFO overrun error interrupt
0779   *            @arg SDMMC_IT_CMDREND:    Command response received (CRC check passed) interrupt
0780   *            @arg SDMMC_IT_CMDSENT:    Command sent (no response required) interrupt
0781   *            @arg SDMMC_IT_DATAEND:    Data end (data counter, DATACOUNT, is zero) interrupt
0782   *            @arg SDMMC_IT_DHOLD:      Data transfer Hold interrupt
0783   *            @arg SDMMC_IT_DBCKEND:    Data block sent/received (CRC check passed) interrupt
0784   *            @arg SDMMC_IT_DABORT:     Data transfer aborted by CMD12 interrupt
0785   *            @arg SDMMC_IT_TXFIFOHE:   Transmit FIFO Half Empty interrupt
0786   *            @arg SDMMC_IT_RXFIFOHF:   Receive FIFO Half Full interrupt
0787   *            @arg SDMMC_IT_RXFIFOF:    Receive FIFO full interrupt
0788   *            @arg SDMMC_IT_TXFIFOE:    Transmit FIFO empty interrupt
0789   *            @arg SDMMC_IT_BUSYD0END:  End of SDMMC_D0 Busy following a CMD response detected interrupt
0790   *            @arg SDMMC_IT_SDIOIT:     SDIO interrupt received interrupt
0791   *            @arg SDMMC_IT_ACKFAIL:    Boot Acknowledgment received interrupt
0792   *            @arg SDMMC_IT_ACKTIMEOUT: Boot Acknowledgment timeout interrupt
0793   *            @arg SDMMC_IT_VSWEND:     Voltage switch critical timing section completion interrupt
0794   *            @arg SDMMC_IT_CKSTOP:     SDMMC_CK stopped in Voltage switch procedure interrupt
0795   *            @arg SDMMC_IT_IDMABTC:    IDMA buffer transfer complete interrupt
0796   * @retval None
0797   */
0798 #define __SDMMC_DISABLE_IT(__INSTANCE__, __INTERRUPT__)  ((__INSTANCE__)->MASK &= ~(__INTERRUPT__))
0799 
0800 /**
0801   * @brief  Checks whether the specified SDMMC flag is set or not.
0802   * @param  __INSTANCE__ Pointer to SDMMC register base
0803   * @param  __FLAG__ specifies the flag to check.
0804   *          This parameter can be one of the following values:
0805   *            @arg SDMMC_FLAG_CCRCFAIL:   Command response received (CRC check failed)
0806   *            @arg SDMMC_FLAG_DCRCFAIL:   Data block sent/received (CRC check failed)
0807   *            @arg SDMMC_FLAG_CTIMEOUT:   Command response timeout
0808   *            @arg SDMMC_FLAG_DTIMEOUT:   Data timeout
0809   *            @arg SDMMC_FLAG_TXUNDERR:   Transmit FIFO underrun error
0810   *            @arg SDMMC_FLAG_RXOVERR:    Received FIFO overrun error
0811   *            @arg SDMMC_FLAG_CMDREND:    Command response received (CRC check passed)
0812   *            @arg SDMMC_FLAG_CMDSENT:    Command sent (no response required)
0813   *            @arg SDMMC_FLAG_DATAEND:    Data end (data counter, DATACOUNT, is zero)
0814   *            @arg SDMMC_FLAG_DHOLD:      Data transfer Hold
0815   *            @arg SDMMC_FLAG_DBCKEND:    Data block sent/received (CRC check passed)
0816   *            @arg SDMMC_FLAG_DABORT:     Data transfer aborted by CMD12
0817   *            @arg SDMMC_FLAG_DPSMACT:    Data path state machine active
0818   *            @arg SDMMC_FLAG_CPSMACT:    Command path state machine active
0819   *            @arg SDMMC_FLAG_TXFIFOHE:   Transmit FIFO Half Empty
0820   *            @arg SDMMC_FLAG_RXFIFOHF:   Receive FIFO Half Full
0821   *            @arg SDMMC_FLAG_TXFIFOF:    Transmit FIFO full
0822   *            @arg SDMMC_FLAG_RXFIFOF:    Receive FIFO full
0823   *            @arg SDMMC_FLAG_TXFIFOE:    Transmit FIFO empty
0824   *            @arg SDMMC_FLAG_RXFIFOE:    Receive FIFO empty
0825   *            @arg SDMMC_FLAG_BUSYD0:     Inverted value of SDMMC_D0 line (Busy)
0826   *            @arg SDMMC_FLAG_BUSYD0END:  End of SDMMC_D0 Busy following a CMD response detected
0827   *            @arg SDMMC_FLAG_SDIOIT:     SDIO interrupt received
0828   *            @arg SDMMC_FLAG_ACKFAIL:    Boot Acknowledgment received
0829   *            @arg SDMMC_FLAG_ACKTIMEOUT: Boot Acknowledgment timeout
0830   *            @arg SDMMC_FLAG_VSWEND:     Voltage switch critical timing section completion
0831   *            @arg SDMMC_FLAG_CKSTOP:     SDMMC_CK stopped in Voltage switch procedure
0832   *            @arg SDMMC_FLAG_IDMATE:     IDMA transfer error
0833   *            @arg SDMMC_FLAG_IDMABTC:    IDMA buffer transfer complete
0834   * @retval The new state of SDMMC_FLAG (SET or RESET).
0835   */
0836 #define __SDMMC_GET_FLAG(__INSTANCE__, __FLAG__)  (((__INSTANCE__)->STA &(__FLAG__)) != 0U)
0837 
0838 
0839 /**
0840   * @brief  Clears the SDMMC pending flags.
0841   * @param  __INSTANCE__ Pointer to SDMMC register base
0842   * @param  __FLAG__ specifies the flag to clear.
0843   *          This parameter can be one or a combination of the following values:
0844   *            @arg SDMMC_FLAG_CCRCFAIL:   Command response received (CRC check failed)
0845   *            @arg SDMMC_FLAG_DCRCFAIL:   Data block sent/received (CRC check failed)
0846   *            @arg SDMMC_FLAG_CTIMEOUT:   Command response timeout
0847   *            @arg SDMMC_FLAG_DTIMEOUT:   Data timeout
0848   *            @arg SDMMC_FLAG_TXUNDERR:   Transmit FIFO underrun error
0849   *            @arg SDMMC_FLAG_RXOVERR:    Received FIFO overrun error
0850   *            @arg SDMMC_FLAG_CMDREND:    Command response received (CRC check passed)
0851   *            @arg SDMMC_FLAG_CMDSENT:    Command sent (no response required)
0852   *            @arg SDMMC_FLAG_DATAEND:    Data end (data counter, DATACOUNT, is zero)
0853   *            @arg SDMMC_FLAG_DHOLD:      Data transfer Hold
0854   *            @arg SDMMC_FLAG_DBCKEND:    Data block sent/received (CRC check passed)
0855   *            @arg SDMMC_FLAG_DABORT:     Data transfer aborted by CMD12
0856   *            @arg SDMMC_FLAG_BUSYD0END:  End of SDMMC_D0 Busy following a CMD response detected
0857   *            @arg SDMMC_FLAG_SDIOIT:     SDIO interrupt received
0858   *            @arg SDMMC_FLAG_ACKFAIL:    Boot Acknowledgment received
0859   *            @arg SDMMC_FLAG_ACKTIMEOUT: Boot Acknowledgment timeout
0860   *            @arg SDMMC_FLAG_VSWEND:     Voltage switch critical timing section completion
0861   *            @arg SDMMC_FLAG_CKSTOP:     SDMMC_CK stopped in Voltage switch procedure
0862   *            @arg SDMMC_FLAG_IDMATE:     IDMA transfer error
0863   *            @arg SDMMC_FLAG_IDMABTC:    IDMA buffer transfer complete
0864   * @retval None
0865   */
0866 #define __SDMMC_CLEAR_FLAG(__INSTANCE__, __FLAG__)  ((__INSTANCE__)->ICR = (__FLAG__))
0867 
0868 /**
0869   * @brief  Checks whether the specified SDMMC interrupt has occurred or not.
0870   * @param  __INSTANCE__ Pointer to SDMMC register base
0871   * @param  __INTERRUPT__ specifies the SDMMC interrupt source to check.
0872   *          This parameter can be one of the following values:
0873   *            @arg SDMMC_IT_CCRCFAIL:   Command response received (CRC check failed) interrupt
0874   *            @arg SDMMC_IT_DCRCFAIL:   Data block sent/received (CRC check failed) interrupt
0875   *            @arg SDMMC_IT_CTIMEOUT:   Command response timeout interrupt
0876   *            @arg SDMMC_IT_DTIMEOUT:   Data timeout interrupt
0877   *            @arg SDMMC_IT_TXUNDERR:   Transmit FIFO underrun error interrupt
0878   *            @arg SDMMC_IT_RXOVERR:    Received FIFO overrun error interrupt
0879   *            @arg SDMMC_IT_CMDREND:    Command response received (CRC check passed) interrupt
0880   *            @arg SDMMC_IT_CMDSENT:    Command sent (no response required) interrupt
0881   *            @arg SDMMC_IT_DATAEND:    Data end (data counter, DATACOUNT, is zero) interrupt
0882   *            @arg SDMMC_IT_DHOLD:      Data transfer Hold interrupt
0883   *            @arg SDMMC_IT_DBCKEND:    Data block sent/received (CRC check passed) interrupt
0884   *            @arg SDMMC_IT_DABORT:     Data transfer aborted by CMD12 interrupt
0885   *            @arg SDMMC_IT_TXFIFOHE:   Transmit FIFO Half Empty interrupt
0886   *            @arg SDMMC_IT_RXFIFOHF:   Receive FIFO Half Full interrupt
0887   *            @arg SDMMC_IT_RXFIFOF:    Receive FIFO full interrupt
0888   *            @arg SDMMC_IT_TXFIFOE:    Transmit FIFO empty interrupt
0889   *            @arg SDMMC_IT_BUSYD0END:  End of SDMMC_D0 Busy following a CMD response detected interrupt
0890   *            @arg SDMMC_IT_SDIOIT:     SDIO interrupt received interrupt
0891   *            @arg SDMMC_IT_ACKFAIL:    Boot Acknowledgment received interrupt
0892   *            @arg SDMMC_IT_ACKTIMEOUT: Boot Acknowledgment timeout interrupt
0893   *            @arg SDMMC_IT_VSWEND:     Voltage switch critical timing section completion interrupt
0894   *            @arg SDMMC_IT_CKSTOP:     SDMMC_CK stopped in Voltage switch procedure interrupt
0895   *            @arg SDMMC_IT_IDMABTC:    IDMA buffer transfer complete interrupt
0896   * @retval The new state of SDMMC_IT (SET or RESET).
0897   */
0898 #define __SDMMC_GET_IT(__INSTANCE__, __INTERRUPT__)  (((__INSTANCE__)->STA &(__INTERRUPT__)) == (__INTERRUPT__))
0899 
0900 /**
0901   * @brief  Clears the SDMMC's interrupt pending bits.
0902   * @param  __INSTANCE__ Pointer to SDMMC register base
0903   * @param  __INTERRUPT__ specifies the interrupt pending bit to clear.
0904   *          This parameter can be one or a combination of the following values:
0905   *            @arg SDMMC_IT_CCRCFAIL:   Command response received (CRC check failed) interrupt
0906   *            @arg SDMMC_IT_DCRCFAIL:   Data block sent/received (CRC check failed) interrupt
0907   *            @arg SDMMC_IT_CTIMEOUT:   Command response timeout interrupt
0908   *            @arg SDMMC_IT_DTIMEOUT:   Data timeout interrupt
0909   *            @arg SDMMC_IT_TXUNDERR:   Transmit FIFO underrun error interrupt
0910   *            @arg SDMMC_IT_RXOVERR:    Received FIFO overrun error interrupt
0911   *            @arg SDMMC_IT_CMDREND:    Command response received (CRC check passed) interrupt
0912   *            @arg SDMMC_IT_CMDSENT:    Command sent (no response required) interrupt
0913   *            @arg SDMMC_IT_DATAEND:    Data end (data counter, DATACOUNT, is zero) interrupt
0914   *            @arg SDMMC_IT_DHOLD:      Data transfer Hold interrupt
0915   *            @arg SDMMC_IT_DBCKEND:    Data block sent/received (CRC check passed) interrupt
0916   *            @arg SDMMC_IT_DABORT:     Data transfer aborted by CMD12 interrupt
0917   *            @arg SDMMC_IT_BUSYD0END:  End of SDMMC_D0 Busy following a CMD response detected interrupt
0918   *            @arg SDMMC_IT_SDIOIT:     SDIO interrupt received interrupt
0919   *            @arg SDMMC_IT_ACKFAIL:    Boot Acknowledgment received interrupt
0920   *            @arg SDMMC_IT_ACKTIMEOUT: Boot Acknowledgment timeout interrupt
0921   *            @arg SDMMC_IT_VSWEND:     Voltage switch critical timing section completion interrupt
0922   *            @arg SDMMC_IT_CKSTOP:     SDMMC_CK stopped in Voltage switch procedure interrupt
0923   *            @arg SDMMC_IT_IDMABTC:    IDMA buffer transfer complete interrupt
0924   * @retval None
0925   */
0926 #define __SDMMC_CLEAR_IT(__INSTANCE__, __INTERRUPT__)  ((__INSTANCE__)->ICR = (__INTERRUPT__))
0927 
0928 /**
0929   * @brief  Enable Start the SD I/O Read Wait operation.
0930   * @param  __INSTANCE__ Pointer to SDMMC register base
0931   * @retval None
0932   */
0933 #define __SDMMC_START_READWAIT_ENABLE(__INSTANCE__)  ((__INSTANCE__)->DCTRL |= SDMMC_DCTRL_RWSTART)
0934 
0935 /**
0936   * @brief  Disable Start the SD I/O Read Wait operations.
0937   * @param  __INSTANCE__ Pointer to SDMMC register base
0938   * @retval None
0939   */
0940 #define __SDMMC_START_READWAIT_DISABLE(__INSTANCE__)  ((__INSTANCE__)->DCTRL &= ~SDMMC_DCTRL_RWSTART)
0941 
0942 /**
0943   * @brief  Enable Start the SD I/O Read Wait operation.
0944   * @param  __INSTANCE__ Pointer to SDMMC register base
0945   * @retval None
0946   */
0947 #define __SDMMC_STOP_READWAIT_ENABLE(__INSTANCE__)  ((__INSTANCE__)->DCTRL |= SDMMC_DCTRL_RWSTOP)
0948 
0949 /**
0950   * @brief  Disable Stop the SD I/O Read Wait operations.
0951   * @param  __INSTANCE__ Pointer to SDMMC register base
0952   * @retval None
0953   */
0954 #define __SDMMC_STOP_READWAIT_DISABLE(__INSTANCE__)  ((__INSTANCE__)->DCTRL &= ~SDMMC_DCTRL_RWSTOP)
0955 
0956 /**
0957   * @brief  Enable the SD I/O Mode Operation.
0958   * @param  __INSTANCE__ Pointer to SDMMC register base
0959   * @retval None
0960   */
0961 #define __SDMMC_OPERATION_ENABLE(__INSTANCE__)  ((__INSTANCE__)->DCTRL |= SDMMC_DCTRL_SDIOEN)
0962 
0963 /**
0964   * @brief  Disable the SD I/O Mode Operation.
0965   * @param  __INSTANCE__ Pointer to SDMMC register base
0966   * @retval None
0967   */
0968 #define __SDMMC_OPERATION_DISABLE(__INSTANCE__)  ((__INSTANCE__)->DCTRL &= ~SDMMC_DCTRL_SDIOEN)
0969 
0970 /**
0971   * @brief  Enable the SD I/O Suspend command sending.
0972   * @param  __INSTANCE__ Pointer to SDMMC register base
0973   * @retval None
0974   */
0975 #define __SDMMC_SUSPEND_CMD_ENABLE(__INSTANCE__)  ((__INSTANCE__)->CMD |= SDMMC_CMD_CMDSUSPEND)
0976 
0977 /**
0978   * @brief  Disable the SD I/O Suspend command sending.
0979   * @param  __INSTANCE__ Pointer to SDMMC register base
0980   * @retval None
0981   */
0982 #define __SDMMC_SUSPEND_CMD_DISABLE(__INSTANCE__)  ((__INSTANCE__)->CMD &= ~SDMMC_CMD_CMDSUSPEND)
0983 
0984 /**
0985   * @brief  Enable the CMDTRANS mode.
0986   * @param  __INSTANCE__ Pointer to SDMMC register base
0987   * @retval None
0988   */
0989 #define __SDMMC_CMDTRANS_ENABLE(__INSTANCE__)  ((__INSTANCE__)->CMD |= SDMMC_CMD_CMDTRANS)
0990 
0991 /**
0992   * @brief  Disable the CMDTRANS mode.
0993   * @param  __INSTANCE__ Pointer to SDMMC register base
0994   * @retval None
0995   */
0996 #define __SDMMC_CMDTRANS_DISABLE(__INSTANCE__)  ((__INSTANCE__)->CMD &= ~SDMMC_CMD_CMDTRANS)
0997 
0998 /**
0999   * @brief  Enable the CMDSTOP mode.
1000   * @param  __INSTANCE__ Pointer to SDMMC register base
1001   * @retval None
1002   */
1003 #define __SDMMC_CMDSTOP_ENABLE(__INSTANCE__)  ((__INSTANCE__)->CMD |= SDMMC_CMD_CMDSTOP)
1004 
1005 /**
1006   * @brief  Disable the CMDSTOP mode.
1007   * @param  __INSTANCE__ Pointer to SDMMC register base
1008   * @retval None
1009   */
1010 #define __SDMMC_CMDSTOP_DISABLE(__INSTANCE__)  ((__INSTANCE__)->CMD &= ~SDMMC_CMD_CMDSTOP)
1011 
1012 /**
1013   * @}
1014   */
1015 
1016 /**
1017   * @}
1018   */
1019 
1020 /* Exported functions --------------------------------------------------------*/
1021 /** @addtogroup SDMMC_LL_Exported_Functions
1022   * @{
1023   */
1024 
1025 /* Initialization/de-initialization functions  **********************************/
1026 /** @addtogroup HAL_SDMMC_LL_Group1
1027   * @{
1028   */
1029 HAL_StatusTypeDef SDMMC_Init(SDMMC_TypeDef *SDMMCx, SDMMC_InitTypeDef Init);
1030 /**
1031   * @}
1032   */
1033 
1034 /* I/O operation functions  *****************************************************/
1035 /** @addtogroup HAL_SDMMC_LL_Group2
1036   * @{
1037   */
1038 uint32_t          SDMMC_ReadFIFO(SDMMC_TypeDef *SDMMCx);
1039 HAL_StatusTypeDef SDMMC_WriteFIFO(SDMMC_TypeDef *SDMMCx, uint32_t *pWriteData);
1040 /**
1041   * @}
1042   */
1043 
1044 /* Peripheral Control functions  ************************************************/
1045 /** @addtogroup HAL_SDMMC_LL_Group3
1046   * @{
1047   */
1048 HAL_StatusTypeDef SDMMC_PowerState_ON(SDMMC_TypeDef *SDMMCx);
1049 HAL_StatusTypeDef SDMMC_PowerState_Cycle(SDMMC_TypeDef *SDMMCx);
1050 HAL_StatusTypeDef SDMMC_PowerState_OFF(SDMMC_TypeDef *SDMMCx);
1051 uint32_t          SDMMC_GetPowerState(SDMMC_TypeDef *SDMMCx);
1052 
1053 /* Command path state machine (CPSM) management functions */
1054 HAL_StatusTypeDef SDMMC_SendCommand(SDMMC_TypeDef *SDMMCx, SDMMC_CmdInitTypeDef *Command);
1055 uint8_t           SDMMC_GetCommandResponse(SDMMC_TypeDef *SDMMCx);
1056 uint32_t          SDMMC_GetResponse(SDMMC_TypeDef *SDMMCx, uint32_t Response);
1057 
1058 /* Data path state machine (DPSM) management functions */
1059 HAL_StatusTypeDef SDMMC_ConfigData(SDMMC_TypeDef *SDMMCx, SDMMC_DataInitTypeDef *Data);
1060 uint32_t          SDMMC_GetDataCounter(SDMMC_TypeDef *SDMMCx);
1061 uint32_t          SDMMC_GetFIFOCount(SDMMC_TypeDef *SDMMCx);
1062 
1063 /* SDMMC Cards mode management functions */
1064 HAL_StatusTypeDef SDMMC_SetSDMMCReadWaitMode(SDMMC_TypeDef *SDMMCx, uint32_t SDMMC_ReadWaitMode);
1065 /**
1066   * @}
1067   */
1068 
1069 /* SDMMC Commands management functions ******************************************/
1070 /** @addtogroup HAL_SDMMC_LL_Group4
1071   * @{
1072   */
1073 uint32_t SDMMC_CmdBlockLength(SDMMC_TypeDef *SDMMCx, uint32_t BlockSize);
1074 uint32_t SDMMC_CmdReadSingleBlock(SDMMC_TypeDef *SDMMCx, uint32_t ReadAdd);
1075 uint32_t SDMMC_CmdReadMultiBlock(SDMMC_TypeDef *SDMMCx, uint32_t ReadAdd);
1076 uint32_t SDMMC_CmdWriteSingleBlock(SDMMC_TypeDef *SDMMCx, uint32_t WriteAdd);
1077 uint32_t SDMMC_CmdWriteMultiBlock(SDMMC_TypeDef *SDMMCx, uint32_t WriteAdd);
1078 uint32_t SDMMC_CmdEraseStartAdd(SDMMC_TypeDef *SDMMCx, uint32_t StartAdd);
1079 uint32_t SDMMC_CmdSDEraseStartAdd(SDMMC_TypeDef *SDMMCx, uint32_t StartAdd);
1080 uint32_t SDMMC_CmdEraseEndAdd(SDMMC_TypeDef *SDMMCx, uint32_t EndAdd);
1081 uint32_t SDMMC_CmdSDEraseEndAdd(SDMMC_TypeDef *SDMMCx, uint32_t EndAdd);
1082 uint32_t SDMMC_CmdErase(SDMMC_TypeDef *SDMMCx, uint32_t EraseType);
1083 uint32_t SDMMC_CmdStopTransfer(SDMMC_TypeDef *SDMMCx);
1084 uint32_t SDMMC_CmdSelDesel(SDMMC_TypeDef *SDMMCx, uint32_t Addr);
1085 uint32_t SDMMC_CmdGoIdleState(SDMMC_TypeDef *SDMMCx);
1086 uint32_t SDMMC_CmdOperCond(SDMMC_TypeDef *SDMMCx);
1087 uint32_t SDMMC_CmdAppCommand(SDMMC_TypeDef *SDMMCx, uint32_t Argument);
1088 uint32_t SDMMC_CmdAppOperCommand(SDMMC_TypeDef *SDMMCx, uint32_t Argument);
1089 uint32_t SDMMC_CmdBusWidth(SDMMC_TypeDef *SDMMCx, uint32_t BusWidth);
1090 uint32_t SDMMC_CmdSendSCR(SDMMC_TypeDef *SDMMCx);
1091 uint32_t SDMMC_CmdSendCID(SDMMC_TypeDef *SDMMCx);
1092 uint32_t SDMMC_CmdSendCSD(SDMMC_TypeDef *SDMMCx, uint32_t Argument);
1093 uint32_t SDMMC_CmdSetRelAdd(SDMMC_TypeDef *SDMMCx, uint16_t *pRCA);
1094 uint32_t SDMMC_CmdSetRelAddMmc(SDMMC_TypeDef *SDMMCx, uint16_t RCA);
1095 uint32_t SDMMC_CmdSleepMmc(SDMMC_TypeDef *SDMMCx, uint32_t Argument);
1096 uint32_t SDMMC_CmdSendStatus(SDMMC_TypeDef *SDMMCx, uint32_t Argument);
1097 uint32_t SDMMC_CmdStatusRegister(SDMMC_TypeDef *SDMMCx);
1098 uint32_t SDMMC_CmdVoltageSwitch(SDMMC_TypeDef *SDMMCx);
1099 uint32_t SDMMC_CmdOpCondition(SDMMC_TypeDef *SDMMCx, uint32_t Argument);
1100 uint32_t SDMMC_CmdSwitch(SDMMC_TypeDef *SDMMCx, uint32_t Argument);
1101 uint32_t SDMMC_CmdSendEXTCSD(SDMMC_TypeDef *SDMMCx, uint32_t Argument);
1102 /**
1103   * @}
1104   */
1105 
1106 /* SDMMC Responses management functions *****************************************/
1107 /** @addtogroup HAL_SDMMC_LL_Group5
1108   * @{
1109   */
1110 uint32_t SDMMC_GetCmdResp1(SDMMC_TypeDef *SDMMCx, uint8_t SD_CMD, uint32_t Timeout);
1111 uint32_t SDMMC_GetCmdResp2(SDMMC_TypeDef *SDMMCx);
1112 uint32_t SDMMC_GetCmdResp3(SDMMC_TypeDef *SDMMCx);
1113 uint32_t SDMMC_GetCmdResp6(SDMMC_TypeDef *SDMMCx, uint8_t SD_CMD, uint16_t *pRCA);
1114 uint32_t SDMMC_GetCmdResp7(SDMMC_TypeDef *SDMMCx);
1115 /**
1116   * @}
1117   */
1118 
1119 
1120 /**
1121   * @}
1122   */
1123 
1124 /**
1125   * @}
1126   */
1127 
1128 /**
1129   * @}
1130   */
1131 
1132 /**
1133   * @}
1134   */
1135 
1136 /**
1137   * @}
1138   */
1139 #ifdef __cplusplus
1140 }
1141 #endif
1142 
1143 #endif /* STM32H7xx_LL_SDMMC_H */