diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index b4442f75..d80271a2 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -558,3 +558,10 @@ uartDetectBaudrate(uart_t *uart) return default_rates[i]; } + +/* + * Returns the status of the RX state machine, if the value is non-zero the state machine is active. + */ +bool uartRxActive(uart_t* uart) { + return uart->dev->status.st_urx_out != 0; +} diff --git a/cores/esp32/esp32-hal-uart.h b/cores/esp32/esp32-hal-uart.h index 3a317324..9874866b 100644 --- a/cores/esp32/esp32-hal-uart.h +++ b/cores/esp32/esp32-hal-uart.h @@ -74,6 +74,8 @@ int uartGetDebug(); unsigned long uartDetectBaudrate(uart_t *uart); +bool uartRxActive(uart_t* uart); + #ifdef __cplusplus } #endif