60#define CARD_TYPE_UNKNOWN (0)
61#define CARD_TYPE_SD (1 << 0)
62#define CARD_TYPE_MMC (1 << 1)
63#define CARD_TYPE_SDIO (1 << 2)
64#define CARD_TYPE_HC (1 << 3)
66#define CARD_TYPE_SD_COMBO (CARD_TYPE_SD | CARD_TYPE_SDIO)
71#define CARD_VER_UNKNOWN (0)
72#define CARD_VER_SD_1_0 (0x10)
73#define CARD_VER_SD_1_10 (0x1A)
74#define CARD_VER_SD_2_0 (0X20)
75#define CARD_VER_SD_3_0 (0X30)
76#define CARD_VER_MMC_1_2 (0x12)
77#define CARD_VER_MMC_1_4 (0x14)
78#define CARD_VER_MMC_2_2 (0x22)
79#define CARD_VER_MMC_3 (0x30)
80#define CARD_VER_MMC_4 (0x40)
85#define MCI_RESP_PRESENT (1ul << 8)
86#define MCI_RESP_136 (1ul << 11)
87#define MCI_RESP_CRC (1ul << 12)
88#define MCI_RESP_BUSY (1ul << 13)
89#define MCI_CMD_OPENDRAIN (1ul << 14)
90#define MCI_CMD_WRITE (1ul << 15)
91#define MCI_CMD_SDIO_BYTE (1ul << 16)
92#define MCI_CMD_SDIO_BLOCK (1ul << 17)
93#define MCI_CMD_STREAM (1ul << 18)
94#define MCI_CMD_SINGLE_BLOCK (1ul << 19)
95#define MCI_CMD_MULTI_BLOCK (1ul << 20)
99#define SD_MMC_BLOCK_SIZE 512
100#define SDHC_SLOW_CLOCK_HZ 400000
101#define SDHC_FAST_CLOCK_HZ 25000000
Low-level GPIO peripheral driver interface definitions.
int sdhc_write_blocks(sdhc_state_t *state, uint32_t block, const void *src, uint16_t num)
Write memory to SD card blocks.
bool sdhc_send_cmd(sdhc_state_t *state, uint32_t cmd, uint32_t arg)
Send a command to the SD card.
int sdhc_erase_blocks(sdhc_state_t *state, uint32_t block, uint16_t num)
Erase memory from SD card blocks.
int sdhc_init(sdhc_state_t *state)
Initialize the SD host controller.
int sdhc_read_blocks(sdhc_state_t *state, uint32_t block, void *dst, uint16_t num)
Read blocks from the SD card into memory.
Mutex for thread synchronization.
uint16_t error
Last error state
bool need_init
Card installed but not initialized if true.
uint8_t bus_width
Acceptable Bus Width (1 or 4)
uint8_t version
Version of Card
gpio_t wp
Write Protect pin
uint32_t sectors
Capacity in bytes
uint16_t rca
Relative Card Address
uint32_t clock
Accepted Cloc Rate in Hz
mutex_t lock
Ensure thread-safe access
bool high_speed
Turbo mode