From c2b3f2d6afc1911db1974a324782730dd642d524 Mon Sep 17 00:00:00 2001 From: "Dirk O. Kaar" <19971886+dok-net@users.noreply.github.com> Date: Fri, 4 Oct 2019 11:49:39 +0200 Subject: [PATCH] Make yield() overridable (#2991) --- cores/esp32/HardwareSerial.h | 4 +++- cores/esp32/esp32-hal-misc.c | 4 +++- cores/esp32/main.cpp | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cores/esp32/HardwareSerial.h b/cores/esp32/HardwareSerial.h index 89eacf85..5f886650 100644 --- a/cores/esp32/HardwareSerial.h +++ b/cores/esp32/HardwareSerial.h @@ -97,10 +97,12 @@ protected: uart_t* _uart; }; +extern void serialEventRun(void) __attribute__((weak)); + #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL) extern HardwareSerial Serial; extern HardwareSerial Serial1; extern HardwareSerial Serial2; #endif -#endif +#endif // HardwareSerial_h diff --git a/cores/esp32/esp32-hal-misc.c b/cores/esp32/esp32-hal-misc.c index ae06edc3..be08e4b7 100644 --- a/cores/esp32/esp32-hal-misc.c +++ b/cores/esp32/esp32-hal-misc.c @@ -44,11 +44,13 @@ float temperatureRead() return (temprature_sens_read() - 32) / 1.8; } -void yield() +void __yield() { vPortYield(); } +void yield() __attribute__ ((weak, alias("__yield"))); + #if CONFIG_AUTOSTART_ARDUINO extern TaskHandle_t loopTaskHandle; diff --git a/cores/esp32/main.cpp b/cores/esp32/main.cpp index 3a455c8a..41f1985b 100644 --- a/cores/esp32/main.cpp +++ b/cores/esp32/main.cpp @@ -17,6 +17,7 @@ void loopTask(void *pvParameters) esp_task_wdt_reset(); } loop(); + if (serialEventRun) serialEventRun(); } }