From 2e2fc563e2b6598e7887b867878022aa2965e1e5 Mon Sep 17 00:00:00 2001 From: Mike Date: Mon, 11 Feb 2019 10:50:42 +0000 Subject: [PATCH] Put `HardwareSerial` interrupt callback code in IRAM (#1610) Reverted to regular static callback handler. --- Sming/SmingCore/HardwareSerial.cpp | 17 +++++++++-------- Sming/SmingCore/HardwareSerial.h | 3 ++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Sming/SmingCore/HardwareSerial.cpp b/Sming/SmingCore/HardwareSerial.cpp index a217703ea2..28e113dd36 100644 --- a/Sming/SmingCore/HardwareSerial.cpp +++ b/Sming/SmingCore/HardwareSerial.cpp @@ -156,6 +156,14 @@ void HardwareSerial::callbackHandler(uint32_t status) } } +void HardwareSerial::staticCallbackHandler(uart_t* uart, uint32_t status) +{ + auto serial = reinterpret_cast(uart_get_callback_param(uart)); + if(serial) { + serial->callbackHandler(status); + } +} + bool HardwareSerial::updateUartCallback() { if(uart == nullptr) { @@ -167,14 +175,7 @@ bool HardwareSerial::updateUartCallback() #else if(HWSDelegate || transmitComplete) { #endif - setUartCallback( - [](uart_t* uart, uint32_t status) { - auto serial = reinterpret_cast(uart_get_callback_param(uart)); - if(serial) { - serial->callbackHandler(status); - } - }, - this); + setUartCallback(staticCallbackHandler, this); return true; } else { setUartCallback(nullptr, nullptr); diff --git a/Sming/SmingCore/HardwareSerial.h b/Sming/SmingCore/HardwareSerial.h index 5767e44e60..14093306dc 100644 --- a/Sming/SmingCore/HardwareSerial.h +++ b/Sming/SmingCore/HardwareSerial.h @@ -419,10 +419,11 @@ class HardwareSerial : public Stream size_t rxSize = DEFAULT_RX_BUFFER_SIZE; /** - * @brief Interrupt handler for UART0 receive events + * @brief Serial interrupt handler, called by serial driver * @param uart_t* pointer to UART object * @param status UART status flags indicating cause(s) of interrupt */ + static void IRAM_ATTR staticCallbackHandler(uart_t* uart, uint32_t status); void IRAM_ATTR callbackHandler(uint32_t status); /**