From fadae0bf393ce45416b6c75e5d3506f90cba88e9 Mon Sep 17 00:00:00 2001 From: Dong Heng Date: Mon, 4 Jan 2021 10:55:50 +0800 Subject: [PATCH] xtensa/esp32: Fix ESP32 serial UART tx ready check error --- arch/xtensa/src/esp32/esp32_serial.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/xtensa/src/esp32/esp32_serial.c b/arch/xtensa/src/esp32/esp32_serial.c index ddaa6ec69d..80b0acc3cc 100644 --- a/arch/xtensa/src/esp32/esp32_serial.c +++ b/arch/xtensa/src/esp32/esp32_serial.c @@ -1154,10 +1154,13 @@ static void esp32_txint(struct uart_dev_s *dev, bool enable) static bool esp32_txready(struct uart_dev_s *dev) { + uint32_t txcnt; struct esp32_dev_s *priv = (struct esp32_dev_s *)dev->priv; - return ((esp32_serialin(priv, UART_STATUS_OFFSET) & UART_TXFIFO_CNT_M) < - 0x7f); + txcnt = (esp32_serialin(priv, UART_STATUS_OFFSET) >> UART_TXFIFO_CNT_S) & + UART_TXFIFO_CNT_V; + + return txcnt < 0x7f; } /****************************************************************************