From 8c603c24cd4650b541b596103ca58cc84e8b95e6 Mon Sep 17 00:00:00 2001 From: Song Ruo Jing Date: Sat, 7 Oct 2023 12:59:01 +0800 Subject: [PATCH] fix(uart): re-initialize uart_event fields to some certain values for every loop Although uart_event.size and uart_event.timeout_flags fields are meaningless to events other than UART_DATA, fix the values to 0 could help reduce confusion. Closes https://github.com/espressif/esp-idf/issues/12299 --- components/esp_driver_uart/src/uart.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/esp_driver_uart/src/uart.c b/components/esp_driver_uart/src/uart.c index 98a0b912e6..5765800dae 100644 --- a/components/esp_driver_uart/src/uart.c +++ b/components/esp_driver_uart/src/uart.c @@ -908,7 +908,6 @@ static void UART_ISR_ATTR uart_rx_intr_handler_default(void *param) uint8_t uart_num = p_uart->uart_num; int rx_fifo_len = 0; uint32_t uart_intr_status = 0; - uart_event_t uart_event; BaseType_t HPTaskAwoken = 0; bool need_yield = false; static uint8_t pat_flg = 0; @@ -921,7 +920,9 @@ static void UART_ISR_ATTR uart_rx_intr_handler_default(void *param) if (uart_intr_status == 0) { break; } - uart_event.type = UART_EVENT_MAX; + uart_event_t uart_event = { + .type = UART_EVENT_MAX, + }; if (uart_intr_status & UART_INTR_TXFIFO_EMPTY) { UART_ENTER_CRITICAL_ISR(&(uart_context[uart_num].spinlock)); uart_hal_disable_intr_mask(&(uart_context[uart_num].hal), UART_INTR_TXFIFO_EMPTY);