STM32F103xB HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32f1xx_hal_mmc.h 00004 * @author MCD Application Team 00005 * @brief Header file of MMC HAL module. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * <h2><center>© Copyright (c) 2018 STMicroelectronics. 00010 * All rights reserved.</center></h2> 00011 * 00012 * This software component is licensed by ST under BSD 3-Clause license, 00013 * the "License"; You may not use this file except in compliance with the 00014 * License. You may obtain a copy of the License at: 00015 * opensource.org/licenses/BSD-3-Clause 00016 * 00017 ****************************************************************************** 00018 */ 00019 00020 /* Define to prevent recursive inclusion -------------------------------------*/ 00021 #ifndef STM32F1xx_HAL_MMC_H 00022 #define STM32F1xx_HAL_MMC_H 00023 00024 #if defined(SDIO) 00025 00026 #ifdef __cplusplus 00027 extern "C" { 00028 #endif 00029 00030 /* Includes ------------------------------------------------------------------*/ 00031 #include "stm32f1xx_ll_sdmmc.h" 00032 00033 /** @addtogroup STM32F1xx_HAL_Driver 00034 * @{ 00035 */ 00036 00037 /** @addtogroup MMC 00038 * @{ 00039 */ 00040 00041 /* Exported types ------------------------------------------------------------*/ 00042 /** @defgroup MMC_Exported_Types MMC Exported Types 00043 * @{ 00044 */ 00045 00046 /** @defgroup MMC_Exported_Types_Group1 MMC State enumeration structure 00047 * @{ 00048 */ 00049 typedef enum 00050 { 00051 HAL_MMC_STATE_RESET = 0x00000000U, /*!< MMC not yet initialized or disabled */ 00052 HAL_MMC_STATE_READY = 0x00000001U, /*!< MMC initialized and ready for use */ 00053 HAL_MMC_STATE_TIMEOUT = 0x00000002U, /*!< MMC Timeout state */ 00054 HAL_MMC_STATE_BUSY = 0x00000003U, /*!< MMC process ongoing */ 00055 HAL_MMC_STATE_PROGRAMMING = 0x00000004U, /*!< MMC Programming State */ 00056 HAL_MMC_STATE_RECEIVING = 0x00000005U, /*!< MMC Receinving State */ 00057 HAL_MMC_STATE_TRANSFER = 0x00000006U, /*!< MMC Transfer State */ 00058 HAL_MMC_STATE_ERROR = 0x0000000FU /*!< MMC is in error state */ 00059 }HAL_MMC_StateTypeDef; 00060 /** 00061 * @} 00062 */ 00063 00064 /** @defgroup MMC_Exported_Types_Group2 MMC Card State enumeration structure 00065 * @{ 00066 */ 00067 typedef uint32_t HAL_MMC_CardStateTypeDef; 00068 00069 #define HAL_MMC_CARD_READY 0x00000001U /*!< Card state is ready */ 00070 #define HAL_MMC_CARD_IDENTIFICATION 0x00000002U /*!< Card is in identification state */ 00071 #define HAL_MMC_CARD_STANDBY 0x00000003U /*!< Card is in standby state */ 00072 #define HAL_MMC_CARD_TRANSFER 0x00000004U /*!< Card is in transfer state */ 00073 #define HAL_MMC_CARD_SENDING 0x00000005U /*!< Card is sending an operation */ 00074 #define HAL_MMC_CARD_RECEIVING 0x00000006U /*!< Card is receiving operation information */ 00075 #define HAL_MMC_CARD_PROGRAMMING 0x00000007U /*!< Card is in programming state */ 00076 #define HAL_MMC_CARD_DISCONNECTED 0x00000008U /*!< Card is disconnected */ 00077 #define HAL_MMC_CARD_ERROR 0x000000FFU /*!< Card response Error */ 00078 /** 00079 * @} 00080 */ 00081 00082 /** @defgroup MMC_Exported_Types_Group3 MMC Handle Structure definition 00083 * @{ 00084 */ 00085 #define MMC_InitTypeDef SDIO_InitTypeDef 00086 #define MMC_TypeDef SDIO_TypeDef 00087 00088 /** 00089 * @brief MMC Card Information Structure definition 00090 */ 00091 typedef struct 00092 { 00093 uint32_t CardType; /*!< Specifies the card Type */ 00094 00095 uint32_t Class; /*!< Specifies the class of the card class */ 00096 00097 uint32_t RelCardAdd; /*!< Specifies the Relative Card Address */ 00098 00099 uint32_t BlockNbr; /*!< Specifies the Card Capacity in blocks */ 00100 00101 uint32_t BlockSize; /*!< Specifies one block size in bytes */ 00102 00103 uint32_t LogBlockNbr; /*!< Specifies the Card logical Capacity in blocks */ 00104 00105 uint32_t LogBlockSize; /*!< Specifies logical block size in bytes */ 00106 00107 }HAL_MMC_CardInfoTypeDef; 00108 00109 /** 00110 * @brief MMC handle Structure definition 00111 */ 00112 #if defined (USE_HAL_MMC_REGISTER_CALLBACKS) && (USE_HAL_MMC_REGISTER_CALLBACKS == 1U) 00113 typedef struct __MMC_HandleTypeDef 00114 #else 00115 typedef struct 00116 #endif /* USE_HAL_MMC_REGISTER_CALLBACKS */ 00117 { 00118 MMC_TypeDef *Instance; /*!< MMC registers base address */ 00119 00120 MMC_InitTypeDef Init; /*!< MMC required parameters */ 00121 00122 HAL_LockTypeDef Lock; /*!< MMC locking object */ 00123 00124 uint8_t *pTxBuffPtr; /*!< Pointer to MMC Tx transfer Buffer */ 00125 00126 uint32_t TxXferSize; /*!< MMC Tx Transfer size */ 00127 00128 uint8_t *pRxBuffPtr; /*!< Pointer to MMC Rx transfer Buffer */ 00129 00130 uint32_t RxXferSize; /*!< MMC Rx Transfer size */ 00131 00132 __IO uint32_t Context; /*!< MMC transfer context */ 00133 00134 __IO HAL_MMC_StateTypeDef State; /*!< MMC card State */ 00135 00136 __IO uint32_t ErrorCode; /*!< MMC Card Error codes */ 00137 00138 DMA_HandleTypeDef *hdmarx; /*!< MMC Rx DMA handle parameters */ 00139 00140 DMA_HandleTypeDef *hdmatx; /*!< MMC Tx DMA handle parameters */ 00141 00142 HAL_MMC_CardInfoTypeDef MmcCard; /*!< MMC Card information */ 00143 00144 uint32_t CSD[4U]; /*!< MMC card specific data table */ 00145 00146 uint32_t CID[4U]; /*!< MMC card identification number table */ 00147 00148 #if defined (USE_HAL_MMC_REGISTER_CALLBACKS) && (USE_HAL_MMC_REGISTER_CALLBACKS == 1U) 00149 void (* TxCpltCallback) (struct __MMC_HandleTypeDef *hmmc); 00150 void (* RxCpltCallback) (struct __MMC_HandleTypeDef *hmmc); 00151 void (* ErrorCallback) (struct __MMC_HandleTypeDef *hmmc); 00152 void (* AbortCpltCallback) (struct __MMC_HandleTypeDef *hmmc); 00153 00154 void (* MspInitCallback) (struct __MMC_HandleTypeDef *hmmc); 00155 void (* MspDeInitCallback) (struct __MMC_HandleTypeDef *hmmc); 00156 #endif 00157 }MMC_HandleTypeDef; 00158 00159 /** 00160 * @} 00161 */ 00162 00163 /** @defgroup MMC_Exported_Types_Group4 Card Specific Data: CSD Register 00164 * @{ 00165 */ 00166 typedef struct 00167 { 00168 __IO uint8_t CSDStruct; /*!< CSD structure */ 00169 __IO uint8_t SysSpecVersion; /*!< System specification version */ 00170 __IO uint8_t Reserved1; /*!< Reserved */ 00171 __IO uint8_t TAAC; /*!< Data read access time 1 */ 00172 __IO uint8_t NSAC; /*!< Data read access time 2 in CLK cycles */ 00173 __IO uint8_t MaxBusClkFrec; /*!< Max. bus clock frequency */ 00174 __IO uint16_t CardComdClasses; /*!< Card command classes */ 00175 __IO uint8_t RdBlockLen; /*!< Max. read data block length */ 00176 __IO uint8_t PartBlockRead; /*!< Partial blocks for read allowed */ 00177 __IO uint8_t WrBlockMisalign; /*!< Write block misalignment */ 00178 __IO uint8_t RdBlockMisalign; /*!< Read block misalignment */ 00179 __IO uint8_t DSRImpl; /*!< DSR implemented */ 00180 __IO uint8_t Reserved2; /*!< Reserved */ 00181 __IO uint32_t DeviceSize; /*!< Device Size */ 00182 __IO uint8_t MaxRdCurrentVDDMin; /*!< Max. read current @ VDD min */ 00183 __IO uint8_t MaxRdCurrentVDDMax; /*!< Max. read current @ VDD max */ 00184 __IO uint8_t MaxWrCurrentVDDMin; /*!< Max. write current @ VDD min */ 00185 __IO uint8_t MaxWrCurrentVDDMax; /*!< Max. write current @ VDD max */ 00186 __IO uint8_t DeviceSizeMul; /*!< Device size multiplier */ 00187 __IO uint8_t EraseGrSize; /*!< Erase group size */ 00188 __IO uint8_t EraseGrMul; /*!< Erase group size multiplier */ 00189 __IO uint8_t WrProtectGrSize; /*!< Write protect group size */ 00190 __IO uint8_t WrProtectGrEnable; /*!< Write protect group enable */ 00191 __IO uint8_t ManDeflECC; /*!< Manufacturer default ECC */ 00192 __IO uint8_t WrSpeedFact; /*!< Write speed factor */ 00193 __IO uint8_t MaxWrBlockLen; /*!< Max. write data block length */ 00194 __IO uint8_t WriteBlockPaPartial; /*!< Partial blocks for write allowed */ 00195 __IO uint8_t Reserved3; /*!< Reserved */ 00196 __IO uint8_t ContentProtectAppli; /*!< Content protection application */ 00197 __IO uint8_t FileFormatGroup; /*!< File format group */ 00198 __IO uint8_t CopyFlag; /*!< Copy flag (OTP) */ 00199 __IO uint8_t PermWrProtect; /*!< Permanent write protection */ 00200 __IO uint8_t TempWrProtect; /*!< Temporary write protection */ 00201 __IO uint8_t FileFormat; /*!< File format */ 00202 __IO uint8_t ECC; /*!< ECC code */ 00203 __IO uint8_t CSD_CRC; /*!< CSD CRC */ 00204 __IO uint8_t Reserved4; /*!< Always 1 */ 00205 00206 }HAL_MMC_CardCSDTypeDef; 00207 /** 00208 * @} 00209 */ 00210 00211 /** @defgroup MMC_Exported_Types_Group5 Card Identification Data: CID Register 00212 * @{ 00213 */ 00214 typedef struct 00215 { 00216 __IO uint8_t ManufacturerID; /*!< Manufacturer ID */ 00217 __IO uint16_t OEM_AppliID; /*!< OEM/Application ID */ 00218 __IO uint32_t ProdName1; /*!< Product Name part1 */ 00219 __IO uint8_t ProdName2; /*!< Product Name part2 */ 00220 __IO uint8_t ProdRev; /*!< Product Revision */ 00221 __IO uint32_t ProdSN; /*!< Product Serial Number */ 00222 __IO uint8_t Reserved1; /*!< Reserved1 */ 00223 __IO uint16_t ManufactDate; /*!< Manufacturing Date */ 00224 __IO uint8_t CID_CRC; /*!< CID CRC */ 00225 __IO uint8_t Reserved2; /*!< Always 1 */ 00226 00227 }HAL_MMC_CardCIDTypeDef; 00228 /** 00229 * @} 00230 */ 00231 00232 #if defined (USE_HAL_MMC_REGISTER_CALLBACKS) && (USE_HAL_MMC_REGISTER_CALLBACKS == 1U) 00233 /** @defgroup MMC_Exported_Types_Group6 MMC Callback ID enumeration definition 00234 * @{ 00235 */ 00236 typedef enum 00237 { 00238 HAL_MMC_TX_CPLT_CB_ID = 0x00U, /*!< MMC Tx Complete Callback ID */ 00239 HAL_MMC_RX_CPLT_CB_ID = 0x01U, /*!< MMC Rx Complete Callback ID */ 00240 HAL_MMC_ERROR_CB_ID = 0x02U, /*!< MMC Error Callback ID */ 00241 HAL_MMC_ABORT_CB_ID = 0x03U, /*!< MMC Abort Callback ID */ 00242 00243 HAL_MMC_MSP_INIT_CB_ID = 0x10U, /*!< MMC MspInit Callback ID */ 00244 HAL_MMC_MSP_DEINIT_CB_ID = 0x11U /*!< MMC MspDeInit Callback ID */ 00245 }HAL_MMC_CallbackIDTypeDef; 00246 /** 00247 * @} 00248 */ 00249 00250 /** @defgroup MMC_Exported_Types_Group7 MMC Callback pointer definition 00251 * @{ 00252 */ 00253 typedef void (*pMMC_CallbackTypeDef) (MMC_HandleTypeDef *hmmc); 00254 /** 00255 * @} 00256 */ 00257 #endif 00258 /** 00259 * @} 00260 */ 00261 00262 /* Exported constants --------------------------------------------------------*/ 00263 /** @defgroup MMC_Exported_Constants Exported Constants 00264 * @{ 00265 */ 00266 00267 #define MMC_BLOCKSIZE 512U /*!< Block size is 512 bytes */ 00268 00269 /** @defgroup MMC_Exported_Constansts_Group1 MMC Error status enumeration Structure definition 00270 * @{ 00271 */ 00272 #define HAL_MMC_ERROR_NONE SDMMC_ERROR_NONE /*!< No error */ 00273 #define HAL_MMC_ERROR_CMD_CRC_FAIL SDMMC_ERROR_CMD_CRC_FAIL /*!< Command response received (but CRC check failed) */ 00274 #define HAL_MMC_ERROR_DATA_CRC_FAIL SDMMC_ERROR_DATA_CRC_FAIL /*!< Data block sent/received (CRC check failed) */ 00275 #define HAL_MMC_ERROR_CMD_RSP_TIMEOUT SDMMC_ERROR_CMD_RSP_TIMEOUT /*!< Command response timeout */ 00276 #define HAL_MMC_ERROR_DATA_TIMEOUT SDMMC_ERROR_DATA_TIMEOUT /*!< Data timeout */ 00277 #define HAL_MMC_ERROR_TX_UNDERRUN SDMMC_ERROR_TX_UNDERRUN /*!< Transmit FIFO underrun */ 00278 #define HAL_MMC_ERROR_RX_OVERRUN SDMMC_ERROR_RX_OVERRUN /*!< Receive FIFO overrun */ 00279 #define HAL_MMC_ERROR_ADDR_MISALIGNED SDMMC_ERROR_ADDR_MISALIGNED /*!< Misaligned address */ 00280 #define HAL_MMC_ERROR_BLOCK_LEN_ERR SDMMC_ERROR_BLOCK_LEN_ERR /*!< Transferred block length is not allowed for the card or the 00281 number of transferred bytes does not match the block length */ 00282 #define HAL_MMC_ERROR_ERASE_SEQ_ERR SDMMC_ERROR_ERASE_SEQ_ERR /*!< An error in the sequence of erase command occurs */ 00283 #define HAL_MMC_ERROR_BAD_ERASE_PARAM SDMMC_ERROR_BAD_ERASE_PARAM /*!< An invalid selection for erase groups */ 00284 #define HAL_MMC_ERROR_WRITE_PROT_VIOLATION SDMMC_ERROR_WRITE_PROT_VIOLATION /*!< Attempt to program a write protect block */ 00285 #define HAL_MMC_ERROR_LOCK_UNLOCK_FAILED SDMMC_ERROR_LOCK_UNLOCK_FAILED /*!< Sequence or password error has been detected in unlock 00286 command or if there was an attempt to access a locked card */ 00287 #define HAL_MMC_ERROR_COM_CRC_FAILED SDMMC_ERROR_COM_CRC_FAILED /*!< CRC check of the previous command failed */ 00288 #define HAL_MMC_ERROR_ILLEGAL_CMD SDMMC_ERROR_ILLEGAL_CMD /*!< Command is not legal for the card state */ 00289 #define HAL_MMC_ERROR_CARD_ECC_FAILED SDMMC_ERROR_CARD_ECC_FAILED /*!< Card internal ECC was applied but failed to correct the data */ 00290 #define HAL_MMC_ERROR_CC_ERR SDMMC_ERROR_CC_ERR /*!< Internal card controller error */ 00291 #define HAL_MMC_ERROR_GENERAL_UNKNOWN_ERR SDMMC_ERROR_GENERAL_UNKNOWN_ERR /*!< General or unknown error */ 00292 #define HAL_MMC_ERROR_STREAM_READ_UNDERRUN SDMMC_ERROR_STREAM_READ_UNDERRUN /*!< The card could not sustain data reading in stream rmode */ 00293 #define HAL_MMC_ERROR_STREAM_WRITE_OVERRUN SDMMC_ERROR_STREAM_WRITE_OVERRUN /*!< The card could not sustain data programming in stream mode */ 00294 #define HAL_MMC_ERROR_CID_CSD_OVERWRITE SDMMC_ERROR_CID_CSD_OVERWRITE /*!< CID/CSD overwrite error */ 00295 #define HAL_MMC_ERROR_WP_ERASE_SKIP SDMMC_ERROR_WP_ERASE_SKIP /*!< Only partial address space was erased */ 00296 #define HAL_MMC_ERROR_CARD_ECC_DISABLED SDMMC_ERROR_CARD_ECC_DISABLED /*!< Command has been executed without using internal ECC */ 00297 #define HAL_MMC_ERROR_ERASE_RESET SDMMC_ERROR_ERASE_RESET /*!< Erase sequence was cleared before executing because an out 00298 of erase sequence command was received */ 00299 #define HAL_MMC_ERROR_AKE_SEQ_ERR SDMMC_ERROR_AKE_SEQ_ERR /*!< Error in sequence of authentication */ 00300 #define HAL_MMC_ERROR_INVALID_VOLTRANGE SDMMC_ERROR_INVALID_VOLTRANGE /*!< Error in case of invalid voltage range */ 00301 #define HAL_MMC_ERROR_ADDR_OUT_OF_RANGE SDMMC_ERROR_ADDR_OUT_OF_RANGE /*!< Error when addressed block is out of range */ 00302 #define HAL_MMC_ERROR_REQUEST_NOT_APPLICABLE SDMMC_ERROR_REQUEST_NOT_APPLICABLE /*!< Error when command request is not applicable */ 00303 #define HAL_MMC_ERROR_PARAM SDMMC_ERROR_INVALID_PARAMETER /*!< the used parameter is not valid */ 00304 #define HAL_MMC_ERROR_UNSUPPORTED_FEATURE SDMMC_ERROR_UNSUPPORTED_FEATURE /*!< Error when feature is not insupported */ 00305 #define HAL_MMC_ERROR_BUSY SDMMC_ERROR_BUSY /*!< Error when transfer process is busy */ 00306 #define HAL_MMC_ERROR_DMA SDMMC_ERROR_DMA /*!< Error while DMA transfer */ 00307 #define HAL_MMC_ERROR_TIMEOUT SDMMC_ERROR_TIMEOUT /*!< Timeout error */ 00308 00309 #if defined (USE_HAL_MMC_REGISTER_CALLBACKS) && (USE_HAL_MMC_REGISTER_CALLBACKS == 1U) 00310 #define HAL_MMC_ERROR_INVALID_CALLBACK SDMMC_ERROR_INVALID_PARAMETER /*!< Invalid callback error */ 00311 #endif 00312 /** 00313 * @} 00314 */ 00315 00316 /** @defgroup MMC_Exported_Constansts_Group2 MMC context enumeration 00317 * @{ 00318 */ 00319 #define MMC_CONTEXT_NONE 0x00000000U /*!< None */ 00320 #define MMC_CONTEXT_READ_SINGLE_BLOCK 0x00000001U /*!< Read single block operation */ 00321 #define MMC_CONTEXT_READ_MULTIPLE_BLOCK 0x00000002U /*!< Read multiple blocks operation */ 00322 #define MMC_CONTEXT_WRITE_SINGLE_BLOCK 0x00000010U /*!< Write single block operation */ 00323 #define MMC_CONTEXT_WRITE_MULTIPLE_BLOCK 0x00000020U /*!< Write multiple blocks operation */ 00324 #define MMC_CONTEXT_IT 0x00000008U /*!< Process in Interrupt mode */ 00325 #define MMC_CONTEXT_DMA 0x00000080U /*!< Process in DMA mode */ 00326 00327 /** 00328 * @} 00329 */ 00330 00331 /** @defgroup MMC_Exported_Constansts_Group3 MMC Voltage mode 00332 * @{ 00333 */ 00334 /** 00335 * @brief 00336 */ 00337 #define MMC_HIGH_VOLTAGE_RANGE 0x80FF8000U /*!< VALUE OF ARGUMENT */ 00338 #define MMC_DUAL_VOLTAGE_RANGE 0x80FF8080U /*!< VALUE OF ARGUMENT */ 00339 #define eMMC_HIGH_VOLTAGE_RANGE 0xC0FF8000U /*!< for eMMC > 2Gb sector mode */ 00340 #define eMMC_DUAL_VOLTAGE_RANGE 0xC0FF8080U /*!< for eMMC > 2Gb sector mode */ 00341 #define MMC_INVALID_VOLTAGE_RANGE 0x0001FF01U 00342 /** 00343 * @} 00344 */ 00345 00346 /** @defgroup MMC_Exported_Constansts_Group4 MMC Memory Cards 00347 * @{ 00348 */ 00349 #define MMC_LOW_CAPACITY_CARD 0x00000000U /*!< MMC Card Capacity <=2Gbytes */ 00350 #define MMC_HIGH_CAPACITY_CARD 0x00000001U /*!< MMC Card Capacity >2Gbytes and <2Tbytes */ 00351 00352 /** 00353 * @} 00354 */ 00355 00356 /** 00357 * @} 00358 */ 00359 00360 /* Exported macro ------------------------------------------------------------*/ 00361 /** @defgroup MMC_Exported_macros MMC Exported Macros 00362 * @brief macros to handle interrupts and specific clock configurations 00363 * @{ 00364 */ 00365 /** @brief Reset MMC handle state. 00366 * @param __HANDLE__ : MMC handle. 00367 * @retval None 00368 */ 00369 #if defined (USE_HAL_MMC_REGISTER_CALLBACKS) && (USE_HAL_MMC_REGISTER_CALLBACKS == 1U) 00370 #define __HAL_MMC_RESET_HANDLE_STATE(__HANDLE__) do { \ 00371 (__HANDLE__)->State = HAL_MMC_STATE_RESET; \ 00372 (__HANDLE__)->MspInitCallback = NULL; \ 00373 (__HANDLE__)->MspDeInitCallback = NULL; \ 00374 } while(0) 00375 #else 00376 #define __HAL_MMC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_MMC_STATE_RESET) 00377 #endif 00378 00379 /** 00380 * @brief Enable the MMC device. 00381 * @retval None 00382 */ 00383 #define __HAL_MMC_ENABLE(__HANDLE__) __SDIO_ENABLE((__HANDLE__)->Instance) 00384 00385 /** 00386 * @brief Disable the MMC device. 00387 * @retval None 00388 */ 00389 #define __HAL_MMC_DISABLE(__HANDLE__) __SDIO_DISABLE((__HANDLE__)->Instance) 00390 00391 /** 00392 * @brief Enable the SDMMC DMA transfer. 00393 * @retval None 00394 */ 00395 #define __HAL_MMC_DMA_ENABLE(__HANDLE__) __SDIO_DMA_ENABLE((__HANDLE__)->Instance) 00396 00397 /** 00398 * @brief Disable the SDMMC DMA transfer. 00399 * @retval None 00400 */ 00401 #define __HAL_MMC_DMA_DISABLE(__HANDLE__) __SDIO_DMA_DISABLE((__HANDLE__)->Instance) 00402 00403 /** 00404 * @brief Enable the MMC device interrupt. 00405 * @param __HANDLE__: MMC Handle 00406 * @param __INTERRUPT__: specifies the SDMMC interrupt sources to be enabled. 00407 * This parameter can be one or a combination of the following values: 00408 * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt 00409 * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt 00410 * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt 00411 * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt 00412 * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt 00413 * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt 00414 * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt 00415 * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt 00416 * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt 00417 * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt 00418 * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt 00419 * @arg SDIO_IT_TXACT: Data transmit in progress interrupt 00420 * @arg SDIO_IT_RXACT: Data receive in progress interrupt 00421 * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt 00422 * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt 00423 * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt 00424 * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt 00425 * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt 00426 * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt 00427 * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt 00428 * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt 00429 * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt 00430 * @retval None 00431 */ 00432 #define __HAL_MMC_ENABLE_IT(__HANDLE__, __INTERRUPT__) __SDIO_ENABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__)) 00433 00434 /** 00435 * @brief Disable the MMC device interrupt. 00436 * @param __HANDLE__: MMC Handle 00437 * @param __INTERRUPT__: specifies the SDMMC interrupt sources to be disabled. 00438 * This parameter can be one or a combination of the following values: 00439 * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt 00440 * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt 00441 * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt 00442 * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt 00443 * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt 00444 * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt 00445 * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt 00446 * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt 00447 * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt 00448 * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt 00449 * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt 00450 * @arg SDIO_IT_TXACT: Data transmit in progress interrupt 00451 * @arg SDIO_IT_RXACT: Data receive in progress interrupt 00452 * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt 00453 * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt 00454 * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt 00455 * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt 00456 * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt 00457 * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt 00458 * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt 00459 * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt 00460 * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt 00461 * @retval None 00462 */ 00463 #define __HAL_MMC_DISABLE_IT(__HANDLE__, __INTERRUPT__) __SDIO_DISABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__)) 00464 00465 /** 00466 * @brief Check whether the specified MMC flag is set or not. 00467 * @param __HANDLE__: MMC Handle 00468 * @param __FLAG__: specifies the flag to check. 00469 * This parameter can be one of the following values: 00470 * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed) 00471 * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) 00472 * @arg SDIO_FLAG_CTIMEOUT: Command response timeout 00473 * @arg SDIO_FLAG_DTIMEOUT: Data timeout 00474 * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error 00475 * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error 00476 * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed) 00477 * @arg SDIO_FLAG_CMDSENT: Command sent (no response required) 00478 * @arg SDIO_FLAG_DATAEND: Data end (data counter, DATACOUNT, is zero) 00479 * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed) 00480 * @arg SDIO_FLAG_CMDACT: Command transfer in progress 00481 * @arg SDIO_FLAG_TXACT: Data transmit in progress 00482 * @arg SDIO_FLAG_RXACT: Data receive in progress 00483 * @arg SDIO_FLAG_TXFIFOHE: Transmit FIFO Half Empty 00484 * @arg SDIO_FLAG_RXFIFOHF: Receive FIFO Half Full 00485 * @arg SDIO_FLAG_TXFIFOF: Transmit FIFO full 00486 * @arg SDIO_FLAG_RXFIFOF: Receive FIFO full 00487 * @arg SDIO_FLAG_TXFIFOE: Transmit FIFO empty 00488 * @arg SDIO_FLAG_RXFIFOE: Receive FIFO empty 00489 * @arg SDIO_FLAG_TXDAVL: Data available in transmit FIFO 00490 * @arg SDIO_FLAG_RXDAVL: Data available in receive FIFO 00491 * @arg SDIO_FLAG_SDIOIT: SD I/O interrupt received 00492 * @retval The new state of MMC FLAG (SET or RESET). 00493 */ 00494 #define __HAL_MMC_GET_FLAG(__HANDLE__, __FLAG__) __SDIO_GET_FLAG((__HANDLE__)->Instance, (__FLAG__)) 00495 00496 /** 00497 * @brief Clear the MMC's pending flags. 00498 * @param __HANDLE__: MMC Handle 00499 * @param __FLAG__: specifies the flag to clear. 00500 * This parameter can be one or a combination of the following values: 00501 * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed) 00502 * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) 00503 * @arg SDIO_FLAG_CTIMEOUT: Command response timeout 00504 * @arg SDIO_FLAG_DTIMEOUT: Data timeout 00505 * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error 00506 * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error 00507 * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed) 00508 * @arg SDIO_FLAG_CMDSENT: Command sent (no response required) 00509 * @arg SDIO_FLAG_DATAEND: Data end (data counter, DATACOUNT, is zero) 00510 * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed) 00511 * @arg SDIO_FLAG_SDIOIT: SD I/O interrupt received 00512 * @retval None 00513 */ 00514 #define __HAL_MMC_CLEAR_FLAG(__HANDLE__, __FLAG__) __SDIO_CLEAR_FLAG((__HANDLE__)->Instance, (__FLAG__)) 00515 00516 /** 00517 * @brief Check whether the specified MMC interrupt has occurred or not. 00518 * @param __HANDLE__: MMC Handle 00519 * @param __INTERRUPT__: specifies the SDMMC interrupt source to check. 00520 * This parameter can be one of the following values: 00521 * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt 00522 * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt 00523 * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt 00524 * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt 00525 * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt 00526 * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt 00527 * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt 00528 * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt 00529 * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt 00530 * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt 00531 * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt 00532 * @arg SDIO_IT_TXACT: Data transmit in progress interrupt 00533 * @arg SDIO_IT_RXACT: Data receive in progress interrupt 00534 * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt 00535 * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt 00536 * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt 00537 * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt 00538 * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt 00539 * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt 00540 * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt 00541 * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt 00542 * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt 00543 * @retval The new state of MMC IT (SET or RESET). 00544 */ 00545 #define __HAL_MMC_GET_IT(__HANDLE__, __INTERRUPT__) __SDIO_GET_IT((__HANDLE__)->Instance, (__INTERRUPT__)) 00546 00547 /** 00548 * @brief Clear the MMC's interrupt pending bits. 00549 * @param __HANDLE__: MMC Handle 00550 * @param __INTERRUPT__: specifies the interrupt pending bit to clear. 00551 * This parameter can be one or a combination of the following values: 00552 * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt 00553 * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt 00554 * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt 00555 * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt 00556 * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt 00557 * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt 00558 * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt 00559 * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt 00560 * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt 00561 * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt 00562 * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt 00563 * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt 00564 * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt 00565 * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt 00566 * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt 00567 * @retval None 00568 */ 00569 #define __HAL_MMC_CLEAR_IT(__HANDLE__, __INTERRUPT__) __SDIO_CLEAR_IT((__HANDLE__)->Instance, (__INTERRUPT__)) 00570 00571 /** 00572 * @} 00573 */ 00574 00575 /* Exported functions --------------------------------------------------------*/ 00576 /** @defgroup MMC_Exported_Functions MMC Exported Functions 00577 * @{ 00578 */ 00579 00580 /** @defgroup MMC_Exported_Functions_Group1 Initialization and de-initialization functions 00581 * @{ 00582 */ 00583 HAL_StatusTypeDef HAL_MMC_Init(MMC_HandleTypeDef *hmmc); 00584 HAL_StatusTypeDef HAL_MMC_InitCard(MMC_HandleTypeDef *hmmc); 00585 HAL_StatusTypeDef HAL_MMC_DeInit (MMC_HandleTypeDef *hmmc); 00586 void HAL_MMC_MspInit(MMC_HandleTypeDef *hmmc); 00587 void HAL_MMC_MspDeInit(MMC_HandleTypeDef *hmmc); 00588 00589 /** 00590 * @} 00591 */ 00592 00593 /** @defgroup MMC_Exported_Functions_Group2 Input and Output operation functions 00594 * @{ 00595 */ 00596 /* Blocking mode: Polling */ 00597 HAL_StatusTypeDef HAL_MMC_ReadBlocks(MMC_HandleTypeDef *hmmc, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout); 00598 HAL_StatusTypeDef HAL_MMC_WriteBlocks(MMC_HandleTypeDef *hmmc, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout); 00599 HAL_StatusTypeDef HAL_MMC_Erase(MMC_HandleTypeDef *hmmc, uint32_t BlockStartAdd, uint32_t BlockEndAdd); 00600 /* Non-Blocking mode: IT */ 00601 HAL_StatusTypeDef HAL_MMC_ReadBlocks_IT(MMC_HandleTypeDef *hmmc, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks); 00602 HAL_StatusTypeDef HAL_MMC_WriteBlocks_IT(MMC_HandleTypeDef *hmmc, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks); 00603 /* Non-Blocking mode: DMA */ 00604 HAL_StatusTypeDef HAL_MMC_ReadBlocks_DMA(MMC_HandleTypeDef *hmmc, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks); 00605 HAL_StatusTypeDef HAL_MMC_WriteBlocks_DMA(MMC_HandleTypeDef *hmmc, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks); 00606 00607 void HAL_MMC_IRQHandler(MMC_HandleTypeDef *hmmc); 00608 00609 /* Callback in non blocking modes (DMA) */ 00610 void HAL_MMC_TxCpltCallback(MMC_HandleTypeDef *hmmc); 00611 void HAL_MMC_RxCpltCallback(MMC_HandleTypeDef *hmmc); 00612 void HAL_MMC_ErrorCallback(MMC_HandleTypeDef *hmmc); 00613 void HAL_MMC_AbortCallback(MMC_HandleTypeDef *hmmc); 00614 00615 #if defined (USE_HAL_MMC_REGISTER_CALLBACKS) && (USE_HAL_MMC_REGISTER_CALLBACKS == 1U) 00616 /* MMC callback registering/unregistering */ 00617 HAL_StatusTypeDef HAL_MMC_RegisterCallback (MMC_HandleTypeDef *hmmc, HAL_MMC_CallbackIDTypeDef CallbackId, pMMC_CallbackTypeDef pCallback); 00618 HAL_StatusTypeDef HAL_MMC_UnRegisterCallback(MMC_HandleTypeDef *hmmc, HAL_MMC_CallbackIDTypeDef CallbackId); 00619 #endif 00620 /** 00621 * @} 00622 */ 00623 00624 /** @defgroup MMC_Exported_Functions_Group3 Peripheral Control functions 00625 * @{ 00626 */ 00627 HAL_StatusTypeDef HAL_MMC_ConfigWideBusOperation(MMC_HandleTypeDef *hmmc, uint32_t WideMode); 00628 /** 00629 * @} 00630 */ 00631 00632 /** @defgroup MMC_Exported_Functions_Group4 MMC card related functions 00633 * @{ 00634 */ 00635 HAL_MMC_CardStateTypeDef HAL_MMC_GetCardState(MMC_HandleTypeDef *hmmc); 00636 HAL_StatusTypeDef HAL_MMC_GetCardCID(MMC_HandleTypeDef *hmmc, HAL_MMC_CardCIDTypeDef *pCID); 00637 HAL_StatusTypeDef HAL_MMC_GetCardCSD(MMC_HandleTypeDef *hmmc, HAL_MMC_CardCSDTypeDef *pCSD); 00638 HAL_StatusTypeDef HAL_MMC_GetCardInfo(MMC_HandleTypeDef *hmmc, HAL_MMC_CardInfoTypeDef *pCardInfo); 00639 /** 00640 * @} 00641 */ 00642 00643 /** @defgroup MMC_Exported_Functions_Group5 Peripheral State and Errors functions 00644 * @{ 00645 */ 00646 HAL_MMC_StateTypeDef HAL_MMC_GetState(MMC_HandleTypeDef *hmmc); 00647 uint32_t HAL_MMC_GetError(MMC_HandleTypeDef *hmmc); 00648 /** 00649 * @} 00650 */ 00651 00652 /** @defgroup MMC_Exported_Functions_Group6 Perioheral Abort management 00653 * @{ 00654 */ 00655 HAL_StatusTypeDef HAL_MMC_Abort(MMC_HandleTypeDef *hmmc); 00656 HAL_StatusTypeDef HAL_MMC_Abort_IT(MMC_HandleTypeDef *hmmc); 00657 /** 00658 * @} 00659 */ 00660 00661 /* Private types -------------------------------------------------------------*/ 00662 /** @defgroup MMC_Private_Types MMC Private Types 00663 * @{ 00664 */ 00665 00666 /** 00667 * @} 00668 */ 00669 00670 /* Private defines -----------------------------------------------------------*/ 00671 /** @defgroup MMC_Private_Defines MMC Private Defines 00672 * @{ 00673 */ 00674 00675 /** 00676 * @} 00677 */ 00678 00679 /* Private variables ---------------------------------------------------------*/ 00680 /** @defgroup MMC_Private_Variables MMC Private Variables 00681 * @{ 00682 */ 00683 00684 /** 00685 * @} 00686 */ 00687 00688 /* Private constants ---------------------------------------------------------*/ 00689 /** @defgroup MMC_Private_Constants MMC Private Constants 00690 * @{ 00691 */ 00692 00693 /** 00694 * @} 00695 */ 00696 00697 /* Private macros ------------------------------------------------------------*/ 00698 /** @defgroup MMC_Private_Macros MMC Private Macros 00699 * @{ 00700 */ 00701 00702 /** 00703 * @} 00704 */ 00705 00706 /* Private functions prototypes ----------------------------------------------*/ 00707 /** @defgroup MMC_Private_Functions_Prototypes MMC Private Functions Prototypes 00708 * @{ 00709 */ 00710 00711 /** 00712 * @} 00713 */ 00714 00715 /* Private functions ---------------------------------------------------------*/ 00716 /** @defgroup MMC_Private_Functions MMC Private Functions 00717 * @{ 00718 */ 00719 00720 /** 00721 * @} 00722 */ 00723 00724 00725 /** 00726 * @} 00727 */ 00728 00729 /** 00730 * @} 00731 */ 00732 00733 /** 00734 * @} 00735 */ 00736 00737 #ifdef __cplusplus 00738 } 00739 #endif 00740 00741 #endif /* SDIO */ 00742 00743 #endif /* STM32F1xx_HAL_MMC_H */ 00744 00745 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/