Skip to content

Commit 5ef3a18

Browse files
committed
drivers: serial: nrf_sw_lpuart: Fix case of flushing RX FIFO
In Bluetooth HCI there is a case where uart_fifo_read is called not from the UART interrupt context. If that happens and there is pending UART data then LPUART was not able to reset the receiver as it remained in the blocked state. Case like that happens when HCI device sends data to the host core after host core got reset but before HCI device is reset by the host. Calling uart_fifo_read not from UART interrupt handler is a violation of the API but it has been used like that to drain UART FIFO for years and it has been useful so LPUART adapts to it. Case is fixed by triggering the UART interrupt if receiver is in blocked state. Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
1 parent dd805e7 commit 5ef3a18

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/serial/uart_nrf_sw_lpuart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ static void api_irq_rx_enable(const struct device *dev)
992992
struct lpuart_data *data = get_dev_data(dev);
993993

994994
data->int_driven.rx_enabled = true;
995-
if (int_driven_rd_available(data)) {
995+
if (int_driven_rd_available(data) || data->rx_state == RX_BLOCKED) {
996996
/* We need to move to the interrupt context of the same priority as UARTE. */
997997
k_timer_start(&data->int_driven.trampoline_timer, K_NO_WAIT, K_NO_WAIT);
998998
}

0 commit comments

Comments
 (0)