arduino-esp32/cores/esp32/main.cpp

50 lines
1.3 KiB
C++
Raw Normal View History

2021-02-18 11:14:35 +01:00
// 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.
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
#ifndef CONFIG_ARDUINO_LOOP_STACK_SIZE
#define CONFIG_ARDUINO_LOOP_STACK_SIZE 8192
#endif
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", CONFIG_ARDUINO_LOOP_STACK_SIZE, NULL, 1, &loopTaskHandle, CONFIG_ARDUINO_RUNNING_CORE);
2016-10-06 13:21:30 +02:00
}
#endif