Skip to content

Commit

Permalink
Prevent SD access from resetting ESP32 (#16690)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixstorm-c4a8 authored and thinkyhead committed Jan 28, 2020
1 parent 0c3cae5 commit e4eaf32
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Marlin/src/sd/SdVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,16 @@ int32_t SdVolume::freeClusterCount() {
for (uint16_t i = 0; i < n; i++)
if (cacheBuffer_.fat32[i] == 0) free++;
}
#ifdef ESP32
// Needed to reset the idle task watchdog timer on ESP32 as reading the complete FAT may easily
// block for 10+ seconds. yield() is insufficient since it blocks lower prio tasks (e.g., idle).
static millis_t nextTaskTime = 0;
const millis_t ms = millis();
if (ELAPSED(ms, nextTaskTime) {
vTaskDelay(1); // delay 1 tick (Minimum. Usually 10 or 1 ms depending on skdconfig.h)
nextTaskTime = ms + 1000; // tickle the task manager again in 1 second
}
#endif // ESP32
}
return free;
}
Expand Down

0 comments on commit e4eaf32

Please sign in to comment.