Skip to content

Commit

Permalink
Put HardwareSerial interrupt callback code in IRAM (#1610)
Browse files Browse the repository at this point in the history
Reverted to regular static callback handler.
  • Loading branch information
mikee47 authored and slaff committed Feb 11, 2019
1 parent 81f5d10 commit 2e2fc56
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
17 changes: 9 additions & 8 deletions Sming/SmingCore/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ void HardwareSerial::callbackHandler(uint32_t status)
}
}

void HardwareSerial::staticCallbackHandler(uart_t* uart, uint32_t status)
{
auto serial = reinterpret_cast<HardwareSerial*>(uart_get_callback_param(uart));
if(serial) {
serial->callbackHandler(status);
}
}

bool HardwareSerial::updateUartCallback()
{
if(uart == nullptr) {
Expand All @@ -167,14 +175,7 @@ bool HardwareSerial::updateUartCallback()
#else
if(HWSDelegate || transmitComplete) {
#endif
setUartCallback(
[](uart_t* uart, uint32_t status) {
auto serial = reinterpret_cast<HardwareSerial*>(uart_get_callback_param(uart));
if(serial) {
serial->callbackHandler(status);
}
},
this);
setUartCallback(staticCallbackHandler, this);
return true;
} else {
setUartCallback(nullptr, nullptr);
Expand Down
3 changes: 2 additions & 1 deletion Sming/SmingCore/HardwareSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/**
Expand Down

0 comments on commit 2e2fc56

Please sign in to comment.