| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 | #include "freertos/FreeRTOS.h"#include "freertos/task.h"#include "esp_task_wdt.h"#include "Arduino.h"#if (ARDUINO_USB_CDC_ON_BOOT|ARDUINO_USB_MSC_ON_BOOT|ARDUINO_USB_DFU_ON_BOOT) && !ARDUINO_USB_MODE#include "USB.h"#if ARDUINO_USB_MSC_ON_BOOT#include "FirmwareMSC.h"#endif#endif#ifndef ARDUINO_LOOP_STACK_SIZE#ifndef CONFIG_ARDUINO_LOOP_STACK_SIZE#define ARDUINO_LOOP_STACK_SIZE 8192#else#define ARDUINO_LOOP_STACK_SIZE CONFIG_ARDUINO_LOOP_STACK_SIZE#endif#endifTaskHandle_t loopTaskHandle = NULL;#if CONFIG_AUTOSTART_ARDUINO#if CONFIG_FREERTOS_UNICOREvoid yieldIfNecessary(void){    static uint64_t lastYield = 0;    uint64_t now = millis();    if((now - lastYield) > 2000) {        lastYield = now;        vTaskDelay(5); //delay 1 RTOS tick    }}#endifbool loopTaskWDTEnabled;__attribute__((weak)) size_t getArduinoLoopTaskStackSize(void) {    return ARDUINO_LOOP_STACK_SIZE;}void loopTask(void *pvParameters){    setup();    for(;;) {#if CONFIG_FREERTOS_UNICORE        yieldIfNecessary();#endif        if(loopTaskWDTEnabled){            esp_task_wdt_reset();        }        loop();        if (serialEventRun) serialEventRun();    }}extern void setup_usb_ids();extern "C" void app_main(){    setup_usb_ids();		/* Local addition */#if ARDUINO_USB_CDC_ON_BOOT && !ARDUINO_USB_MODE    Serial.begin();#endif#if ARDUINO_USB_MSC_ON_BOOT && !ARDUINO_USB_MODE    MSC_Update.begin();#endif#if ARDUINO_USB_DFU_ON_BOOT && !ARDUINO_USB_MODE    USB.enableDFU();#endif#if ARDUINO_USB_ON_BOOT && !ARDUINO_USB_MODE    USB.begin();#endif    loopTaskWDTEnabled = false;    initArduino();    xTaskCreateUniversal(loopTask, "loopTask", getArduinoLoopTaskStackSize(), NULL, 1, &loopTaskHandle, ARDUINO_RUNNING_CORE);}#endif
 |