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)
315
315
return true;
316
316
#else
317
317
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 );
322
323
err = sd_mmc_check (0 );
323
324
if (err != SD_MMC_INIT_ONGOING ) {
324
325
break ;
@@ -334,7 +335,7 @@ bool sd_card_inserted(void)
334
335
util_log ("sd_mmc_check returned \"SD_MMC_ERR_UNUSABLE\"" );
335
336
break ;
336
337
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 " );
338
339
break ;
339
340
default :
340
341
util_log ("sd_mmc_check returned %d" , err );
You can’t perform that action at this time.
0 commit comments