turn on thread watchdog

This commit is contained in:
geeksville
2020-06-28 11:12:12 -07:00
parent a595fc4642
commit bd477f0fb2
4 changed files with 44 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
#include <Arduino.h>
#include "esp_task_wdt.h"
#include "freertosinc.h"
#include <Arduino.h>
#ifdef HAS_FREE_RTOS
@@ -26,6 +27,23 @@ class Thread
*/
virtual void doRun() = 0;
/**
* All thread run methods must periodically call serviceWatchdog, or the system will declare them hung and panic.
*
* this only applies after startWatchdog() has been called. If you need to sleep for a long time call stopWatchdog()
*/
void serviceWatchdog() { esp_task_wdt_reset(); }
void startWatchdog()
{
auto r = esp_task_wdt_add(taskHandle);
assert(r == ESP_OK);
}
void stopWatchdog()
{
auto r = esp_task_wdt_delete(taskHandle);
assert(r == ESP_OK);
}
private:
static void callRun(void *_this);
};