Data Structures | |
struct | sd_mmc_card |
SD/MMC card information structure. More... | |
Macros | |
#define | driver_adtc_start ATPASTE2(driver, _adtc_start) |
#define | driver_adtc_stop ATPASTE2(driver, _send_cmd) |
#define | driver_deselect_device ATPASTE2(driver, _deselect_device) |
#define | driver_get_bus_width ATPASTE2(driver, _get_bus_width) |
#define | driver_get_response ATPASTE2(driver, _get_response) |
#define | driver_get_response_128 ATPASTE2(driver, _get_response_128) |
#define | driver_init ATPASTE2(driver, _init) |
#define | driver_is_high_speed_capable ATPASTE2(driver, _is_high_speed_capable) |
#define | driver_read_word ATPASTE2(driver, _read_word) |
#define | driver_select_device ATPASTE2(driver, _select_device) |
#define | driver_send_clock ATPASTE2(driver, _send_clock) |
#define | driver_send_cmd ATPASTE2(driver, _send_cmd) |
#define | driver_start_read_blocks ATPASTE2(driver, _start_read_blocks) |
#define | driver_start_write_blocks ATPASTE2(driver, _start_write_blocks) |
#define | driver_wait_end_of_read_blocks ATPASTE2(driver, _wait_end_of_read_blocks) |
#define | driver_wait_end_of_write_blocks ATPASTE2(driver, _wait_end_of_write_blocks) |
#define | driver_write_word ATPASTE2(driver, _write_word) |
#define | IS_SDIO() false |
#define | sd_mmc_debug(...) |
#define | SD_MMC_HSMCI_MEM_CNT 0 |
#define | sd_mmc_is_mci() (!sd_mmc_is_spi()) |
#define | SD_MMC_MCI_MEM_CNT 0 |
#define | SD_MMC_SPI_MEM_CNT 0 |
#define | SD_MMC_VOLTAGE_SUPPORT |
This SD MMC stack supports only the high voltage. More... | |
Enumerations | |
enum | card_state { SD_MMC_CARD_STATE_READY = 0, SD_MMC_CARD_STATE_DEBOUNCE = 1, SD_MMC_CARD_STATE_INIT = 2, SD_MMC_CARD_STATE_UNUSABLE = 3, SD_MMC_CARD_STATE_NO_CARD = 4 } |
SD/MMC card states. More... | |
Functions | |
sd_mmc_err_t | sd_mmc_check (uint8_t slot) |
Performs a card checks. More... | |
uint32_t | sd_mmc_get_capacity (uint8_t slot) |
Get the memory capacity. More... | |
card_type_t | sd_mmc_get_type (uint8_t slot) |
Get the card type. More... | |
card_version_t | sd_mmc_get_version (uint8_t slot) |
Get the card version. More... | |
void | sd_mmc_init (void) |
Initialize the SD/MMC stack and low level driver required. More... | |
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. More... | |
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. More... | |
bool | sd_mmc_is_write_protected (uint8_t slot) |
Get the card write protection status. More... | |
uint8_t | sd_mmc_nb_slot (void) |
Return the number of slot available. More... | |
sd_mmc_err_t | sd_mmc_start_read_blocks (void *dest, uint16_t nb_block) |
Start the read blocks of data from the card. More... | |
sd_mmc_err_t | sd_mmc_start_write_blocks (const void *src, uint16_t nb_block) |
Start the write blocks of data. More... | |
sd_mmc_err_t | sd_mmc_wait_end_of_read_blocks (bool abort) |
Wait the end of read blocks of data from the card. More... | |
sd_mmc_err_t | sd_mmc_wait_end_of_write_blocks (bool abort) |
Wait the end of write blocks of data. More... | |
Variables | |
const uint32_t | mmc_trans_multipliers [16] |
MMC transfer multiplier factor codes (1/10) list. More... | |
static struct sd_mmc_card * | sd_mmc_card |
Pointer on current slot configurated. More... | |
static struct sd_mmc_card | sd_mmc_cards [SD_MMC_MEM_CNT] |
SD/MMC card list Note: Initialize card detect pin fields if present. More... | |
static uint16_t | sd_mmc_nb_block_remaining = 0 |
Number of block remaining to read or write on the current transfer. More... | |
static uint16_t | sd_mmc_nb_block_to_tranfer = 0 |
Number of block to read or write on the current transfer. More... | |
static uint8_t | sd_mmc_slot_sel |
Index of current slot configurated. More... | |
const uint32_t | sd_mmc_trans_units [7] |
SD/MMC transfer rate unit codes (10K) list. More... | |
const uint32_t | sd_trans_multipliers [16] |
SD transfer multiplier factor codes (1/10) list. More... | |
MMC, SD and SDIO commands process | |
static bool | mmc_spi_op_cond (void) |
Sends operation condition command and read OCR (SPI only) More... | |
static bool | mmc_mci_op_cond (void) |
Sends operation condition command and read OCR (MCI only) More... | |
static bool | sd_spi_op_cond (uint8_t v2) |
Ask to all cards to send their operations conditions (SPI only). More... | |
static bool | sd_mci_op_cond (uint8_t v2) |
Ask to all cards to send their operations conditions (MCI only). More... | |
static bool | sdio_op_cond (void) |
static bool | sdio_get_max_speed (void) |
static bool | sdio_cmd52_set_bus_width (void) |
static bool | sdio_cmd52_set_high_speed (void) |
static bool | sd_cm6_set_high_speed (void) |
CMD6 for SD - Switch card in high speed mode. More... | |
static bool | mmc_cmd6_set_bus_width (uint8_t bus_width) |
CMD6 for MMC - Switches the bus width mode. More... | |
static bool | mmc_cmd6_set_high_speed (void) |
CMD6 for MMC - Switches in high speed mode. More... | |
static bool | sd_cmd8 (uint8_t *v2) |
CMD8 for SD card - Send Interface Condition Command. More... | |
static bool | mmc_cmd8 (uint8_t *b_authorize_high_speed) |
CMD8 - The card sends its EXT_CSD register as a block of data. More... | |
static bool | sd_mmc_cmd9_spi (void) |
CMD9: Addressed card sends its card-specific data (CSD) on the CMD line spi. More... | |
static bool | sd_mmc_cmd9_mci (void) |
CMD9: Addressed card sends its card-specific data (CSD) on the CMD line mci. More... | |
static void | mmc_decode_csd (void) |
Decodes MMC CSD register. More... | |
static void | sd_decode_csd (void) |
Decodes SD CSD register. More... | |
static bool | sd_mmc_cmd13 (void) |
CMD13 - Addressed card sends its status register. More... | |
static bool | sd_acmd6 (void) |
ACMD6 - Define the data bus width to 4 bits bus. More... | |
static bool | sd_acmd51 (void) |
ACMD51 - Read the SD Configuration Register. More... | |
Internal function to process the initialization and install | |
static sd_mmc_err_t | sd_mmc_select_slot (uint8_t slot) |
Select a card slot and initialize the associated driver. More... | |
static void | sd_mmc_configure_slot (void) |
Configures the driver with the selected card configuration. More... | |
static void | sd_mmc_deselect_slot (void) |
Deselect the current card slot. More... | |
static bool | sd_mmc_spi_card_init (void) |
Initialize the SD card in SPI mode. More... | |
static bool | sd_mmc_mci_card_init (void) |
Initialize the SD card in MCI mode. More... | |
static bool | sd_mmc_spi_install_mmc (void) |
Initialize the MMC card in SPI mode. More... | |
static bool | sd_mmc_mci_install_mmc (void) |
Initialize the MMC card in MCI mode. More... | |
Internal functions to manage a large timeout after a card insertion | |
#define | SD_MMC_DEBOUNCE_TIMEOUT 1000 |
#define driver_adtc_start ATPASTE2(driver, _adtc_start) |
Referenced by mmc_cmd8(), sd_acmd51(), sd_cm6_set_high_speed(), sd_mmc_cmd9_spi(), sd_mmc_init_read_blocks(), and sd_mmc_init_write_blocks().
#define driver_adtc_stop ATPASTE2(driver, _send_cmd) |
Referenced by sd_mmc_wait_end_of_read_blocks(), and sd_mmc_wait_end_of_write_blocks().
#define driver_deselect_device ATPASTE2(driver, _deselect_device) |
Referenced by sd_mmc_deselect_slot().
#define driver_get_bus_width ATPASTE2(driver, _get_bus_width) |
Referenced by sd_mmc_mci_card_init(), and sd_mmc_mci_install_mmc().
#define driver_get_response ATPASTE2(driver, _get_response) |
#define driver_get_response_128 ATPASTE2(driver, _get_response_128) |
Referenced by sd_mmc_cmd9_mci().
#define driver_init ATPASTE2(driver, _init) |
Referenced by sd_mmc_init().
#define driver_is_high_speed_capable ATPASTE2(driver, _is_high_speed_capable) |
Referenced by sd_mmc_mci_card_init(), and sd_mmc_mci_install_mmc().
#define driver_read_word ATPASTE2(driver, _read_word) |
Referenced by mmc_cmd8().
#define driver_select_device ATPASTE2(driver, _select_device) |
Referenced by sd_mmc_configure_slot().
#define driver_send_clock ATPASTE2(driver, _send_clock) |
Referenced by sd_cm6_set_high_speed(), sd_mmc_mci_card_init(), and sd_mmc_spi_card_init().
#define driver_send_cmd ATPASTE2(driver, _send_cmd) |
Referenced by mmc_cmd6_set_bus_width(), mmc_cmd6_set_high_speed(), mmc_mci_op_cond(), mmc_spi_op_cond(), sd_acmd51(), sd_acmd6(), sd_cmd8(), sd_mci_op_cond(), sd_mmc_cmd13(), sd_mmc_cmd9_mci(), sd_mmc_mci_card_init(), sd_mmc_mci_install_mmc(), sd_mmc_spi_card_init(), sd_mmc_spi_install_mmc(), and sd_spi_op_cond().
#define driver_start_read_blocks ATPASTE2(driver, _start_read_blocks) |
Referenced by sd_acmd51(), sd_cm6_set_high_speed(), sd_mmc_cmd9_spi(), and sd_mmc_start_read_blocks().
#define driver_start_write_blocks ATPASTE2(driver, _start_write_blocks) |
Referenced by sd_mmc_start_write_blocks().
#define driver_wait_end_of_read_blocks ATPASTE2(driver, _wait_end_of_read_blocks) |
Referenced by sd_acmd51(), sd_cm6_set_high_speed(), sd_mmc_cmd9_spi(), and sd_mmc_wait_end_of_read_blocks().
#define driver_wait_end_of_write_blocks ATPASTE2(driver, _wait_end_of_write_blocks) |
Referenced by sd_mmc_wait_end_of_write_blocks().
#define driver_write_word ATPASTE2(driver, _write_word) |
#define IS_SDIO | ( | ) | false |
Referenced by sd_mmc_mci_card_init(), and sd_mmc_spi_card_init().
#define SD_MMC_DEBOUNCE_TIMEOUT 1000 |
#define sd_mmc_debug | ( | ... | ) |
Referenced by mmc_cmd6_set_bus_width(), mmc_cmd6_set_high_speed(), mmc_mci_op_cond(), mmc_spi_op_cond(), sd_acmd6(), sd_cm6_set_high_speed(), sd_cmd8(), sd_mci_op_cond(), sd_mmc_check(), sd_mmc_cmd13(), sd_mmc_init_read_blocks(), sd_mmc_init_write_blocks(), sd_mmc_mci_card_init(), sd_mmc_spi_card_init(), and sd_spi_op_cond().
#define SD_MMC_HSMCI_MEM_CNT 0 |
#define sd_mmc_is_mci | ( | ) | (!sd_mmc_is_spi()) |
Referenced by sd_mmc_init_read_blocks(), sd_mmc_init_write_blocks(), and sd_mmc_wait_end_of_write_blocks().
#define SD_MMC_MCI_MEM_CNT 0 |
#define SD_MMC_SPI_MEM_CNT 0 |
#define SD_MMC_VOLTAGE_SUPPORT |
This SD MMC stack supports only the high voltage.
Referenced by mmc_mci_op_cond(), and sd_mci_op_cond().
enum card_state |
|
static |
CMD6 for MMC - Switches the bus width mode.
bus_width | Bus width to set |
References sd_mmc_card::bus_width, CARD_STATUS_SWITCH_ERROR, driver_get_response, driver_send_cmd, MMC_CMD6_ACCESS_SET_BITS, MMC_CMD6_INDEX_BUS_WIDTH, MMC_CMD6_SWITCH, MMC_CMD6_VALUE_BUS_WIDTH_1BIT, MMC_CMD6_VALUE_BUS_WIDTH_4BIT, MMC_CMD6_VALUE_BUS_WIDTH_8BIT, and sd_mmc_debug.
Referenced by sd_mmc_mci_install_mmc().
|
static |
CMD6 for MMC - Switches in high speed mode.
References CARD_STATUS_SWITCH_ERROR, sd_mmc_card::clock, driver_get_response, driver_send_cmd, sd_mmc_card::high_speed, MMC_CMD6_ACCESS_WRITE_BYTE, MMC_CMD6_INDEX_HS_TIMING, MMC_CMD6_SWITCH, MMC_CMD6_VALUE_HS_TIMING_ENABLE, and sd_mmc_debug.
Referenced by sd_mmc_mci_install_mmc().
|
static |
CMD8 - The card sends its EXT_CSD register as a block of data.
b_authorize_high_speed | Pointer to update with the high speed support information |
References sd_mmc_card::capacity, sd_mmc_card::csd, driver_adtc_start, driver_read_word, EXT_CSD_BSIZE, EXT_CSD_CARD_TYPE_INDEX, EXT_CSD_SEC_COUNT_INDEX, MMC_CMD8_SEND_EXT_CSD, MMC_CSD_C_SIZE, and MMC_CTYPE_52MHZ.
Referenced by sd_mmc_mci_install_mmc(), and sd_mmc_spi_install_mmc().
|
static |
Decodes MMC CSD register.
References sd_mmc_card::capacity, CARD_VER_MMC_1_2, CARD_VER_MMC_1_4, CARD_VER_MMC_2_2, CARD_VER_MMC_3, CARD_VER_MMC_4, sd_mmc_card::clock, sd_mmc_card::csd, CSD_TRAN_SPEED, MMC_CSD_C_SIZE, MMC_CSD_C_SIZE_MULT, MMC_CSD_READ_BL_LEN, MMC_CSD_SPEC_VERS, and sd_mmc_card::version.
Referenced by sd_mmc_mci_install_mmc(), and sd_mmc_spi_install_mmc().
|
static |
Sends operation condition command and read OCR (MCI only)
References CARD_TYPE_HC, driver_get_response, driver_send_cmd, MMC_MCI_CMD1_SEND_OP_COND, OCR_ACCESS_MODE_MASK, OCR_ACCESS_MODE_SECTOR, OCR_POWER_UP_BUSY, sd_mmc_debug, SD_MMC_VOLTAGE_SUPPORT, and sd_mmc_card::type.
Referenced by sd_mmc_mci_install_mmc().
|
static |
Sends operation condition command and read OCR (SPI only)
References CARD_TYPE_HC, driver_get_response, driver_send_cmd, MMC_SPI_CMD1_SEND_OP_COND, OCR_ACCESS_MODE_MASK, OCR_ACCESS_MODE_SECTOR, R1_SPI_IDLE, sd_mmc_debug, SDMMC_SPI_CMD58_READ_OCR, and sd_mmc_card::type.
Referenced by sd_mmc_spi_install_mmc().
|
static |
ACMD51 - Read the SD Configuration Register.
References CARD_VER_SD_1_0, CARD_VER_SD_1_10, CARD_VER_SD_2_0, CARD_VER_SD_3_0, driver_adtc_start, driver_send_cmd, driver_start_read_blocks, driver_wait_end_of_read_blocks, sd_mmc_card::rca, SD_ACMD51_SEND_SCR, SD_SCR_REG_BSIZE, SD_SCR_SD_SPEC, SD_SCR_SD_SPEC3, SD_SCR_SD_SPEC_1_0_01, SD_SCR_SD_SPEC_1_10, SD_SCR_SD_SPEC_2_00, SD_SCR_SD_SPEC_3_00, SDMMC_CMD55_APP_CMD, and sd_mmc_card::version.
Referenced by sd_mmc_mci_card_init(), and sd_mmc_spi_card_init().
|
static |
ACMD6 - Define the data bus width to 4 bits bus.
References sd_mmc_card::bus_width, driver_send_cmd, sd_mmc_card::rca, SD_ACMD6_SET_BUS_WIDTH, sd_mmc_debug, and SDMMC_CMD55_APP_CMD.
Referenced by sd_mmc_mci_card_init().
|
static |
CMD6 for SD - Switch card in high speed mode.
References CARD_STATUS_SWITCH_ERROR, sd_mmc_card::clock, driver_adtc_start, driver_get_response, driver_send_clock, driver_start_read_blocks, driver_wait_end_of_read_blocks, sd_mmc_card::high_speed, SD_CMD6_GRP1_HIGH_SPEED, SD_CMD6_GRP2_DEFAULT, SD_CMD6_GRP3_NO_INFLUENCE, SD_CMD6_GRP4_NO_INFLUENCE, SD_CMD6_GRP5_NO_INFLUENCE, SD_CMD6_GRP6_NO_INFLUENCE, SD_CMD6_MODE_SWITCH, SD_CMD6_SWITCH_FUNC, sd_mmc_debug, SD_SW_STATUS_BSIZE, SD_SW_STATUS_FUN_GRP1_BUSY, SD_SW_STATUS_FUN_GRP1_RC, and SD_SW_STATUS_FUN_GRP_RC_ERROR.
Referenced by sd_mmc_mci_card_init().
|
static |
CMD8 for SD card - Send Interface Condition Command.
v2 | Pointer to v2 flag to update |
References driver_get_response, driver_send_cmd, SD_CMD8_HIGH_VOLTAGE, SD_CMD8_MASK_PATTERN, SD_CMD8_MASK_VOLTAGE, SD_CMD8_PATTERN, SD_CMD8_SEND_IF_COND, and sd_mmc_debug.
Referenced by sd_mmc_mci_card_init(), and sd_mmc_spi_card_init().
|
static |
Decodes SD CSD register.
References sd_mmc_card::capacity, sd_mmc_card::clock, sd_mmc_card::csd, CSD_STRUCTURE_VERSION, CSD_TRAN_SPEED, SD_CSD_1_0_C_SIZE, SD_CSD_1_0_C_SIZE_MULT, SD_CSD_1_0_READ_BL_LEN, SD_CSD_2_0_C_SIZE, and SD_CSD_VER_2_0.
Referenced by sd_mmc_mci_card_init(), and sd_mmc_spi_card_init().
|
static |
Ask to all cards to send their operations conditions (MCI only).
v2 | Shall be 1 if it is a SD card V2 |
References CARD_TYPE_HC, driver_get_response, driver_send_cmd, OCR_CCS, OCR_POWER_UP_BUSY, SD_ACMD41_HCS, SD_MCI_ACMD41_SD_SEND_OP_COND, sd_mmc_debug, SD_MMC_VOLTAGE_SUPPORT, SDMMC_CMD55_APP_CMD, and sd_mmc_card::type.
Referenced by sd_mmc_mci_card_init().
sd_mmc_err_t sd_mmc_check | ( | uint8_t | slot | ) |
Performs a card checks.
slot | Card slot to use |
SD_MMC_OK | Card ready |
SD_MMC_INIT_ONGOING | Initialization on going |
SD_MMC_ERR_NO_CARD | Card not present in slot |
Other | value for error cases, see sd_mmc_err_t |
References SD_MMC_CARD_STATE_READY, SD_MMC_CARD_STATE_UNUSABLE, sd_mmc_debug, sd_mmc_deselect_slot(), SD_MMC_ERR_UNUSABLE, SD_MMC_INIT_ONGOING, sd_mmc_mci_card_init(), sd_mmc_select_slot(), sd_mmc_spi_card_init(), and sd_mmc_card::state.
Referenced by main(), run_sd_mmc_init_test(), run_sd_mmc_sdio_rw_test(), and sd_mmc_test_unit_ready().
|
static |
CMD13 - Addressed card sends its status register.
This function waits the clear of the busy flag
References CARD_STATUS_READY_FOR_DATA, driver_get_response, driver_send_cmd, sd_mmc_card::rca, sd_mmc_debug, SDMMC_MCI_CMD13_SEND_STATUS, and SDMMC_SPI_CMD13_SEND_STATUS.
Referenced by sd_mmc_init_read_blocks(), sd_mmc_spi_card_init(), and sd_mmc_spi_install_mmc().
|
static |
CMD9: Addressed card sends its card-specific data (CSD) on the CMD line mci.
References sd_mmc_card::csd, driver_get_response_128, driver_send_cmd, sd_mmc_card::rca, and SDMMC_MCI_CMD9_SEND_CSD.
Referenced by sd_mmc_mci_card_init(), and sd_mmc_mci_install_mmc().
|
static |
CMD9: Addressed card sends its card-specific data (CSD) on the CMD line spi.
References sd_mmc_card::csd, CSD_REG_BSIZE, driver_adtc_start, driver_start_read_blocks, driver_wait_end_of_read_blocks, sd_mmc_card::rca, and SDMMC_SPI_CMD9_SEND_CSD.
Referenced by sd_mmc_spi_card_init(), and sd_mmc_spi_install_mmc().
|
static |
Configures the driver with the selected card configuration.
References sd_mmc_card::bus_width, sd_mmc_card::clock, driver_select_device, and sd_mmc_card::high_speed.
Referenced by sd_mmc_mci_card_init(), sd_mmc_mci_install_mmc(), sd_mmc_select_slot(), sd_mmc_spi_card_init(), and sd_mmc_spi_install_mmc().
|
static |
Deselect the current card slot.
References driver_deselect_device.
Referenced by sd_mmc_check(), sd_mmc_get_capacity(), sd_mmc_get_type(), sd_mmc_get_version(), sd_mmc_init_read_blocks(), sd_mmc_init_write_blocks(), sd_mmc_wait_end_of_read_blocks(), and sd_mmc_wait_end_of_write_blocks().
uint32_t sd_mmc_get_capacity | ( | uint8_t | slot | ) |
Get the memory capacity.
slot | Card slot |
References sd_mmc_card::capacity, sd_mmc_deselect_slot(), SD_MMC_OK, and sd_mmc_select_slot().
Referenced by main_display_info_card(), main_test_memory(), run_sd_mmc_rw_test(), and sd_mmc_read_capacity().
card_type_t sd_mmc_get_type | ( | uint8_t | slot | ) |
Get the card type.
slot | Card slot |
References CARD_TYPE_UNKNOWN, sd_mmc_deselect_slot(), SD_MMC_OK, sd_mmc_select_slot(), and sd_mmc_card::type.
Referenced by main(), main_display_info_card(), run_sd_mmc_sdio_rw_test(), and sd_mmc_test_unit_ready().
card_version_t sd_mmc_get_version | ( | uint8_t | slot | ) |
Get the card version.
slot | Card slot |
References CARD_VER_UNKNOWN, sd_mmc_deselect_slot(), SD_MMC_OK, sd_mmc_select_slot(), and sd_mmc_card::version.
void sd_mmc_init | ( | void | ) |
Initialize the SD/MMC stack and low level driver required.
Enable the PMC clock for the card detect pins
Enable the PMC clock for the card write protection pins
References driver_init, MREPEAT, SD_MMC_CARD_STATE_NO_CARD, sd_mmc_cards, and sd_mmc_card::state.
Referenced by main(), memories_initialization(), and run_sd_mmc_init_test().
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.
slot | Card slot to use |
start | Start block number to to read. |
nb_block | Total number of blocks to be read. |
References CARD_STATUS_ERR_RD_WR, CARD_TYPE_HC, driver_adtc_start, driver_get_response, SD_MMC_BLOCK_SIZE, sd_mmc_cmd13(), sd_mmc_debug, sd_mmc_deselect_slot(), SD_MMC_ERR_COMM, sd_mmc_is_mci, SD_MMC_OK, sd_mmc_select_slot(), SDMMC_CMD17_READ_SINGLE_BLOCK, SDMMC_CMD18_READ_MULTIPLE_BLOCK, SDMMC_CMD_GET_INDEX, and sd_mmc_card::type.
Referenced by main_test_memory(), run_sd_mmc_rw_test(), sd_mmc_mem_2_ram(), and sd_mmc_usb_read_10().
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.
slot | Card slot to use |
start | Start block number to be written. |
nb_block | Total number of blocks to be written. |
References CARD_STATUS_ERR_RD_WR, CARD_TYPE_HC, driver_adtc_start, driver_get_response, SD_MMC_BLOCK_SIZE, sd_mmc_debug, sd_mmc_deselect_slot(), SD_MMC_ERR_COMM, SD_MMC_ERR_WP, sd_mmc_is_mci, sd_mmc_is_write_protected(), SD_MMC_OK, sd_mmc_select_slot(), SDMMC_CMD24_WRITE_BLOCK, SDMMC_CMD25_WRITE_MULTIPLE_BLOCK, SDMMC_CMD_GET_INDEX, and sd_mmc_card::type.
Referenced by main_test_memory(), run_sd_mmc_rw_test(), sd_mmc_ram_2_mem(), and sd_mmc_usb_write_10().
bool sd_mmc_is_write_protected | ( | uint8_t | slot | ) |
Get the card write protection status.
slot | Card slot |
References ioport_get_pin_level(), sd_mmc_cards, and UNUSED.
Referenced by main_test_memory(), run_sd_mmc_rw_test(), sd_mmc_init_write_blocks(), and sd_mmc_wr_protect().
|
static |
Initialize the SD card in MCI mode.
References CARD_TYPE_MMC, CARD_TYPE_SD, CARD_VER_SD_1_0, CARD_VER_UNKNOWN, data, driver_get_bus_width, driver_get_response, driver_is_high_speed_capable, driver_send_clock, driver_send_cmd, IS_SDIO, sd_mmc_card::rca, sd_acmd51(), sd_acmd6(), sd_cm6_set_high_speed(), SD_CMD3_SEND_RELATIVE_ADDR, sd_cmd8(), sd_decode_csd(), sd_mci_op_cond(), SD_MMC_BLOCK_SIZE, sd_mmc_cmd9_mci(), sd_mmc_configure_slot(), sd_mmc_debug, sd_mmc_mci_install_mmc(), SDIO_CCCR_IOA, SDIO_CIA, sdio_cmd52_set_bus_width(), sdio_cmd52_set_high_speed(), SDIO_CMD52_WRITE_FLAG, sdio_get_max_speed(), sdio_op_cond(), SDMMC_CMD16_SET_BLOCKLEN, SDMMC_CMD2_ALL_SEND_CID, SDMMC_CMD7_SELECT_CARD_CMD, SDMMC_MCI_CMD0_GO_IDLE_STATE, sd_mmc_card::type, and sd_mmc_card::version.
Referenced by sd_mmc_check().
|
static |
Initialize the MMC card in MCI mode.
References CARD_VER_MMC_4, driver_get_bus_width, driver_is_high_speed_capable, driver_send_cmd, MMC_CMD3_SET_RELATIVE_ADDR, mmc_cmd6_set_bus_width(), mmc_cmd6_set_high_speed(), mmc_cmd8(), mmc_decode_csd(), mmc_mci_op_cond(), sd_mmc_card::rca, SD_MMC_BLOCK_SIZE, sd_mmc_cmd9_mci(), sd_mmc_configure_slot(), SDMMC_CMD16_SET_BLOCKLEN, SDMMC_CMD2_ALL_SEND_CID, SDMMC_CMD7_SELECT_CARD_CMD, SDMMC_MCI_CMD0_GO_IDLE_STATE, and sd_mmc_card::version.
Referenced by sd_mmc_mci_card_init().
uint8_t sd_mmc_nb_slot | ( | void | ) |
|
static |
Select a card slot and initialize the associated driver.
slot | Card slot number |
SD_MMC_ERR_SLOT | Wrong slot number |
SD_MMC_ERR_NO_CARD | No card present on slot |
SD_MMC_ERR_UNUSABLE | Unusable card |
SD_MMC_INIT_ONGOING | Card initialization requested |
SD_MMC_OK | Card present |
References Assert, sd_mmc_card::bus_width, sd_mmc_card::clock, sd_mmc_card::high_speed, ioport_get_pin_level(), SD_MMC_CARD_STATE_DEBOUNCE, SD_MMC_CARD_STATE_INIT, SD_MMC_CARD_STATE_NO_CARD, SD_MMC_CARD_STATE_UNUSABLE, sd_mmc_cards, sd_mmc_configure_slot(), SD_MMC_ERR_NO_CARD, SD_MMC_ERR_SLOT, SD_MMC_ERR_UNUSABLE, SD_MMC_INIT_ONGOING, SD_MMC_OK, SDMMC_CLOCK_INIT, state, and sd_mmc_card::state.
Referenced by sd_mmc_check(), sd_mmc_get_capacity(), sd_mmc_get_type(), sd_mmc_get_version(), sd_mmc_init_read_blocks(), and sd_mmc_init_write_blocks().
|
static |
Initialize the SD card in SPI mode.
References CARD_TYPE_HC, CARD_TYPE_MMC, CARD_TYPE_SD, CARD_VER_UNKNOWN, driver_send_clock, driver_send_cmd, IS_SDIO, sd_mmc_card::rca, sd_acmd51(), sd_cmd8(), sd_decode_csd(), SD_MMC_BLOCK_SIZE, sd_mmc_cmd13(), sd_mmc_cmd9_spi(), sd_mmc_configure_slot(), sd_mmc_debug, sd_mmc_spi_install_mmc(), sd_spi_op_cond(), sdio_get_max_speed(), sdio_op_cond(), SDMMC_CMD16_SET_BLOCKLEN, SDMMC_SPI_CMD0_GO_IDLE_STATE, SDMMC_SPI_CMD59_CRC_ON_OFF, sd_mmc_card::type, and sd_mmc_card::version.
Referenced by sd_mmc_check().
|
static |
Initialize the MMC card in SPI mode.
References CARD_VER_MMC_4, driver_send_cmd, mmc_cmd8(), mmc_decode_csd(), mmc_spi_op_cond(), SD_MMC_BLOCK_SIZE, sd_mmc_cmd13(), sd_mmc_cmd9_spi(), sd_mmc_configure_slot(), SDMMC_CMD16_SET_BLOCKLEN, SDMMC_SPI_CMD0_GO_IDLE_STATE, SDMMC_SPI_CMD59_CRC_ON_OFF, and sd_mmc_card::version.
Referenced by sd_mmc_spi_card_init().
sd_mmc_err_t sd_mmc_start_read_blocks | ( | void * | dest, |
uint16_t | nb_block | ||
) |
Start the read blocks of data from the card.
dest | Pointer to read buffer. |
nb_block | Number of blocks to be read. |
References Assert, driver_start_read_blocks, SD_MMC_ERR_COMM, and SD_MMC_OK.
Referenced by main_test_memory(), run_sd_mmc_rw_test(), sd_mmc_mem_2_ram(), and sd_mmc_usb_read_10().
sd_mmc_err_t sd_mmc_start_write_blocks | ( | const void * | src, |
uint16_t | nb_block | ||
) |
Start the write blocks of data.
src | Pointer to write buffer. |
nb_block | Number of blocks to be written. |
References Assert, driver_start_write_blocks, SD_MMC_ERR_COMM, and SD_MMC_OK.
Referenced by main_test_memory(), run_sd_mmc_rw_test(), sd_mmc_ram_2_mem(), and sd_mmc_usb_write_10().
sd_mmc_err_t sd_mmc_wait_end_of_read_blocks | ( | bool | abort | ) |
Wait the end of read blocks of data from the card.
abort | Abort reading process initialized by sd_mmc_init_read_blocks() after the reading issued by sd_mmc_start_read_blocks() is done |
References driver_adtc_stop, driver_wait_end_of_read_blocks, sd_mmc_deselect_slot(), SD_MMC_ERR_COMM, SD_MMC_OK, and SDMMC_CMD12_STOP_TRANSMISSION.
Referenced by main_test_memory(), run_sd_mmc_rw_test(), sd_mmc_mem_2_ram(), and sd_mmc_usb_read_10().
sd_mmc_err_t sd_mmc_wait_end_of_write_blocks | ( | bool | abort | ) |
Wait the end of write blocks of data.
abort | Abort writing process initialized by sd_mmc_init_write_blocks() after the writing issued by sd_mmc_start_write_blocks() is done |
References driver_adtc_stop, driver_wait_end_of_write_blocks, sd_mmc_deselect_slot(), SD_MMC_ERR_COMM, sd_mmc_is_mci, SD_MMC_OK, and SDMMC_CMD12_STOP_TRANSMISSION.
Referenced by main_test_memory(), run_sd_mmc_rw_test(), sd_mmc_ram_2_mem(), and sd_mmc_usb_write_10().
|
static |
Ask to all cards to send their operations conditions (SPI only).
v2 | Shall be 1 if it is a SD card V2 |
References CARD_TYPE_HC, driver_get_response, driver_send_cmd, OCR_CCS, R1_SPI_IDLE, SD_ACMD41_HCS, sd_mmc_debug, SD_SPI_ACMD41_SD_SEND_OP_COND, SDMMC_CMD55_APP_CMD, SDMMC_SPI_CMD58_READ_OCR, and sd_mmc_card::type.
Referenced by sd_mmc_spi_card_init().
|
static |
Referenced by sd_mmc_mci_card_init().
|
static |
Referenced by sd_mmc_mci_card_init().
|
static |
Referenced by sd_mmc_mci_card_init(), and sd_mmc_spi_card_init().
|
static |
Referenced by sd_mmc_mci_card_init(), and sd_mmc_spi_card_init().
const uint32_t mmc_trans_multipliers[16] |
MMC transfer multiplier factor codes (1/10) list.
|
static |
Pointer on current slot configurated.
|
static |
SD/MMC card list Note: Initialize card detect pin fields if present.
Referenced by sd_mmc_init(), sd_mmc_is_write_protected(), and sd_mmc_select_slot().
|
static |
Number of block remaining to read or write on the current transfer.
|
static |
Number of block to read or write on the current transfer.
|
static |
Index of current slot configurated.
const uint32_t sd_mmc_trans_units[7] |
SD/MMC transfer rate unit codes (10K) list.
const uint32_t sd_trans_multipliers[16] |
SD transfer multiplier factor codes (1/10) list.