A simple 128x32 graphical LCD program to quickstart with LCD on ARM mbed IoT Starter Kit. This requires mbed Applciation Shield with FRDM-K64F platform.

Dependencies:   C12832

Committer:
tushki7
Date:
Sun Apr 12 15:45:52 2015 +0000
Revision:
1:eb68c94a8ee5
Parent:
0:60d829a0353a
A simple 128x32 LCD program with ARM mbed IoT Starter Kit;

Who changed what in which revision?

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