1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 22:43:50 +01:00

drivers/sdmmc: add additional debugging info

This commit is contained in:
Gunar Schorcht 2025-05-07 18:07:10 +02:00
parent 4c74f54eb0
commit 3a81390b2a
2 changed files with 28 additions and 5 deletions

View File

@ -269,7 +269,7 @@ typedef enum {
[48 bit (16 bit RCA, 16 bit not defined) */
SDMMC_R6 = 6 | SDMMC_RESP_CRC, /**< Published RCA Response [48 bit (16 bit RCA,
16 bit card status) */
SDMMC_R7 = 7 | SDMMC_RESP_CRC, /**< Card Interface Condition [48 bit] (32 bit data,
SDMMC_R7 = 7 | SDMMC_RESP_CRC, /**< Card Interface Condition [48 bit (32 bit data)],
see section 4.9.6) */
} sdmmc_resp_t;
/** @} */

View File

@ -462,7 +462,12 @@ int sdmmc_card_init(sdmmc_dev_t *dev)
/* the card is either SD card, Combo card or MMC */
do {
_ZTIMER_SLEEP_MS(100);
/* According to the Physical Layer Simplified Specification
* Version 9.00 [[sdcard.org](https://www.sdcard.org)] section 4.4
* "Clock Control", the polling interval for ACMD41 must be less than
* 50 ms, if the clock is stopped by the host and not continuous
* during ACMD41 polling until the card becomes ready. */
_ZTIMER_SLEEP_MS(10);
DEBUG("[sdmmc] send %s %s to test whether card is SDSC/SDXC or MMC card\n",
cmd == SDMMC_ACMD41 ? "ACMD41" : "CMD1",
arg & SDMMC_ACMD41_HCS ? "HCS=1" : "HCS=0");
@ -917,7 +922,7 @@ int sdmmc_read_sds(sdmmc_dev_t *dev, sdmmc_sd_status_t *sds)
static int _send_cmd(sdmmc_dev_t *dev, sdmmc_cmd_t cmd_idx, uint32_t arg,
sdmmc_resp_t resp_type, uint32_t *resp)
{
DEBUG("[sdmmc] %s dev=%p cmd_idx=%u arg=%"PRIu32" resp_type=%u resp=%p\n",
DEBUG("[sdmmc] %s dev=%p cmd_idx=%u arg=0x%"PRIx32" resp_type=0x%x resp=%p\n",
__func__, dev, cmd_idx, arg, resp_type, resp);
#if !IS_USED(MODULE_PERIPH_SDMMC_AUTO_CLK)
@ -928,7 +933,25 @@ static int _send_cmd(sdmmc_dev_t *dev, sdmmc_cmd_t cmd_idx, uint32_t arg,
}
#endif
return dev->driver->send_cmd(dev, cmd_idx, arg, resp_type, resp);
int res = dev->driver->send_cmd(dev, cmd_idx, arg, resp_type, resp);
#if ENABLE_DEBUG
if (!resp) {
return res;
}
if (resp_type == SDMMC_R2) {
DEBUG("[sdmmc] %s dev=%p cmd_idx=%u "
"r[0]=0x%08"PRIx32" r[2]=0x%08"PRIx32" r[1]=0x%08"PRIx32" r[3]=0x%08"PRIx32"\n",
__func__, dev, cmd_idx, resp[0], resp[1], resp[2], resp[3]);
}
else if (resp_type != SDMMC_NO_R) {
DEBUG("[sdmmc] %s dev=%p cmd_idx=%u r=0x%08"PRIx32"\n",
__func__, dev, cmd_idx, *resp);
}
#endif
return res;
}
static int _send_acmd(sdmmc_dev_t *dev, sdmmc_cmd_t cmd_idx, uint32_t arg,
@ -937,7 +960,7 @@ static int _send_acmd(sdmmc_dev_t *dev, sdmmc_cmd_t cmd_idx, uint32_t arg,
uint32_t response;
int res;
DEBUG("[sdmmc] %s dev=%p cmd_idx=%u arg=%"PRIu32" resp_type=%u resp=%p\n",
DEBUG("[sdmmc] %s dev=%p cmd_idx=%u arg=0x%"PRIx32" resp_type=0x%x resp=%p\n",
__func__, dev, cmd_idx, arg, resp_type, resp);
assert(cmd_idx & SDMMC_ACMD_PREFIX);