mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
shaoziyang
Date:
Sat Sep 13 14:25:46 2014 +0000
Revision:
323:9e901b0a5aa1
Parent:
235:685d5f11838f
test with CLOCK_SETUP = 0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 235:685d5f11838f 1 /**
mbed_official 235:685d5f11838f 2 ******************************************************************************
mbed_official 235:685d5f11838f 3 * @file stm32f4xx_hal_sd.h
mbed_official 235:685d5f11838f 4 * @author MCD Application Team
mbed_official 235:685d5f11838f 5 * @version V1.1.0
mbed_official 235:685d5f11838f 6 * @date 19-June-2014
mbed_official 235:685d5f11838f 7 * @brief Header file of SD HAL module.
mbed_official 235:685d5f11838f 8 ******************************************************************************
mbed_official 235:685d5f11838f 9 * @attention
mbed_official 235:685d5f11838f 10 *
mbed_official 235:685d5f11838f 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 235:685d5f11838f 12 *
mbed_official 235:685d5f11838f 13 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 235:685d5f11838f 14 * are permitted provided that the following conditions are met:
mbed_official 235:685d5f11838f 15 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 235:685d5f11838f 16 * this list of conditions and the following disclaimer.
mbed_official 235:685d5f11838f 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 235:685d5f11838f 18 * this list of conditions and the following disclaimer in the documentation
mbed_official 235:685d5f11838f 19 * and/or other materials provided with the distribution.
mbed_official 235:685d5f11838f 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 235:685d5f11838f 21 * may be used to endorse or promote products derived from this software
mbed_official 235:685d5f11838f 22 * without specific prior written permission.
mbed_official 235:685d5f11838f 23 *
mbed_official 235:685d5f11838f 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 235:685d5f11838f 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 235:685d5f11838f 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 235:685d5f11838f 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 235:685d5f11838f 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 235:685d5f11838f 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 235:685d5f11838f 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 235:685d5f11838f 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 235:685d5f11838f 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 235:685d5f11838f 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 235:685d5f11838f 34 *
mbed_official 235:685d5f11838f 35 ******************************************************************************
mbed_official 235:685d5f11838f 36 */
mbed_official 235:685d5f11838f 37
mbed_official 235:685d5f11838f 38 /* Define to prevent recursive inclusion -------------------------------------*/
mbed_official 235:685d5f11838f 39 #ifndef __STM32F4xx_HAL_SD_H
mbed_official 235:685d5f11838f 40 #define __STM32F4xx_HAL_SD_H
mbed_official 235:685d5f11838f 41
mbed_official 235:685d5f11838f 42 #ifdef __cplusplus
mbed_official 235:685d5f11838f 43 extern "C" {
mbed_official 235:685d5f11838f 44 #endif
mbed_official 235:685d5f11838f 45
mbed_official 235:685d5f11838f 46 /* Includes ------------------------------------------------------------------*/
mbed_official 235:685d5f11838f 47 #include "stm32f4xx_ll_sdmmc.h"
mbed_official 235:685d5f11838f 48
mbed_official 235:685d5f11838f 49 /** @addtogroup STM32F4xx_HAL_Driver
mbed_official 235:685d5f11838f 50 * @{
mbed_official 235:685d5f11838f 51 */
mbed_official 235:685d5f11838f 52
mbed_official 235:685d5f11838f 53 /** @addtogroup SD
mbed_official 235:685d5f11838f 54 * @{
mbed_official 235:685d5f11838f 55 */
mbed_official 235:685d5f11838f 56
mbed_official 235:685d5f11838f 57 /* Exported types ------------------------------------------------------------*/
mbed_official 235:685d5f11838f 58 /** @defgroup SD_Exported_Types
mbed_official 235:685d5f11838f 59 * @{
mbed_official 235:685d5f11838f 60 */
mbed_official 235:685d5f11838f 61 #define SD_InitTypeDef SDIO_InitTypeDef
mbed_official 235:685d5f11838f 62 #define SD_TypeDef SDIO_TypeDef
mbed_official 235:685d5f11838f 63
mbed_official 235:685d5f11838f 64 /**
mbed_official 235:685d5f11838f 65 * @brief SDIO Handle Structure definition
mbed_official 235:685d5f11838f 66 */
mbed_official 235:685d5f11838f 67 typedef struct
mbed_official 235:685d5f11838f 68 {
mbed_official 235:685d5f11838f 69 SD_TypeDef *Instance; /*!< SDIO register base address */
mbed_official 235:685d5f11838f 70
mbed_official 235:685d5f11838f 71 SD_InitTypeDef Init; /*!< SD required parameters */
mbed_official 235:685d5f11838f 72
mbed_official 235:685d5f11838f 73 HAL_LockTypeDef Lock; /*!< SD locking object */
mbed_official 235:685d5f11838f 74
mbed_official 235:685d5f11838f 75 uint32_t CardType; /*!< SD card type */
mbed_official 235:685d5f11838f 76
mbed_official 235:685d5f11838f 77 uint32_t RCA; /*!< SD relative card address */
mbed_official 235:685d5f11838f 78
mbed_official 235:685d5f11838f 79 uint32_t CSD[4]; /*!< SD card specific data table */
mbed_official 235:685d5f11838f 80
mbed_official 235:685d5f11838f 81 uint32_t CID[4]; /*!< SD card identification number table */
mbed_official 235:685d5f11838f 82
mbed_official 235:685d5f11838f 83 __IO uint32_t SdTransferCplt; /*!< SD transfer complete flag in non blocking mode */
mbed_official 235:685d5f11838f 84
mbed_official 235:685d5f11838f 85 __IO uint32_t SdTransferErr; /*!< SD transfer error flag in non blocking mode */
mbed_official 235:685d5f11838f 86
mbed_official 235:685d5f11838f 87 __IO uint32_t DmaTransferCplt; /*!< SD DMA transfer complete flag */
mbed_official 235:685d5f11838f 88
mbed_official 235:685d5f11838f 89 __IO uint32_t SdOperation; /*!< SD transfer operation (read/write) */
mbed_official 235:685d5f11838f 90
mbed_official 235:685d5f11838f 91 DMA_HandleTypeDef *hdmarx; /*!< SD Rx DMA handle parameters */
mbed_official 235:685d5f11838f 92
mbed_official 235:685d5f11838f 93 DMA_HandleTypeDef *hdmatx; /*!< SD Tx DMA handle parameters */
mbed_official 235:685d5f11838f 94
mbed_official 235:685d5f11838f 95 }SD_HandleTypeDef;
mbed_official 235:685d5f11838f 96
mbed_official 235:685d5f11838f 97 /**
mbed_official 235:685d5f11838f 98 * @brief Card Specific Data: CSD Register
mbed_official 235:685d5f11838f 99 */
mbed_official 235:685d5f11838f 100 typedef struct
mbed_official 235:685d5f11838f 101 {
mbed_official 235:685d5f11838f 102 __IO uint8_t CSDStruct; /*!< CSD structure */
mbed_official 235:685d5f11838f 103 __IO uint8_t SysSpecVersion; /*!< System specification version */
mbed_official 235:685d5f11838f 104 __IO uint8_t Reserved1; /*!< Reserved */
mbed_official 235:685d5f11838f 105 __IO uint8_t TAAC; /*!< Data read access time 1 */
mbed_official 235:685d5f11838f 106 __IO uint8_t NSAC; /*!< Data read access time 2 in CLK cycles */
mbed_official 235:685d5f11838f 107 __IO uint8_t MaxBusClkFrec; /*!< Max. bus clock frequency */
mbed_official 235:685d5f11838f 108 __IO uint16_t CardComdClasses; /*!< Card command classes */
mbed_official 235:685d5f11838f 109 __IO uint8_t RdBlockLen; /*!< Max. read data block length */
mbed_official 235:685d5f11838f 110 __IO uint8_t PartBlockRead; /*!< Partial blocks for read allowed */
mbed_official 235:685d5f11838f 111 __IO uint8_t WrBlockMisalign; /*!< Write block misalignment */
mbed_official 235:685d5f11838f 112 __IO uint8_t RdBlockMisalign; /*!< Read block misalignment */
mbed_official 235:685d5f11838f 113 __IO uint8_t DSRImpl; /*!< DSR implemented */
mbed_official 235:685d5f11838f 114 __IO uint8_t Reserved2; /*!< Reserved */
mbed_official 235:685d5f11838f 115 __IO uint32_t DeviceSize; /*!< Device Size */
mbed_official 235:685d5f11838f 116 __IO uint8_t MaxRdCurrentVDDMin; /*!< Max. read current @ VDD min */
mbed_official 235:685d5f11838f 117 __IO uint8_t MaxRdCurrentVDDMax; /*!< Max. read current @ VDD max */
mbed_official 235:685d5f11838f 118 __IO uint8_t MaxWrCurrentVDDMin; /*!< Max. write current @ VDD min */
mbed_official 235:685d5f11838f 119 __IO uint8_t MaxWrCurrentVDDMax; /*!< Max. write current @ VDD max */
mbed_official 235:685d5f11838f 120 __IO uint8_t DeviceSizeMul; /*!< Device size multiplier */
mbed_official 235:685d5f11838f 121 __IO uint8_t EraseGrSize; /*!< Erase group size */
mbed_official 235:685d5f11838f 122 __IO uint8_t EraseGrMul; /*!< Erase group size multiplier */
mbed_official 235:685d5f11838f 123 __IO uint8_t WrProtectGrSize; /*!< Write protect group size */
mbed_official 235:685d5f11838f 124 __IO uint8_t WrProtectGrEnable; /*!< Write protect group enable */
mbed_official 235:685d5f11838f 125 __IO uint8_t ManDeflECC; /*!< Manufacturer default ECC */
mbed_official 235:685d5f11838f 126 __IO uint8_t WrSpeedFact; /*!< Write speed factor */
mbed_official 235:685d5f11838f 127 __IO uint8_t MaxWrBlockLen; /*!< Max. write data block length */
mbed_official 235:685d5f11838f 128 __IO uint8_t WriteBlockPaPartial; /*!< Partial blocks for write allowed */
mbed_official 235:685d5f11838f 129 __IO uint8_t Reserved3; /*!< Reserved */
mbed_official 235:685d5f11838f 130 __IO uint8_t ContentProtectAppli; /*!< Content protection application */
mbed_official 235:685d5f11838f 131 __IO uint8_t FileFormatGrouop; /*!< File format group */
mbed_official 235:685d5f11838f 132 __IO uint8_t CopyFlag; /*!< Copy flag (OTP) */
mbed_official 235:685d5f11838f 133 __IO uint8_t PermWrProtect; /*!< Permanent write protection */
mbed_official 235:685d5f11838f 134 __IO uint8_t TempWrProtect; /*!< Temporary write protection */
mbed_official 235:685d5f11838f 135 __IO uint8_t FileFormat; /*!< File format */
mbed_official 235:685d5f11838f 136 __IO uint8_t ECC; /*!< ECC code */
mbed_official 235:685d5f11838f 137 __IO uint8_t CSD_CRC; /*!< CSD CRC */
mbed_official 235:685d5f11838f 138 __IO uint8_t Reserved4; /*!< Always 1 */
mbed_official 235:685d5f11838f 139
mbed_official 235:685d5f11838f 140 }HAL_SD_CSDTypedef;
mbed_official 235:685d5f11838f 141
mbed_official 235:685d5f11838f 142 /**
mbed_official 235:685d5f11838f 143 * @brief Card Identification Data: CID Register
mbed_official 235:685d5f11838f 144 */
mbed_official 235:685d5f11838f 145 typedef struct
mbed_official 235:685d5f11838f 146 {
mbed_official 235:685d5f11838f 147 __IO uint8_t ManufacturerID; /*!< Manufacturer ID */
mbed_official 235:685d5f11838f 148 __IO uint16_t OEM_AppliID; /*!< OEM/Application ID */
mbed_official 235:685d5f11838f 149 __IO uint32_t ProdName1; /*!< Product Name part1 */
mbed_official 235:685d5f11838f 150 __IO uint8_t ProdName2; /*!< Product Name part2 */
mbed_official 235:685d5f11838f 151 __IO uint8_t ProdRev; /*!< Product Revision */
mbed_official 235:685d5f11838f 152 __IO uint32_t ProdSN; /*!< Product Serial Number */
mbed_official 235:685d5f11838f 153 __IO uint8_t Reserved1; /*!< Reserved1 */
mbed_official 235:685d5f11838f 154 __IO uint16_t ManufactDate; /*!< Manufacturing Date */
mbed_official 235:685d5f11838f 155 __IO uint8_t CID_CRC; /*!< CID CRC */
mbed_official 235:685d5f11838f 156 __IO uint8_t Reserved2; /*!< Always 1 */
mbed_official 235:685d5f11838f 157
mbed_official 235:685d5f11838f 158 }HAL_SD_CIDTypedef;
mbed_official 235:685d5f11838f 159
mbed_official 235:685d5f11838f 160 /**
mbed_official 235:685d5f11838f 161 * @brief SD Card Status returned by ACMD13
mbed_official 235:685d5f11838f 162 */
mbed_official 235:685d5f11838f 163 typedef struct
mbed_official 235:685d5f11838f 164 {
mbed_official 235:685d5f11838f 165 __IO uint8_t DAT_BUS_WIDTH; /*!< Shows the currently defined data bus width */
mbed_official 235:685d5f11838f 166 __IO uint8_t SECURED_MODE; /*!< Card is in secured mode of operation */
mbed_official 235:685d5f11838f 167 __IO uint16_t SD_CARD_TYPE; /*!< Carries information about card type */
mbed_official 235:685d5f11838f 168 __IO uint32_t SIZE_OF_PROTECTED_AREA; /*!< Carries information about the capacity of protected area */
mbed_official 235:685d5f11838f 169 __IO uint8_t SPEED_CLASS; /*!< Carries information about the speed class of the card */
mbed_official 235:685d5f11838f 170 __IO uint8_t PERFORMANCE_MOVE; /*!< Carries information about the card's performance move */
mbed_official 235:685d5f11838f 171 __IO uint8_t AU_SIZE; /*!< Carries information about the card's allocation unit size */
mbed_official 235:685d5f11838f 172 __IO uint16_t ERASE_SIZE; /*!< Determines the number of AUs to be erased in one operation */
mbed_official 235:685d5f11838f 173 __IO uint8_t ERASE_TIMEOUT; /*!< Determines the timeout for any number of AU erase */
mbed_official 235:685d5f11838f 174 __IO uint8_t ERASE_OFFSET; /*!< Carries information about the erase offset */
mbed_official 235:685d5f11838f 175
mbed_official 235:685d5f11838f 176 }HAL_SD_CardStatusTypedef;
mbed_official 235:685d5f11838f 177
mbed_official 235:685d5f11838f 178 /**
mbed_official 235:685d5f11838f 179 * @brief SD Card information structure
mbed_official 235:685d5f11838f 180 */
mbed_official 235:685d5f11838f 181 typedef struct
mbed_official 235:685d5f11838f 182 {
mbed_official 235:685d5f11838f 183 HAL_SD_CSDTypedef SD_csd; /*!< SD card specific data register */
mbed_official 235:685d5f11838f 184 HAL_SD_CIDTypedef SD_cid; /*!< SD card identification number register */
mbed_official 235:685d5f11838f 185 uint64_t CardCapacity; /*!< Card capacity */
mbed_official 235:685d5f11838f 186 uint32_t CardBlockSize; /*!< Card block size */
mbed_official 235:685d5f11838f 187 uint16_t RCA; /*!< SD relative card address */
mbed_official 235:685d5f11838f 188 uint8_t CardType; /*!< SD card type */
mbed_official 235:685d5f11838f 189
mbed_official 235:685d5f11838f 190 }HAL_SD_CardInfoTypedef;
mbed_official 235:685d5f11838f 191
mbed_official 235:685d5f11838f 192 /**
mbed_official 235:685d5f11838f 193 * @brief SD Error status enumeration Structure definition
mbed_official 235:685d5f11838f 194 */
mbed_official 235:685d5f11838f 195 typedef enum
mbed_official 235:685d5f11838f 196 {
mbed_official 235:685d5f11838f 197 /**
mbed_official 235:685d5f11838f 198 * @brief SD specific error defines
mbed_official 235:685d5f11838f 199 */
mbed_official 235:685d5f11838f 200 SD_CMD_CRC_FAIL = (1), /*!< Command response received (but CRC check failed) */
mbed_official 235:685d5f11838f 201 SD_DATA_CRC_FAIL = (2), /*!< Data block sent/received (CRC check failed) */
mbed_official 235:685d5f11838f 202 SD_CMD_RSP_TIMEOUT = (3), /*!< Command response timeout */
mbed_official 235:685d5f11838f 203 SD_DATA_TIMEOUT = (4), /*!< Data timeout */
mbed_official 235:685d5f11838f 204 SD_TX_UNDERRUN = (5), /*!< Transmit FIFO underrun */
mbed_official 235:685d5f11838f 205 SD_RX_OVERRUN = (6), /*!< Receive FIFO overrun */
mbed_official 235:685d5f11838f 206 SD_START_BIT_ERR = (7), /*!< Start bit not detected on all data signals in wide bus mode */
mbed_official 235:685d5f11838f 207 SD_CMD_OUT_OF_RANGE = (8), /*!< Command's argument was out of range. */
mbed_official 235:685d5f11838f 208 SD_ADDR_MISALIGNED = (9), /*!< Misaligned address */
mbed_official 235:685d5f11838f 209 SD_BLOCK_LEN_ERR = (10), /*!< Transferred block length is not allowed for the card or the number of transferred bytes does not match the block length */
mbed_official 235:685d5f11838f 210 SD_ERASE_SEQ_ERR = (11), /*!< An error in the sequence of erase command occurs. */
mbed_official 235:685d5f11838f 211 SD_BAD_ERASE_PARAM = (12), /*!< An invalid selection for erase groups */
mbed_official 235:685d5f11838f 212 SD_WRITE_PROT_VIOLATION = (13), /*!< Attempt to program a write protect block */
mbed_official 235:685d5f11838f 213 SD_LOCK_UNLOCK_FAILED = (14), /*!< Sequence or password error has been detected in unlock command or if there was an attempt to access a locked card */
mbed_official 235:685d5f11838f 214 SD_COM_CRC_FAILED = (15), /*!< CRC check of the previous command failed */
mbed_official 235:685d5f11838f 215 SD_ILLEGAL_CMD = (16), /*!< Command is not legal for the card state */
mbed_official 235:685d5f11838f 216 SD_CARD_ECC_FAILED = (17), /*!< Card internal ECC was applied but failed to correct the data */
mbed_official 235:685d5f11838f 217 SD_CC_ERROR = (18), /*!< Internal card controller error */
mbed_official 235:685d5f11838f 218 SD_GENERAL_UNKNOWN_ERROR = (19), /*!< General or unknown error */
mbed_official 235:685d5f11838f 219 SD_STREAM_READ_UNDERRUN = (20), /*!< The card could not sustain data transfer in stream read operation. */
mbed_official 235:685d5f11838f 220 SD_STREAM_WRITE_OVERRUN = (21), /*!< The card could not sustain data programming in stream mode */
mbed_official 235:685d5f11838f 221 SD_CID_CSD_OVERWRITE = (22), /*!< CID/CSD overwrite error */
mbed_official 235:685d5f11838f 222 SD_WP_ERASE_SKIP = (23), /*!< Only partial address space was erased */
mbed_official 235:685d5f11838f 223 SD_CARD_ECC_DISABLED = (24), /*!< Command has been executed without using internal ECC */
mbed_official 235:685d5f11838f 224 SD_ERASE_RESET = (25), /*!< Erase sequence was cleared before executing because an out of erase sequence command was received */
mbed_official 235:685d5f11838f 225 SD_AKE_SEQ_ERROR = (26), /*!< Error in sequence of authentication. */
mbed_official 235:685d5f11838f 226 SD_INVALID_VOLTRANGE = (27),
mbed_official 235:685d5f11838f 227 SD_ADDR_OUT_OF_RANGE = (28),
mbed_official 235:685d5f11838f 228 SD_SWITCH_ERROR = (29),
mbed_official 235:685d5f11838f 229 SD_SDIO_DISABLED = (30),
mbed_official 235:685d5f11838f 230 SD_SDIO_FUNCTION_BUSY = (31),
mbed_official 235:685d5f11838f 231 SD_SDIO_FUNCTION_FAILED = (32),
mbed_official 235:685d5f11838f 232 SD_SDIO_UNKNOWN_FUNCTION = (33),
mbed_official 235:685d5f11838f 233
mbed_official 235:685d5f11838f 234 /**
mbed_official 235:685d5f11838f 235 * @brief Standard error defines
mbed_official 235:685d5f11838f 236 */
mbed_official 235:685d5f11838f 237 SD_INTERNAL_ERROR = (34),
mbed_official 235:685d5f11838f 238 SD_NOT_CONFIGURED = (35),
mbed_official 235:685d5f11838f 239 SD_REQUEST_PENDING = (36),
mbed_official 235:685d5f11838f 240 SD_REQUEST_NOT_APPLICABLE = (37),
mbed_official 235:685d5f11838f 241 SD_INVALID_PARAMETER = (38),
mbed_official 235:685d5f11838f 242 SD_UNSUPPORTED_FEATURE = (39),
mbed_official 235:685d5f11838f 243 SD_UNSUPPORTED_HW = (40),
mbed_official 235:685d5f11838f 244 SD_ERROR = (41),
mbed_official 235:685d5f11838f 245 SD_OK = (0)
mbed_official 235:685d5f11838f 246
mbed_official 235:685d5f11838f 247 }HAL_SD_ErrorTypedef;
mbed_official 235:685d5f11838f 248
mbed_official 235:685d5f11838f 249 /**
mbed_official 235:685d5f11838f 250 * @brief SD Transfer state enumeration structure
mbed_official 235:685d5f11838f 251 */
mbed_official 235:685d5f11838f 252 typedef enum
mbed_official 235:685d5f11838f 253 {
mbed_official 235:685d5f11838f 254 SD_TRANSFER_OK = 0, /*!< Transfer success */
mbed_official 235:685d5f11838f 255 SD_TRANSFER_BUSY = 1, /*!< Transfer is occurring */
mbed_official 235:685d5f11838f 256 SD_TRANSFER_ERROR = 2 /*!< Transfer failed */
mbed_official 235:685d5f11838f 257
mbed_official 235:685d5f11838f 258 }HAL_SD_TransferStateTypedef;
mbed_official 235:685d5f11838f 259
mbed_official 235:685d5f11838f 260 /**
mbed_official 235:685d5f11838f 261 * @brief SD Card State enumeration structure
mbed_official 235:685d5f11838f 262 */
mbed_official 235:685d5f11838f 263 typedef enum
mbed_official 235:685d5f11838f 264 {
mbed_official 235:685d5f11838f 265 SD_CARD_READY = ((uint32_t)0x00000001), /*!< Card state is ready */
mbed_official 235:685d5f11838f 266 SD_CARD_IDENTIFICATION = ((uint32_t)0x00000002), /*!< Card is in identification state */
mbed_official 235:685d5f11838f 267 SD_CARD_STANDBY = ((uint32_t)0x00000003), /*!< Card is in standby state */
mbed_official 235:685d5f11838f 268 SD_CARD_TRANSFER = ((uint32_t)0x00000004), /*!< Card is in transfer state */
mbed_official 235:685d5f11838f 269 SD_CARD_SENDING = ((uint32_t)0x00000005), /*!< Card is sending an operation */
mbed_official 235:685d5f11838f 270 SD_CARD_RECEIVING = ((uint32_t)0x00000006), /*!< Card is receiving operation information */
mbed_official 235:685d5f11838f 271 SD_CARD_PROGRAMMING = ((uint32_t)0x00000007), /*!< Card is in programming state */
mbed_official 235:685d5f11838f 272 SD_CARD_DISCONNECTED = ((uint32_t)0x00000008), /*!< Card is disconnected */
mbed_official 235:685d5f11838f 273 SD_CARD_ERROR = ((uint32_t)0x000000FF) /*!< Card is in error state */
mbed_official 235:685d5f11838f 274
mbed_official 235:685d5f11838f 275 }HAL_SD_CardStateTypedef;
mbed_official 235:685d5f11838f 276
mbed_official 235:685d5f11838f 277 /**
mbed_official 235:685d5f11838f 278 * @brief SD Operation enumeration structure
mbed_official 235:685d5f11838f 279 */
mbed_official 235:685d5f11838f 280 typedef enum
mbed_official 235:685d5f11838f 281 {
mbed_official 235:685d5f11838f 282 SD_READ_SINGLE_BLOCK = 0, /*!< Read single block operation */
mbed_official 235:685d5f11838f 283 SD_READ_MULTIPLE_BLOCK = 1, /*!< Read multiple blocks operation */
mbed_official 235:685d5f11838f 284 SD_WRITE_SINGLE_BLOCK = 2, /*!< Write single block operation */
mbed_official 235:685d5f11838f 285 SD_WRITE_MULTIPLE_BLOCK = 3 /*!< Write multiple blocks operation */
mbed_official 235:685d5f11838f 286
mbed_official 235:685d5f11838f 287 }HAL_SD_OperationTypedef;
mbed_official 235:685d5f11838f 288
mbed_official 235:685d5f11838f 289
mbed_official 235:685d5f11838f 290 /* Exported constants --------------------------------------------------------*/
mbed_official 235:685d5f11838f 291 /** @defgroup SD_Exported_Constants
mbed_official 235:685d5f11838f 292 * @{
mbed_official 235:685d5f11838f 293 */
mbed_official 235:685d5f11838f 294
mbed_official 235:685d5f11838f 295 /**
mbed_official 235:685d5f11838f 296 * @brief SD Commands Index
mbed_official 235:685d5f11838f 297 */
mbed_official 235:685d5f11838f 298 #define SD_CMD_GO_IDLE_STATE ((uint8_t)0) /*!< Resets the SD memory card. */
mbed_official 235:685d5f11838f 299 #define SD_CMD_SEND_OP_COND ((uint8_t)1) /*!< Sends host capacity support information and activates the card's initialization process. */
mbed_official 235:685d5f11838f 300 #define SD_CMD_ALL_SEND_CID ((uint8_t)2) /*!< Asks any card connected to the host to send the CID numbers on the CMD line. */
mbed_official 235:685d5f11838f 301 #define SD_CMD_SET_REL_ADDR ((uint8_t)3) /*!< Asks the card to publish a new relative address (RCA). */
mbed_official 235:685d5f11838f 302 #define SD_CMD_SET_DSR ((uint8_t)4) /*!< Programs the DSR of all cards. */
mbed_official 235:685d5f11838f 303 #define SD_CMD_SDIO_SEN_OP_COND ((uint8_t)5) /*!< Sends host capacity support information (HCS) and asks the accessed card to send its
mbed_official 235:685d5f11838f 304 operating condition register (OCR) content in the response on the CMD line. */
mbed_official 235:685d5f11838f 305 #define SD_CMD_HS_SWITCH ((uint8_t)6) /*!< Checks switchable function (mode 0) and switch card function (mode 1). */
mbed_official 235:685d5f11838f 306 #define SD_CMD_SEL_DESEL_CARD ((uint8_t)7) /*!< Selects the card by its own relative address and gets deselected by any other address */
mbed_official 235:685d5f11838f 307 #define SD_CMD_HS_SEND_EXT_CSD ((uint8_t)8) /*!< Sends SD Memory Card interface condition, which includes host supply voltage information
mbed_official 235:685d5f11838f 308 and asks the card whether card supports voltage. */
mbed_official 235:685d5f11838f 309 #define SD_CMD_SEND_CSD ((uint8_t)9) /*!< Addressed card sends its card specific data (CSD) on the CMD line. */
mbed_official 235:685d5f11838f 310 #define SD_CMD_SEND_CID ((uint8_t)10) /*!< Addressed card sends its card identification (CID) on the CMD line. */
mbed_official 235:685d5f11838f 311 #define SD_CMD_READ_DAT_UNTIL_STOP ((uint8_t)11) /*!< SD card doesn't support it. */
mbed_official 235:685d5f11838f 312 #define SD_CMD_STOP_TRANSMISSION ((uint8_t)12) /*!< Forces the card to stop transmission. */
mbed_official 235:685d5f11838f 313 #define SD_CMD_SEND_STATUS ((uint8_t)13) /*!< Addressed card sends its status register. */
mbed_official 235:685d5f11838f 314 #define SD_CMD_HS_BUSTEST_READ ((uint8_t)14)
mbed_official 235:685d5f11838f 315 #define SD_CMD_GO_INACTIVE_STATE ((uint8_t)15) /*!< Sends an addressed card into the inactive state. */
mbed_official 235:685d5f11838f 316 #define SD_CMD_SET_BLOCKLEN ((uint8_t)16) /*!< Sets the block length (in bytes for SDSC) for all following block commands
mbed_official 235:685d5f11838f 317 (read, write, lock). Default block length is fixed to 512 Bytes. Not effective
mbed_official 235:685d5f11838f 318 for SDHS and SDXC. */
mbed_official 235:685d5f11838f 319 #define SD_CMD_READ_SINGLE_BLOCK ((uint8_t)17) /*!< Reads single block of size selected by SET_BLOCKLEN in case of SDSC, and a block of
mbed_official 235:685d5f11838f 320 fixed 512 bytes in case of SDHC and SDXC. */
mbed_official 235:685d5f11838f 321 #define SD_CMD_READ_MULT_BLOCK ((uint8_t)18) /*!< Continuously transfers data blocks from card to host until interrupted by
mbed_official 235:685d5f11838f 322 STOP_TRANSMISSION command. */
mbed_official 235:685d5f11838f 323 #define SD_CMD_HS_BUSTEST_WRITE ((uint8_t)19) /*!< 64 bytes tuning pattern is sent for SDR50 and SDR104. */
mbed_official 235:685d5f11838f 324 #define SD_CMD_WRITE_DAT_UNTIL_STOP ((uint8_t)20) /*!< Speed class control command. */
mbed_official 235:685d5f11838f 325 #define SD_CMD_SET_BLOCK_COUNT ((uint8_t)23) /*!< Specify block count for CMD18 and CMD25. */
mbed_official 235:685d5f11838f 326 #define SD_CMD_WRITE_SINGLE_BLOCK ((uint8_t)24) /*!< Writes single block of size selected by SET_BLOCKLEN in case of SDSC, and a block of
mbed_official 235:685d5f11838f 327 fixed 512 bytes in case of SDHC and SDXC. */
mbed_official 235:685d5f11838f 328 #define SD_CMD_WRITE_MULT_BLOCK ((uint8_t)25) /*!< Continuously writes blocks of data until a STOP_TRANSMISSION follows. */
mbed_official 235:685d5f11838f 329 #define SD_CMD_PROG_CID ((uint8_t)26) /*!< Reserved for manufacturers. */
mbed_official 235:685d5f11838f 330 #define SD_CMD_PROG_CSD ((uint8_t)27) /*!< Programming of the programmable bits of the CSD. */
mbed_official 235:685d5f11838f 331 #define SD_CMD_SET_WRITE_PROT ((uint8_t)28) /*!< Sets the write protection bit of the addressed group. */
mbed_official 235:685d5f11838f 332 #define SD_CMD_CLR_WRITE_PROT ((uint8_t)29) /*!< Clears the write protection bit of the addressed group. */
mbed_official 235:685d5f11838f 333 #define SD_CMD_SEND_WRITE_PROT ((uint8_t)30) /*!< Asks the card to send the status of the write protection bits. */
mbed_official 235:685d5f11838f 334 #define SD_CMD_SD_ERASE_GRP_START ((uint8_t)32) /*!< Sets the address of the first write block to be erased. (For SD card only). */
mbed_official 235:685d5f11838f 335 #define SD_CMD_SD_ERASE_GRP_END ((uint8_t)33) /*!< Sets the address of the last write block of the continuous range to be erased. */
mbed_official 235:685d5f11838f 336 #define SD_CMD_ERASE_GRP_START ((uint8_t)35) /*!< Sets the address of the first write block to be erased. Reserved for each command
mbed_official 235:685d5f11838f 337 system set by switch function command (CMD6). */
mbed_official 235:685d5f11838f 338 #define SD_CMD_ERASE_GRP_END ((uint8_t)36) /*!< Sets the address of the last write block of the continuous range to be erased.
mbed_official 235:685d5f11838f 339 Reserved for each command system set by switch function command (CMD6). */
mbed_official 235:685d5f11838f 340 #define SD_CMD_ERASE ((uint8_t)38) /*!< Reserved for SD security applications. */
mbed_official 235:685d5f11838f 341 #define SD_CMD_FAST_IO ((uint8_t)39) /*!< SD card doesn't support it (Reserved). */
mbed_official 235:685d5f11838f 342 #define SD_CMD_GO_IRQ_STATE ((uint8_t)40) /*!< SD card doesn't support it (Reserved). */
mbed_official 235:685d5f11838f 343 #define SD_CMD_LOCK_UNLOCK ((uint8_t)42) /*!< Sets/resets the password or lock/unlock the card. The size of the data block is set by
mbed_official 235:685d5f11838f 344 the SET_BLOCK_LEN command. */
mbed_official 235:685d5f11838f 345 #define SD_CMD_APP_CMD ((uint8_t)55) /*!< Indicates to the card that the next command is an application specific command rather
mbed_official 235:685d5f11838f 346 than a standard command. */
mbed_official 235:685d5f11838f 347 #define SD_CMD_GEN_CMD ((uint8_t)56) /*!< Used either to transfer a data block to the card or to get a data block from the card
mbed_official 235:685d5f11838f 348 for general purpose/application specific commands. */
mbed_official 235:685d5f11838f 349 #define SD_CMD_NO_CMD ((uint8_t)64)
mbed_official 235:685d5f11838f 350
mbed_official 235:685d5f11838f 351 /**
mbed_official 235:685d5f11838f 352 * @brief Following commands are SD Card Specific commands.
mbed_official 235:685d5f11838f 353 * SDIO_APP_CMD should be sent before sending these commands.
mbed_official 235:685d5f11838f 354 */
mbed_official 235:685d5f11838f 355 #define SD_CMD_APP_SD_SET_BUSWIDTH ((uint8_t)6) /*!< (ACMD6) Defines the data bus width to be used for data transfer. The allowed data bus
mbed_official 235:685d5f11838f 356 widths are given in SCR register. */
mbed_official 235:685d5f11838f 357 #define SD_CMD_SD_APP_STAUS ((uint8_t)13) /*!< (ACMD13) Sends the SD status. */
mbed_official 235:685d5f11838f 358 #define SD_CMD_SD_APP_SEND_NUM_WRITE_BLOCKS ((uint8_t)22) /*!< (ACMD22) Sends the number of the written (without errors) write blocks. Responds with
mbed_official 235:685d5f11838f 359 32bit+CRC data block. */
mbed_official 235:685d5f11838f 360 #define SD_CMD_SD_APP_OP_COND ((uint8_t)41) /*!< (ACMD41) Sends host capacity support information (HCS) and asks the accessed card to
mbed_official 235:685d5f11838f 361 send its operating condition register (OCR) content in the response on the CMD line. */
mbed_official 235:685d5f11838f 362 #define SD_CMD_SD_APP_SET_CLR_CARD_DETECT ((uint8_t)42) /*!< (ACMD42) Connects/Disconnects the 50 KOhm pull-up resistor on CD/DAT3 (pin 1) of the card. */
mbed_official 235:685d5f11838f 363 #define SD_CMD_SD_APP_SEND_SCR ((uint8_t)51) /*!< Reads the SD Configuration Register (SCR). */
mbed_official 235:685d5f11838f 364 #define SD_CMD_SDIO_RW_DIRECT ((uint8_t)52) /*!< For SD I/O card only, reserved for security specification. */
mbed_official 235:685d5f11838f 365 #define SD_CMD_SDIO_RW_EXTENDED ((uint8_t)53) /*!< For SD I/O card only, reserved for security specification. */
mbed_official 235:685d5f11838f 366
mbed_official 235:685d5f11838f 367 /**
mbed_official 235:685d5f11838f 368 * @brief Following commands are SD Card Specific security commands.
mbed_official 235:685d5f11838f 369 * SD_CMD_APP_CMD should be sent before sending these commands.
mbed_official 235:685d5f11838f 370 */
mbed_official 235:685d5f11838f 371 #define SD_CMD_SD_APP_GET_MKB ((uint8_t)43) /*!< For SD card only */
mbed_official 235:685d5f11838f 372 #define SD_CMD_SD_APP_GET_MID ((uint8_t)44) /*!< For SD card only */
mbed_official 235:685d5f11838f 373 #define SD_CMD_SD_APP_SET_CER_RN1 ((uint8_t)45) /*!< For SD card only */
mbed_official 235:685d5f11838f 374 #define SD_CMD_SD_APP_GET_CER_RN2 ((uint8_t)46) /*!< For SD card only */
mbed_official 235:685d5f11838f 375 #define SD_CMD_SD_APP_SET_CER_RES2 ((uint8_t)47) /*!< For SD card only */
mbed_official 235:685d5f11838f 376 #define SD_CMD_SD_APP_GET_CER_RES1 ((uint8_t)48) /*!< For SD card only */
mbed_official 235:685d5f11838f 377 #define SD_CMD_SD_APP_SECURE_READ_MULTIPLE_BLOCK ((uint8_t)18) /*!< For SD card only */
mbed_official 235:685d5f11838f 378 #define SD_CMD_SD_APP_SECURE_WRITE_MULTIPLE_BLOCK ((uint8_t)25) /*!< For SD card only */
mbed_official 235:685d5f11838f 379 #define SD_CMD_SD_APP_SECURE_ERASE ((uint8_t)38) /*!< For SD card only */
mbed_official 235:685d5f11838f 380 #define SD_CMD_SD_APP_CHANGE_SECURE_AREA ((uint8_t)49) /*!< For SD card only */
mbed_official 235:685d5f11838f 381 #define SD_CMD_SD_APP_SECURE_WRITE_MKB ((uint8_t)48) /*!< For SD card only */
mbed_official 235:685d5f11838f 382
mbed_official 235:685d5f11838f 383 /**
mbed_official 235:685d5f11838f 384 * @brief Supported SD Memory Cards
mbed_official 235:685d5f11838f 385 */
mbed_official 235:685d5f11838f 386 #define STD_CAPACITY_SD_CARD_V1_1 ((uint32_t)0x00000000)
mbed_official 235:685d5f11838f 387 #define STD_CAPACITY_SD_CARD_V2_0 ((uint32_t)0x00000001)
mbed_official 235:685d5f11838f 388 #define HIGH_CAPACITY_SD_CARD ((uint32_t)0x00000002)
mbed_official 235:685d5f11838f 389 #define MULTIMEDIA_CARD ((uint32_t)0x00000003)
mbed_official 235:685d5f11838f 390 #define SECURE_DIGITAL_IO_CARD ((uint32_t)0x00000004)
mbed_official 235:685d5f11838f 391 #define HIGH_SPEED_MULTIMEDIA_CARD ((uint32_t)0x00000005)
mbed_official 235:685d5f11838f 392 #define SECURE_DIGITAL_IO_COMBO_CARD ((uint32_t)0x00000006)
mbed_official 235:685d5f11838f 393 #define HIGH_CAPACITY_MMC_CARD ((uint32_t)0x00000007)
mbed_official 235:685d5f11838f 394 /**
mbed_official 235:685d5f11838f 395 * @}
mbed_official 235:685d5f11838f 396 */
mbed_official 235:685d5f11838f 397
mbed_official 235:685d5f11838f 398 /* Exported macro ------------------------------------------------------------*/
mbed_official 235:685d5f11838f 399
mbed_official 235:685d5f11838f 400 /** @defgroup SD_Exported_macros
mbed_official 235:685d5f11838f 401 * @brief macros to handle interrupts and specific clock configurations
mbed_official 235:685d5f11838f 402 * @{
mbed_official 235:685d5f11838f 403 */
mbed_official 235:685d5f11838f 404
mbed_official 235:685d5f11838f 405 /**
mbed_official 235:685d5f11838f 406 * @brief Enable the SD device.
mbed_official 235:685d5f11838f 407 * @retval None
mbed_official 235:685d5f11838f 408 */
mbed_official 235:685d5f11838f 409 #define __HAL_SD_SDIO_ENABLE() __SDIO_ENABLE()
mbed_official 235:685d5f11838f 410
mbed_official 235:685d5f11838f 411 /**
mbed_official 235:685d5f11838f 412 * @brief Disable the SD device.
mbed_official 235:685d5f11838f 413 * @retval None
mbed_official 235:685d5f11838f 414 */
mbed_official 235:685d5f11838f 415 #define __HAL_SD_SDIO_DISABLE() __SDIO_DISABLE()
mbed_official 235:685d5f11838f 416
mbed_official 235:685d5f11838f 417 /**
mbed_official 235:685d5f11838f 418 * @brief Enable the SDIO DMA transfer.
mbed_official 235:685d5f11838f 419 * @retval None
mbed_official 235:685d5f11838f 420 */
mbed_official 235:685d5f11838f 421 #define __HAL_SD_SDIO_DMA_ENABLE() __SDIO_DMA_ENABLE()
mbed_official 235:685d5f11838f 422
mbed_official 235:685d5f11838f 423 /**
mbed_official 235:685d5f11838f 424 * @brief Disable the SDIO DMA transfer.
mbed_official 235:685d5f11838f 425 * @retval None
mbed_official 235:685d5f11838f 426 */
mbed_official 235:685d5f11838f 427 #define __HAL_SD_SDIO_DMA_DISABLE() __SDIO_DMA_DISABLE()
mbed_official 235:685d5f11838f 428
mbed_official 235:685d5f11838f 429 /**
mbed_official 235:685d5f11838f 430 * @brief Enable the SD device interrupt.
mbed_official 235:685d5f11838f 431 * @param __HANDLE__: SD Handle
mbed_official 235:685d5f11838f 432 * @param __INTERRUPT__: specifies the SDIO interrupt sources to be enabled.
mbed_official 235:685d5f11838f 433 * This parameter can be one or a combination of the following values:
mbed_official 235:685d5f11838f 434 * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
mbed_official 235:685d5f11838f 435 * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
mbed_official 235:685d5f11838f 436 * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt
mbed_official 235:685d5f11838f 437 * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt
mbed_official 235:685d5f11838f 438 * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt
mbed_official 235:685d5f11838f 439 * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt
mbed_official 235:685d5f11838f 440 * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt
mbed_official 235:685d5f11838f 441 * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt
mbed_official 235:685d5f11838f 442 * @arg SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt
mbed_official 235:685d5f11838f 443 * @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide
mbed_official 235:685d5f11838f 444 * bus mode interrupt
mbed_official 235:685d5f11838f 445 * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt
mbed_official 235:685d5f11838f 446 * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt
mbed_official 235:685d5f11838f 447 * @arg SDIO_IT_TXACT: Data transmit in progress interrupt
mbed_official 235:685d5f11838f 448 * @arg SDIO_IT_RXACT: Data receive in progress interrupt
mbed_official 235:685d5f11838f 449 * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
mbed_official 235:685d5f11838f 450 * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt
mbed_official 235:685d5f11838f 451 * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt
mbed_official 235:685d5f11838f 452 * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt
mbed_official 235:685d5f11838f 453 * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt
mbed_official 235:685d5f11838f 454 * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt
mbed_official 235:685d5f11838f 455 * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt
mbed_official 235:685d5f11838f 456 * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt
mbed_official 235:685d5f11838f 457 * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt
mbed_official 235:685d5f11838f 458 * @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61 interrupt
mbed_official 235:685d5f11838f 459 * @retval None
mbed_official 235:685d5f11838f 460 */
mbed_official 235:685d5f11838f 461 #define __HAL_SD_SDIO_ENABLE_IT(__HANDLE__, __INTERRUPT__) __SDIO_ENABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__))
mbed_official 235:685d5f11838f 462
mbed_official 235:685d5f11838f 463 /**
mbed_official 235:685d5f11838f 464 * @brief Disable the SD device interrupt.
mbed_official 235:685d5f11838f 465 * @param __HANDLE__: SD Handle
mbed_official 235:685d5f11838f 466 * @param __INTERRUPT__: specifies the SDIO interrupt sources to be disabled.
mbed_official 235:685d5f11838f 467 * This parameter can be one or a combination of the following values:
mbed_official 235:685d5f11838f 468 * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
mbed_official 235:685d5f11838f 469 * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
mbed_official 235:685d5f11838f 470 * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt
mbed_official 235:685d5f11838f 471 * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt
mbed_official 235:685d5f11838f 472 * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt
mbed_official 235:685d5f11838f 473 * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt
mbed_official 235:685d5f11838f 474 * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt
mbed_official 235:685d5f11838f 475 * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt
mbed_official 235:685d5f11838f 476 * @arg SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt
mbed_official 235:685d5f11838f 477 * @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide
mbed_official 235:685d5f11838f 478 * bus mode interrupt
mbed_official 235:685d5f11838f 479 * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt
mbed_official 235:685d5f11838f 480 * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt
mbed_official 235:685d5f11838f 481 * @arg SDIO_IT_TXACT: Data transmit in progress interrupt
mbed_official 235:685d5f11838f 482 * @arg SDIO_IT_RXACT: Data receive in progress interrupt
mbed_official 235:685d5f11838f 483 * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
mbed_official 235:685d5f11838f 484 * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt
mbed_official 235:685d5f11838f 485 * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt
mbed_official 235:685d5f11838f 486 * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt
mbed_official 235:685d5f11838f 487 * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt
mbed_official 235:685d5f11838f 488 * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt
mbed_official 235:685d5f11838f 489 * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt
mbed_official 235:685d5f11838f 490 * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt
mbed_official 235:685d5f11838f 491 * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt
mbed_official 235:685d5f11838f 492 * @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61 interrupt
mbed_official 235:685d5f11838f 493 * @retval None
mbed_official 235:685d5f11838f 494 */
mbed_official 235:685d5f11838f 495 #define __HAL_SD_SDIO_DISABLE_IT(__HANDLE__, __INTERRUPT__) __SDIO_DISABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__))
mbed_official 235:685d5f11838f 496
mbed_official 235:685d5f11838f 497 /**
mbed_official 235:685d5f11838f 498 * @brief Check whether the specified SD flag is set or not.
mbed_official 235:685d5f11838f 499 * @param __HANDLE__: SD Handle
mbed_official 235:685d5f11838f 500 * @param __FLAG__: specifies the flag to check.
mbed_official 235:685d5f11838f 501 * This parameter can be one of the following values:
mbed_official 235:685d5f11838f 502 * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed)
mbed_official 235:685d5f11838f 503 * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed)
mbed_official 235:685d5f11838f 504 * @arg SDIO_FLAG_CTIMEOUT: Command response timeout
mbed_official 235:685d5f11838f 505 * @arg SDIO_FLAG_DTIMEOUT: Data timeout
mbed_official 235:685d5f11838f 506 * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error
mbed_official 235:685d5f11838f 507 * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error
mbed_official 235:685d5f11838f 508 * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed)
mbed_official 235:685d5f11838f 509 * @arg SDIO_FLAG_CMDSENT: Command sent (no response required)
mbed_official 235:685d5f11838f 510 * @arg SDIO_FLAG_DATAEND: Data end (data counter, SDIDCOUNT, is zero)
mbed_official 235:685d5f11838f 511 * @arg SDIO_FLAG_STBITERR: Start bit not detected on all data signals in wide bus mode.
mbed_official 235:685d5f11838f 512 * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed)
mbed_official 235:685d5f11838f 513 * @arg SDIO_FLAG_CMDACT: Command transfer in progress
mbed_official 235:685d5f11838f 514 * @arg SDIO_FLAG_TXACT: Data transmit in progress
mbed_official 235:685d5f11838f 515 * @arg SDIO_FLAG_RXACT: Data receive in progress
mbed_official 235:685d5f11838f 516 * @arg SDIO_FLAG_TXFIFOHE: Transmit FIFO Half Empty
mbed_official 235:685d5f11838f 517 * @arg SDIO_FLAG_RXFIFOHF: Receive FIFO Half Full
mbed_official 235:685d5f11838f 518 * @arg SDIO_FLAG_TXFIFOF: Transmit FIFO full
mbed_official 235:685d5f11838f 519 * @arg SDIO_FLAG_RXFIFOF: Receive FIFO full
mbed_official 235:685d5f11838f 520 * @arg SDIO_FLAG_TXFIFOE: Transmit FIFO empty
mbed_official 235:685d5f11838f 521 * @arg SDIO_FLAG_RXFIFOE: Receive FIFO empty
mbed_official 235:685d5f11838f 522 * @arg SDIO_FLAG_TXDAVL: Data available in transmit FIFO
mbed_official 235:685d5f11838f 523 * @arg SDIO_FLAG_RXDAVL: Data available in receive FIFO
mbed_official 235:685d5f11838f 524 * @arg SDIO_FLAG_SDIOIT: SD I/O interrupt received
mbed_official 235:685d5f11838f 525 * @arg SDIO_FLAG_CEATAEND: CE-ATA command completion signal received for CMD61
mbed_official 235:685d5f11838f 526 * @retval The new state of SD FLAG (SET or RESET).
mbed_official 235:685d5f11838f 527 */
mbed_official 235:685d5f11838f 528 #define __HAL_SD_SDIO_GET_FLAG(__HANDLE__, __FLAG__) __SDIO_GET_FLAG((__HANDLE__)->Instance, (__FLAG__))
mbed_official 235:685d5f11838f 529
mbed_official 235:685d5f11838f 530 /**
mbed_official 235:685d5f11838f 531 * @brief Clear the SD's pending flags.
mbed_official 235:685d5f11838f 532 * @param __HANDLE__: SD Handle
mbed_official 235:685d5f11838f 533 * @param __FLAG__: specifies the flag to clear.
mbed_official 235:685d5f11838f 534 * This parameter can be one or a combination of the following values:
mbed_official 235:685d5f11838f 535 * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed)
mbed_official 235:685d5f11838f 536 * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed)
mbed_official 235:685d5f11838f 537 * @arg SDIO_FLAG_CTIMEOUT: Command response timeout
mbed_official 235:685d5f11838f 538 * @arg SDIO_FLAG_DTIMEOUT: Data timeout
mbed_official 235:685d5f11838f 539 * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error
mbed_official 235:685d5f11838f 540 * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error
mbed_official 235:685d5f11838f 541 * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed)
mbed_official 235:685d5f11838f 542 * @arg SDIO_FLAG_CMDSENT: Command sent (no response required)
mbed_official 235:685d5f11838f 543 * @arg SDIO_FLAG_DATAEND: Data end (data counter, SDIDCOUNT, is zero)
mbed_official 235:685d5f11838f 544 * @arg SDIO_FLAG_STBITERR: Start bit not detected on all data signals in wide bus mode
mbed_official 235:685d5f11838f 545 * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed)
mbed_official 235:685d5f11838f 546 * @arg SDIO_FLAG_SDIOIT: SD I/O interrupt received
mbed_official 235:685d5f11838f 547 * @arg SDIO_FLAG_CEATAEND: CE-ATA command completion signal received for CMD61
mbed_official 235:685d5f11838f 548 * @retval None
mbed_official 235:685d5f11838f 549 */
mbed_official 235:685d5f11838f 550 #define __HAL_SD_SDIO_CLEAR_FLAG(__HANDLE__, __FLAG__) __SDIO_CLEAR_FLAG((__HANDLE__)->Instance, (__FLAG__))
mbed_official 235:685d5f11838f 551
mbed_official 235:685d5f11838f 552 /**
mbed_official 235:685d5f11838f 553 * @brief Check whether the specified SD interrupt has occurred or not.
mbed_official 235:685d5f11838f 554 * @param __HANDLE__: SD Handle
mbed_official 235:685d5f11838f 555 * @param __INTERRUPT__: specifies the SDIO interrupt source to check.
mbed_official 235:685d5f11838f 556 * This parameter can be one of the following values:
mbed_official 235:685d5f11838f 557 * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
mbed_official 235:685d5f11838f 558 * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
mbed_official 235:685d5f11838f 559 * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt
mbed_official 235:685d5f11838f 560 * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt
mbed_official 235:685d5f11838f 561 * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt
mbed_official 235:685d5f11838f 562 * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt
mbed_official 235:685d5f11838f 563 * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt
mbed_official 235:685d5f11838f 564 * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt
mbed_official 235:685d5f11838f 565 * @arg SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt
mbed_official 235:685d5f11838f 566 * @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide
mbed_official 235:685d5f11838f 567 * bus mode interrupt
mbed_official 235:685d5f11838f 568 * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt
mbed_official 235:685d5f11838f 569 * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt
mbed_official 235:685d5f11838f 570 * @arg SDIO_IT_TXACT: Data transmit in progress interrupt
mbed_official 235:685d5f11838f 571 * @arg SDIO_IT_RXACT: Data receive in progress interrupt
mbed_official 235:685d5f11838f 572 * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
mbed_official 235:685d5f11838f 573 * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt
mbed_official 235:685d5f11838f 574 * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt
mbed_official 235:685d5f11838f 575 * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt
mbed_official 235:685d5f11838f 576 * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt
mbed_official 235:685d5f11838f 577 * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt
mbed_official 235:685d5f11838f 578 * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt
mbed_official 235:685d5f11838f 579 * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt
mbed_official 235:685d5f11838f 580 * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt
mbed_official 235:685d5f11838f 581 * @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61 interrupt
mbed_official 235:685d5f11838f 582 * @retval The new state of SD IT (SET or RESET).
mbed_official 235:685d5f11838f 583 */
mbed_official 235:685d5f11838f 584 #define __HAL_SD_SDIO_GET_IT (__HANDLE__, __INTERRUPT__) __SDIO_GET_IT ((__HANDLE__)->Instance, __INTERRUPT__)
mbed_official 235:685d5f11838f 585
mbed_official 235:685d5f11838f 586 /**
mbed_official 235:685d5f11838f 587 * @brief Clear the SD's interrupt pending bits.
mbed_official 235:685d5f11838f 588 * @param __HANDLE__ : SD Handle
mbed_official 235:685d5f11838f 589 * @param __INTERRUPT__: specifies the interrupt pending bit to clear.
mbed_official 235:685d5f11838f 590 * This parameter can be one or a combination of the following values:
mbed_official 235:685d5f11838f 591 * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
mbed_official 235:685d5f11838f 592 * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
mbed_official 235:685d5f11838f 593 * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt
mbed_official 235:685d5f11838f 594 * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt
mbed_official 235:685d5f11838f 595 * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt
mbed_official 235:685d5f11838f 596 * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt
mbed_official 235:685d5f11838f 597 * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt
mbed_official 235:685d5f11838f 598 * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt
mbed_official 235:685d5f11838f 599 * @arg SDIO_IT_DATAEND: Data end (data counter, SDIO_DCOUNT, is zero) interrupt
mbed_official 235:685d5f11838f 600 * @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide
mbed_official 235:685d5f11838f 601 * bus mode interrupt
mbed_official 235:685d5f11838f 602 * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt
mbed_official 235:685d5f11838f 603 * @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61
mbed_official 235:685d5f11838f 604 * @retval None
mbed_official 235:685d5f11838f 605 */
mbed_official 235:685d5f11838f 606 #define __HAL_SD_SDIO_CLEAR_IT(__HANDLE__, __INTERRUPT__) __SDIO_CLEAR_IT((__HANDLE__)->Instance, (__INTERRUPT__))
mbed_official 235:685d5f11838f 607 /**
mbed_official 235:685d5f11838f 608 * @}
mbed_official 235:685d5f11838f 609 */
mbed_official 235:685d5f11838f 610
mbed_official 235:685d5f11838f 611 /* Exported functions --------------------------------------------------------*/
mbed_official 235:685d5f11838f 612 /** @addtogroup SD_Exported_Functions
mbed_official 235:685d5f11838f 613 * @{
mbed_official 235:685d5f11838f 614 */
mbed_official 235:685d5f11838f 615
mbed_official 235:685d5f11838f 616 /* Initialization/de-initialization functions ********************************/
mbed_official 235:685d5f11838f 617 /** @addtogroup SD_Group1
mbed_official 235:685d5f11838f 618 * @{
mbed_official 235:685d5f11838f 619 */
mbed_official 235:685d5f11838f 620 HAL_SD_ErrorTypedef HAL_SD_Init(SD_HandleTypeDef *hsd, HAL_SD_CardInfoTypedef *SDCardInfo);
mbed_official 235:685d5f11838f 621 HAL_StatusTypeDef HAL_SD_DeInit (SD_HandleTypeDef *hsd);
mbed_official 235:685d5f11838f 622 void HAL_SD_MspInit(SD_HandleTypeDef *hsd);
mbed_official 235:685d5f11838f 623 void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd);
mbed_official 235:685d5f11838f 624 /**
mbed_official 235:685d5f11838f 625 * @}
mbed_official 235:685d5f11838f 626 */
mbed_official 235:685d5f11838f 627
mbed_official 235:685d5f11838f 628 /* I/O operation functions ***************************************************/
mbed_official 235:685d5f11838f 629 /** @addtogroup SD_Group2
mbed_official 235:685d5f11838f 630 * @{
mbed_official 235:685d5f11838f 631 */
mbed_official 235:685d5f11838f 632 /* Blocking mode: Polling */
mbed_official 235:685d5f11838f 633 HAL_SD_ErrorTypedef HAL_SD_ReadBlocks(SD_HandleTypeDef *hsd, uint32_t *pReadBuffer, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumberOfBlocks);
mbed_official 235:685d5f11838f 634 HAL_SD_ErrorTypedef HAL_SD_WriteBlocks(SD_HandleTypeDef *hsd, uint32_t *pWriteBuffer, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumberOfBlocks);
mbed_official 235:685d5f11838f 635 HAL_SD_ErrorTypedef HAL_SD_Erase(SD_HandleTypeDef *hsd, uint64_t startaddr, uint64_t endaddr);
mbed_official 235:685d5f11838f 636
mbed_official 235:685d5f11838f 637 /* Non-Blocking mode: Interrupt */
mbed_official 235:685d5f11838f 638 void HAL_SD_IRQHandler(SD_HandleTypeDef *hsd);
mbed_official 235:685d5f11838f 639
mbed_official 235:685d5f11838f 640 /* Callback in non blocking modes (DMA) */
mbed_official 235:685d5f11838f 641 void HAL_SD_DMA_RxCpltCallback(DMA_HandleTypeDef *hdma);
mbed_official 235:685d5f11838f 642 void HAL_SD_DMA_RxErrorCallback(DMA_HandleTypeDef *hdma);
mbed_official 235:685d5f11838f 643 void HAL_SD_DMA_TxCpltCallback(DMA_HandleTypeDef *hdma);
mbed_official 235:685d5f11838f 644 void HAL_SD_DMA_TxErrorCallback(DMA_HandleTypeDef *hdma);
mbed_official 235:685d5f11838f 645 void HAL_SD_XferCpltCallback(SD_HandleTypeDef *hsd);
mbed_official 235:685d5f11838f 646 void HAL_SD_XferErrorCallback(SD_HandleTypeDef *hsd);
mbed_official 235:685d5f11838f 647
mbed_official 235:685d5f11838f 648 /* Non-Blocking mode: DMA */
mbed_official 235:685d5f11838f 649 HAL_SD_ErrorTypedef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint32_t *pReadBuffer, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumberOfBlocks);
mbed_official 235:685d5f11838f 650 HAL_SD_ErrorTypedef HAL_SD_WriteBlocks_DMA(SD_HandleTypeDef *hsd, uint32_t *pWriteBuffer, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumberOfBlocks);
mbed_official 235:685d5f11838f 651 HAL_SD_ErrorTypedef HAL_SD_CheckWriteOperation(SD_HandleTypeDef *hsd, uint32_t Timeout);
mbed_official 235:685d5f11838f 652 HAL_SD_ErrorTypedef HAL_SD_CheckReadOperation(SD_HandleTypeDef *hsd, uint32_t Timeout);
mbed_official 235:685d5f11838f 653 /**
mbed_official 235:685d5f11838f 654 * @}
mbed_official 235:685d5f11838f 655 */
mbed_official 235:685d5f11838f 656
mbed_official 235:685d5f11838f 657 /* Peripheral Control functions **********************************************/
mbed_official 235:685d5f11838f 658 /** @addtogroup SD_Group3
mbed_official 235:685d5f11838f 659 * @{
mbed_official 235:685d5f11838f 660 */
mbed_official 235:685d5f11838f 661 HAL_SD_ErrorTypedef HAL_SD_Get_CardInfo(SD_HandleTypeDef *hsd, HAL_SD_CardInfoTypedef *pCardInfo);
mbed_official 235:685d5f11838f 662 HAL_SD_ErrorTypedef HAL_SD_WideBusOperation_Config(SD_HandleTypeDef *hsd, uint32_t WideMode);
mbed_official 235:685d5f11838f 663 HAL_SD_ErrorTypedef HAL_SD_StopTransfer(SD_HandleTypeDef *hsd);
mbed_official 235:685d5f11838f 664 HAL_SD_ErrorTypedef HAL_SD_HighSpeed (SD_HandleTypeDef *hsd);
mbed_official 235:685d5f11838f 665 /**
mbed_official 235:685d5f11838f 666 * @}
mbed_official 235:685d5f11838f 667 */
mbed_official 235:685d5f11838f 668
mbed_official 235:685d5f11838f 669 /* Peripheral State functions ************************************************/
mbed_official 235:685d5f11838f 670 /** @addtogroup SD_Group4
mbed_official 235:685d5f11838f 671 * @{
mbed_official 235:685d5f11838f 672 */
mbed_official 235:685d5f11838f 673 HAL_SD_ErrorTypedef HAL_SD_SendSDStatus(SD_HandleTypeDef *hsd, uint32_t *pSDstatus);
mbed_official 235:685d5f11838f 674 HAL_SD_ErrorTypedef HAL_SD_GetCardStatus(SD_HandleTypeDef *hsd, HAL_SD_CardStatusTypedef *pCardStatus);
mbed_official 235:685d5f11838f 675 HAL_SD_TransferStateTypedef HAL_SD_GetStatus(SD_HandleTypeDef *hsd);
mbed_official 235:685d5f11838f 676 /**
mbed_official 235:685d5f11838f 677 * @}
mbed_official 235:685d5f11838f 678 */
mbed_official 235:685d5f11838f 679
mbed_official 235:685d5f11838f 680 /**
mbed_official 235:685d5f11838f 681 * @}
mbed_official 235:685d5f11838f 682 */
mbed_official 235:685d5f11838f 683
mbed_official 235:685d5f11838f 684 /**
mbed_official 235:685d5f11838f 685 * @}
mbed_official 235:685d5f11838f 686 */
mbed_official 235:685d5f11838f 687
mbed_official 235:685d5f11838f 688 /**
mbed_official 235:685d5f11838f 689 * @}
mbed_official 235:685d5f11838f 690 */
mbed_official 235:685d5f11838f 691
mbed_official 235:685d5f11838f 692 #ifdef __cplusplus
mbed_official 235:685d5f11838f 693 }
mbed_official 235:685d5f11838f 694 #endif
mbed_official 235:685d5f11838f 695
mbed_official 235:685d5f11838f 696
mbed_official 235:685d5f11838f 697 #endif /* __STM32F4xx_HAL_SD_H */
mbed_official 235:685d5f11838f 698
mbed_official 235:685d5f11838f 699 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/