2016-10-06 13:21:30 +02:00
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
|
#include "freertos/task.h"
|
2018-12-28 19:37:33 +01:00
|
|
|
#include "esp_task_wdt.h"
|
2016-12-12 01:12:13 +01:00
|
|
|
#include "Arduino.h"
|
2016-10-06 13:21:30 +02:00
|
|
|
|
2020-12-02 10:52:04 +01:00
|
|
|
#ifndef CONFIG_ARDUINO_LOOP_STACK_SIZE
|
|
|
|
#define CONFIG_ARDUINO_LOOP_STACK_SIZE 8192
|
|
|
|
#endif
|
|
|
|
|
2018-12-28 19:37:33 +01:00
|
|
|
TaskHandle_t loopTaskHandle = NULL;
|
|
|
|
|
2016-11-18 14:07:25 +01:00
|
|
|
#if CONFIG_AUTOSTART_ARDUINO
|
2016-10-06 13:21:30 +02:00
|
|
|
|
2018-12-28 19:37:33 +01:00
|
|
|
bool loopTaskWDTEnabled;
|
|
|
|
|
2016-10-06 13:21:30 +02:00
|
|
|
void loopTask(void *pvParameters)
|
|
|
|
{
|
2016-12-12 01:12:13 +01:00
|
|
|
setup();
|
2016-10-06 13:21:30 +02:00
|
|
|
for(;;) {
|
2018-12-28 19:37:33 +01:00
|
|
|
if(loopTaskWDTEnabled){
|
|
|
|
esp_task_wdt_reset();
|
|
|
|
}
|
2016-10-06 13:21:30 +02:00
|
|
|
loop();
|
2019-10-04 11:49:39 +02:00
|
|
|
if (serialEventRun) serialEventRun();
|
2016-10-06 13:21:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" void app_main()
|
|
|
|
{
|
2018-12-28 19:37:33 +01:00
|
|
|
loopTaskWDTEnabled = false;
|
2016-11-18 14:07:25 +01:00
|
|
|
initArduino();
|
2020-12-02 10:52:04 +01:00
|
|
|
xTaskCreateUniversal(loopTask, "loopTask", CONFIG_ARDUINO_LOOP_STACK_SIZE, NULL, 1, &loopTaskHandle, CONFIG_ARDUINO_RUNNING_CORE);
|
2016-10-06 13:21:30 +02:00
|
|
|
}
|
|
|
|
|
2016-11-18 14:07:25 +01:00
|
|
|
#endif
|