From 5ca809f74db196cd2562bd1375a6ded87a524cfa Mon Sep 17 00:00:00 2001 From: Mike Dunston Date: Thu, 14 Feb 2019 06:48:59 -0800 Subject: [PATCH] adding uartRxActive to expose the RX state machine status as a boolean value --- cores/esp32/esp32-hal-uart.c | 7 +++++++ cores/esp32/esp32-hal-uart.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index b4442f756e2..d80271a2c11 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 3a317324f68..9874866bcf7 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