File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -315,10 +315,11 @@ bool sd_card_inserted(void)
315315 return true;
316316#else
317317 sd_mmc_err_t err = sd_mmc_check (0 );
318- /* If initialization is ongoing, wait up to 1 second for it to initialize */
319- if (err == SD_MMC_INIT_ONGOING ) {
320- for (int i = 0 ; i < 10 ; ++ i ) {
321- delay_ms (100 );
318+ /* If initialization is ongoing, wait up to 1 second for it to initialize. */
319+ /* The first time sd_mmc_check is called it may return SD_MMC_ERR_NO_CARD. */
320+ if (err == SD_MMC_ERR_NO_CARD || err == SD_MMC_INIT_ONGOING ) {
321+ for (int i = 0 ; i < 100 ; ++ i ) {
322+ delay_ms (10 );
322323 err = sd_mmc_check (0 );
323324 if (err != SD_MMC_INIT_ONGOING ) {
324325 break ;
@@ -334,7 +335,7 @@ bool sd_card_inserted(void)
334335 util_log ("sd_mmc_check returned \"SD_MMC_ERR_UNUSABLE\"" );
335336 break ;
336337 case SD_MMC_INIT_ONGOING :
337- util_log ("sd_mmc_check returned \"SD_MMC_INIT_ONGOING\" after 10 retries " );
338+ util_log ("sd_mmc_check returned \"SD_MMC_INIT_ONGOING\" after 1s " );
338339 break ;
339340 default :
340341 util_log ("sd_mmc_check returned %d" , err );
You can’t perform that action at this time.
0 commit comments