kopia lustrzana https://github.com/espressif/esp-idf
Merge branch 'bugfix/sdspi_acmd41_arg_v4.4' into 'release/v4.4'
fix(sdmmc): fixes for card initialization (ACMD41) (v4.4) See merge request espressif/esp-idf!29379release/v4.4
commit
30f96ffe48
|
@ -28,17 +28,27 @@ esp_err_t sdmmc_init_ocr(sdmmc_card_t* card)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint32_t host_ocr = get_host_ocr(card->host.io_voltage);
|
uint32_t host_ocr = get_host_ocr(card->host.io_voltage);
|
||||||
if ((card->ocr & SD_OCR_SDHC_CAP) != 0) {
|
|
||||||
host_ocr |= SD_OCR_SDHC_CAP;
|
/* In SPI mode, the only non-zero bit of ACMD41 is HCS (bit 30)
|
||||||
|
* In SD mode, bits 23:8 contain the supported voltage mask
|
||||||
|
*/
|
||||||
|
uint32_t acmd41_arg = 0;
|
||||||
|
if (!host_is_spi(card)) {
|
||||||
|
acmd41_arg = host_ocr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((card->ocr & SD_OCR_SDHC_CAP) != 0) {
|
||||||
|
acmd41_arg |= SD_OCR_SDHC_CAP;
|
||||||
|
}
|
||||||
|
|
||||||
/* Send SEND_OP_COND (ACMD41) command to the card until it becomes ready. */
|
/* Send SEND_OP_COND (ACMD41) command to the card until it becomes ready. */
|
||||||
err = sdmmc_send_cmd_send_op_cond(card, host_ocr, &card->ocr);
|
err = sdmmc_send_cmd_send_op_cond(card, acmd41_arg, &card->ocr);
|
||||||
|
|
||||||
/* If time-out, re-try send_op_cond as MMC */
|
/* If time-out, re-try send_op_cond as MMC */
|
||||||
if (err == ESP_ERR_TIMEOUT && !host_is_spi(card)) {
|
if (err == ESP_ERR_TIMEOUT && !host_is_spi(card)) {
|
||||||
ESP_LOGD(TAG, "send_op_cond timeout, trying MMC");
|
ESP_LOGD(TAG, "send_op_cond timeout, trying MMC");
|
||||||
card->is_mmc = 1;
|
card->is_mmc = 1;
|
||||||
err = sdmmc_send_cmd_send_op_cond(card, host_ocr, &card->ocr);
|
err = sdmmc_send_cmd_send_op_cond(card, acmd41_arg, &card->ocr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
/* Maximum retry/error count for SEND_OP_COND (CMD1).
|
/* Maximum retry/error count for SEND_OP_COND (CMD1).
|
||||||
* These are somewhat arbitrary, values originate from OpenBSD driver.
|
* These are somewhat arbitrary, values originate from OpenBSD driver.
|
||||||
*/
|
*/
|
||||||
#define SDMMC_SEND_OP_COND_MAX_RETRIES 100
|
#define SDMMC_SEND_OP_COND_MAX_RETRIES 300
|
||||||
#define SDMMC_SEND_OP_COND_MAX_ERRORS 3
|
#define SDMMC_SEND_OP_COND_MAX_ERRORS 3
|
||||||
|
|
||||||
/* Functions to send individual commands */
|
/* Functions to send individual commands */
|
||||||
|
|
Ładowanie…
Reference in New Issue