diff --git a/drivers/mmcsd/Kconfig b/drivers/mmcsd/Kconfig index 8a663eb113..7ace74ea7e 100644 --- a/drivers/mmcsd/Kconfig +++ b/drivers/mmcsd/Kconfig @@ -177,6 +177,19 @@ config MMCSD_BLOCK_WDATADELAY Some hardware needs to configure this delay to write one data block, because the hardware needs more time for wear leveling and bad block management. +config MMCSD_CHECK_READY_STATUS_WITHOUT_SLEEP + bool "No sleep in ready-check function." + default n + ---help--- + Since nxsig_usleep returns at the tick after the next tick, when + CONFIG_USEC_PER_TICK is big, the real sleep time is much more than + desired in mmcsd_transferready(). As a result, write speed is + affected seriously. + + When this configuration is enabled, the sleep in mmcsd_transferready + will be skipped. However, CPU will be hogged by the process during + this period of writing time. + endif endif # MMCSD diff --git a/drivers/mmcsd/mmcsd_sdio.c b/drivers/mmcsd/mmcsd_sdio.c index 3ee7eb2680..debb7d9c12 100644 --- a/drivers/mmcsd/mmcsd_sdio.c +++ b/drivers/mmcsd/mmcsd_sdio.c @@ -1251,7 +1251,13 @@ static int mmcsd_transferready(FAR struct mmcsd_state_s *priv) /* Do not hog the CPU */ +#ifdef CONFIG_MMCSD_CHECK_READY_STATUS_WITHOUT_SLEEP + /* Use sched_yield when tick is big to avoid low writing speed */ + + sched_yield(); +#else nxsig_usleep(1000); +#endif /* We are still in the programming state. Calculate the elapsed * time... we can't stay in this loop forever!