SD/MMC/SDIO basic APIs used by SD/MMC/SDIO memory APIs (sd_mmc_stack_mem_group).
Also, it can be used by application which use the SDIO card or specific application which does not need of File System.
For usual application which use the SD/MMC card in memory mode with a file system, please refer to sd_mmc_stack_mem_group.
Modules | |
Related Project(s) | |
In this section you can find all the projects related to the SD/MMC/SDIO common stack. | |
Common SPI interface for SD/MMC stack | |
SD/MMC Memory | |
SD/MMC memory APIs required by CTRL_ACCESS module (Memory Control Access). | |
SD/MMC Protocol Definition | |
Macros | |
#define | SD_MMC_BLOCK_SIZE 512 |
This SD MMC stack uses the maximum block size autorized (512 bytes) More... | |
Typedefs | |
typedef uint8_t | card_type_t |
Type of card type. More... | |
typedef uint8_t | card_version_t |
Type of card version. More... | |
typedef uint8_t | sd_mmc_err_t |
Type of return error code. 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... | |
Return error codes | |
#define | SD_MMC_OK 0 |
#define | SD_MMC_INIT_ONGOING 1 |
#define | SD_MMC_ERR_NO_CARD 2 |
#define | SD_MMC_ERR_UNUSABLE 3 |
#define | SD_MMC_ERR_SLOT 4 |
#define | SD_MMC_ERR_COMM 5 |
#define | SD_MMC_ERR_PARAM 6 |
#define | SD_MMC_ERR_WP 7 |
Card Types | |
#define | CARD_TYPE_UNKNOWN (0) |
Unknown type card. More... | |
#define | CARD_TYPE_SD (1 << 0) |
SD card. More... | |
#define | CARD_TYPE_MMC (1 << 1) |
MMC card. More... | |
#define | CARD_TYPE_SDIO (1 << 2) |
SDIO card. More... | |
#define | CARD_TYPE_HC (1 << 3) |
High capacity card. More... | |
#define | CARD_TYPE_SD_COMBO (CARD_TYPE_SD | CARD_TYPE_SDIO) |
SD combo card (io + memory) More... | |
Card Versions | |
#define | CARD_VER_UNKNOWN (0) |
#define | CARD_VER_SD_1_0 (0x10) |
#define | CARD_VER_SD_1_10 (0x1A) |
#define | CARD_VER_SD_2_0 (0X20) |
#define | CARD_VER_SD_3_0 (0X30) |
#define | CARD_VER_MMC_1_2 (0x12) |
#define | CARD_VER_MMC_1_4 (0x14) |
#define | CARD_VER_MMC_2_2 (0x22) |
#define | CARD_VER_MMC_3 (0x30) |
#define | CARD_VER_MMC_4 (0x40) |
#define CARD_TYPE_HC (1 << 3) |
High capacity card.
Referenced by main_display_info_card(), mmc_mci_op_cond(), mmc_spi_op_cond(), sd_mci_op_cond(), sd_mmc_init_read_blocks(), sd_mmc_init_write_blocks(), sd_mmc_spi_card_init(), and sd_spi_op_cond().
#define CARD_TYPE_MMC (1 << 1) |
MMC card.
Referenced by main(), main_display_info_card(), run_sd_mmc_rw_test(), sd_mmc_mci_card_init(), sd_mmc_spi_card_init(), and sd_mmc_test_unit_ready().
#define CARD_TYPE_SD (1 << 0) |
SD card.
Referenced by main(), main_display_info_card(), run_sd_mmc_rw_test(), sd_mmc_mci_card_init(), sd_mmc_spi_card_init(), and sd_mmc_test_unit_ready().
#define CARD_TYPE_SD_COMBO (CARD_TYPE_SD | CARD_TYPE_SDIO) |
SD combo card (io + memory)
Referenced by main_display_info_card().
#define CARD_TYPE_SDIO (1 << 2) |
SDIO card.
#define CARD_TYPE_UNKNOWN (0) |
Unknown type card.
Referenced by main_display_info_card(), and sd_mmc_get_type().
#define CARD_VER_MMC_1_2 (0x12) |
Referenced by mmc_decode_csd().
#define CARD_VER_MMC_1_4 (0x14) |
Referenced by mmc_decode_csd().
#define CARD_VER_MMC_2_2 (0x22) |
Referenced by mmc_decode_csd().
#define CARD_VER_MMC_3 (0x30) |
Referenced by mmc_decode_csd().
#define CARD_VER_MMC_4 (0x40) |
Referenced by mmc_decode_csd(), sd_mmc_mci_install_mmc(), and sd_mmc_spi_install_mmc().
#define CARD_VER_SD_1_0 (0x10) |
Referenced by sd_acmd51(), and sd_mmc_mci_card_init().
#define CARD_VER_SD_1_10 (0x1A) |
Referenced by sd_acmd51().
#define CARD_VER_SD_2_0 (0X20) |
Referenced by sd_acmd51().
#define CARD_VER_SD_3_0 (0X30) |
Referenced by sd_acmd51().
#define CARD_VER_UNKNOWN (0) |
Referenced by sd_mmc_get_version(), sd_mmc_mci_card_init(), and sd_mmc_spi_card_init().
#define SD_MMC_BLOCK_SIZE 512 |
This SD MMC stack uses the maximum block size autorized (512 bytes)
Referenced by main_test_memory(), rw_test(), sd_mmc_init_read_blocks(), sd_mmc_init_write_blocks(), sd_mmc_mci_card_init(), sd_mmc_mci_install_mmc(), sd_mmc_spi_card_init(), sd_mmc_spi_install_mmc(), sd_mmc_usb_read_10(), and sd_mmc_usb_write_10().
#define SD_MMC_ERR_COMM 5 |
#define SD_MMC_ERR_NO_CARD 2 |
#define SD_MMC_ERR_PARAM 6 |
#define SD_MMC_ERR_SLOT 4 |
Referenced by sd_mmc_select_slot().
#define SD_MMC_ERR_UNUSABLE 3 |
Referenced by sd_mmc_check(), and sd_mmc_select_slot().
#define SD_MMC_ERR_WP 7 |
Referenced by sd_mmc_init_write_blocks().
#define SD_MMC_INIT_ONGOING 1 |
Referenced by main(), run_sd_mmc_init_test(), sd_mmc_check(), sd_mmc_select_slot(), and sd_mmc_test_unit_ready().
#define SD_MMC_OK 0 |
Referenced by main(), main_test_memory(), run_sd_mmc_init_test(), run_sd_mmc_rw_test(), rw_test(), sd_mmc_get_capacity(), sd_mmc_get_type(), sd_mmc_get_version(), sd_mmc_init_read_blocks(), sd_mmc_init_write_blocks(), sd_mmc_mem_2_ram(), sd_mmc_ram_2_mem(), sd_mmc_select_slot(), sd_mmc_start_read_blocks(), sd_mmc_start_write_blocks(), sd_mmc_test_unit_ready(), sd_mmc_usb_read_10(), sd_mmc_usb_write_10(), sd_mmc_wait_end_of_read_blocks(), and sd_mmc_wait_end_of_write_blocks().
typedef uint8_t card_type_t |
Type of card type.
typedef uint8_t card_version_t |
Type of card version.
typedef uint8_t sd_mmc_err_t |
Type of return error code.
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 _sd_init(), init_storage(), main(), run_sd_mmc_init_test(), run_sd_mmc_rw_test(), and sd_mmc_test_unit_ready().
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(), 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_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 _sd_init(), init_storage(), main(), 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(), 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(), 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 port_pin_get_input_level(), sd_mmc_cards, and UNUSED.
Referenced by main_test_memory(), rw_test(), sd_mmc_init_write_blocks(), and sd_mmc_wr_protect().
uint8_t sd_mmc_nb_slot | ( | void | ) |
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(), 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(), 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(), 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(), rw_test(), sd_mmc_ram_2_mem(), and sd_mmc_usb_write_10().