You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1103 lines
61 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_ll_sdmmc.h
  4. * @author MCD Application Team
  5. * @brief Header file of SDMMC HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32H7xx_LL_SDMMC_H
  21. #define STM32H7xx_LL_SDMMC_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32h7xx_hal_def.h"
  27. /** @addtogroup STM32H7xx_Driver
  28. * @{
  29. */
  30. /** @addtogroup SDMMC_LL
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. /** @defgroup SDMMC_LL_Exported_Types SDMMC_LL Exported Types
  35. * @{
  36. */
  37. /**
  38. * @brief SDMMC Configuration Structure definition
  39. */
  40. typedef struct
  41. {
  42. uint32_t ClockEdge; /*!< Specifies the SDMMC_CCK clock transition on which Data and Command change.
  43. This parameter can be a value of @ref SDMMC_LL_Clock_Edge */
  44. uint32_t ClockPowerSave; /*!< Specifies whether SDMMC Clock output is enabled or
  45. disabled when the bus is idle.
  46. This parameter can be a value of @ref SDMMC_LL_Clock_Power_Save */
  47. uint32_t BusWide; /*!< Specifies the SDMMC bus width.
  48. This parameter can be a value of @ref SDMMC_LL_Bus_Wide */
  49. uint32_t HardwareFlowControl; /*!< Specifies whether the SDMMC hardware flow control is enabled or disabled.
  50. This parameter can be a value of @ref SDMMC_LL_Hardware_Flow_Control */
  51. uint32_t ClockDiv; /*!< Specifies the clock frequency of the SDMMC controller.
  52. This parameter can be a value between Min_Data = 0 and Max_Data = 1023 */
  53. #if (USE_SD_TRANSCEIVER != 0U)
  54. uint32_t TranceiverPresent; /*!< Specifies if there is a 1V8 Tranceiver/Switcher.
  55. This parameter can be a value of @ref SDMMC_LL_TRANCEIVER_PRESENT */
  56. #endif /* USE_SD_TRANSCEIVER */
  57. }SDMMC_InitTypeDef;
  58. /**
  59. * @brief SDMMC Command Control structure
  60. */
  61. typedef struct
  62. {
  63. uint32_t Argument; /*!< Specifies the SDMMC command argument which is sent
  64. to a card as part of a command message. If a command
  65. contains an argument, it must be loaded into this register
  66. before writing the command to the command register. */
  67. uint32_t CmdIndex; /*!< Specifies the SDMMC command index. It must be Min_Data = 0 and
  68. Max_Data = 64 */
  69. uint32_t Response; /*!< Specifies the SDMMC response type.
  70. This parameter can be a value of @ref SDMMC_LL_Response_Type */
  71. uint32_t WaitForInterrupt; /*!< Specifies whether SDMMC wait for interrupt request is
  72. enabled or disabled.
  73. This parameter can be a value of @ref SDMMC_LL_Wait_Interrupt_State */
  74. uint32_t CPSM; /*!< Specifies whether SDMMC Command path state machine (CPSM)
  75. is enabled or disabled.
  76. This parameter can be a value of @ref SDMMC_LL_CPSM_State */
  77. }SDMMC_CmdInitTypeDef;
  78. /**
  79. * @brief SDMMC Data Control structure
  80. */
  81. typedef struct
  82. {
  83. uint32_t DataTimeOut; /*!< Specifies the data timeout period in card bus clock periods. */
  84. uint32_t DataLength; /*!< Specifies the number of data bytes to be transferred. */
  85. uint32_t DataBlockSize; /*!< Specifies the data block size for block transfer.
  86. This parameter can be a value of @ref SDMMC_LL_Data_Block_Size */
  87. uint32_t TransferDir; /*!< Specifies the data transfer direction, whether the transfer
  88. is a read or write.
  89. This parameter can be a value of @ref SDMMC_LL_Transfer_Direction */
  90. uint32_t TransferMode; /*!< Specifies whether data transfer is in stream or block mode.
  91. This parameter can be a value of @ref SDMMC_LL_Transfer_Type */
  92. uint32_t DPSM; /*!< Specifies whether SDMMC Data path state machine (DPSM)
  93. is enabled or disabled.
  94. This parameter can be a value of @ref SDMMC_LL_DPSM_State */
  95. }SDMMC_DataInitTypeDef;
  96. /**
  97. * @}
  98. */
  99. /* Exported constants --------------------------------------------------------*/
  100. /** @defgroup SDMMC_LL_Exported_Constants SDMMC_LL Exported Constants
  101. * @{
  102. */
  103. #define SDMMC_ERROR_NONE ((uint32_t)0x00000000U) /*!< No error */
  104. #define SDMMC_ERROR_CMD_CRC_FAIL ((uint32_t)0x00000001U) /*!< Command response received (but CRC check failed) */
  105. #define SDMMC_ERROR_DATA_CRC_FAIL ((uint32_t)0x00000002U) /*!< Data block sent/received (CRC check failed) */
  106. #define SDMMC_ERROR_CMD_RSP_TIMEOUT ((uint32_t)0x00000004U) /*!< Command response timeout */
  107. #define SDMMC_ERROR_DATA_TIMEOUT ((uint32_t)0x00000008U) /*!< Data timeout */
  108. #define SDMMC_ERROR_TX_UNDERRUN ((uint32_t)0x00000010U) /*!< Transmit FIFO underrun */
  109. #define SDMMC_ERROR_RX_OVERRUN ((uint32_t)0x00000020U) /*!< Receive FIFO overrun */
  110. #define SDMMC_ERROR_ADDR_MISALIGNED ((uint32_t)0x00000040U) /*!< Misaligned address */
  111. #define SDMMC_ERROR_BLOCK_LEN_ERR ((uint32_t)0x00000080U) /*!< Transferred block length is not allowed for the card or the
  112. number of transferred bytes does not match the block length */
  113. #define SDMMC_ERROR_ERASE_SEQ_ERR ((uint32_t)0x00000100U) /*!< An error in the sequence of erase command occurs */
  114. #define SDMMC_ERROR_BAD_ERASE_PARAM ((uint32_t)0x00000200U) /*!< An invalid selection for erase groups */
  115. #define SDMMC_ERROR_WRITE_PROT_VIOLATION ((uint32_t)0x00000400U) /*!< Attempt to program a write protect block */
  116. #define SDMMC_ERROR_LOCK_UNLOCK_FAILED ((uint32_t)0x00000800U) /*!< Sequence or password error has been detected in unlock
  117. command or if there was an attempt to access a locked card */
  118. #define SDMMC_ERROR_COM_CRC_FAILED ((uint32_t)0x00001000U) /*!< CRC check of the previous command failed */
  119. #define SDMMC_ERROR_ILLEGAL_CMD ((uint32_t)0x00002000U) /*!< Command is not legal for the card state */
  120. #define SDMMC_ERROR_CARD_ECC_FAILED ((uint32_t)0x00004000U) /*!< Card internal ECC was applied but failed to correct the data */
  121. #define SDMMC_ERROR_CC_ERR ((uint32_t)0x00008000U) /*!< Internal card controller error */
  122. #define SDMMC_ERROR_GENERAL_UNKNOWN_ERR ((uint32_t)0x00010000U) /*!< General or unknown error */
  123. #define SDMMC_ERROR_STREAM_READ_UNDERRUN ((uint32_t)0x00020000U) /*!< The card could not sustain data reading in stream rmode */
  124. #define SDMMC_ERROR_STREAM_WRITE_OVERRUN ((uint32_t)0x00040000U) /*!< The card could not sustain data programming in stream mode */
  125. #define SDMMC_ERROR_CID_CSD_OVERWRITE ((uint32_t)0x00080000U) /*!< CID/CSD overwrite error */
  126. #define SDMMC_ERROR_WP_ERASE_SKIP ((uint32_t)0x00100000U) /*!< Only partial address space was erased */
  127. #define SDMMC_ERROR_CARD_ECC_DISABLED ((uint32_t)0x00200000U) /*!< Command has been executed without using internal ECC */
  128. #define SDMMC_ERROR_ERASE_RESET ((uint32_t)0x00400000U) /*!< Erase sequence was cleared before executing because an out
  129. of erase sequence command was received */
  130. #define SDMMC_ERROR_AKE_SEQ_ERR ((uint32_t)0x00800000U) /*!< Error in sequence of authentication */
  131. #define SDMMC_ERROR_INVALID_VOLTRANGE ((uint32_t)0x01000000U) /*!< Error in case of invalid voltage range */
  132. #define SDMMC_ERROR_ADDR_OUT_OF_RANGE ((uint32_t)0x02000000U) /*!< Error when addressed block is out of range */
  133. #define SDMMC_ERROR_REQUEST_NOT_APPLICABLE ((uint32_t)0x04000000U) /*!< Error when command request is not applicable */
  134. #define SDMMC_ERROR_INVALID_PARAMETER ((uint32_t)0x08000000U) /*!< the used parameter is not valid */
  135. #define SDMMC_ERROR_UNSUPPORTED_FEATURE ((uint32_t)0x10000000U) /*!< Error when feature is not insupported */
  136. #define SDMMC_ERROR_BUSY ((uint32_t)0x20000000U) /*!< Error when transfer process is busy */
  137. #define SDMMC_ERROR_DMA ((uint32_t)0x40000000U) /*!< Error while DMA transfer */
  138. #define SDMMC_ERROR_TIMEOUT ((uint32_t)0x80000000U) /*!< Timeout error */
  139. /**
  140. * @brief SDMMC Commands Index
  141. */
  142. #define SDMMC_CMD_GO_IDLE_STATE ((uint8_t)0U) /*!< Resets the SD memory card. */
  143. #define SDMMC_CMD_SEND_OP_COND ((uint8_t)1U) /*!< Sends host capacity support information and activates the card's initialization process. */
  144. #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. */
  145. #define SDMMC_CMD_SET_REL_ADDR ((uint8_t)3U) /*!< Asks the card to publish a new relative address (RCA). */
  146. #define SDMMC_CMD_SET_DSR ((uint8_t)4U) /*!< Programs the DSR of all cards. */
  147. #define SDMMC_CMD_SDMMC_SEN_OP_COND ((uint8_t)5U) /*!< Sends host capacity support information (HCS) and asks the accessed card to send its
  148. operating condition register (OCR) content in the response on the CMD line. */
  149. #define SDMMC_CMD_HS_SWITCH ((uint8_t)6U) /*!< Checks switchable function (mode 0) and switch card function (mode 1). */
  150. #define SDMMC_CMD_SEL_DESEL_CARD ((uint8_t)7U) /*!< Selects the card by its own relative address and gets deselected by any other address */
  151. #define SDMMC_CMD_HS_SEND_EXT_CSD ((uint8_t)8U) /*!< Sends SD Memory Card interface condition, which includes host supply voltage information
  152. and asks the card whether card supports voltage. */
  153. #define SDMMC_CMD_SEND_CSD ((uint8_t)9U) /*!< Addressed card sends its card specific data (CSD) on the CMD line. */
  154. #define SDMMC_CMD_SEND_CID ((uint8_t)10U) /*!< Addressed card sends its card identification (CID) on the CMD line. */
  155. #define SDMMC_CMD_VOLTAGE_SWITCH ((uint8_t)11U) /*!< SD card Voltage switch to 1.8V mode. */
  156. #define SDMMC_CMD_STOP_TRANSMISSION ((uint8_t)12U) /*!< Forces the card to stop transmission. */
  157. #define SDMMC_CMD_SEND_STATUS ((uint8_t)13U) /*!< Addressed card sends its status register. */
  158. #define SDMMC_CMD_HS_BUSTEST_READ ((uint8_t)14U) /*!< Reserved */
  159. #define SDMMC_CMD_GO_INACTIVE_STATE ((uint8_t)15U) /*!< Sends an addressed card into the inactive state. */
  160. #define SDMMC_CMD_SET_BLOCKLEN ((uint8_t)16U) /*!< Sets the block length (in bytes for SDSC) for all following block commands
  161. (read, write, lock). Default block length is fixed to 512 Bytes. Not effective
  162. for SDHS and SDXC. */
  163. #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
  164. fixed 512 bytes in case of SDHC and SDXC. */
  165. #define SDMMC_CMD_READ_MULT_BLOCK ((uint8_t)18U) /*!< Continuously transfers data blocks from card to host until interrupted by
  166. STOP_TRANSMISSION command. */
  167. #define SDMMC_CMD_HS_BUSTEST_WRITE ((uint8_t)19U) /*!< 64 bytes tuning pattern is sent for SDR50 and SDR104. */
  168. #define SDMMC_CMD_WRITE_DAT_UNTIL_STOP ((uint8_t)20U) /*!< Speed class control command. */
  169. #define SDMMC_CMD_SET_BLOCK_COUNT ((uint8_t)23U) /*!< Specify block count for CMD18 and CMD25. */
  170. #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
  171. fixed 512 bytes in case of SDHC and SDXC. */
  172. #define SDMMC_CMD_WRITE_MULT_BLOCK ((uint8_t)25U) /*!< Continuously writes blocks of data until a STOP_TRANSMISSION follows. */
  173. #define SDMMC_CMD_PROG_CID ((uint8_t)26U) /*!< Reserved for manufacturers. */
  174. #define SDMMC_CMD_PROG_CSD ((uint8_t)27U) /*!< Programming of the programmable bits of the CSD. */
  175. #define SDMMC_CMD_SET_WRITE_PROT ((uint8_t)28U) /*!< Sets the write protection bit of the addressed group. */
  176. #define SDMMC_CMD_CLR_WRITE_PROT ((uint8_t)29U) /*!< Clears the write protection bit of the addressed group. */
  177. #define SDMMC_CMD_SEND_WRITE_PROT ((uint8_t)30U) /*!< Asks the card to send the status of the write protection bits. */
  178. #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). */
  179. #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. */
  180. #define SDMMC_CMD_ERASE_GRP_START ((uint8_t)35U) /*!< Sets the address of the first write block to be erased. Reserved for each command
  181. system set by switch function command (CMD6). */
  182. #define SDMMC_CMD_ERASE_GRP_END ((uint8_t)36U) /*!< Sets the address of the last write block of the continuous range to be erased.
  183. Reserved for each command system set by switch function command (CMD6). */
  184. #define SDMMC_CMD_ERASE ((uint8_t)38U) /*!< Reserved for SD security applications. */
  185. #define SDMMC_CMD_FAST_IO ((uint8_t)39U) /*!< SD card doesn't support it (Reserved). */
  186. #define SDMMC_CMD_GO_IRQ_STATE ((uint8_t)40U) /*!< SD card doesn't support it (Reserved). */
  187. #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
  188. the SET_BLOCK_LEN command. */
  189. #define SDMMC_CMD_APP_CMD ((uint8_t)55U) /*!< Indicates to the card that the next command is an application specific command rather
  190. than a standard command. */
  191. #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
  192. for general purpose/application specific commands. */
  193. #define SDMMC_CMD_NO_CMD ((uint8_t)64U) /*!< No command */
  194. /**
  195. * @brief Following commands are SD Card Specific commands.
  196. * SDMMC_APP_CMD should be sent before sending these commands.
  197. */
  198. #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
  199. widths are given in SCR register. */
  200. #define SDMMC_CMD_SD_APP_STATUS ((uint8_t)13U) /*!< (ACMD13) Sends the SD status. */
  201. #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
  202. 32bit+CRC data block. */
  203. #define SDMMC_CMD_SD_APP_OP_COND ((uint8_t)41U) /*!< (ACMD41) Sends host capacity support information (HCS) and asks the accessed card to
  204. send its operating condition register (OCR) content in the response on the CMD line. */
  205. #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 */
  206. #define SDMMC_CMD_SD_APP_SEND_SCR ((uint8_t)51U) /*!< Reads the SD Configuration Register (SCR). */
  207. #define SDMMC_CMD_SDMMC_RW_DIRECT ((uint8_t)52U) /*!< For SD I/O card only, reserved for security specification. */
  208. #define SDMMC_CMD_SDMMC_RW_EXTENDED ((uint8_t)53U) /*!< For SD I/O card only, reserved for security specification. */
  209. /**
  210. * @brief Following commands are SD Card Specific security commands.
  211. * SDMMC_CMD_APP_CMD should be sent before sending these commands.
  212. */
  213. #define SDMMC_CMD_SD_APP_GET_MKB ((uint8_t)43U)
  214. #define SDMMC_CMD_SD_APP_GET_MID ((uint8_t)44U)
  215. #define SDMMC_CMD_SD_APP_SET_CER_RN1 ((uint8_t)45U)
  216. #define SDMMC_CMD_SD_APP_GET_CER_RN2 ((uint8_t)46U)
  217. #define SDMMC_CMD_SD_APP_SET_CER_RES2 ((uint8_t)47U)
  218. #define SDMMC_CMD_SD_APP_GET_CER_RES1 ((uint8_t)48U)
  219. #define SDMMC_CMD_SD_APP_SECURE_READ_MULTIPLE_BLOCK ((uint8_t)18U)
  220. #define SDMMC_CMD_SD_APP_SECURE_WRITE_MULTIPLE_BLOCK ((uint8_t)25U)
  221. #define SDMMC_CMD_SD_APP_SECURE_ERASE ((uint8_t)38U)
  222. #define SDMMC_CMD_SD_APP_CHANGE_SECURE_AREA ((uint8_t)49U)
  223. #define SDMMC_CMD_SD_APP_SECURE_WRITE_MKB ((uint8_t)48U)
  224. /**
  225. * @brief Masks for errors Card Status R1 (OCR Register)
  226. */
  227. #define SDMMC_OCR_ADDR_OUT_OF_RANGE ((uint32_t)0x80000000U)
  228. #define SDMMC_OCR_ADDR_MISALIGNED ((uint32_t)0x40000000U)
  229. #define SDMMC_OCR_BLOCK_LEN_ERR ((uint32_t)0x20000000U)
  230. #define SDMMC_OCR_ERASE_SEQ_ERR ((uint32_t)0x10000000U)
  231. #define SDMMC_OCR_BAD_ERASE_PARAM ((uint32_t)0x08000000U)
  232. #define SDMMC_OCR_WRITE_PROT_VIOLATION ((uint32_t)0x04000000U)
  233. #define SDMMC_OCR_LOCK_UNLOCK_FAILED ((uint32_t)0x01000000U)
  234. #define SDMMC_OCR_COM_CRC_FAILED ((uint32_t)0x00800000U)
  235. #define SDMMC_OCR_ILLEGAL_CMD ((uint32_t)0x00400000U)
  236. #define SDMMC_OCR_CARD_ECC_FAILED ((uint32_t)0x00200000U)
  237. #define SDMMC_OCR_CC_ERROR ((uint32_t)0x00100000U)
  238. #define SDMMC_OCR_GENERAL_UNKNOWN_ERROR ((uint32_t)0x00080000U)
  239. #define SDMMC_OCR_STREAM_READ_UNDERRUN ((uint32_t)0x00040000U)
  240. #define SDMMC_OCR_STREAM_WRITE_OVERRUN ((uint32_t)0x00020000U)
  241. #define SDMMC_OCR_CID_CSD_OVERWRITE ((uint32_t)0x00010000U)
  242. #define SDMMC_OCR_WP_ERASE_SKIP ((uint32_t)0x00008000U)
  243. #define SDMMC_OCR_CARD_ECC_DISABLED ((uint32_t)0x00004000U)
  244. #define SDMMC_OCR_ERASE_RESET ((uint32_t)0x00002000U)
  245. #define SDMMC_OCR_AKE_SEQ_ERROR ((uint32_t)0x00000008U)
  246. #define SDMMC_OCR_ERRORBITS ((uint32_t)0xFDFFE008U)
  247. /**
  248. * @brief Masks for R6 Response
  249. */
  250. #define SDMMC_R6_GENERAL_UNKNOWN_ERROR ((uint32_t)0x00002000U)
  251. #define SDMMC_R6_ILLEGAL_CMD ((uint32_t)0x00004000U)
  252. #define SDMMC_R6_COM_CRC_FAILED ((uint32_t)0x00008000U)
  253. #define SDMMC_VOLTAGE_WINDOW_SD ((uint32_t)0x80100000U)
  254. #define SDMMC_HIGH_CAPACITY ((uint32_t)0x40000000U)
  255. #define SDMMC_STD_CAPACITY ((uint32_t)0x00000000U)
  256. #define SDMMC_CHECK_PATTERN ((uint32_t)0x000001AAU)
  257. #define SD_SWITCH_1_8V_CAPACITY ((uint32_t)0x01000000U)
  258. #define SDMMC_DDR50_SWITCH_PATTERN ((uint32_t)0x80FFFF04U)
  259. #define SDMMC_SDR104_SWITCH_PATTERN ((uint32_t)0x80FF1F03U)
  260. #define SDMMC_SDR50_SWITCH_PATTERN ((uint32_t)0x80FF1F02U)
  261. #define SDMMC_SDR25_SWITCH_PATTERN ((uint32_t)0x80FFFF01U)
  262. #define SDMMC_MAX_VOLT_TRIAL ((uint32_t)0x0000FFFFU)
  263. #define SDMMC_MAX_TRIAL ((uint32_t)0x0000FFFFU)
  264. #define SDMMC_ALLZERO ((uint32_t)0x00000000U)
  265. #define SDMMC_WIDE_BUS_SUPPORT ((uint32_t)0x00040000U)
  266. #define SDMMC_SINGLE_BUS_SUPPORT ((uint32_t)0x00010000U)
  267. #define SDMMC_CARD_LOCKED ((uint32_t)0x02000000U)
  268. #define SDMMC_DATATIMEOUT ((uint32_t)0xFFFFFFFFU)
  269. #define SDMMC_0TO7BITS ((uint32_t)0x000000FFU)
  270. #define SDMMC_8TO15BITS ((uint32_t)0x0000FF00U)
  271. #define SDMMC_16TO23BITS ((uint32_t)0x00FF0000U)
  272. #define SDMMC_24TO31BITS ((uint32_t)0xFF000000U)
  273. #define SDMMC_MAX_DATA_LENGTH ((uint32_t)0x01FFFFFFU)
  274. #define SDMMC_HALFFIFO ((uint32_t)0x00000008U)
  275. #define SDMMC_HALFFIFOBYTES ((uint32_t)0x00000020U)
  276. /**
  277. * @brief Command Class supported
  278. */
  279. #define SDMMC_CCCC_ERASE ((uint32_t)0x00000020U)
  280. #define SDMMC_CMDTIMEOUT ((uint32_t)5000U) /* Command send and response timeout */
  281. #define SDMMC_MAXERASETIMEOUT ((uint32_t)63000U) /* Max erase Timeout 63 s */
  282. #define SDMMC_STOPTRANSFERTIMEOUT ((uint32_t)100000000U) /* Timeout for STOP TRANSMISSION command */
  283. /** @defgroup SDMMC_LL_Clock_Edge Clock Edge
  284. * @{
  285. */
  286. #define SDMMC_CLOCK_EDGE_RISING ((uint32_t)0x00000000U)
  287. #define SDMMC_CLOCK_EDGE_FALLING SDMMC_CLKCR_NEGEDGE
  288. #define IS_SDMMC_CLOCK_EDGE(EDGE) (((EDGE) == SDMMC_CLOCK_EDGE_RISING) || \
  289. ((EDGE) == SDMMC_CLOCK_EDGE_FALLING))
  290. /**
  291. * @}
  292. */
  293. /** @defgroup SDMMC_LL_Clock_Power_Save Clock Power Saving
  294. * @{
  295. */
  296. #define SDMMC_CLOCK_POWER_SAVE_DISABLE ((uint32_t)0x00000000U)
  297. #define SDMMC_CLOCK_POWER_SAVE_ENABLE SDMMC_CLKCR_PWRSAV
  298. #define IS_SDMMC_CLOCK_POWER_SAVE(SAVE) (((SAVE) == SDMMC_CLOCK_POWER_SAVE_DISABLE) || \
  299. ((SAVE) == SDMMC_CLOCK_POWER_SAVE_ENABLE))
  300. /**
  301. * @}
  302. */
  303. /** @defgroup SDMMC_LL_Bus_Wide Bus Width
  304. * @{
  305. */
  306. #define SDMMC_BUS_WIDE_1B ((uint32_t)0x00000000U)
  307. #define SDMMC_BUS_WIDE_4B SDMMC_CLKCR_WIDBUS_0
  308. #define SDMMC_BUS_WIDE_8B SDMMC_CLKCR_WIDBUS_1
  309. #define IS_SDMMC_BUS_WIDE(WIDE) (((WIDE) == SDMMC_BUS_WIDE_1B) || \
  310. ((WIDE) == SDMMC_BUS_WIDE_4B) || \
  311. ((WIDE) == SDMMC_BUS_WIDE_8B))
  312. /**
  313. * @}
  314. */
  315. /** @defgroup SDMMC_LL_Speed_Mode
  316. * @{
  317. */
  318. #define SDMMC_SPEED_MODE_AUTO ((uint32_t)0x00000000U)
  319. #define SDMMC_SPEED_MODE_DEFAULT ((uint32_t)0x00000001U)
  320. #define SDMMC_SPEED_MODE_HIGH ((uint32_t)0x00000002U)
  321. #define SDMMC_SPEED_MODE_ULTRA ((uint32_t)0x00000003U)
  322. #define SDMMC_SPEED_MODE_DDR ((uint32_t)0x00000004U)
  323. #define IS_SDMMC_SPEED_MODE(MODE) (((MODE) == SDMMC_SPEED_MODE_AUTO) || \
  324. ((MODE) == SDMMC_SPEED_MODE_DEFAULT) || \
  325. ((MODE) == SDMMC_SPEED_MODE_HIGH) || \
  326. ((MODE) == SDMMC_SPEED_MODE_ULTRA) || \
  327. ((MODE) == SDMMC_SPEED_MODE_DDR))
  328. /**
  329. * @}
  330. */
  331. /** @defgroup SDMMC_LL_Hardware_Flow_Control Hardware Flow Control
  332. * @{
  333. */
  334. #define SDMMC_HARDWARE_FLOW_CONTROL_DISABLE ((uint32_t)0x00000000U)
  335. #define SDMMC_HARDWARE_FLOW_CONTROL_ENABLE SDMMC_CLKCR_HWFC_EN
  336. #define IS_SDMMC_HARDWARE_FLOW_CONTROL(CONTROL) (((CONTROL) == SDMMC_HARDWARE_FLOW_CONTROL_DISABLE) || \
  337. ((CONTROL) == SDMMC_HARDWARE_FLOW_CONTROL_ENABLE))
  338. /**
  339. * @}
  340. */
  341. /** @defgroup SDMMC_LL_Clock_Division Clock Division
  342. * @{
  343. */
  344. /* SDMMC_CK frequency = SDMMCCLK / [2 * CLKDIV] */
  345. #define IS_SDMMC_CLKDIV(DIV) ((DIV) < 0x400U)
  346. /**
  347. * @}
  348. */
  349. /** @defgroup SDMMC_LL_TRANSCEIVER_PRESENT Tranceiver Present
  350. * @{
  351. */
  352. #define SDMMC_TRANSCEIVER_UNKNOWN ((uint32_t)0x00000000U)
  353. #define SDMMC_TRANSCEIVER_NOT_PRESENT ((uint32_t)0x00000001U)
  354. #define SDMMC_TRANSCEIVER_PRESENT ((uint32_t)0x00000002U)
  355. /**
  356. * @}
  357. */
  358. /** @defgroup SDMMC_LL_Command_Index Command Index
  359. * @{
  360. */
  361. #define IS_SDMMC_CMD_INDEX(INDEX) ((INDEX) < 0x40U)
  362. /**
  363. * @}
  364. */
  365. /** @defgroup SDMMC_LL_Response_Type Response Type
  366. * @{
  367. */
  368. #define SDMMC_RESPONSE_NO ((uint32_t)0x00000000U)
  369. #define SDMMC_RESPONSE_SHORT SDMMC_CMD_WAITRESP_0
  370. #define SDMMC_RESPONSE_LONG SDMMC_CMD_WAITRESP
  371. #define IS_SDMMC_RESPONSE(RESPONSE) (((RESPONSE) == SDMMC_RESPONSE_NO) || \
  372. ((RESPONSE) == SDMMC_RESPONSE_SHORT) || \
  373. ((RESPONSE) == SDMMC_RESPONSE_LONG))
  374. /**
  375. * @}
  376. */
  377. /** @defgroup SDMMC_LL_Wait_Interrupt_State Wait Interrupt
  378. * @{
  379. */
  380. #define SDMMC_WAIT_NO ((uint32_t)0x00000000U)
  381. #define SDMMC_WAIT_IT SDMMC_CMD_WAITINT
  382. #define SDMMC_WAIT_PEND SDMMC_CMD_WAITPEND
  383. #define IS_SDMMC_WAIT(WAIT) (((WAIT) == SDMMC_WAIT_NO) || \
  384. ((WAIT) == SDMMC_WAIT_IT) || \
  385. ((WAIT) == SDMMC_WAIT_PEND))
  386. /**
  387. * @}
  388. */
  389. /** @defgroup SDMMC_LL_CPSM_State CPSM State
  390. * @{
  391. */
  392. #define SDMMC_CPSM_DISABLE ((uint32_t)0x00000000U)
  393. #define SDMMC_CPSM_ENABLE SDMMC_CMD_CPSMEN
  394. #define IS_SDMMC_CPSM(CPSM) (((CPSM) == SDMMC_CPSM_DISABLE) || \
  395. ((CPSM) == SDMMC_CPSM_ENABLE))
  396. /**
  397. * @}
  398. */
  399. /** @defgroup SDMMC_LL_Response_Registers Response Register
  400. * @{
  401. */
  402. #define SDMMC_RESP1 ((uint32_t)0x00000000U)
  403. #define SDMMC_RESP2 ((uint32_t)0x00000004U)
  404. #define SDMMC_RESP3 ((uint32_t)0x00000008U)
  405. #define SDMMC_RESP4 ((uint32_t)0x0000000CU)
  406. #define IS_SDMMC_RESP(RESP) (((RESP) == SDMMC_RESP1) || \
  407. ((RESP) == SDMMC_RESP2) || \
  408. ((RESP) == SDMMC_RESP3) || \
  409. ((RESP) == SDMMC_RESP4))
  410. /** @defgroup SDMMC_Internal_DMA_Mode SDMMC Internal DMA Mode
  411. * @{
  412. */
  413. #define SDMMC_DISABLE_IDMA ((uint32_t)0x00000000)
  414. #define SDMMC_ENABLE_IDMA_SINGLE_BUFF (SDMMC_IDMA_IDMAEN)
  415. #define SDMMC_ENABLE_IDMA_DOUBLE_BUFF0 (SDMMC_IDMA_IDMAEN | SDMMC_IDMA_IDMABMODE)
  416. #define SDMMC_ENABLE_IDMA_DOUBLE_BUFF1 (SDMMC_IDMA_IDMAEN | SDMMC_IDMA_IDMABMODE | SDMMC_IDMA_IDMABACT)
  417. /**
  418. * @}
  419. */
  420. /** @defgroup SDMMC_LL_Data_Length Data Lenght
  421. * @{
  422. */
  423. #define IS_SDMMC_DATA_LENGTH(LENGTH) ((LENGTH) <= 0x01FFFFFFU)
  424. /**
  425. * @}
  426. */
  427. /** @defgroup SDMMC_LL_Data_Block_Size Data Block Size
  428. * @{
  429. */
  430. #define SDMMC_DATABLOCK_SIZE_1B ((uint32_t)0x00000000U)
  431. #define SDMMC_DATABLOCK_SIZE_2B SDMMC_DCTRL_DBLOCKSIZE_0
  432. #define SDMMC_DATABLOCK_SIZE_4B SDMMC_DCTRL_DBLOCKSIZE_1
  433. #define SDMMC_DATABLOCK_SIZE_8B (SDMMC_DCTRL_DBLOCKSIZE_0|SDMMC_DCTRL_DBLOCKSIZE_1)
  434. #define SDMMC_DATABLOCK_SIZE_16B SDMMC_DCTRL_DBLOCKSIZE_2
  435. #define SDMMC_DATABLOCK_SIZE_32B (SDMMC_DCTRL_DBLOCKSIZE_0|SDMMC_DCTRL_DBLOCKSIZE_2)
  436. #define SDMMC_DATABLOCK_SIZE_64B (SDMMC_DCTRL_DBLOCKSIZE_1|SDMMC_DCTRL_DBLOCKSIZE_2)
  437. #define SDMMC_DATABLOCK_SIZE_128B (SDMMC_DCTRL_DBLOCKSIZE_0|SDMMC_DCTRL_DBLOCKSIZE_1|SDMMC_DCTRL_DBLOCKSIZE_2)
  438. #define SDMMC_DATABLOCK_SIZE_256B SDMMC_DCTRL_DBLOCKSIZE_3
  439. #define SDMMC_DATABLOCK_SIZE_512B (SDMMC_DCTRL_DBLOCKSIZE_0|SDMMC_DCTRL_DBLOCKSIZE_3)
  440. #define SDMMC_DATABLOCK_SIZE_1024B (SDMMC_DCTRL_DBLOCKSIZE_1|SDMMC_DCTRL_DBLOCKSIZE_3)
  441. #define SDMMC_DATABLOCK_SIZE_2048B (SDMMC_DCTRL_DBLOCKSIZE_0|SDMMC_DCTRL_DBLOCKSIZE_1|SDMMC_DCTRL_DBLOCKSIZE_3)
  442. #define SDMMC_DATABLOCK_SIZE_4096B (SDMMC_DCTRL_DBLOCKSIZE_2|SDMMC_DCTRL_DBLOCKSIZE_3)
  443. #define SDMMC_DATABLOCK_SIZE_8192B (SDMMC_DCTRL_DBLOCKSIZE_0|SDMMC_DCTRL_DBLOCKSIZE_2|SDMMC_DCTRL_DBLOCKSIZE_3)
  444. #define SDMMC_DATABLOCK_SIZE_16384B (SDMMC_DCTRL_DBLOCKSIZE_1|SDMMC_DCTRL_DBLOCKSIZE_2|SDMMC_DCTRL_DBLOCKSIZE_3)
  445. #define IS_SDMMC_BLOCK_SIZE(SIZE) (((SIZE) == SDMMC_DATABLOCK_SIZE_1B) || \
  446. ((SIZE) == SDMMC_DATABLOCK_SIZE_2B) || \
  447. ((SIZE) == SDMMC_DATABLOCK_SIZE_4B) || \
  448. ((SIZE) == SDMMC_DATABLOCK_SIZE_8B) || \
  449. ((SIZE) == SDMMC_DATABLOCK_SIZE_16B) || \
  450. ((SIZE) == SDMMC_DATABLOCK_SIZE_32B) || \
  451. ((SIZE) == SDMMC_DATABLOCK_SIZE_64B) || \
  452. ((SIZE) == SDMMC_DATABLOCK_SIZE_128B) || \
  453. ((SIZE) == SDMMC_DATABLOCK_SIZE_256B) || \
  454. ((SIZE) == SDMMC_DATABLOCK_SIZE_512B) || \
  455. ((SIZE) == SDMMC_DATABLOCK_SIZE_1024B) || \
  456. ((SIZE) == SDMMC_DATABLOCK_SIZE_2048B) || \
  457. ((SIZE) == SDMMC_DATABLOCK_SIZE_4096B) || \
  458. ((SIZE) == SDMMC_DATABLOCK_SIZE_8192B) || \
  459. ((SIZE) == SDMMC_DATABLOCK_SIZE_16384B))
  460. /**
  461. * @}
  462. */
  463. /** @defgroup SDMMC_LL_Transfer_Direction Transfer Direction
  464. * @{
  465. */
  466. #define SDMMC_TRANSFER_DIR_TO_CARD ((uint32_t)0x00000000U)
  467. #define SDMMC_TRANSFER_DIR_TO_SDMMC SDMMC_DCTRL_DTDIR
  468. #define IS_SDMMC_TRANSFER_DIR(DIR) (((DIR) == SDMMC_TRANSFER_DIR_TO_CARD) || \
  469. ((DIR) == SDMMC_TRANSFER_DIR_TO_SDMMC))
  470. /**
  471. * @}
  472. */
  473. /** @defgroup SDMMC_LL_Transfer_Type Transfer Type
  474. * @{
  475. */
  476. #define SDMMC_TRANSFER_MODE_BLOCK ((uint32_t)0x00000000U)
  477. #define SDMMC_TRANSFER_MODE_STREAM SDMMC_DCTRL_DTMODE_1
  478. #define IS_SDMMC_TRANSFER_MODE(MODE) (((MODE) == SDMMC_TRANSFER_MODE_BLOCK) || \
  479. ((MODE) == SDMMC_TRANSFER_MODE_STREAM))
  480. /**
  481. * @}
  482. */
  483. /** @defgroup SDMMC_LL_DPSM_State DPSM State
  484. * @{
  485. */
  486. #define SDMMC_DPSM_DISABLE ((uint32_t)0x00000000U)
  487. #define SDMMC_DPSM_ENABLE SDMMC_DCTRL_DTEN
  488. #define IS_SDMMC_DPSM(DPSM) (((DPSM) == SDMMC_DPSM_DISABLE) ||\
  489. ((DPSM) == SDMMC_DPSM_ENABLE))
  490. /**
  491. * @}
  492. */
  493. /** @defgroup SDMMC_LL_Read_Wait_Mode Read Wait Mode
  494. * @{
  495. */
  496. #define SDMMC_READ_WAIT_MODE_DATA2 ((uint32_t)0x00000000U)
  497. #define SDMMC_READ_WAIT_MODE_CLK (SDMMC_DCTRL_RWMOD)
  498. #define IS_SDMMC_READWAIT_MODE(MODE) (((MODE) == SDMMC_READ_WAIT_MODE_CLK) || \
  499. ((MODE) == SDMMC_READ_WAIT_MODE_DATA2))
  500. /**
  501. * @}
  502. */
  503. /** @defgroup SDMMC_LL_Interrupt_sources Interrupt Sources
  504. * @{
  505. */
  506. #define SDMMC_IT_CCRCFAIL SDMMC_MASK_CCRCFAILIE
  507. #define SDMMC_IT_DCRCFAIL SDMMC_MASK_DCRCFAILIE
  508. #define SDMMC_IT_CTIMEOUT SDMMC_MASK_CTIMEOUTIE
  509. #define SDMMC_IT_DTIMEOUT SDMMC_MASK_DTIMEOUTIE
  510. #define SDMMC_IT_TXUNDERR SDMMC_MASK_TXUNDERRIE
  511. #define SDMMC_IT_RXOVERR SDMMC_MASK_RXOVERRIE
  512. #define SDMMC_IT_CMDREND SDMMC_MASK_CMDRENDIE
  513. #define SDMMC_IT_CMDSENT SDMMC_MASK_CMDSENTIE
  514. #define SDMMC_IT_DATAEND SDMMC_MASK_DATAENDIE
  515. #define SDMMC_IT_DHOLD SDMMC_MASK_DHOLDIE
  516. #define SDMMC_IT_DBCKEND SDMMC_MASK_DBCKENDIE
  517. #define SDMMC_IT_DABORT SDMMC_MASK_DABORTIE
  518. #define SDMMC_IT_TXFIFOHE SDMMC_MASK_TXFIFOHEIE
  519. #define SDMMC_IT_RXFIFOHF SDMMC_MASK_RXFIFOHFIE
  520. #define SDMMC_IT_RXFIFOF SDMMC_MASK_RXFIFOFIE
  521. #define SDMMC_IT_TXFIFOE SDMMC_MASK_TXFIFOEIE
  522. #define SDMMC_IT_BUSYD0END SDMMC_MASK_BUSYD0ENDIE
  523. #define SDMMC_IT_SDIOIT SDMMC_MASK_SDIOITIE
  524. #define SDMMC_IT_ACKFAIL SDMMC_MASK_ACKFAILIE
  525. #define SDMMC_IT_ACKTIMEOUT SDMMC_MASK_ACKTIMEOUTIE
  526. #define SDMMC_IT_VSWEND SDMMC_MASK_VSWENDIE
  527. #define SDMMC_IT_CKSTOP SDMMC_MASK_CKSTOPIE
  528. #define SDMMC_IT_IDMABTC SDMMC_MASK_IDMABTCIE
  529. /**
  530. * @}
  531. */
  532. /** @defgroup SDMMC_LL_Flags Flags
  533. * @{
  534. */
  535. #define SDMMC_FLAG_CCRCFAIL SDMMC_STA_CCRCFAIL
  536. #define SDMMC_FLAG_DCRCFAIL SDMMC_STA_DCRCFAIL
  537. #define SDMMC_FLAG_CTIMEOUT SDMMC_STA_CTIMEOUT
  538. #define SDMMC_FLAG_DTIMEOUT SDMMC_STA_DTIMEOUT
  539. #define SDMMC_FLAG_TXUNDERR SDMMC_STA_TXUNDERR
  540. #define SDMMC_FLAG_RXOVERR SDMMC_STA_RXOVERR
  541. #define SDMMC_FLAG_CMDREND SDMMC_STA_CMDREND
  542. #define SDMMC_FLAG_CMDSENT SDMMC_STA_CMDSENT
  543. #define SDMMC_FLAG_DATAEND SDMMC_STA_DATAEND
  544. #define SDMMC_FLAG_DHOLD SDMMC_STA_DHOLD
  545. #define SDMMC_FLAG_DBCKEND SDMMC_STA_DBCKEND
  546. #define SDMMC_FLAG_DABORT SDMMC_STA_DABORT
  547. #define SDMMC_FLAG_DPSMACT SDMMC_STA_DPSMACT
  548. #define SDMMC_FLAG_CMDACT SDMMC_STA_CPSMACT
  549. #define SDMMC_FLAG_TXFIFOHE SDMMC_STA_TXFIFOHE
  550. #define SDMMC_FLAG_RXFIFOHF SDMMC_STA_RXFIFOHF
  551. #define SDMMC_FLAG_TXFIFOF SDMMC_STA_TXFIFOF
  552. #define SDMMC_FLAG_RXFIFOF SDMMC_STA_RXFIFOF
  553. #define SDMMC_FLAG_TXFIFOE SDMMC_STA_TXFIFOE
  554. #define SDMMC_FLAG_RXFIFOE SDMMC_STA_RXFIFOE
  555. #define SDMMC_FLAG_BUSYD0 SDMMC_STA_BUSYD0
  556. #define SDMMC_FLAG_BUSYD0END SDMMC_STA_BUSYD0END
  557. #define SDMMC_FLAG_SDIOIT SDMMC_STA_SDIOIT
  558. #define SDMMC_FLAG_ACKFAIL SDMMC_STA_ACKFAIL
  559. #define SDMMC_FLAG_ACKTIMEOUT SDMMC_STA_ACKTIMEOUT
  560. #define SDMMC_FLAG_VSWEND SDMMC_STA_VSWEND
  561. #define SDMMC_FLAG_CKSTOP SDMMC_STA_CKSTOP
  562. #define SDMMC_FLAG_IDMATE SDMMC_STA_IDMATE
  563. #define SDMMC_FLAG_IDMABTC SDMMC_STA_IDMABTC
  564. #define SDMMC_STATIC_FLAGS ((uint32_t)(SDMMC_FLAG_CCRCFAIL | SDMMC_FLAG_DCRCFAIL | SDMMC_FLAG_CTIMEOUT |\
  565. SDMMC_FLAG_DTIMEOUT | SDMMC_FLAG_TXUNDERR | SDMMC_FLAG_RXOVERR |\
  566. SDMMC_FLAG_CMDREND | SDMMC_FLAG_CMDSENT | SDMMC_FLAG_DATAEND |\
  567. SDMMC_FLAG_DHOLD | SDMMC_FLAG_DBCKEND | SDMMC_FLAG_DABORT |\
  568. SDMMC_FLAG_BUSYD0END | SDMMC_FLAG_SDIOIT | SDMMC_FLAG_ACKFAIL |\
  569. SDMMC_FLAG_ACKTIMEOUT | SDMMC_FLAG_VSWEND | SDMMC_FLAG_CKSTOP |\
  570. SDMMC_FLAG_IDMATE | SDMMC_FLAG_IDMABTC))
  571. #define SDMMC_STATIC_CMD_FLAGS ((uint32_t)(SDMMC_FLAG_CCRCFAIL | SDMMC_FLAG_CTIMEOUT | SDMMC_FLAG_CMDREND |\
  572. SDMMC_FLAG_CMDSENT | SDMMC_FLAG_BUSYD0END))
  573. #define SDMMC_STATIC_DATA_FLAGS ((uint32_t)(SDMMC_FLAG_DCRCFAIL | SDMMC_FLAG_DTIMEOUT | SDMMC_FLAG_TXUNDERR |\
  574. SDMMC_FLAG_RXOVERR | SDMMC_FLAG_DATAEND | SDMMC_FLAG_DHOLD |\
  575. SDMMC_FLAG_DBCKEND | SDMMC_FLAG_DABORT | SDMMC_FLAG_IDMATE |\
  576. SDMMC_FLAG_IDMABTC))
  577. /**
  578. * @}
  579. */
  580. /**
  581. * @}
  582. */
  583. /* Exported macro ------------------------------------------------------------*/
  584. /** @defgroup SDMMC_LL_Exported_macros SDMMC_LL Exported Macros
  585. * @{
  586. */
  587. /** @defgroup SDMMC_LL_Register Bits And Addresses Definitions
  588. * @brief SDMMC_LL registers bit address in the alias region
  589. * @{
  590. */
  591. /* ---------------------- SDMMC registers bit mask --------------------------- */
  592. /* --- CLKCR Register ---*/
  593. /* CLKCR register clear mask */
  594. #define CLKCR_CLEAR_MASK ((uint32_t)(SDMMC_CLKCR_CLKDIV | SDMMC_CLKCR_PWRSAV |\
  595. SDMMC_CLKCR_WIDBUS |\
  596. SDMMC_CLKCR_NEGEDGE | SDMMC_CLKCR_HWFC_EN |\
  597. SDMMC_CLKCR_DDR | SDMMC_CLKCR_BUSSPEED |\
  598. SDMMC_CLKCR_SELCLKRX))
  599. /* --- DCTRL Register ---*/
  600. /* SDMMC DCTRL Clear Mask */
  601. #define DCTRL_CLEAR_MASK ((uint32_t)(SDMMC_DCTRL_DTEN | SDMMC_DCTRL_DTDIR |\
  602. SDMMC_DCTRL_DTMODE | SDMMC_DCTRL_DBLOCKSIZE))
  603. /* --- CMD Register ---*/
  604. /* CMD Register clear mask */
  605. #define CMD_CLEAR_MASK ((uint32_t)(SDMMC_CMD_CMDINDEX | SDMMC_CMD_WAITRESP |\
  606. SDMMC_CMD_WAITINT | SDMMC_CMD_WAITPEND |\
  607. SDMMC_CMD_CPSMEN | SDMMC_CMD_CMDSUSPEND))
  608. /* SDMMC Initialization Frequency (400KHz max) for Peripheral CLK 200MHz*/
  609. #define SDMMC_INIT_CLK_DIV ((uint8_t)0xFA)
  610. /* SDMMC Default Speed Frequency (25Mhz max) for Peripheral CLK 200MHz*/
  611. #define SDMMC_NSpeed_CLK_DIV ((uint8_t)0x4)
  612. /* SDMMC High Speed Frequency (50Mhz max) for Peripheral CLK 200MHz*/
  613. #define SDMMC_HSpeed_CLK_DIV ((uint8_t)0x2)
  614. /**
  615. * @}
  616. */
  617. /** @defgroup SDMMC_LL_Interrupt_Clock Interrupt And Clock Configuration
  618. * @brief macros to handle interrupts and specific clock configurations
  619. * @{
  620. */
  621. /**
  622. * @brief Enable the SDMMC device interrupt.
  623. * @param __INSTANCE__ Pointer to SDMMC register base
  624. * @param __INTERRUPT__ specifies the SDMMC interrupt sources to be enabled.
  625. * This parameter can be one or a combination of the following values:
  626. * @arg SDMMC_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
  627. * @arg SDMMC_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
  628. * @arg SDMMC_IT_CTIMEOUT: Command response timeout interrupt
  629. * @arg SDMMC_IT_DTIMEOUT: Data timeout interrupt
  630. * @arg SDMMC_IT_TXUNDERR: Transmit FIFO underrun error interrupt
  631. * @arg SDMMC_IT_RXOVERR: Received FIFO overrun error interrupt
  632. * @arg SDMMC_IT_CMDREND: Command response received (CRC check passed) interrupt
  633. * @arg SDMMC_IT_CMDSENT: Command sent (no response required) interrupt
  634. * @arg SDMMC_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt
  635. * @arg SDMMC_IT_DHOLD: Data transfer Hold interrupt
  636. * @arg SDMMC_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt
  637. * @arg SDMMC_IT_DABORT: Data transfer aborted by CMD12 interrupt
  638. * @arg SDMMC_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
  639. * @arg SDMMC_IT_RXFIFOHF: Receive FIFO Half Full interrupt
  640. * @arg SDMMC_IT_RXFIFOF: Receive FIFO full interrupt
  641. * @arg SDMMC_IT_TXFIFOE: Transmit FIFO empty interrupt
  642. * @arg SDMMC_IT_BUSYD0END: End of SDMMC_D0 Busy following a CMD response detected interrupt
  643. * @arg SDMMC_IT_SDIOIT: SDIO interrupt received interrupt
  644. * @arg SDMMC_IT_ACKFAIL: Boot Acknowledgment received interrupt
  645. * @arg SDMMC_IT_ACKTIMEOUT: Boot Acknowledgment timeout interrupt
  646. * @arg SDMMC_IT_VSWEND: Voltage switch critical timing section completion interrupt
  647. * @arg SDMMC_IT_CKSTOP: SDMMC_CK stopped in Voltage switch procedure interrupt
  648. * @arg SDMMC_IT_IDMABTC: IDMA buffer transfer complete interrupt
  649. * @retval None
  650. */
  651. #define __SDMMC_ENABLE_IT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->MASK |= (__INTERRUPT__))
  652. /**
  653. * @brief Disable the SDMMC device interrupt.
  654. * @param __INSTANCE__ Pointer to SDMMC register base
  655. * @param __INTERRUPT__ specifies the SDMMC interrupt sources to be disabled.
  656. * This parameter can be one or a combination of the following values:
  657. * @arg SDMMC_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
  658. * @arg SDMMC_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
  659. * @arg SDMMC_IT_CTIMEOUT: Command response timeout interrupt
  660. * @arg SDMMC_IT_DTIMEOUT: Data timeout interrupt
  661. * @arg SDMMC_IT_TXUNDERR: Transmit FIFO underrun error interrupt
  662. * @arg SDMMC_IT_RXOVERR: Received FIFO overrun error interrupt
  663. * @arg SDMMC_IT_CMDREND: Command response received (CRC check passed) interrupt
  664. * @arg SDMMC_IT_CMDSENT: Command sent (no response required) interrupt
  665. * @arg SDMMC_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt
  666. * @arg SDMMC_IT_DHOLD: Data transfer Hold interrupt
  667. * @arg SDMMC_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt
  668. * @arg SDMMC_IT_DABORT: Data transfer aborted by CMD12 interrupt
  669. * @arg SDMMC_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
  670. * @arg SDMMC_IT_RXFIFOHF: Receive FIFO Half Full interrupt
  671. * @arg SDMMC_IT_RXFIFOF: Receive FIFO full interrupt
  672. * @arg SDMMC_IT_TXFIFOE: Transmit FIFO empty interrupt
  673. * @arg SDMMC_IT_BUSYD0END: End of SDMMC_D0 Busy following a CMD response detected interrupt
  674. * @arg SDMMC_IT_SDIOIT: SDIO interrupt received interrupt
  675. * @arg SDMMC_IT_ACKFAIL: Boot Acknowledgment received interrupt
  676. * @arg SDMMC_IT_ACKTIMEOUT: Boot Acknowledgment timeout interrupt
  677. * @arg SDMMC_IT_VSWEND: Voltage switch critical timing section completion interrupt
  678. * @arg SDMMC_IT_CKSTOP: SDMMC_CK stopped in Voltage switch procedure interrupt
  679. * @arg SDMMC_IT_IDMABTC: IDMA buffer transfer complete interrupt
  680. * @retval None
  681. */
  682. #define __SDMMC_DISABLE_IT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->MASK &= ~(__INTERRUPT__))
  683. /**
  684. * @brief Checks whether the specified SDMMC flag is set or not.
  685. * @param __INSTANCE__ Pointer to SDMMC register base
  686. * @param __FLAG__ specifies the flag to check.
  687. * This parameter can be one of the following values:
  688. * @arg SDMMC_FLAG_CCRCFAIL: Command response received (CRC check failed)
  689. * @arg SDMMC_FLAG_DCRCFAIL: Data block sent/received (CRC check failed)
  690. * @arg SDMMC_FLAG_CTIMEOUT: Command response timeout
  691. * @arg SDMMC_FLAG_DTIMEOUT: Data timeout
  692. * @arg SDMMC_FLAG_TXUNDERR: Transmit FIFO underrun error
  693. * @arg SDMMC_FLAG_RXOVERR: Received FIFO overrun error
  694. * @arg SDMMC_FLAG_CMDREND: Command response received (CRC check passed)
  695. * @arg SDMMC_FLAG_CMDSENT: Command sent (no response required)
  696. * @arg SDMMC_FLAG_DATAEND: Data end (data counter, DATACOUNT, is zero)
  697. * @arg SDMMC_FLAG_DHOLD: Data transfer Hold
  698. * @arg SDMMC_FLAG_DBCKEND: Data block sent/received (CRC check passed)
  699. * @arg SDMMC_FLAG_DABORT: Data transfer aborted by CMD12
  700. * @arg SDMMC_FLAG_DPSMACT: Data path state machine active
  701. * @arg SDMMC_FLAG_CPSMACT: Command path state machine active
  702. * @arg SDMMC_FLAG_TXFIFOHE: Transmit FIFO Half Empty
  703. * @arg SDMMC_FLAG_RXFIFOHF: Receive FIFO Half Full
  704. * @arg SDMMC_FLAG_TXFIFOF: Transmit FIFO full
  705. * @arg SDMMC_FLAG_RXFIFOF: Receive FIFO full
  706. * @arg SDMMC_FLAG_TXFIFOE: Transmit FIFO empty
  707. * @arg SDMMC_FLAG_RXFIFOE: Receive FIFO empty
  708. * @arg SDMMC_FLAG_BUSYD0: Inverted value of SDMMC_D0 line (Busy)
  709. * @arg SDMMC_FLAG_BUSYD0END: End of SDMMC_D0 Busy following a CMD response detected
  710. * @arg SDMMC_FLAG_SDIOIT: SDIO interrupt received
  711. * @arg SDMMC_FLAG_ACKFAIL: Boot Acknowledgment received
  712. * @arg SDMMC_FLAG_ACKTIMEOUT: Boot Acknowledgment timeout
  713. * @arg SDMMC_FLAG_VSWEND: Voltage switch critical timing section completion
  714. * @arg SDMMC_FLAG_CKSTOP: SDMMC_CK stopped in Voltage switch procedure
  715. * @arg SDMMC_FLAG_IDMATE: IDMA transfer error
  716. * @arg SDMMC_FLAG_IDMABTC: IDMA buffer transfer complete
  717. * @retval The new state of SDMMC_FLAG (SET or RESET).
  718. */
  719. #define __SDMMC_GET_FLAG(__INSTANCE__, __FLAG__) (((__INSTANCE__)->STA &(__FLAG__)) != 0U)
  720. /**
  721. * @brief Clears the SDMMC pending flags.
  722. * @param __INSTANCE__ Pointer to SDMMC register base
  723. * @param __FLAG__ specifies the flag to clear.
  724. * This parameter can be one or a combination of the following values:
  725. * @arg SDMMC_FLAG_CCRCFAIL: Command response received (CRC check failed)
  726. * @arg SDMMC_FLAG_DCRCFAIL: Data block sent/received (CRC check failed)
  727. * @arg SDMMC_FLAG_CTIMEOUT: Command response timeout
  728. * @arg SDMMC_FLAG_DTIMEOUT: Data timeout
  729. * @arg SDMMC_FLAG_TXUNDERR: Transmit FIFO underrun error
  730. * @arg SDMMC_FLAG_RXOVERR: Received FIFO overrun error
  731. * @arg SDMMC_FLAG_CMDREND: Command response received (CRC check passed)
  732. * @arg SDMMC_FLAG_CMDSENT: Command sent (no response required)
  733. * @arg SDMMC_FLAG_DATAEND: Data end (data counter, DATACOUNT, is zero)
  734. * @arg SDMMC_FLAG_DHOLD: Data transfer Hold
  735. * @arg SDMMC_FLAG_DBCKEND: Data block sent/received (CRC check passed)
  736. * @arg SDMMC_FLAG_DABORT: Data transfer aborted by CMD12
  737. * @arg SDMMC_FLAG_BUSYD0END: End of SDMMC_D0 Busy following a CMD response detected
  738. * @arg SDMMC_FLAG_SDIOIT: SDIO interrupt received
  739. * @arg SDMMC_FLAG_ACKFAIL: Boot Acknowledgment received
  740. * @arg SDMMC_FLAG_ACKTIMEOUT: Boot Acknowledgment timeout
  741. * @arg SDMMC_FLAG_VSWEND: Voltage switch critical timing section completion
  742. * @arg SDMMC_FLAG_CKSTOP: SDMMC_CK stopped in Voltage switch procedure
  743. * @arg SDMMC_FLAG_IDMATE: IDMA transfer error
  744. * @arg SDMMC_FLAG_IDMABTC: IDMA buffer transfer complete
  745. * @retval None
  746. */
  747. #define __SDMMC_CLEAR_FLAG(__INSTANCE__, __FLAG__) ((__INSTANCE__)->ICR = (__FLAG__))
  748. /**
  749. * @brief Checks whether the specified SDMMC interrupt has occurred or not.
  750. * @param __INSTANCE__ Pointer to SDMMC register base
  751. * @param __INTERRUPT__ specifies the SDMMC interrupt source to check.
  752. * This parameter can be one of the following values:
  753. * @arg SDMMC_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
  754. * @arg SDMMC_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
  755. * @arg SDMMC_IT_CTIMEOUT: Command response timeout interrupt
  756. * @arg SDMMC_IT_DTIMEOUT: Data timeout interrupt
  757. * @arg SDMMC_IT_TXUNDERR: Transmit FIFO underrun error interrupt
  758. * @arg SDMMC_IT_RXOVERR: Received FIFO overrun error interrupt
  759. * @arg SDMMC_IT_CMDREND: Command response received (CRC check passed) interrupt
  760. * @arg SDMMC_IT_CMDSENT: Command sent (no response required) interrupt
  761. * @arg SDMMC_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt
  762. * @arg SDMMC_IT_DHOLD: Data transfer Hold interrupt
  763. * @arg SDMMC_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt
  764. * @arg SDMMC_IT_DABORT: Data transfer aborted by CMD12 interrupt
  765. * @arg SDMMC_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
  766. * @arg SDMMC_IT_RXFIFOHF: Receive FIFO Half Full interrupt
  767. * @arg SDMMC_IT_RXFIFOF: Receive FIFO full interrupt
  768. * @arg SDMMC_IT_TXFIFOE: Transmit FIFO empty interrupt
  769. * @arg SDMMC_IT_BUSYD0END: End of SDMMC_D0 Busy following a CMD response detected interrupt
  770. * @arg SDMMC_IT_SDIOIT: SDIO interrupt received interrupt
  771. * @arg SDMMC_IT_ACKFAIL: Boot Acknowledgment received interrupt
  772. * @arg SDMMC_IT_ACKTIMEOUT: Boot Acknowledgment timeout interrupt
  773. * @arg SDMMC_IT_VSWEND: Voltage switch critical timing section completion interrupt
  774. * @arg SDMMC_IT_CKSTOP: SDMMC_CK stopped in Voltage switch procedure interrupt
  775. * @arg SDMMC_IT_IDMABTC: IDMA buffer transfer complete interrupt
  776. * @retval The new state of SDMMC_IT (SET or RESET).
  777. */
  778. #define __SDMMC_GET_IT(__INSTANCE__, __INTERRUPT__) (((__INSTANCE__)->STA &(__INTERRUPT__)) == (__INTERRUPT__))
  779. /**
  780. * @brief Clears the SDMMC's interrupt pending bits.
  781. * @param __INSTANCE__ Pointer to SDMMC register base
  782. * @param __INTERRUPT__ specifies the interrupt pending bit to clear.
  783. * This parameter can be one or a combination of the following values:
  784. * @arg SDMMC_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
  785. * @arg SDMMC_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
  786. * @arg SDMMC_IT_CTIMEOUT: Command response timeout interrupt
  787. * @arg SDMMC_IT_DTIMEOUT: Data timeout interrupt
  788. * @arg SDMMC_IT_TXUNDERR: Transmit FIFO underrun error interrupt
  789. * @arg SDMMC_IT_RXOVERR: Received FIFO overrun error interrupt
  790. * @arg SDMMC_IT_CMDREND: Command response received (CRC check passed) interrupt
  791. * @arg SDMMC_IT_CMDSENT: Command sent (no response required) interrupt
  792. * @arg SDMMC_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt
  793. * @arg SDMMC_IT_DHOLD: Data transfer Hold interrupt
  794. * @arg SDMMC_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt
  795. * @arg SDMMC_IT_DABORT: Data transfer aborted by CMD12 interrupt
  796. * @arg SDMMC_IT_BUSYD0END: End of SDMMC_D0 Busy following a CMD response detected interrupt
  797. * @arg SDMMC_IT_SDIOIT: SDIO interrupt received interrupt
  798. * @arg SDMMC_IT_ACKFAIL: Boot Acknowledgment received interrupt
  799. * @arg SDMMC_IT_ACKTIMEOUT: Boot Acknowledgment timeout interrupt
  800. * @arg SDMMC_IT_VSWEND: Voltage switch critical timing section completion interrupt
  801. * @arg SDMMC_IT_CKSTOP: SDMMC_CK stopped in Voltage switch procedure interrupt
  802. * @arg SDMMC_IT_IDMABTC: IDMA buffer transfer complete interrupt
  803. * @retval None
  804. */
  805. #define __SDMMC_CLEAR_IT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->ICR = (__INTERRUPT__))
  806. /**
  807. * @brief Enable Start the SD I/O Read Wait operation.
  808. * @param __INSTANCE__ Pointer to SDMMC register base
  809. * @retval None
  810. */
  811. #define __SDMMC_START_READWAIT_ENABLE(__INSTANCE__) ((__INSTANCE__)->DCTRL |= SDMMC_DCTRL_RWSTART)
  812. /**
  813. * @brief Disable Start the SD I/O Read Wait operations.
  814. * @param __INSTANCE__ Pointer to SDMMC register base
  815. * @retval None
  816. */
  817. #define __SDMMC_START_READWAIT_DISABLE(__INSTANCE__) ((__INSTANCE__)->DCTRL &= ~SDMMC_DCTRL_RWSTART)
  818. /**
  819. * @brief Enable Start the SD I/O Read Wait operation.
  820. * @param __INSTANCE__ Pointer to SDMMC register base
  821. * @retval None
  822. */
  823. #define __SDMMC_STOP_READWAIT_ENABLE(__INSTANCE__) ((__INSTANCE__)->DCTRL |= SDMMC_DCTRL_RWSTOP)
  824. /**
  825. * @brief Disable Stop the SD I/O Read Wait operations.
  826. * @param __INSTANCE__ Pointer to SDMMC register base
  827. * @retval None
  828. */
  829. #define __SDMMC_STOP_READWAIT_DISABLE(__INSTANCE__) ((__INSTANCE__)->DCTRL &= ~SDMMC_DCTRL_RWSTOP)
  830. /**
  831. * @brief Enable the SD I/O Mode Operation.
  832. * @param __INSTANCE__ Pointer to SDMMC register base
  833. * @retval None
  834. */
  835. #define __SDMMC_OPERATION_ENABLE(__INSTANCE__) ((__INSTANCE__)->DCTRL |= SDMMC_DCTRL_SDIOEN)
  836. /**
  837. * @brief Disable the SD I/O Mode Operation.
  838. * @param __INSTANCE__ Pointer to SDMMC register base
  839. * @retval None
  840. */
  841. #define __SDMMC_OPERATION_DISABLE(__INSTANCE__) ((__INSTANCE__)->DCTRL &= ~SDMMC_DCTRL_SDIOEN)
  842. /**
  843. * @brief Enable the SD I/O Suspend command sending.
  844. * @param __INSTANCE__ Pointer to SDMMC register base
  845. * @retval None
  846. */
  847. #define __SDMMC_SUSPEND_CMD_ENABLE(__INSTANCE__) ((__INSTANCE__)->CMD |= SDMMC_CMD_CMDSUSPEND)
  848. /**
  849. * @brief Disable the SD I/O Suspend command sending.
  850. * @param __INSTANCE__ Pointer to SDMMC register base
  851. * @retval None
  852. */
  853. #define __SDMMC_SUSPEND_CMD_DISABLE(__INSTANCE__) ((__INSTANCE__)->CMD &= ~SDMMC_CMD_CMDSUSPEND)
  854. /**
  855. * @brief Enable the CMDTRANS mode.
  856. * @param __INSTANCE__ Pointer to SDMMC register base
  857. * @retval None
  858. */
  859. #define __SDMMC_CMDTRANS_ENABLE(__INSTANCE__) ((__INSTANCE__)->CMD |= SDMMC_CMD_CMDTRANS)
  860. /**
  861. * @brief Disable the CMDTRANS mode.
  862. * @param __INSTANCE__ Pointer to SDMMC register base
  863. * @retval None
  864. */
  865. #define __SDMMC_CMDTRANS_DISABLE(__INSTANCE__) ((__INSTANCE__)->CMD &= ~SDMMC_CMD_CMDTRANS)
  866. /**
  867. * @brief Enable the CMDSTOP mode.
  868. * @param __INSTANCE__ Pointer to SDMMC register base
  869. * @retval None
  870. */
  871. #define __SDMMC_CMDSTOP_ENABLE(__INSTANCE__) ((__INSTANCE__)->CMD |= SDMMC_CMD_CMDSTOP)
  872. /**
  873. * @brief Disable the CMDSTOP mode.
  874. * @param __INSTANCE__ Pointer to SDMMC register base
  875. * @retval None
  876. */
  877. #define __SDMMC_CMDSTOP_DISABLE(__INSTANCE__) ((__INSTANCE__)->CMD &= ~SDMMC_CMD_CMDSTOP)
  878. /**
  879. * @}
  880. */
  881. /**
  882. * @}
  883. */
  884. /* Exported functions --------------------------------------------------------*/
  885. /** @addtogroup SDMMC_LL_Exported_Functions
  886. * @{
  887. */
  888. /* Initialization/de-initialization functions **********************************/
  889. /** @addtogroup HAL_SDMMC_LL_Group1
  890. * @{
  891. */
  892. HAL_StatusTypeDef SDMMC_Init(SDMMC_TypeDef *SDMMCx, SDMMC_InitTypeDef Init);
  893. /**
  894. * @}
  895. */
  896. /* I/O operation functions *****************************************************/
  897. /** @addtogroup HAL_SDMMC_LL_Group2
  898. * @{
  899. */
  900. uint32_t SDMMC_ReadFIFO(SDMMC_TypeDef *SDMMCx);
  901. HAL_StatusTypeDef SDMMC_WriteFIFO(SDMMC_TypeDef *SDMMCx, uint32_t *pWriteData);
  902. /**
  903. * @}
  904. */
  905. /* Peripheral Control functions ************************************************/
  906. /** @addtogroup HAL_SDMMC_LL_Group3
  907. * @{
  908. */
  909. HAL_StatusTypeDef SDMMC_PowerState_ON(SDMMC_TypeDef *SDMMCx);
  910. HAL_StatusTypeDef SDMMC_PowerState_Cycle(SDMMC_TypeDef *SDMMCx);
  911. HAL_StatusTypeDef SDMMC_PowerState_OFF(SDMMC_TypeDef *SDMMCx);
  912. uint32_t SDMMC_GetPowerState(SDMMC_TypeDef *SDMMCx);
  913. /* Command path state machine (CPSM) management functions */
  914. HAL_StatusTypeDef SDMMC_SendCommand(SDMMC_TypeDef *SDMMCx, SDMMC_CmdInitTypeDef *Command);
  915. uint8_t SDMMC_GetCommandResponse(SDMMC_TypeDef *SDMMCx);
  916. uint32_t SDMMC_GetResponse(SDMMC_TypeDef *SDMMCx, uint32_t Response);
  917. /* Data path state machine (DPSM) management functions */
  918. HAL_StatusTypeDef SDMMC_ConfigData(SDMMC_TypeDef *SDMMCx, SDMMC_DataInitTypeDef* Data);
  919. uint32_t SDMMC_GetDataCounter(SDMMC_TypeDef *SDMMCx);
  920. uint32_t SDMMC_GetFIFOCount(SDMMC_TypeDef *SDMMCx);
  921. /* SDMMC Cards mode management functions */
  922. HAL_StatusTypeDef SDMMC_SetSDMMCReadWaitMode(SDMMC_TypeDef *SDMMCx, uint32_t SDMMC_ReadWaitMode);
  923. /* SDMMC Commands management functions */
  924. uint32_t SDMMC_CmdBlockLength(SDMMC_TypeDef *SDMMCx, uint32_t BlockSize);
  925. uint32_t SDMMC_CmdReadSingleBlock(SDMMC_TypeDef *SDMMCx, uint32_t ReadAdd);
  926. uint32_t SDMMC_CmdReadMultiBlock(SDMMC_TypeDef *SDMMCx, uint32_t ReadAdd);
  927. uint32_t SDMMC_CmdWriteSingleBlock(SDMMC_TypeDef *SDMMCx, uint32_t WriteAdd);
  928. uint32_t SDMMC_CmdWriteMultiBlock(SDMMC_TypeDef *SDMMCx, uint32_t WriteAdd);
  929. uint32_t SDMMC_CmdEraseStartAdd(SDMMC_TypeDef *SDMMCx, uint32_t StartAdd);
  930. uint32_t SDMMC_CmdSDEraseStartAdd(SDMMC_TypeDef *SDMMCx, uint32_t StartAdd);
  931. uint32_t SDMMC_CmdEraseEndAdd(SDMMC_TypeDef *SDMMCx, uint32_t EndAdd);
  932. uint32_t SDMMC_CmdSDEraseEndAdd(SDMMC_TypeDef *SDMMCx, uint32_t EndAdd);
  933. uint32_t SDMMC_CmdErase(SDMMC_TypeDef *SDMMCx);
  934. uint32_t SDMMC_CmdStopTransfer(SDMMC_TypeDef *SDMMCx);
  935. uint32_t SDMMC_CmdSelDesel(SDMMC_TypeDef *SDMMCx, uint64_t Addr);
  936. uint32_t SDMMC_CmdGoIdleState(SDMMC_TypeDef *SDMMCx);
  937. uint32_t SDMMC_CmdOperCond(SDMMC_TypeDef *SDMMCx);
  938. uint32_t SDMMC_CmdAppCommand(SDMMC_TypeDef *SDMMCx, uint32_t Argument);
  939. uint32_t SDMMC_CmdAppOperCommand(SDMMC_TypeDef *SDMMCx, uint32_t Argument);
  940. uint32_t SDMMC_CmdBusWidth(SDMMC_TypeDef *SDMMCx, uint32_t BusWidth);
  941. uint32_t SDMMC_CmdSendSCR(SDMMC_TypeDef *SDMMCx);
  942. uint32_t SDMMC_CmdSendCID(SDMMC_TypeDef *SDMMCx);
  943. uint32_t SDMMC_CmdSendCSD(SDMMC_TypeDef *SDMMCx, uint32_t Argument);
  944. uint32_t SDMMC_CmdSetRelAdd(SDMMC_TypeDef *SDMMCx, uint16_t *pRCA);
  945. uint32_t SDMMC_CmdSendStatus(SDMMC_TypeDef *SDMMCx, uint32_t Argument);
  946. uint32_t SDMMC_CmdStatusRegister(SDMMC_TypeDef *SDMMCx);
  947. uint32_t SDMMC_CmdVoltageSwitch(SDMMC_TypeDef *SDMMCx);
  948. uint32_t SDMMC_CmdOpCondition(SDMMC_TypeDef *SDMMCx, uint32_t Argument);
  949. uint32_t SDMMC_CmdSwitch(SDMMC_TypeDef *SDMMCx, uint32_t Argument);
  950. uint32_t SDMMC_CmdSendEXTCSD(SDMMC_TypeDef *SDMMCx, uint32_t Argument);
  951. /**
  952. * @}
  953. */
  954. /**
  955. * @}
  956. */
  957. /**
  958. * @}
  959. */
  960. /**
  961. * @}
  962. */
  963. /**
  964. * @}
  965. */
  966. /**
  967. * @}
  968. */
  969. #ifdef __cplusplus
  970. }
  971. #endif
  972. #endif /* STM32H7xx_LL_SDMMC_H */
  973. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/