50 lines
1.3 KiB
C++
50 lines
1.3 KiB
C++
// Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
#include "esp_task_wdt.h"
|
|
#include "Arduino.h"
|
|
|
|
#ifndef CONFIG_ARDUINO_LOOP_STACK_SIZE
|
|
#define CONFIG_ARDUINO_LOOP_STACK_SIZE 8192
|
|
#endif
|
|
|
|
TaskHandle_t loopTaskHandle = NULL;
|
|
|
|
#if CONFIG_AUTOSTART_ARDUINO
|
|
|
|
bool loopTaskWDTEnabled;
|
|
|
|
void loopTask(void *pvParameters)
|
|
{
|
|
setup();
|
|
for(;;) {
|
|
if(loopTaskWDTEnabled){
|
|
esp_task_wdt_reset();
|
|
}
|
|
loop();
|
|
if (serialEventRun) serialEventRun();
|
|
}
|
|
}
|
|
|
|
extern "C" void app_main()
|
|
{
|
|
loopTaskWDTEnabled = false;
|
|
initArduino();
|
|
xTaskCreateUniversal(loopTask, "loopTask", CONFIG_ARDUINO_LOOP_STACK_SIZE, NULL, 1, &loopTaskHandle, CONFIG_ARDUINO_RUNNING_CORE);
|
|
}
|
|
|
|
#endif
|