Browse Source

Prevent SD access from resetting ESP32 (#16690)

felixstorm 5 years ago
parent
commit
e4eaf32b4d
1 changed files with 10 additions and 0 deletions
  1. 10
    0
      Marlin/src/sd/SdVolume.cpp

+ 10
- 0
Marlin/src/sd/SdVolume.cpp View File

291
       for (uint16_t i = 0; i < n; i++)
291
       for (uint16_t i = 0; i < n; i++)
292
         if (cacheBuffer_.fat32[i] == 0) free++;
292
         if (cacheBuffer_.fat32[i] == 0) free++;
293
     }
293
     }
294
+    #ifdef ESP32
295
+      // Needed to reset the idle task watchdog timer on ESP32 as reading the complete FAT may easily 
296
+      // block for 10+ seconds. yield() is insufficient since it blocks lower prio tasks (e.g., idle).
297
+      static millis_t nextTaskTime = 0;
298
+      const millis_t ms = millis();
299
+      if (ELAPSED(ms, nextTaskTime) {
300
+        vTaskDelay(1);            // delay 1 tick (Minimum. Usually 10 or 1 ms depending on skdconfig.h)
301
+        nextTaskTime = ms + 1000; // tickle the task manager again in 1 second
302
+      }
303
+    #endif // ESP32
294
   }
304
   }
295
   return free;
305
   return free;
296
 }
306
 }

Loading…
Cancel
Save