Files
firmware/src/concurrency/FreeRtosThread.cpp

45 lines
775 B
C++
Raw Normal View History

2020-09-04 15:03:22 -07:00
#include "FreeRtosThread.h"
#ifdef HAS_FREE_RTOS
2020-07-09 19:57:55 -07:00
#include <assert.h>
2020-07-09 19:57:55 -07:00
#ifdef ARDUINO_ARCH_ESP32
#include "esp_task_wdt.h"
#endif
namespace concurrency
{
2020-09-04 15:03:22 -07:00
void FreeRtosThread::start(const char *name, size_t stackSize, uint32_t priority)
{
auto r = xTaskCreate(callRun, name, stackSize, this, priority, &taskHandle);
assert(r == pdPASS);
}
2020-09-04 15:03:22 -07:00
void FreeRtosThread::serviceWatchdog()
2020-07-09 19:57:55 -07:00
{
#ifdef ARDUINO_ARCH_ESP32
esp_task_wdt_reset();
#endif
}
2020-09-04 15:03:22 -07:00
void FreeRtosThread::startWatchdog()
2020-07-09 19:57:55 -07:00
{
#ifdef ARDUINO_ARCH_ESP32
auto r = esp_task_wdt_add(taskHandle);
assert(r == ESP_OK);
#endif
}
2020-09-04 15:03:22 -07:00
void FreeRtosThread::stopWatchdog()
2020-07-09 19:57:55 -07:00
{
#ifdef ARDUINO_ARCH_ESP32
auto r = esp_task_wdt_delete(taskHandle);
assert(r == ESP_OK);
#endif
}
} // namespace concurrency
2020-09-04 15:03:22 -07:00
#endif