mirror of
https://github.com/espressif/arduino-esp32
synced 2024-09-21 18:38:17 +00:00
7d26b070d7
* [pin_remap 1/3] platform: define ARDUINO_CORE_BUILD when building core files * [pin_remap 2/3] core,libs: add pin remap hooks * platform: remove previous build options if file is missing "touch" would create the file if not present, but not delete its contents if a previous run left the file in the build dir. * platform: make debug_custom.json file customizable by board * platform: fix default debug prefix "debug.toolchain.prefix" must end with a dash, since only the tool name is appended to this string. The reason this is not a major issue is that the "debug_custom.json" file (copied in the sketch directory when debugging is enabled) forces its own prefix. And to make things more interesting, the "toolchainPrefix" entry in that file should _not_ end with a dash. * [pin_remap 3/3]: add Arduino Nano ESP32 board * fix: periman: include it by default, add include guard * fix: io_pin_remap: adjust for new perimap APIs * fix: libraries: manually handled pin remapping files Previously all libraries invoked either high-level APIs (transparently remapped, like the user sketch) or low-level ESP-IDF calls (where the remap to GPIO numbers had to be added manually). Since 3.x, some of these are mixed (for example, periman* APIs are remapped, while soc* are not). This must be handled by disabling the automatic API remapping and making sure all calls use GPIO numbers. * feat: show remapped pins in chip debug reports --------- Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com>
99 lines
2.4 KiB
C++
99 lines
2.4 KiB
C++
#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
|
|
|
|
#include "chip-debug-report.h"
|
|
|
|
#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
|
|
#endif
|
|
|
|
TaskHandle_t loopTaskHandle = NULL;
|
|
|
|
#if CONFIG_AUTOSTART_ARDUINO
|
|
#if CONFIG_FREERTOS_UNICORE
|
|
void yieldIfNecessary(void){
|
|
static uint64_t lastYield = 0;
|
|
uint64_t now = millis();
|
|
if((now - lastYield) > 2000) {
|
|
lastYield = now;
|
|
vTaskDelay(5); //delay 1 RTOS tick
|
|
}
|
|
}
|
|
#endif
|
|
|
|
bool loopTaskWDTEnabled;
|
|
|
|
__attribute__((weak)) size_t getArduinoLoopTaskStackSize(void) {
|
|
return ARDUINO_LOOP_STACK_SIZE;
|
|
}
|
|
|
|
__attribute__((weak)) bool shouldPrintChipDebugReport(void) {
|
|
return false;
|
|
}
|
|
|
|
void loopTask(void *pvParameters)
|
|
{
|
|
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
|
|
// sets UART0 (default console) RX/TX pins as already configured in boot or as defined in variants/pins_arduino.h
|
|
Serial0.setPins(gpioNumberToDigitalPin(SOC_RX0), gpioNumberToDigitalPin(SOC_TX0));
|
|
#endif
|
|
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
|
|
printBeforeSetupInfo();
|
|
#else
|
|
if(shouldPrintChipDebugReport()){
|
|
printBeforeSetupInfo();
|
|
}
|
|
#endif
|
|
setup();
|
|
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
|
|
printAfterSetupInfo();
|
|
#else
|
|
if(shouldPrintChipDebugReport()){
|
|
printAfterSetupInfo();
|
|
}
|
|
#endif
|
|
for(;;) {
|
|
#if CONFIG_FREERTOS_UNICORE
|
|
yieldIfNecessary();
|
|
#endif
|
|
if(loopTaskWDTEnabled){
|
|
esp_task_wdt_reset();
|
|
}
|
|
loop();
|
|
if (serialEventRun) serialEventRun();
|
|
}
|
|
}
|
|
|
|
extern "C" void app_main()
|
|
{
|
|
#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
|