mbed(SerialHalfDuplex入り)

Fork of mbed by mbed official

Committer:
yusuke_kyo
Date:
Wed Apr 08 08:04:18 2015 +0000
Revision:
98:01a414ca7d6d
Parent:
96:487b796308b0
remove SerialHalfDuplex.h

Who changed what in which revision?

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