mirror of
https://github.com/espressif/esp-idf
synced 2025-03-12 10:39:11 -04:00
Merge branch 'fixbug/sdmmc_spi_highspeed_v4.2' into 'release/v4.2'
sdmmc: fix the probe issue that forbid sdspi working in highspeed mode(backport v4.2) See merge request espressif/esp-idf!9841
This commit is contained in:
commit
789119262b
@ -225,24 +225,29 @@ esp_err_t sdmmc_enable_hs_mode_and_check(sdmmc_card_t* card)
|
|||||||
/* HS mode has been enabled on the card.
|
/* HS mode has been enabled on the card.
|
||||||
* Read CSD again, it should now indicate that the card supports
|
* Read CSD again, it should now indicate that the card supports
|
||||||
* 50MHz clock.
|
* 50MHz clock.
|
||||||
* Since SEND_CSD is allowed only in standby mode, and the card is
|
* Since SEND_CSD is allowed only in standby mode, and the card is currently in data transfer
|
||||||
* currently in data transfer more, deselect the card first, then
|
* mode, deselect the card first, then get the CSD, then select the card again. This step is
|
||||||
* get the CSD, then select the card again.
|
* not required in SPI mode, since CMD7 (select_card) is not supported.
|
||||||
*/
|
*/
|
||||||
err = sdmmc_send_cmd_select_card(card, 0);
|
const bool is_spi = host_is_spi(card);
|
||||||
if (err != ESP_OK) {
|
if (!is_spi) {
|
||||||
ESP_LOGE(TAG, "%s: select_card (1) returned 0x%x", __func__, err);
|
err = sdmmc_send_cmd_select_card(card, 0);
|
||||||
return err;
|
if (err != ESP_OK) {
|
||||||
|
ESP_LOGE(TAG, "%s: select_card (1) returned 0x%x", __func__, err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
err = sdmmc_send_cmd_send_csd(card, &card->csd);
|
err = sdmmc_send_cmd_send_csd(card, &card->csd);
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "%s: send_csd returned 0x%x", __func__, err);
|
ESP_LOGE(TAG, "%s: send_csd returned 0x%x", __func__, err);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
err = sdmmc_send_cmd_select_card(card, card->rca);
|
if (!is_spi) {
|
||||||
if (err != ESP_OK) {
|
err = sdmmc_send_cmd_select_card(card, card->rca);
|
||||||
ESP_LOGE(TAG, "%s: select_card (2) returned 0x%x", __func__, err);
|
if (err != ESP_OK) {
|
||||||
return err;
|
ESP_LOGE(TAG, "%s: select_card (2) returned 0x%x", __func__, err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (card->csd.tr_speed != 50000000) {
|
if (card->csd.tr_speed != 50000000) {
|
||||||
|
@ -388,6 +388,8 @@ TEST_CASE("SDMMC read/write test (SD slot 1, in SPI mode)", "[sdspi][test_env=UT
|
|||||||
|
|
||||||
sdmmc_host_t config = SDSPI_HOST_DEFAULT();
|
sdmmc_host_t config = SDSPI_HOST_DEFAULT();
|
||||||
config.slot = handle;
|
config.slot = handle;
|
||||||
|
// This test can only run under 20MHz on ESP32, because the runner connects the card to
|
||||||
|
// non-IOMUX pins of HSPI.
|
||||||
|
|
||||||
sdmmc_card_t* card = malloc(sizeof(sdmmc_card_t));
|
sdmmc_card_t* card = malloc(sizeof(sdmmc_card_t));
|
||||||
TEST_ASSERT_NOT_NULL(card);
|
TEST_ASSERT_NOT_NULL(card);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user