The official mbed C/C SDK provides the software platform and libraries to build your applications.

Fork of mbed by mbed official

Committer:
Kojto
Date:
Tue Oct 28 16:40:41 2014 +0000
Revision:
90:cb3d968589d8
Release 90 of the mbed library

Changes:

- Freescale KSDK update (v1.0)
- K22 - new target addition
- KL43Z - new target addition
- Nucleo F091RC - new target addition
- Nucleo L152RE - STM32Cube driver
- Nordic - Softdevice v7.1.0
- Nvic files - BSD License
- LPC824 - various HAL fixes
- Nucleo F411RE - CMSIS - IAR files

Who changed what in which revision?

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