mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 17:19:09 -04:00
fix(uart): fix race condition with the use of UART_SELECT_READ_NOTIF
UART_SELECT_READ_NOTIF needs to be sent after received data got processed to avoid the potential race condition
This commit is contained in:
parent
d43f647f80
commit
f693485ad0
@ -1133,12 +1133,6 @@ static void UART_ISR_ATTR uart_rx_intr_handler_default(void *param)
|
||||
uart_event.type = UART_DATA;
|
||||
uart_event.size = rx_fifo_len;
|
||||
uart_event.timeout_flag = (uart_intr_status & UART_INTR_RXFIFO_TOUT) ? true : false;
|
||||
UART_ENTER_CRITICAL_ISR(&uart_selectlock);
|
||||
if (p_uart->uart_select_notif_callback) {
|
||||
p_uart->uart_select_notif_callback(uart_num, UART_SELECT_READ_NOTIF, &HPTaskAwoken);
|
||||
need_yield |= (HPTaskAwoken == pdTRUE);
|
||||
}
|
||||
UART_EXIT_CRITICAL_ISR(&uart_selectlock);
|
||||
}
|
||||
p_uart->rx_stash_len = rx_fifo_len;
|
||||
//If we fail to push data to ring buffer, we will have to stash the data, and send next time.
|
||||
@ -1187,6 +1181,15 @@ static void UART_ISR_ATTR uart_rx_intr_handler_default(void *param)
|
||||
p_uart->rx_buffered_len += p_uart->rx_stash_len;
|
||||
UART_EXIT_CRITICAL_ISR(&(uart_context[uart_num].spinlock));
|
||||
}
|
||||
|
||||
if (uart_event.type == UART_DATA) {
|
||||
UART_ENTER_CRITICAL_ISR(&uart_selectlock);
|
||||
if (p_uart->uart_select_notif_callback) {
|
||||
p_uart->uart_select_notif_callback(uart_num, UART_SELECT_READ_NOTIF, &HPTaskAwoken);
|
||||
need_yield |= (HPTaskAwoken == pdTRUE);
|
||||
}
|
||||
UART_EXIT_CRITICAL_ISR(&uart_selectlock);
|
||||
}
|
||||
} else {
|
||||
UART_ENTER_CRITICAL_ISR(&(uart_context[uart_num].spinlock));
|
||||
uart_hal_disable_intr_mask(&(uart_context[uart_num].hal), UART_INTR_RXFIFO_FULL | UART_INTR_RXFIFO_TOUT);
|
||||
|
Loading…
x
Reference in New Issue
Block a user