来自中国的硬件平台

Dependents:   mbed_in_china_blink_led

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Mon Mar 24 17:45:07 2014 +0000
Revision:
133:d4dda5c437f0
Synchronized with git revision 47b961246bed973fe4cb8932781ffc8025b78a61

Full URL: https://github.com/mbedmicro/mbed/commit/47b961246bed973fe4cb8932781ffc8025b78a61/

[STM32F4-Discovery (STM32F407VG)] initial port

Who changed what in which revision?

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