62 # define sd_mmc_debug(...) printf(__VA_ARGS__) 64 # define sd_mmc_debug(...) 67 #ifndef SD_MMC_SPI_MEM_CNT 68 # define SD_MMC_SPI_MEM_CNT 0 70 #ifndef SD_MMC_MCI_MEM_CNT 71 # define SD_MMC_MCI_MEM_CNT 0 73 #ifndef SD_MMC_HSMCI_MEM_CNT 74 # define SD_MMC_HSMCI_MEM_CNT 0 78 #ifdef SD_MMC_SPI_MODE 79 # if (SD_MMC_SPI_MEM_CNT != 0) 80 # include "sd_mmc_spi.h" 81 # define driver sd_mmc_spi 82 # define SD_MMC_MEM_CNT SD_MMC_SPI_MEM_CNT 83 # define sd_mmc_is_spi() true 85 # error No SPI interface is defined for SD MMC stack. \ 86 SD_MMC_SPI_MEM_CNT must be added in board.h file. 89 # if (SD_MMC_HSMCI_MEM_CNT != 0) 92 # define SD_MMC_MEM_CNT SD_MMC_HSMCI_MEM_CNT 93 # define sd_mmc_is_spi() false 94 # elif (SD_MMC_MCI_MEM_CNT != 0) 97 # define SD_MMC_MEM_CNT SD_MMC_MCI_MEM_CNT 98 # define sd_mmc_is_spi() false 100 # error No MCI or HSMCI interfaces are defined for SD MMC stack. \ 101 SD_MMC_MCI_MEM_CNT or SD_MMC_HSMCI_MEM_CNT must be added in board.h file. 106 #define driver_init ATPASTE2(driver, _init) 107 #define driver_select_device ATPASTE2(driver, _select_device) 108 #define driver_deselect_device ATPASTE2(driver, _deselect_device) 109 #define driver_get_bus_width ATPASTE2(driver, _get_bus_width) 110 #define driver_is_high_speed_capable ATPASTE2(driver, _is_high_speed_capable) 111 #define driver_send_clock ATPASTE2(driver, _send_clock) 112 #define driver_send_cmd ATPASTE2(driver, _send_cmd) 113 #define driver_get_response ATPASTE2(driver, _get_response) 114 #define driver_get_response_128 ATPASTE2(driver, _get_response_128) 115 #define driver_adtc_start ATPASTE2(driver, _adtc_start) 116 #define driver_adtc_stop ATPASTE2(driver, _send_cmd) 117 #define driver_read_word ATPASTE2(driver, _read_word) 118 #define driver_write_word ATPASTE2(driver, _write_word) 119 #define driver_start_read_blocks ATPASTE2(driver, _start_read_blocks) 120 #define driver_wait_end_of_read_blocks ATPASTE2(driver, _wait_end_of_read_blocks) 121 #define driver_start_write_blocks ATPASTE2(driver, _start_write_blocks) 122 #define driver_wait_end_of_write_blocks ATPASTE2(driver, _wait_end_of_write_blocks) 125 #if (!defined SD_MMC_0_CD_GPIO) || (!defined SD_MMC_0_CD_DETECT_VALUE) 126 # warning No pin for card detection has been defined in board.h. \ 127 The define SD_MMC_0_CD_GPIO, SD_MMC_0_CD_DETECT_VALUE must be added in board.h file. 130 #ifdef SDIO_SUPPORT_ENABLE 131 # define IS_SDIO() (sd_mmc_card->type & CARD_TYPE_SDIO) 133 # define IS_SDIO() false 136 #define sd_mmc_is_mci() (!sd_mmc_is_spi()) 139 #define SD_MMC_VOLTAGE_SUPPORT \ 140 (OCR_VDD_27_28 | OCR_VDD_28_29 | \ 141 OCR_VDD_29_30 | OCR_VDD_30_31 | \ 142 OCR_VDD_31_32 | OCR_VDD_32_33) 157 #if (defined SD_MMC_0_CD_GPIO) 159 # if (defined SD_MMC_0_WP_GPIO) 177 # define SD_MMC_CD_WP(slot, unused) \ 178 {.cd_gpio = SD_MMC_##slot##_CD_GPIO, \ 179 .wp_gpio = SD_MMC_##slot##_WP_GPIO}, 180 MREPEAT(SD_MMC_MEM_CNT, SD_MMC_CD_WP, ~)
183 #elif (defined SD_MMC_0_CD_GPIO) 185 # define SD_MMC_CD(slot, unused) \ 186 {.cd_gpio = SD_MMC_##slot##_CD_GPIO}, 187 MREPEAT(SD_MMC_MEM_CNT, SD_MMC_CD, ~)
204 10, 100, 1000, 10000, 0, 0, 0
208 0, 10, 12, 13, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80
212 0, 10, 12, 13, 15, 20, 26, 30, 35, 40, 45, 52, 55, 60, 70, 80
228 static bool sd_cmd8(uint8_t * v2);
229 static bool mmc_cmd8(uint8_t *b_authorize_high_speed);
235 #ifdef SDIO_SUPPORT_ENABLE 236 static bool sdio_cmd52(uint8_t rw_flag, uint8_t func_nb,
237 uint32_t reg_addr, uint8_t rd_after_wr, uint8_t *io_data);
238 static bool sdio_cmd53(uint8_t rw_flag, uint8_t func_nb, uint32_t reg_addr,
239 uint8_t inc_addr, uint32_t size,
bool access_block);
240 #endif // SDIO_SUPPORT_ENABLE 259 #define SD_MMC_DEBOUNCE_TIMEOUT 1000 // Unit ms 262 # define SD_MMC_START_TIMEOUT() delay_ms(SD_MMC_DEBOUNCE_TIMEOUT) 263 # define SD_MMC_IS_TIMEOUT() true 264 # define SD_MMC_STOP_TIMEOUT() 268 static t_cpu_time timer;
269 # define SD_MMC_START_TIMEOUT() \ 270 cpu_set_timeout(cpu_ms_2_cy(SD_MMC_DEBOUNCE_TIMEOUT, sysclk_get_cpu_hz()), &timer) 271 # define SD_MMC_IS_TIMEOUT() \ 272 cpu_is_timeout(&timer) 273 # define SD_MMC_STOP_TIMEOUT() 277 static bool sd_mmc_sam_systick_used;
278 # ifdef FREERTOS_USED 282 static inline void SD_MMC_START_TIMEOUT(
void)
285 sd_mmc_sam_systick_used =
true;
290 sd_mmc_sam_systick_used =
false;
301 static inline bool SD_MMC_IS_TIMEOUT(
void)
303 if (!sd_mmc_sam_systick_used) {
319 static inline void SD_MMC_STOP_TIMEOUT(
void)
321 if (sd_mmc_sam_systick_used) {
337 uint32_t retry, resp;
348 __func__, (
int)(7150 - retry));
384 uint32_t retry, resp;
396 __func__, (
int)(4200 - retry));
428 uint32_t arg, retry, resp;
460 sd_mmc_debug(
"%s: ACMD41 Timeout on busy, resp32 0x%08x \n\r",
488 uint32_t arg, retry, resp;
525 sd_mmc_debug(
"%s: ACMD41 Timeout on busy, resp32 0x%08x \n\r",
533 #ifdef SDIO_SUPPORT_ENABLE 563 uint32_t cmd5_retry = 5000;
575 if (cmd5_retry-- == 0) {
601 uint32_t addr_new, addr_old;
605 uint8_t tplfe_max_tran_speed, i;
610 for(i = 0; i < 4; i++) {
614 addr_old = addr_cis[0] + (addr_cis[1] << 8) + \
615 (addr_cis[2] << 16) + (addr_cis[3] << 24);
634 addr_new += buf[1]-1;
635 if (addr_new > (addr_old + 256)) {
642 for(i = 0; i < 6; i++) {
647 tplfe_max_tran_speed = buf[5];
648 if (tplfe_max_tran_speed > 0x32) {
654 tplfe_max_tran_speed = 0x32;
660 sd_mmc_card->
clock = unit * mul * 1000;
724 if ((u8_value &
SDIO_SHS) != SDIO_SHS) {
735 sd_mmc_card->
clock *= 2;
756 #endif // SDIO_SUPPORT_ENABLE 790 sd_mmc_debug(
"%s: CMD6 CARD_STATUS_SWITCH_ERROR\n\r", __func__);
799 sd_mmc_debug(
"%s: CMD6 SD_SW_STATUS_FUN_GRP1_BUSY\n\r", __func__);
806 sd_mmc_card->
clock *= 2;
846 sd_mmc_debug(
"%s: CMD6 CARD_STATUS_SWITCH_ERROR\n\r", __func__);
873 sd_mmc_debug(
"%s: CMD6 CARD_STATUS_SWITCH_ERROR\n\r", __func__);
877 sd_mmc_card->
clock = 52000000lu;
906 if (resp == 0xFFFFFFFF) {
912 sd_mmc_debug(
"%s: CMD8 resp32 0x%08x UNUSABLE CARD\n\r",
929 static bool mmc_cmd8(uint8_t *b_authorize_high_speed)
960 sd_mmc_card->
capacity = sec_count / 2;
1010 uint32_t tran_speed;
1040 sd_mmc_card->
clock = unit * mul * 1000;
1070 uint32_t tran_speed;
1076 sd_mmc_card->
clock = unit * mul * 1000;
1112 uint32_t nec_timeout;
1119 nec_timeout = 200000;
1121 if (sd_mmc_is_spi()) {
1131 (uint32_t)sd_mmc_card->
rca << 16)) {
1139 if (nec_timeout-- == 0) {
1148 #ifdef SDIO_SUPPORT_ENABLE 1160 #if defined(__GNUC__) 1161 #pragma GCC diagnostic push 1162 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" 1165 static bool sdio_cmd52(uint8_t rw_flag, uint8_t func_nb,
1166 uint32_t reg_addr, uint8_t rd_after_wr, uint8_t *io_data)
1181 #if defined(__GNUC__) 1182 #pragma GCC diagnostic pop 1200 static bool sdio_cmd53(uint8_t rw_flag, uint8_t func_nb, uint32_t reg_addr,
1201 uint8_t inc_addr, uint32_t size,
bool access_block)
1215 size, 1, access_block);
1217 #endif // SDIO_SUPPORT_ENABLE 1309 if (slot >= SD_MMC_MEM_CNT) {
1314 #if (defined SD_MMC_0_CD_GPIO) 1319 SD_MMC_STOP_TIMEOUT();
1328 SD_MMC_START_TIMEOUT();
1332 if (!SD_MMC_IS_TIMEOUT()) {
1403 sd_mmc_card->
rca = 0;
1488 #ifdef SDIO_SUPPORT_ENABLE 1489 uint8_t
data = 0x08;
1495 sd_mmc_card->
rca = 0;
1501 #ifdef SDIO_SUPPORT_ENABLE 1550 (uint32_t)sd_mmc_card->
rca << 16)) {
1617 uint8_t b_authorize_high_speed;
1640 if (!
mmc_cmd8(&b_authorize_high_speed)) {
1670 uint8_t b_authorize_high_speed;
1687 sd_mmc_card->
rca = 1;
1689 (uint32_t)sd_mmc_card->
rca << 16)) {
1699 (uint32_t)sd_mmc_card->
rca << 16)) {
1705 if (!
mmc_cmd8(&b_authorize_high_speed)) {
1749 #if (defined SD_MMC_0_CD_GPIO) && (SAM) && (!SAM4L) 1751 # define SD_MMC_ENABLE_CD_PIN(slot, unused) \ 1752 pmc_enable_periph_clk(SD_MMC_##slot##_CD_PIO_ID); 1753 MREPEAT(SD_MMC_MEM_CNT, SD_MMC_ENABLE_CD_PIN, ~)
1754 # undef SD_MMC_ENABLE_CD_PIN 1756 #if (defined SD_MMC_0_WP_GPIO) && (SAM) && (!SAM4L) 1759 # define SD_MMC_ENABLE_WP_PIN(slot, unused) \ 1760 pmc_enable_periph_clk(SD_MMC_##slot##_WP_PIO_ID); 1761 MREPEAT(SD_MMC_MEM_CNT, SD_MMC_ENABLE_WP_PIN, ~)
1762 # undef SD_MMC_ENABLE_WP_PIN 1764 for (uint8_t slot = 0; slot < SD_MMC_MEM_CNT; slot++) {
1773 return SD_MMC_MEM_CNT;
1808 return sd_mmc_card->
type;
1832 #if (defined SD_MMC_0_WP_GPIO) 1835 == SD_MMC_0_WP_DETECT_VALUE) {
1846 uint32_t
cmd, arg, resp;
1882 sd_mmc_debug(
"%s: Read blocks %02d resp32 0x%08x CARD_STATUS_ERR_RD_WR\n\r",
1936 uint32_t
cmd, arg, resp;
1969 sd_mmc_debug(
"%s: Write blocks %02d r1 0x%08x CARD_STATUS_ERR_RD_WR\n\r",
2021 #ifdef SDIO_SUPPORT_ENABLE 2022 sd_mmc_err_t sdio_read_direct(uint8_t slot, uint8_t func_num, uint32_t addr,
2044 sd_mmc_err_t sdio_write_direct(uint8_t slot, uint8_t func_num, uint32_t addr,
2063 sd_mmc_err_t sdio_read_extended(uint8_t slot, uint8_t func_num, uint32_t addr,
2064 uint8_t inc_addr, uint8_t *dest, uint16_t size)
2068 if ((size == 0) || (size > 512)) {
2095 sd_mmc_err_t sdio_write_extended(uint8_t slot, uint8_t func_num, uint32_t addr,
2096 uint8_t inc_addr, uint8_t *src, uint16_t size)
2100 if ((size == 0) || (size > 512)) {
2126 #endif // SDIO_SUPPORT_ENABLE
#define SD_MMC_ERR_UNUSABLE
#define SDMMC_CMD_GET_INDEX(cmd)
#define SDIO_CMD53_BLOCK_MODE
CMD53 arg[ 27] (Optional) 1:block mode.
#define SDMMC_SPI_CMD13_SEND_STATUS
#define SD_CMD6_GRP5_NO_INFLUENCE
CMD6 arg[19:16] function group 5, 0xF or 0x0.
#define MMC_MCI_CMD1_SEND_OP_COND
#define MMC_CMD6_INDEX_HS_TIMING
static sd_mmc_err_t sd_mmc_select_slot(uint8_t slot)
Select a card slot and initialize the associated driver.
#define driver_send_clock
#define UNUSED(v)
Marking v as a unused parameter or value.
static bool sd_cmd8(uint8_t *v2)
CMD8 for SD card - Send Interface Condition Command.
static uint16_t sd_mmc_nb_block_remaining
Number of block remaining to read or write on the current transfer.
static bool sd_mci_op_cond(uint8_t v2)
Ask to all cards to send their operations conditions (MCI only).
SD/MMC protocol definitions.
#define SD_CSD_1_0_C_SIZE_MULT(csd)
#define driver_get_response
#define SD_ACMD51_SEND_SCR
sd_mmc_err_t sd_mmc_init_write_blocks(uint8_t slot, uint32_t start, uint16_t nb_block)
Initialize the write blocks of data.
#define SDMMC_SPI_CMD0_GO_IDLE_STATE
#define SD_CMD8_MASK_PATTERN
#define driver_start_read_blocks
#define driver_get_response_128
#define SDMMC_CMD17_READ_SINGLE_BLOCK
static bool mmc_mci_op_cond(void)
Sends operation condition command and read OCR (MCI only)
static uint32_t sysclk_get_cpu_hz(void)
Return the current rate in Hz of the CPU clock.
#define driver_is_high_speed_capable
static bool sd_acmd51(void)
ACMD51 - Read the SD Configuration Register.
#define MMC_CSD_C_SIZE(csd)
static bool sd_mmc_cmd13(void)
CMD13 - Addressed card sends its status register. This function waits the clear of the busy flag...
#define SD_SPI_ACMD41_SD_SEND_OP_COND
#define OCR_ACCESS_MODE_MASK
#define SD_SW_STATUS_FUN_GRP1_BUSY(status)
#define SDMMC_SPI_CMD59_CRC_ON_OFF
#define SDIO_CCCR_CIS_PTR
card_state
SD/MMC card states.
#define SD_MMC_ERR_NO_CARD
static bool sd_mmc_spi_card_init(void)
Initialize the SD card in SPI mode.
static bool sd_cm6_set_high_speed(void)
CMD6 for SD - Switch card in high speed mode.
#define SDIO_CMD53_RW_FLAG
CMD53 arg[ 31] Direction, 1:WR, 0:RD.
#define SDIO_CMD52_RAW_FLAG
CMD52 arg[ 27] Read after Write flag.
#define SD_CMD8_SEND_IF_COND
uint8_t high_speed
High speed card (1)
#define EXT_CSD_CARD_TYPE_INDEX
#define SDMMC_MCI_CMD0_GO_IDLE_STATE
#define SD_CMD6_MODE_SWITCH
static struct sd_mmc_card * sd_mmc_card
Pointer on current slot configurated.
#define SD_ACMD6_SET_BUS_WIDTH
#define SDMMC_CMD55_APP_CMD
#define driver_select_device
uint8_t card_version_t
Type of card version.
#define CARD_TYPE_SDIO
SDIO card.
#define SD_MCI_ACMD41_SD_SEND_OP_COND
static bool sd_mmc_mci_install_mmc(void)
Initialize the MMC card in MCI mode.
sd_mmc_err_t sd_mmc_wait_end_of_write_blocks(bool abort)
Wait the end of write blocks of data.
uint8_t bus_width
Number of DATA lin on bus (MCI only)
sd_mmc_err_t sd_mmc_check(uint8_t slot)
Performs a card checks.
#define SD_MMC_BLOCK_SIZE
This SD MMC stack uses the maximum block size autorized (512 bytes)
Common IOPORT service main header file for AVR, UC3 and ARM architectures.
#define CSD_REG_BSIZE
16 bytes
#define SDMMC_CMD25_WRITE_MULTIPLE_BLOCK
static bool mmc_spi_op_cond(void)
Sends operation condition command and read OCR (SPI only)
#define SD_MMC_DEBOUNCE_TIMEOUT
#define MMC_CSD_C_SIZE_MULT(csd)
#define MMC_CMD6_INDEX_BUS_WIDTH
#define SD_SCR_SD_SPEC_1_10
#define SD_SW_STATUS_FUN_GRP_RC_ERROR
#define SDIO_CMD53_IO_W_BYTE_EXTENDED
enum card_state state
Card state.
#define SDIO_CMD52_RW_FLAG
CMD52 arg[ 31] Direction, 1:write, 0:read.
#define SD_CMD8_HIGH_VOLTAGE
#define SD_CMD6_GRP4_NO_INFLUENCE
CMD6 arg[15:12] function group 4, 0xF or 0x0.
#define MMC_CSD_READ_BL_LEN(csd)
static void sd_decode_csd(void)
Decodes SD CSD register.
#define SD_SCR_SD_SPEC(scr)
static bool sd_acmd6(void)
ACMD6 - Define the data bus width to 4 bits bus.
static bool ioport_get_pin_level(ioport_pin_t pin)
Get current value of an IOPORT pin, which has been configured as an input.
#define SDMMC_SPI_CMD9_SEND_CSD
#define CARD_STATUS_READY_FOR_DATA
sd_mmc_err_t sd_mmc_start_read_blocks(void *dest, uint16_t nb_block)
Start the read blocks of data from the card.
const uint32_t mmc_trans_multipliers[16]
MMC transfer multiplier factor codes (1/10) list.
#define SDIO_CMD53_OP_CODE
CMD53 arg[ 26] 1:Incrementing address, 0: fixed.
#define MMC_CMD6_VALUE_HS_TIMING_ENABLE
#define SDMMC_CMD24_WRITE_BLOCK
#define SDIO_CMD52_FUNCTION_NUM
CMD52 arg[30:28] Number of the function.
#define MREPEAT(count, macro, data)
Macro repeat.
#define driver_wait_end_of_read_blocks
#define SDMMC_CMD12_STOP_TRANSMISSION
#define CSD_TRAN_SPEED(csd)
static bool sdio_cmd52_set_high_speed(void)
#define SDMMC_CMD7_SELECT_CARD_CMD
#define SD_SW_STATUS_BSIZE
64 bytes
#define SD_SCR_SD_SPEC_2_00
static uint16_t sd_mmc_nb_block_to_tranfer
Number of block to read or write on the current transfer.
#define SDMMC_CMD2_ALL_SEND_CID
#define SDIO_CMD52_WR_DATA
CMD52 arg[ 7: 0] Write data or stuff bits.
card_type_t sd_mmc_get_type(uint8_t slot)
Get the card type.
#define CARD_STATUS_ERR_RD_WR
#define driver_start_write_blocks
static bool mmc_cmd6_set_high_speed(void)
CMD6 for MMC - Switches in high speed mode.
#define CSD_STRUCTURE_VERSION(csd)
#define SDIO_CMD53_FUNCTION_NUM
CMD53 arg[30:28] Number of the function.
static bool sdio_get_max_speed(void)
#define MMC_CSD_SPEC_VERS(csd)
static bool sdio_cmd52_set_bus_width(void)
#define driver_wait_end_of_write_blocks
static void sd_mmc_deselect_slot(void)
Deselect the current card slot.
#define sd_mmc_debug(...)
#define SDMMC_CMD16_SET_BLOCKLEN
#define MMC_SPI_CMD1_SEND_OP_COND
#define MMC_CMD8_SEND_EXT_CSD
#define SD_SCR_SD_SPEC_1_0_01
static bool sd_mmc_mci_card_init(void)
Initialize the SD card in MCI mode.
#define CARD_TYPE_MMC
MMC card.
#define MMC_CMD6_VALUE_BUS_WIDTH_1BIT
[15:8] Value
uint32_t capacity
Card capacity in KBytes.
#define SDIO_CISTPL_FUNCE
#define SDIO_CMD53_READ_FLAG
card_type_t type
Card type.
#define SD_SCR_REG_BSIZE
8 bytes
#define SysTick_CTRL_COUNTFLAG_Msk
const uint32_t sd_trans_multipliers[16]
SD transfer multiplier factor codes (1/10) list.
#define SDIO_CMD52_IO_RW_DIRECT
uint16_t rca
Relative card address.
SD/MMC card information structure.
USBInterfaceDescriptor data
#define CARD_TYPE_SD
SD card.
const uint32_t sd_mmc_trans_units[7]
SD/MMC transfer rate unit codes (10K) list.
#define SDIO_CMD5_SEND_OP_COND
#define driver_deselect_device
#define SD_CMD6_GRP6_NO_INFLUENCE
CMD6 arg[23:20] function group 6, 0xF or 0x0.
#define MMC_CMD6_VALUE_BUS_WIDTH_4BIT
#define SD_CSD_1_0_READ_BL_LEN(csd)
SD/MMC stack configuration file.
#define SysTick_CTRL_ENABLE_Msk
uint8_t sd_mmc_nb_slot(void)
Return the number of slot available.
#define SDIO_CMD53_WRITE_FLAG
#define SD_CMD6_GRP1_HIGH_SPEED
CMD6 arg[ 3: 0] function group 1, access mode.
sd_mmc_err_t sd_mmc_init_read_blocks(uint8_t slot, uint32_t start, uint16_t nb_block)
Initialize the read blocks of data from the card.
Common SD/MMC stack header file.
#define CARD_TYPE_UNKNOWN
Unknown type card.
void vTaskSetTimeOutState(TimeOut_t *const pxTimeOut) PRIVILEGED_FUNCTION
#define SDMMC_SPI_CMD58_READ_OCR
#define SD_SCR_SD_SPEC_3_00
#define SD_MMC_VOLTAGE_SUPPORT
This SD MMC stack supports only the high voltage.
static bool sd_spi_op_cond(uint8_t v2)
Ask to all cards to send their operations conditions (SPI only).
static void sd_mmc_configure_slot(void)
Configures the driver with the selected card configuration.
#define SDIO_CMD52_READ_FLAG
#define EXT_CSD_SEC_COUNT_INDEX
#define OCR_ACCESS_MODE_SECTOR
uint8_t csd[CSD_REG_BSIZE]
CSD register.
static bool sd_mmc_cmd9_spi(void)
CMD9: Addressed card sends its card-specific data (CSD) on the CMD line spi.
uint8_t card_type_t
Type of card type.
#define delay_ms(delay)
Delay in milliseconds.
#define SD_SW_STATUS_FUN_GRP1_RC(status)
sd_mmc_err_t sd_mmc_start_write_blocks(const void *src, uint16_t nb_block)
Start the write blocks of data.
static struct sd_mmc_card sd_mmc_cards[SD_MMC_MEM_CNT]
#define SD_CMD6_GRP2_DEFAULT
#define SDIO_CMD53_REG_ADDR
CMD53 arg[25: 9] Start Address I/O register.
card_version_t sd_mmc_get_version(uint8_t slot)
Get the card version.
uint32_t sd_mmc_get_capacity(uint8_t slot)
Get the memory capacity.
#define SDMMC_CMD18_READ_MULTIPLE_BLOCK
#define SD_CMD6_SWITCH_FUNC
BaseType_t xTaskCheckForTimeOut(TimeOut_t *const pxTimeOut, TickType_t *const pxTicksToWait) PRIVILEGED_FUNCTION
#define OCR_POWER_UP_BUSY
#define CARD_TYPE_SD_COMBO
SD combo card (io + memory)
static bool mmc_cmd8(uint8_t *b_authorize_high_speed)
CMD8 - The card sends its EXT_CSD register as a block of data.
#define SDIO_CMD52_REG_ADRR
CMD52 arg[25: 9] Register address.
static bool sd_mmc_spi_install_mmc(void)
Initialize the MMC card in SPI mode.
#define SDIO_CMD53_IO_R_BYTE_EXTENDED
#define driver_get_bus_width
static bool mmc_cmd6_set_bus_width(uint8_t bus_width)
CMD6 for MMC - Switches the bus width mode.
#define SD_CMD6_GRP3_NO_INFLUENCE
CMD6 arg[11: 8] function group 3, 0xF or 0x0.
#define SDIO_CMD52_WRITE_FLAG
static bool sdio_op_cond(void)
static void mmc_decode_csd(void)
Decodes MMC CSD register.
uint32_t clock
Card access clock.
card_version_t version
Card version.
static bool sd_mmc_cmd9_mci(void)
CMD9: Addressed card sends its card-specific data (CSD) on the CMD line mci.
#define MMC_CMD3_SET_RELATIVE_ADDR
#define SD_CSD_1_0_C_SIZE(csd)
#define SDMMC_MCI_CMD9_SEND_CSD
#define MMC_CMD6_ACCESS_WRITE_BYTE
sd_mmc_err_t sd_mmc_wait_end_of_read_blocks(bool abort)
Wait the end of read blocks of data from the card.
#define Assert(expr)
This macro is used to test fatal errors.
Standard board header file.
#define SDIO_CCCR_BUS_CTRL
#define MMC_CMD6_VALUE_BUS_WIDTH_8BIT
#define SD_CMD8_MASK_VOLTAGE
static uint8_t sd_mmc_slot_sel
Index of current slot configurated.
void sd_mmc_init(void)
Initialize the SD/MMC stack and low level driver required.
#define SDMMC_MCI_CMD13_SEND_STATUS
#define SD_SCR_SD_SPEC3(scr)
#define SD_MMC_0_CD_DETECT_VALUE
#define SD_CMD3_SEND_RELATIVE_ADDR
#define CARD_STATUS_SWITCH_ERROR
uint8_t sd_mmc_err_t
Type of return error code.
#define driver_adtc_start
#define MMC_CMD6_ACCESS_SET_BITS
#define SD_CSD_2_0_C_SIZE(csd)
#define SD_MMC_INIT_ONGOING
bool sd_mmc_is_write_protected(uint8_t slot)
Get the card write protection status.