arduino-esp32/cores/esp32/main.cpp

32 lines
608 B
C++
Raw Normal View History

2016-10-06 13:21:30 +02:00
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_task_wdt.h"
#include "Arduino.h"
2016-10-06 13:21:30 +02:00
TaskHandle_t loopTaskHandle = NULL;
#if CONFIG_AUTOSTART_ARDUINO
2016-10-06 13:21:30 +02:00
bool loopTaskWDTEnabled;
2016-10-06 13:21:30 +02:00
void loopTask(void *pvParameters)
{
setup();
2016-10-06 13:21:30 +02:00
for(;;) {
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()
{
loopTaskWDTEnabled = false;
initArduino();
xTaskCreateUniversal(loopTask, "loopTask", 8192, NULL, 1, &loopTaskHandle, CONFIG_ARDUINO_RUNNING_CORE);
2016-10-06 13:21:30 +02:00
}
#endif