From f3c1a91f8e50f63e17bd4093f53e8fdcd3dfbe2f Mon Sep 17 00:00:00 2001 From: Mike Dunston Date: Sun, 3 Mar 2019 06:47:24 -0800 Subject: [PATCH] adding uartRxActive to expose the RX state machine status as a boolean value (#2457) --- 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 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