Prevent SD access from resetting ESP32 (#16690)
This commit is contained in:
parent
0c3cae59d9
commit
e4eaf32b4d
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue