fix(sdmmc_io): fixed fixed_addr mode will still increase addr when splitting

This commit is contained in:
Michael (XIAO Xufeng) 2024-06-29 02:26:14 +08:00 committed by Xiao Xufeng
parent b1c8757b9f
commit fded5b0ce3

View File

@ -381,11 +381,15 @@ esp_err_t sdmmc_io_rw_extended(sdmmc_card_t* card, int func,
esp_err_t sdmmc_io_read_bytes(sdmmc_card_t* card, uint32_t function,
uint32_t addr, void* dst, size_t size)
{
uint32_t arg = SD_ARG_CMD53_READ | SD_ARG_CMD53_INCREMENT;
//Extract and unset the bit used to indicate the OP Code (inverted logic)
uint32_t arg = SD_ARG_CMD53_READ;
bool incr_addr = true;
//Extract and unset the bit used to indicate the OP Code
if (addr & SDMMC_IO_FIXED_ADDR) {
arg &= ~SD_ARG_CMD53_INCREMENT;
addr &= ~SDMMC_IO_FIXED_ADDR;
incr_addr = false;
}
if (incr_addr) {
arg |= SD_ARG_CMD53_INCREMENT;
}
/* host quirk: SDIO transfer with length not divisible by 4 bytes
@ -405,7 +409,9 @@ esp_err_t sdmmc_io_read_bytes(sdmmc_card_t* card, uint32_t function,
}
pc_dst += will_transfer;
size -= will_transfer;
addr += will_transfer;
if (incr_addr) {
addr += will_transfer;
}
}
return ESP_OK;
}
@ -413,11 +419,15 @@ esp_err_t sdmmc_io_read_bytes(sdmmc_card_t* card, uint32_t function,
esp_err_t sdmmc_io_write_bytes(sdmmc_card_t* card, uint32_t function,
uint32_t addr, const void* src, size_t size)
{
uint32_t arg = SD_ARG_CMD53_WRITE | SD_ARG_CMD53_INCREMENT;
//Extract and unset the bit used to indicate the OP Code (inverted logic)
uint32_t arg = SD_ARG_CMD53_WRITE;
bool incr_addr = true;
//Extract and unset the bit used to indicate the OP Code
if (addr & SDMMC_IO_FIXED_ADDR) {
arg &= ~SD_ARG_CMD53_INCREMENT;
addr &= ~SDMMC_IO_FIXED_ADDR;
incr_addr = false;
}
if (incr_addr) {
arg |= SD_ARG_CMD53_INCREMENT;
}
/* same host quirk as in sdmmc_io_read_bytes */
@ -434,7 +444,9 @@ esp_err_t sdmmc_io_write_bytes(sdmmc_card_t* card, uint32_t function,
}
pc_src += will_transfer;
size -= will_transfer;
addr += will_transfer;
if (incr_addr) {
addr += will_transfer;
}
}
return ESP_OK;
}