Merge branch 'feat/mmc_check_data_switching_freq' into 'master'
sdmmc: add communication check for eMMC after frequency switch See merge request espressif/esp-idf!6893
This commit is contained in:
commit
1f6bb6ef4f
3 changed files with 34 additions and 1 deletions
|
@ -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_mmc_bus_width(sdmmc_card_t* card);
|
||||||
esp_err_t sdmmc_init_card_hs_mode(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_host_frequency(sdmmc_card_t* card);
|
||||||
|
esp_err_t sdmmc_init_mmc_check_csd(sdmmc_card_t* card);
|
||||||
|
|
||||||
/* Various helper functions */
|
/* Various helper functions */
|
||||||
static inline bool host_is_spi(const sdmmc_card_t* card)
|
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 */
|
/* Sanity check after switching the bus mode and frequency */
|
||||||
SDMMC_INIT_STEP(is_sdmem, sdmmc_check_scr);
|
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;
|
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;
|
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 a new issue