LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
CHIP: LPC18xx/43xx SD/SDIO driver

Data Structures

struct  mci_card_struct
 

Macros

#define MMC_GO_IDLE_STATE   0 /* bc */
 
#define MMC_SEND_OP_COND   1 /* bcr [31:0] OCR R3 */
 
#define MMC_ALL_SEND_CID   2 /* bcr R2 */
 
#define MMC_SET_RELATIVE_ADDR   3 /* ac [31:16] RCA R1 */
 
#define MMC_SET_DSR   4 /* bc [31:16] RCA */
 
#define MMC_SELECT_CARD   7 /* ac [31:16] RCA R1 */
 
#define MMC_SEND_EXT_CSD   8 /* bc R1 */
 
#define MMC_SEND_CSD   9 /* ac [31:16] RCA R2 */
 
#define MMC_SEND_CID   10 /* ac [31:16] RCA R2 */
 
#define MMC_STOP_TRANSMISSION   12 /* ac R1b */
 
#define MMC_SEND_STATUS   13 /* ac [31:16] RCA R1 */
 
#define MMC_GO_INACTIVE_STATE   15 /* ac [31:16] RCA */
 
#define MMC_SET_BLOCKLEN   16 /* ac [31:0] block len R1 */
 
#define MMC_READ_SINGLE_BLOCK   17 /* adtc [31:0] data addr R1 */
 
#define MMC_READ_MULTIPLE_BLOCK   18 /* adtc [31:0] data addr R1 */
 
#define MMC_WRITE_DAT_UNTIL_STOP   20 /* adtc [31:0] data addr R1 */
 
#define MMC_SET_BLOCK_COUNT   23 /* adtc [31:0] data addr R1 */
 
#define MMC_WRITE_BLOCK   24 /* adtc [31:0] data addr R1 */
 
#define MMC_WRITE_MULTIPLE_BLOCK   25 /* adtc R1 */
 
#define MMC_PROGRAM_CID   26 /* adtc R1 */
 
#define MMC_PROGRAM_CSD   27 /* adtc R1 */
 
#define MMC_SET_WRITE_PROT   28 /* ac [31:0] data addr R1b */
 
#define MMC_CLR_WRITE_PROT   29 /* ac [31:0] data addr R1b */
 
#define MMC_SEND_WRITE_PROT   30 /* adtc [31:0] wpdata addr R1 */
 
#define MMC_ERASE_GROUP_START   35 /* ac [31:0] data addr R1 */
 
#define MMC_ERASE_GROUP_END   36 /* ac [31:0] data addr R1 */
 
#define MMC_ERASE   37 /* ac R1b */
 
#define MMC_FAST_IO   39 /* ac <Complex> R4 */
 
#define MMC_GO_IRQ_STATE   40 /* bcr R5 */
 
#define MMC_LOCK_UNLOCK   42 /* adtc R1b */
 
#define MMC_APP_CMD   55 /* ac [31:16] RCA R1 */
 
#define MMC_GEN_CMD   56 /* adtc [0] RD/WR R1b */
 
#define SD_SEND_RELATIVE_ADDR   3 /* ac R6 */
 
#define SD_CMD8   8 /* bcr [31:0] OCR R3 */
 
#define SD_APP_SET_BUS_WIDTH   6 /* ac [1:0] bus width R1 */
 
#define SD_APP_OP_COND   41 /* bcr [31:0] OCR R1 (R4) */
 
#define SD_APP_SEND_SCR   51 /* adtc R1 */
 
#define R1_OUT_OF_RANGE   (1UL << 31) /* er, c */
 
#define R1_ADDRESS_ERROR   (1 << 30) /* erx, c */
 
#define R1_BLOCK_LEN_ERROR   (1 << 29) /* er, c */
 
#define R1_ERASE_SEQ_ERROR   (1 << 28) /* er, c */
 
#define R1_ERASE_PARAM   (1 << 27) /* ex, c */
 
#define R1_WP_VIOLATION   (1 << 26) /* erx, c */
 
#define R1_CARD_IS_LOCKED   (1 << 25) /* sx, a */
 
#define R1_LOCK_UNLOCK_FAILED   (1 << 24) /* erx, c */
 
#define R1_COM_CRC_ERROR   (1 << 23) /* er, b */
 
#define R1_ILLEGAL_COMMAND   (1 << 22) /* er, b */
 
#define R1_CARD_ECC_FAILED   (1 << 21) /* ex, c */
 
#define R1_CC_ERROR   (1 << 20) /* erx, c */
 
#define R1_ERROR   (1 << 19) /* erx, c */
 
#define R1_UNDERRUN   (1 << 18) /* ex, c */
 
#define R1_OVERRUN   (1 << 17) /* ex, c */
 
#define R1_CID_CSD_OVERWRITE   (1 << 16) /* erx, c, CID/CSD overwrite */
 
#define R1_WP_ERASE_SKIP   (1 << 15) /* sx, c */
 
#define R1_CARD_ECC_DISABLED   (1 << 14) /* sx, a */
 
#define R1_ERASE_RESET   (1 << 13) /* sr, c */
 
#define R1_STATUS(x)   (x & 0xFFFFE000)
 
#define R1_CURRENT_STATE(x)   ((x & 0x00001E00) >> 9) /* sx, b (4 bits) */
 
#define R1_READY_FOR_DATA   (1 << 8)/* sx, a */
 
#define R1_APP_CMD   (1 << 5)/* sr, c */
 
#define OCR_ALL_READY   (1UL << 31) /* Card Power up status bit */
 
#define OCR_HC_CCS   (1 << 30) /* High capacity card */
 
#define OCR_VOLTAGE_RANGE_MSK   0x00ff8000
 
#define SD_SEND_IF_ARG   0x000001AA
 
#define SD_SEND_IF_ECHO_MSK   0x000000FF
 
#define SD_SEND_IF_RESP   0x000000AA
 
#define CMD_MASK_RESP   (0x3UL << 28)
 
#define CMD_RESP(r)   (((r) & 0x3) << 28)
 
#define CMD_RESP_R0   (0 << 28)
 
#define CMD_RESP_R1   (1 << 28)
 
#define CMD_RESP_R2   (2 << 28)
 
#define CMD_RESP_R3   (3 << 28)
 
#define CMD_BIT_AUTO_STOP   (1 << 24)
 
#define CMD_BIT_APP   (1 << 23)
 
#define CMD_BIT_INIT   (1 << 22)
 
#define CMD_BIT_BUSY   (1 << 21)
 
#define CMD_BIT_LS   (1 << 20) /* Low speed, used during acquire */
 
#define CMD_BIT_DATA   (1 << 19)
 
#define CMD_BIT_WRITE   (1 << 18)
 
#define CMD_BIT_STREAM   (1 << 17)
 
#define CMD_MASK_CMD   (0xff)
 
#define CMD_SHIFT_CMD   (0)
 
#define CMD(c, r)   ( ((c) & CMD_MASK_CMD) | CMD_RESP((r)) )
 
#define CMD_IDLE   CMD(MMC_GO_IDLE_STATE, 0) | CMD_BIT_LS | CMD_BIT_INIT
 
#define CMD_SD_OP_COND   CMD(SD_APP_OP_COND, 1) | CMD_BIT_LS | CMD_BIT_APP
 
#define CMD_SD_SEND_IF_COND   CMD(SD_CMD8, 1) | CMD_BIT_LS
 
#define CMD_MMC_OP_COND   CMD(MMC_SEND_OP_COND, 3) | CMD_BIT_LS | CMD_BIT_INIT
 
#define CMD_ALL_SEND_CID   CMD(MMC_ALL_SEND_CID, 2) | CMD_BIT_LS
 
#define CMD_MMC_SET_RCA   CMD(MMC_SET_RELATIVE_ADDR, 1) | CMD_BIT_LS
 
#define CMD_SD_SEND_RCA   CMD(SD_SEND_RELATIVE_ADDR, 1) | CMD_BIT_LS
 
#define CMD_SEND_CSD   CMD(MMC_SEND_CSD, 2) | CMD_BIT_LS
 
#define CMD_SEND_EXT_CSD   CMD(MMC_SEND_EXT_CSD, 1) | CMD_BIT_LS | CMD_BIT_DATA
 
#define CMD_DESELECT_CARD   CMD(MMC_SELECT_CARD, 0)
 
#define CMD_SELECT_CARD   CMD(MMC_SELECT_CARD, 1)
 
#define CMD_SET_BLOCKLEN   CMD(MMC_SET_BLOCKLEN, 1)
 
#define CMD_SEND_STATUS   CMD(MMC_SEND_STATUS, 1)
 
#define CMD_READ_SINGLE   CMD(MMC_READ_SINGLE_BLOCK, 1) | CMD_BIT_DATA
 
#define CMD_READ_MULTIPLE   CMD(MMC_READ_MULTIPLE_BLOCK, 1) | CMD_BIT_DATA | CMD_BIT_AUTO_STOP
 
#define CMD_SD_SET_WIDTH   CMD(SD_APP_SET_BUS_WIDTH, 1) | CMD_BIT_APP
 
#define CMD_STOP   CMD(MMC_STOP_TRANSMISSION, 1) | CMD_BIT_BUSY
 
#define CMD_WRITE_SINGLE   CMD(MMC_WRITE_BLOCK, 1) | CMD_BIT_DATA | CMD_BIT_WRITE
 
#define CMD_WRITE_MULTIPLE   CMD(MMC_WRITE_MULTIPLE_BLOCK, 1) | CMD_BIT_DATA | CMD_BIT_WRITE | CMD_BIT_AUTO_STOP
 
#define CARD_TYPE_SD   (1 << 0)
 card type defines
 
#define CARD_TYPE_4BIT   (1 << 1)
 
#define CARD_TYPE_8BIT   (1 << 2)
 
#define CARD_TYPE_HC   (OCR_HC_CCS)
 
#define MMC_SECTOR_SIZE   512
 
#define US_TIMEOUT   1000000
 Setup options for the SDIO driver.
 
#define MS_ACQUIRE_DELAY   (10)
 
#define INIT_OP_RETRIES   50
 
#define SET_OP_RETRIES   1000
 
#define SDIO_BUS_WIDTH   4
 
#define SD_MMC_ENUM_CLOCK   400000
 
#define MMC_MAX_CLOCK   20000000
 
#define MMC_LOW_BUS_MAX_CLOCK   26000000
 
#define MMC_HIGH_BUS_MAX_CLOCK   52000000
 
#define SD_MAX_CLOCK   25000000
 

Typedefs

typedef void(* MCI_EVSETUP_FUNC_T )(uint32_t)
 
typedef uint32_t(* MCI_WAIT_CB_FUNC_T )(void)
 
typedef void(* MCI_MSDELAY_FUNC_T )(uint32_t)
 

Enumerations

enum  SDMMC_COMMAND_T {
  SDMMC_IDLE, MMC_SENDOP_COND, SDMMC_ALL_SEND_CID, SDMMC_SRA,
  MMC_PROGRAM_DSR, SDMMC_SELECT_CARD, SDMMC_SEND_CSD, SDMMC_SEND_CID,
  SDMMC_READ_UNTIL_STOP, SDMMC_STOP_XFER, SDMMC_SSTAT, SDMMC_INACTIVE,
  SDMMC_SET_BLEN, SDMMC_READ_SINGLE, SDMMC_READ_MULTIPLE, SDMMC_WRITE_UNTIL_STOP,
  SDMMC_SET_BLOCK_COUNT, SDMMC_WRITE_SINGLE, SDMMC_WRITE_MULTIPLE, MMC_PROGRAM_CID,
  SDMMC_PROGRAM_CSD, SDMMC_SET_WR_PROT, SDMMC_CLEAR_WR_PROT, SDMMC_SEND_WR_PROT,
  SD_ERASE_BLOCK_START, SD_ERASE_BLOCK_END, MMC_ERASE_BLOCK_START, MMC_ERASE_BLOCK_END,
  MMC_ERASE_BLOCKS, MMC_FAST_IO, MMC_GO_IRQ_STATE, MMC_LOCK_UNLOCK,
  SDMMC_APP_CMD, SDMMC_GEN_CMD, SDMMC_INVALID_CMD
}
 SD/MMC command enumeration value. More...
 
enum  SD_APP_CMD_T {
  SD_SET_BUS_WIDTH, SD_SEND_STATUS, SD_SEND_WR_BLOCKS, SD_SET_ERASE_COUNT,
  SD_SENDOP_COND, SD_CLEAR_CARD_DET, SD_SEND_SCR, SD_INVALID_APP_CMD
}
 SDMMC application specific commands for SD cards only - these must be preceded by the SDMMC CMD55 to work correctly. More...
 
enum  SDMMC_RESPONSE_T {
  SDMMC_RESPONSE_R1, SDMMC_RESPONSE_R1B, SDMMC_RESPONSE_R2, SDMMC_RESPONSE_R3,
  SDMMC_RESPONSE_R4, SDMMC_RESPONSE_R5, SDMMC_RESPONSE_R6, SDMMC_RESPONSE_NONE
}
 Possible SDMMC response types. More...
 
enum  SDMMC_STATE_T {
  SDMMC_IDLE_ST = 0, SDMMC_READY_ST, SDMMC_IDENT_ST, SDMMC_STBY_ST,
  SDMMC_TRAN_ST, SDMMC_DATA_ST, SDMMC_RCV_ST, SDMMC_PRG_ST,
  SDMMC_DIS_ST
}
 Possible SDMMC card state types. More...
 

Functions

STATIC INLINE int32_t Chip_SDMMC_CardNDetect (void)
 Detect if an SD card is inserted.
 
STATIC INLINE int32_t Chip_CardWpOn (void)
 Detect if write protect is enabled.
 
STATIC INLINE void Chip_SDMMC_Init (void)
 Initializes the MCI card controller.
 
STATIC INLINE void Chip_SDMMC_PowerOnOff (int32_t enable)
 Enable or disable slot power.
 
STATIC INLINE void Chip_SDMMC_SetIntMask (uint32_t iVal)
 Sets the SD interface interrupt mask.
 
uint32_t Chip_SDMMC_GetIntStatus (void)
 Returns the current SD status, clears pending ints, and disables all ints.
 
int32_t Chip_SDMMC_GetState (void)
 Get card's current state (idle, transfer, program, etc.)
 
uint32_t Chip_SDMMC_Acquire (mci_card_struct *pcardinfo)
 Function to enumerate the SD/MMC/SDHC/MMC+ cards.
 
int32_t Chip_SDMMC_GetDeviceSize (void)
 Get the device size of SD/MMC card (after enumeration)
 
int32_t Chip_SDMMC_ReadBlocks (void *buffer, int32_t start_block, int32_t num_blocks)
 Performs the read of data from the SD/MMC card.
 
int32_t Chip_SDMMC_WriteBlocks (void *buffer, int32_t start_block, int32_t num_blocks)
 Performs write of data to the SD/MMC card.
 

Detailed Description

Macro Definition Documentation

#define CARD_TYPE_4BIT   (1 << 1)

Definition at line 329 of file sdmmc_18xx_43xx.h.

#define CARD_TYPE_8BIT   (1 << 2)

Definition at line 330 of file sdmmc_18xx_43xx.h.

#define CARD_TYPE_HC   (OCR_HC_CCS)

high capacity card > 2GB

Definition at line 331 of file sdmmc_18xx_43xx.h.

#define CARD_TYPE_SD   (1 << 0)

card type defines

Definition at line 328 of file sdmmc_18xx_43xx.h.

#define CMD (   c,
 
)    ( ((c) & CMD_MASK_CMD) | CMD_RESP((r)) )

Definition at line 304 of file sdmmc_18xx_43xx.h.

#define CMD_ALL_SEND_CID   CMD(MMC_ALL_SEND_CID, 2) | CMD_BIT_LS

Definition at line 310 of file sdmmc_18xx_43xx.h.

#define CMD_BIT_APP   (1 << 23)

Definition at line 294 of file sdmmc_18xx_43xx.h.

#define CMD_BIT_AUTO_STOP   (1 << 24)

Definition at line 293 of file sdmmc_18xx_43xx.h.

#define CMD_BIT_BUSY   (1 << 21)

Definition at line 296 of file sdmmc_18xx_43xx.h.

#define CMD_BIT_DATA   (1 << 19)

Definition at line 298 of file sdmmc_18xx_43xx.h.

#define CMD_BIT_INIT   (1 << 22)

Definition at line 295 of file sdmmc_18xx_43xx.h.

#define CMD_BIT_LS   (1 << 20) /* Low speed, used during acquire */

Definition at line 297 of file sdmmc_18xx_43xx.h.

#define CMD_BIT_STREAM   (1 << 17)

Definition at line 300 of file sdmmc_18xx_43xx.h.

#define CMD_BIT_WRITE   (1 << 18)

Definition at line 299 of file sdmmc_18xx_43xx.h.

#define CMD_DESELECT_CARD   CMD(MMC_SELECT_CARD, 0)

Definition at line 315 of file sdmmc_18xx_43xx.h.

#define CMD_IDLE   CMD(MMC_GO_IDLE_STATE, 0) | CMD_BIT_LS | CMD_BIT_INIT

Definition at line 306 of file sdmmc_18xx_43xx.h.

#define CMD_MASK_CMD   (0xff)

Definition at line 301 of file sdmmc_18xx_43xx.h.

#define CMD_MASK_RESP   (0x3UL << 28)

Definition at line 287 of file sdmmc_18xx_43xx.h.

#define CMD_MMC_OP_COND   CMD(MMC_SEND_OP_COND, 3) | CMD_BIT_LS | CMD_BIT_INIT

Definition at line 309 of file sdmmc_18xx_43xx.h.

#define CMD_MMC_SET_RCA   CMD(MMC_SET_RELATIVE_ADDR, 1) | CMD_BIT_LS

Definition at line 311 of file sdmmc_18xx_43xx.h.

#define CMD_READ_MULTIPLE   CMD(MMC_READ_MULTIPLE_BLOCK, 1) | CMD_BIT_DATA | CMD_BIT_AUTO_STOP

Definition at line 320 of file sdmmc_18xx_43xx.h.

#define CMD_READ_SINGLE   CMD(MMC_READ_SINGLE_BLOCK, 1) | CMD_BIT_DATA

Definition at line 319 of file sdmmc_18xx_43xx.h.

#define CMD_RESP (   r)    (((r) & 0x3) << 28)

Definition at line 288 of file sdmmc_18xx_43xx.h.

#define CMD_RESP_R0   (0 << 28)

Definition at line 289 of file sdmmc_18xx_43xx.h.

#define CMD_RESP_R1   (1 << 28)

Definition at line 290 of file sdmmc_18xx_43xx.h.

#define CMD_RESP_R2   (2 << 28)

Definition at line 291 of file sdmmc_18xx_43xx.h.

#define CMD_RESP_R3   (3 << 28)

Definition at line 292 of file sdmmc_18xx_43xx.h.

#define CMD_SD_OP_COND   CMD(SD_APP_OP_COND, 1) | CMD_BIT_LS | CMD_BIT_APP

Definition at line 307 of file sdmmc_18xx_43xx.h.

#define CMD_SD_SEND_IF_COND   CMD(SD_CMD8, 1) | CMD_BIT_LS

Definition at line 308 of file sdmmc_18xx_43xx.h.

#define CMD_SD_SEND_RCA   CMD(SD_SEND_RELATIVE_ADDR, 1) | CMD_BIT_LS

Definition at line 312 of file sdmmc_18xx_43xx.h.

#define CMD_SD_SET_WIDTH   CMD(SD_APP_SET_BUS_WIDTH, 1) | CMD_BIT_APP

Definition at line 321 of file sdmmc_18xx_43xx.h.

#define CMD_SELECT_CARD   CMD(MMC_SELECT_CARD, 1)

Definition at line 316 of file sdmmc_18xx_43xx.h.

#define CMD_SEND_CSD   CMD(MMC_SEND_CSD, 2) | CMD_BIT_LS

Definition at line 313 of file sdmmc_18xx_43xx.h.

#define CMD_SEND_EXT_CSD   CMD(MMC_SEND_EXT_CSD, 1) | CMD_BIT_LS | CMD_BIT_DATA

Definition at line 314 of file sdmmc_18xx_43xx.h.

#define CMD_SEND_STATUS   CMD(MMC_SEND_STATUS, 1)

Definition at line 318 of file sdmmc_18xx_43xx.h.

#define CMD_SET_BLOCKLEN   CMD(MMC_SET_BLOCKLEN, 1)

Definition at line 317 of file sdmmc_18xx_43xx.h.

#define CMD_SHIFT_CMD   (0)

Definition at line 302 of file sdmmc_18xx_43xx.h.

#define CMD_STOP   CMD(MMC_STOP_TRANSMISSION, 1) | CMD_BIT_BUSY

Definition at line 322 of file sdmmc_18xx_43xx.h.

#define CMD_WRITE_MULTIPLE   CMD(MMC_WRITE_MULTIPLE_BLOCK, 1) | CMD_BIT_DATA | CMD_BIT_WRITE | CMD_BIT_AUTO_STOP

Definition at line 324 of file sdmmc_18xx_43xx.h.

#define CMD_WRITE_SINGLE   CMD(MMC_WRITE_BLOCK, 1) | CMD_BIT_DATA | CMD_BIT_WRITE

Definition at line 323 of file sdmmc_18xx_43xx.h.

#define INIT_OP_RETRIES   50

initial OP_COND retries

Definition at line 339 of file sdmmc_18xx_43xx.h.

#define MMC_ALL_SEND_CID   2 /* bcr R2 */

Definition at line 182 of file sdmmc_18xx_43xx.h.

#define MMC_APP_CMD   55 /* ac [31:16] RCA R1 */

Definition at line 226 of file sdmmc_18xx_43xx.h.

#define MMC_CLR_WRITE_PROT   29 /* ac [31:0] data addr R1b */

Definition at line 210 of file sdmmc_18xx_43xx.h.

#define MMC_ERASE   37 /* ac R1b */

Definition at line 216 of file sdmmc_18xx_43xx.h.

#define MMC_ERASE_GROUP_END   36 /* ac [31:0] data addr R1 */

Definition at line 215 of file sdmmc_18xx_43xx.h.

#define MMC_ERASE_GROUP_START   35 /* ac [31:0] data addr R1 */

Definition at line 214 of file sdmmc_18xx_43xx.h.

#define MMC_FAST_IO   39 /* ac <Complex> R4 */

Definition at line 219 of file sdmmc_18xx_43xx.h.

#define MMC_GEN_CMD   56 /* adtc [0] RD/WR R1b */

Definition at line 227 of file sdmmc_18xx_43xx.h.

#define MMC_GO_IDLE_STATE   0 /* bc */

Definition at line 180 of file sdmmc_18xx_43xx.h.

#define MMC_GO_INACTIVE_STATE   15 /* ac [31:16] RCA */

Definition at line 191 of file sdmmc_18xx_43xx.h.

#define MMC_GO_IRQ_STATE   40 /* bcr R5 */

Definition at line 220 of file sdmmc_18xx_43xx.h.

#define MMC_HIGH_BUS_MAX_CLOCK   52000000

Type 1 MMC card max clock rate

Definition at line 345 of file sdmmc_18xx_43xx.h.

#define MMC_LOCK_UNLOCK   42 /* adtc R1b */

Definition at line 223 of file sdmmc_18xx_43xx.h.

#define MMC_LOW_BUS_MAX_CLOCK   26000000

Type 0 MMC card max clock rate

Definition at line 344 of file sdmmc_18xx_43xx.h.

#define MMC_MAX_CLOCK   20000000

Max MMC clock rate

Definition at line 343 of file sdmmc_18xx_43xx.h.

#define MMC_PROGRAM_CID   26 /* adtc R1 */

Definition at line 205 of file sdmmc_18xx_43xx.h.

#define MMC_PROGRAM_CSD   27 /* adtc R1 */

Definition at line 206 of file sdmmc_18xx_43xx.h.

#define MMC_READ_MULTIPLE_BLOCK   18 /* adtc [31:0] data addr R1 */

Definition at line 196 of file sdmmc_18xx_43xx.h.

#define MMC_READ_SINGLE_BLOCK   17 /* adtc [31:0] data addr R1 */

Definition at line 195 of file sdmmc_18xx_43xx.h.

#define MMC_SECTOR_SIZE   512

Definition at line 333 of file sdmmc_18xx_43xx.h.

#define MMC_SELECT_CARD   7 /* ac [31:16] RCA R1 */

Definition at line 185 of file sdmmc_18xx_43xx.h.

#define MMC_SEND_CID   10 /* ac [31:16] RCA R2 */

Definition at line 188 of file sdmmc_18xx_43xx.h.

#define MMC_SEND_CSD   9 /* ac [31:16] RCA R2 */

Definition at line 187 of file sdmmc_18xx_43xx.h.

#define MMC_SEND_EXT_CSD   8 /* bc R1 */

Definition at line 186 of file sdmmc_18xx_43xx.h.

#define MMC_SEND_OP_COND   1 /* bcr [31:0] OCR R3 */

Definition at line 181 of file sdmmc_18xx_43xx.h.

#define MMC_SEND_STATUS   13 /* ac [31:16] RCA R1 */

Definition at line 190 of file sdmmc_18xx_43xx.h.

#define MMC_SEND_WRITE_PROT   30 /* adtc [31:0] wpdata addr R1 */

Definition at line 211 of file sdmmc_18xx_43xx.h.

#define MMC_SET_BLOCK_COUNT   23 /* adtc [31:0] data addr R1 */

Definition at line 202 of file sdmmc_18xx_43xx.h.

#define MMC_SET_BLOCKLEN   16 /* ac [31:0] block len R1 */

Definition at line 194 of file sdmmc_18xx_43xx.h.

#define MMC_SET_DSR   4 /* bc [31:16] RCA */

Definition at line 184 of file sdmmc_18xx_43xx.h.

#define MMC_SET_RELATIVE_ADDR   3 /* ac [31:16] RCA R1 */

Definition at line 183 of file sdmmc_18xx_43xx.h.

#define MMC_SET_WRITE_PROT   28 /* ac [31:0] data addr R1b */

Definition at line 209 of file sdmmc_18xx_43xx.h.

#define MMC_STOP_TRANSMISSION   12 /* ac R1b */

Definition at line 189 of file sdmmc_18xx_43xx.h.

#define MMC_WRITE_BLOCK   24 /* adtc [31:0] data addr R1 */

Definition at line 203 of file sdmmc_18xx_43xx.h.

#define MMC_WRITE_DAT_UNTIL_STOP   20 /* adtc [31:0] data addr R1 */

Definition at line 199 of file sdmmc_18xx_43xx.h.

#define MMC_WRITE_MULTIPLE_BLOCK   25 /* adtc R1 */

Definition at line 204 of file sdmmc_18xx_43xx.h.

#define MS_ACQUIRE_DELAY   (10)

inter-command acquire oper condition delay in msec

Definition at line 338 of file sdmmc_18xx_43xx.h.

#define OCR_ALL_READY   (1UL << 31) /* Card Power up status bit */

Definition at line 279 of file sdmmc_18xx_43xx.h.

#define OCR_HC_CCS   (1 << 30) /* High capacity card */

Definition at line 280 of file sdmmc_18xx_43xx.h.

#define OCR_VOLTAGE_RANGE_MSK   0x00ff8000

Definition at line 281 of file sdmmc_18xx_43xx.h.

#define R1_ADDRESS_ERROR   (1 << 30) /* erx, c */

Definition at line 256 of file sdmmc_18xx_43xx.h.

#define R1_APP_CMD   (1 << 5)/* sr, c */

Definition at line 277 of file sdmmc_18xx_43xx.h.

#define R1_BLOCK_LEN_ERROR   (1 << 29) /* er, c */

Definition at line 257 of file sdmmc_18xx_43xx.h.

#define R1_CARD_ECC_DISABLED   (1 << 14) /* sx, a */

Definition at line 272 of file sdmmc_18xx_43xx.h.

#define R1_CARD_ECC_FAILED   (1 << 21) /* ex, c */

Definition at line 265 of file sdmmc_18xx_43xx.h.

#define R1_CARD_IS_LOCKED   (1 << 25) /* sx, a */

Definition at line 261 of file sdmmc_18xx_43xx.h.

#define R1_CC_ERROR   (1 << 20) /* erx, c */

Definition at line 266 of file sdmmc_18xx_43xx.h.

#define R1_CID_CSD_OVERWRITE   (1 << 16) /* erx, c, CID/CSD overwrite */

Definition at line 270 of file sdmmc_18xx_43xx.h.

#define R1_COM_CRC_ERROR   (1 << 23) /* er, b */

Definition at line 263 of file sdmmc_18xx_43xx.h.

#define R1_CURRENT_STATE (   x)    ((x & 0x00001E00) >> 9) /* sx, b (4 bits) */

Definition at line 275 of file sdmmc_18xx_43xx.h.

#define R1_ERASE_PARAM   (1 << 27) /* ex, c */

Definition at line 259 of file sdmmc_18xx_43xx.h.

#define R1_ERASE_RESET   (1 << 13) /* sr, c */

Definition at line 273 of file sdmmc_18xx_43xx.h.

#define R1_ERASE_SEQ_ERROR   (1 << 28) /* er, c */

Definition at line 258 of file sdmmc_18xx_43xx.h.

#define R1_ERROR   (1 << 19) /* erx, c */

Definition at line 267 of file sdmmc_18xx_43xx.h.

#define R1_ILLEGAL_COMMAND   (1 << 22) /* er, b */

Definition at line 264 of file sdmmc_18xx_43xx.h.

#define R1_LOCK_UNLOCK_FAILED   (1 << 24) /* erx, c */

Definition at line 262 of file sdmmc_18xx_43xx.h.

#define R1_OUT_OF_RANGE   (1UL << 31) /* er, c */

Definition at line 255 of file sdmmc_18xx_43xx.h.

#define R1_OVERRUN   (1 << 17) /* ex, c */

Definition at line 269 of file sdmmc_18xx_43xx.h.

#define R1_READY_FOR_DATA   (1 << 8)/* sx, a */

Definition at line 276 of file sdmmc_18xx_43xx.h.

#define R1_STATUS (   x)    (x & 0xFFFFE000)

Definition at line 274 of file sdmmc_18xx_43xx.h.

#define R1_UNDERRUN   (1 << 18) /* ex, c */

Definition at line 268 of file sdmmc_18xx_43xx.h.

#define R1_WP_ERASE_SKIP   (1 << 15) /* sx, c */

Definition at line 271 of file sdmmc_18xx_43xx.h.

#define R1_WP_VIOLATION   (1 << 26) /* erx, c */

Definition at line 260 of file sdmmc_18xx_43xx.h.

#define SD_APP_OP_COND   41 /* bcr [31:0] OCR R1 (R4) */

Definition at line 237 of file sdmmc_18xx_43xx.h.

#define SD_APP_SEND_SCR   51 /* adtc R1 */

Definition at line 238 of file sdmmc_18xx_43xx.h.

#define SD_APP_SET_BUS_WIDTH   6 /* ac [1:0] bus width R1 */

Definition at line 236 of file sdmmc_18xx_43xx.h.

#define SD_CMD8   8 /* bcr [31:0] OCR R3 */

Definition at line 233 of file sdmmc_18xx_43xx.h.

#define SD_MAX_CLOCK   25000000

Max SD clock rate

Definition at line 346 of file sdmmc_18xx_43xx.h.

#define SD_MMC_ENUM_CLOCK   400000

Typical enumeration clock rate

Definition at line 342 of file sdmmc_18xx_43xx.h.

#define SD_SEND_IF_ARG   0x000001AA

Definition at line 283 of file sdmmc_18xx_43xx.h.

#define SD_SEND_IF_ECHO_MSK   0x000000FF

Definition at line 284 of file sdmmc_18xx_43xx.h.

#define SD_SEND_IF_RESP   0x000000AA

Definition at line 285 of file sdmmc_18xx_43xx.h.

#define SD_SEND_RELATIVE_ADDR   3 /* ac R6 */

Definition at line 232 of file sdmmc_18xx_43xx.h.

#define SDIO_BUS_WIDTH   4

Max bus width supported

Definition at line 341 of file sdmmc_18xx_43xx.h.

#define SET_OP_RETRIES   1000

set OP_COND retries

Definition at line 340 of file sdmmc_18xx_43xx.h.

#define US_TIMEOUT   1000000

Setup options for the SDIO driver.

give 1 atleast 1 sec for the card to respond

Definition at line 337 of file sdmmc_18xx_43xx.h.

Typedef Documentation

typedef void(* MCI_EVSETUP_FUNC_T)(uint32_t)

Definition at line 349 of file sdmmc_18xx_43xx.h.

typedef void(* MCI_MSDELAY_FUNC_T)(uint32_t)

Definition at line 355 of file sdmmc_18xx_43xx.h.

typedef uint32_t(* MCI_WAIT_CB_FUNC_T)(void)

Definition at line 352 of file sdmmc_18xx_43xx.h.

Enumeration Type Documentation

SDMMC application specific commands for SD cards only - these must be preceded by the SDMMC CMD55 to work correctly.

Enumerator:
SD_SET_BUS_WIDTH 

Set the SD bus width

SD_SEND_STATUS 

Send the SD card status

SD_SEND_WR_BLOCKS 

Send the number of written clocks

SD_SET_ERASE_COUNT 

Set the number of blocks to pre-erase

SD_SENDOP_COND 

Send the OCR register (init)

SD_CLEAR_CARD_DET 

Set or clear the 50K detect pullup

SD_SEND_SCR 

Send the SD configuration register

SD_INVALID_APP_CMD 

Invalid SD application command

Definition at line 140 of file sdmmc_18xx_43xx.h.

SD/MMC command enumeration value.

Enumerator:
SDMMC_IDLE 

Put card in idle mode

MMC_SENDOP_COND 

Send operating condition

SDMMC_ALL_SEND_CID 

All cards send CID

SDMMC_SRA 

Set relative address

MMC_PROGRAM_DSR 

Program DSR

SDMMC_SELECT_CARD 

Select card

SDMMC_SEND_CSD 

Send CSD data

SDMMC_SEND_CID 

Send CID register data (with rel. addr)

SDMMC_READ_UNTIL_STOP 

Read data until stop

SDMMC_STOP_XFER 

Stop current transmission

SDMMC_SSTAT 

Send status

SDMMC_INACTIVE 

Put card in inactive state

SDMMC_SET_BLEN 

Set block transfer length

SDMMC_READ_SINGLE 

Read single block

SDMMC_READ_MULTIPLE 

Read multiple blocks

SDMMC_WRITE_UNTIL_STOP 

Write data until stop

SDMMC_SET_BLOCK_COUNT 

Set block count

SDMMC_WRITE_SINGLE 

Write single block

SDMMC_WRITE_MULTIPLE 

Write multiple blocks

MMC_PROGRAM_CID 

Program CID

SDMMC_PROGRAM_CSD 

Program CSD

SDMMC_SET_WR_PROT 

Set write protection

SDMMC_CLEAR_WR_PROT 

Clear write protection

SDMMC_SEND_WR_PROT 

Send write protection

SD_ERASE_BLOCK_START 

Set starting erase block

SD_ERASE_BLOCK_END 

Set ending erase block

MMC_ERASE_BLOCK_START 

Set starting erase block

MMC_ERASE_BLOCK_END 

Set ending erase block

MMC_ERASE_BLOCKS 

Erase blocks

MMC_FAST_IO 

Fast IO

MMC_GO_IRQ_STATE 

Go into IRQ state

MMC_LOCK_UNLOCK 

Lock/unlock

SDMMC_APP_CMD 

Application specific command

SDMMC_GEN_CMD 

General purpose command

SDMMC_INVALID_CMD 

Invalid SDMMC command

Definition at line 99 of file sdmmc_18xx_43xx.h.

Possible SDMMC response types.

Enumerator:
SDMMC_RESPONSE_R1 

Typical status

SDMMC_RESPONSE_R1B 

Typical status with busy

SDMMC_RESPONSE_R2 

CID/CSD registers (CMD2 and CMD10)

SDMMC_RESPONSE_R3 

OCR register (CMD1, ACMD41)

SDMMC_RESPONSE_R4 

Fast IO response word

SDMMC_RESPONSE_R5 

Go IRQ state response word

SDMMC_RESPONSE_R6 

Published RCA response

SDMMC_RESPONSE_NONE 

No response expected

Definition at line 153 of file sdmmc_18xx_43xx.h.

Possible SDMMC card state types.

Enumerator:
SDMMC_IDLE_ST 

Idle state

SDMMC_READY_ST 

Ready state

SDMMC_IDENT_ST 

Identification State

SDMMC_STBY_ST 

standby state

SDMMC_TRAN_ST 

transfer state

SDMMC_DATA_ST 

Sending-data State

SDMMC_RCV_ST 

Receive-data State

SDMMC_PRG_ST 

Programming State

SDMMC_DIS_ST 

Disconnect State

Definition at line 166 of file sdmmc_18xx_43xx.h.

Function Documentation

STATIC INLINE int32_t Chip_CardWpOn ( void  )

Detect if write protect is enabled.

Returns
Returns 1 if card is write protected, otherwise 0 Detect if write protect is enabled (uses SD_WP pin, returns 1 if card is write protected)

Definition at line 393 of file sdmmc_18xx_43xx.h.

uint32_t Chip_SDMMC_Acquire ( mci_card_struct pcardinfo)

Function to enumerate the SD/MMC/SDHC/MMC+ cards.

Parameters
pcardinfo: Pointer to pre-allocated card info structure
Returns
1 if a card is acquired, otherwise 0

Definition at line 334 of file sdmmc_18xx_43xx.c.

STATIC INLINE int32_t Chip_SDMMC_CardNDetect ( void  )

Detect if an SD card is inserted.

Returns
Returns 0 if a card is detected, otherwise 1 Detect if an SD card is inserted (uses SD_CD pin, returns 0 on card detect)

Definition at line 382 of file sdmmc_18xx_43xx.h.

int32_t Chip_SDMMC_GetDeviceSize ( void  )

Get the device size of SD/MMC card (after enumeration)

Returns
Card size (capacity)

Definition at line 496 of file sdmmc_18xx_43xx.c.

uint32_t Chip_SDMMC_GetIntStatus ( void  )

Returns the current SD status, clears pending ints, and disables all ints.

Returns
Current pending interrupt status of Or'ed values MCI_INT_*

Definition at line 306 of file sdmmc_18xx_43xx.c.

int32_t Chip_SDMMC_GetState ( void  )

Get card's current state (idle, transfer, program, etc.)

Returns
Current SD card transfer state

Definition at line 319 of file sdmmc_18xx_43xx.c.

STATIC INLINE void Chip_SDMMC_Init ( void  )

Initializes the MCI card controller.

Returns
None

Definition at line 402 of file sdmmc_18xx_43xx.h.

STATIC INLINE void Chip_SDMMC_PowerOnOff ( int32_t  enable)

Enable or disable slot power.

Parameters
enable: !0 to enable, or 0 to disable
Returns
None Enable or disable slot power, !0 = enable slot power (Uses SD_POW pin, set to high or low based on enable parameter state)

Definition at line 414 of file sdmmc_18xx_43xx.h.

int32_t Chip_SDMMC_ReadBlocks ( void *  buffer,
int32_t  start_block,
int32_t  num_blocks 
)

Performs the read of data from the SD/MMC card.

Parameters
buffer: Pointer to data buffer to copy to
start_block: Start block number
num_blocks: Number of block to read
Returns
Bytes read, or 0 on error

Definition at line 502 of file sdmmc_18xx_43xx.c.

STATIC INLINE void Chip_SDMMC_SetIntMask ( uint32_t  iVal)

Sets the SD interface interrupt mask.

Parameters
iVal: Interrupts to enable, Or'ed values MCI_INT_*
Returns
None

Definition at line 424 of file sdmmc_18xx_43xx.h.

int32_t Chip_SDMMC_WriteBlocks ( void *  buffer,
int32_t  start_block,
int32_t  num_blocks 
)

Performs write of data to the SD/MMC card.

Parameters
buffer: Pointer to data buffer to copy to
start_block: Start block number
num_blocks: Number of block to write
Returns
Number of bytes actually written, or 0 on error

Definition at line 549 of file sdmmc_18xx_43xx.c.