mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
sdmmc: add communication check for eMMC after frequency switch
This commit is contained in:
parent
bcb9ba6783
commit
232d98608a
@ -117,6 +117,7 @@ esp_err_t sdmmc_init_io_bus_width(sdmmc_card_t* card);
|
||||
esp_err_t sdmmc_init_mmc_bus_width(sdmmc_card_t* card);
|
||||
esp_err_t sdmmc_init_card_hs_mode(sdmmc_card_t* card);
|
||||
esp_err_t sdmmc_init_host_frequency(sdmmc_card_t* card);
|
||||
esp_err_t sdmmc_init_mmc_check_csd(sdmmc_card_t* card);
|
||||
|
||||
/* Various helper functions */
|
||||
static inline bool host_is_spi(const sdmmc_card_t* card)
|
||||
|
@ -117,7 +117,9 @@ esp_err_t sdmmc_card_init(const sdmmc_host_t* config, sdmmc_card_t* card)
|
||||
|
||||
/* Sanity check after switching the bus mode and frequency */
|
||||
SDMMC_INIT_STEP(is_sdmem, sdmmc_check_scr);
|
||||
/* TODO: add similar checks for eMMC and SDIO */
|
||||
/* TODO: this is CMD line only, add data checks for eMMC */
|
||||
SDMMC_INIT_STEP(is_mmc, sdmmc_init_mmc_check_csd);
|
||||
/* TODO: add similar checks for SDIO */
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
@ -231,3 +231,33 @@ esp_err_t sdmmc_mmc_switch(sdmmc_card_t* card, uint8_t set, uint8_t index, uint8
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_err_t sdmmc_init_mmc_check_csd(sdmmc_card_t* card)
|
||||
{
|
||||
esp_err_t err;
|
||||
assert(card->is_mem == 1);
|
||||
assert(card->rca != 0);
|
||||
//The card will not respond to send_csd command in the transfer state.
|
||||
//Deselect it first.
|
||||
err = sdmmc_send_cmd_select_card(card, 0);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s: select_card returned 0x%x", __func__, err);
|
||||
return err;
|
||||
}
|
||||
|
||||
sdmmc_csd_t csd;
|
||||
/* Get the contents of CSD register to verify the communication over CMD line
|
||||
is OK. */
|
||||
err = sdmmc_send_cmd_send_csd(card, &csd);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s: send_csd returned 0x%x", __func__, err);
|
||||
return err;
|
||||
}
|
||||
|
||||
//Select the card again
|
||||
err = sdmmc_send_cmd_select_card(card, card->rca);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "%s: select_card returned 0x%x", __func__, err);
|
||||
return err;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user