From 5a969b91a89ac9f0c5e1d6b8e7360fee3e1c0105 Mon Sep 17 00:00:00 2001 From: Song Ruo Jing Date: Thu, 22 Sep 2022 14:21:01 +0800 Subject: [PATCH] uart: Fix unwanted processing of TX_DONE interrupt immediately after calling uart_wait_tx_done() In previous transmission(s), the TX_DONE interrupt raw bit may be raised, but never been cleared. TX_DONE interrrupt status bit should be cleared before enabling it to check the new transmission. Introduced in 4e09d147b11ed8a094b5858642c9f60d658ef656 --- components/driver/uart.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/driver/uart.c b/components/driver/uart.c index 2046cfa33b..57a27e0e50 100644 --- a/components/driver/uart.c +++ b/components/driver/uart.c @@ -1146,6 +1146,9 @@ esp_err_t uart_wait_tx_done(uart_port_t uart_num, TickType_t ticks_to_wait) xSemaphoreGive(p_uart_obj[uart_num]->tx_mux); return ESP_OK; } + if (!UART_IS_MODE_SET(uart_num, UART_MODE_RS485_HALF_DUPLEX)) { + uart_hal_clr_intsts_mask(&(uart_context[uart_num].hal), UART_INTR_TX_DONE); + } UART_ENTER_CRITICAL(&(uart_context[uart_num].spinlock)); uart_hal_ena_intr_mask(&(uart_context[uart_num].hal), UART_INTR_TX_DONE); UART_EXIT_CRITICAL(&(uart_context[uart_num].spinlock));