drivers: uart: fix esp32 TX checks

This fixes both TX ready and completed uart
calls to meet valid condition.

Closes #41526
Closes #41624

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
This commit is contained in:
Sylvio Alves 2022-01-10 11:47:51 -03:00 committed by Anas Nashif
commit 40ad264a47

View file

@ -391,7 +391,8 @@ static void uart_esp32_irq_tx_disable(const struct device *dev)
static int uart_esp32_irq_tx_ready(const struct device *dev)
{
return (uart_hal_get_txfifo_len(&DEV_CFG(dev)->hal) > 0);
return (uart_hal_get_txfifo_len(&DEV_CFG(dev)->hal) > 0 &&
uart_hal_get_intr_ena_status(&DEV_CFG(dev)->hal) & UART_INTR_TXFIFO_EMPTY);
}
static void uart_esp32_irq_rx_enable(const struct device *dev)
@ -410,8 +411,7 @@ static void uart_esp32_irq_rx_disable(const struct device *dev)
static int uart_esp32_irq_tx_complete(const struct device *dev)
{
/* check if TX FIFO is empty */
return (uart_hal_get_txfifo_len(&DEV_CFG(dev)->hal) == UART_LL_FIFO_DEF_LEN ? 1 : 0);
return uart_hal_is_tx_idle(&DEV_CFG(dev)->hal);
}
static int uart_esp32_irq_rx_ready(const struct device *dev)