Skip to content

Commit

Permalink
samples: hci_uart: fix UART IRQ API usage
Browse files Browse the repository at this point in the history
uart_irq_update() should always be called in IRQ processing callback.
From API documentation:
"This function should be called the first thing in the ISR. Calling
uart_irq_rx_ready(), uart_irq_tx_ready(), uart_irq_tx_complete()
allowed only after this."

Signed-off-by: Johann Fischer <[email protected]>
  • Loading branch information
jfischer-no authored and kartben committed Dec 12, 2024
1 parent 8f44b86 commit 9911bd0
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions samples/bluetooth/hci_uart/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,17 +232,19 @@ static void bt_uart_isr(const struct device *unused, void *user_data)
ARG_UNUSED(unused);
ARG_UNUSED(user_data);

if (!(uart_irq_rx_ready(hci_uart_dev) ||
uart_irq_tx_ready(hci_uart_dev))) {
LOG_DBG("spurious interrupt");
}
while (uart_irq_update(hci_uart_dev) && uart_irq_is_pending(hci_uart_dev)) {
if (!(uart_irq_rx_ready(hci_uart_dev) ||
uart_irq_tx_ready(hci_uart_dev))) {
LOG_DBG("spurious interrupt");
}

if (uart_irq_tx_ready(hci_uart_dev)) {
tx_isr();
}
if (uart_irq_tx_ready(hci_uart_dev)) {
tx_isr();
}

if (uart_irq_rx_ready(hci_uart_dev)) {
rx_isr();
if (uart_irq_rx_ready(hci_uart_dev)) {
rx_isr();
}
}
}

Expand Down

0 comments on commit 9911bd0

Please sign in to comment.