Skip to content

Commit 9911bd0

Browse files
jfischer-nokartben
authored andcommitted
samples: hci_uart: fix UART IRQ API usage
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]>
1 parent 8f44b86 commit 9911bd0

File tree

1 file changed

+11
-9
lines changed
  • samples/bluetooth/hci_uart/src

1 file changed

+11
-9
lines changed

samples/bluetooth/hci_uart/src/main.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,19 @@ static void bt_uart_isr(const struct device *unused, void *user_data)
232232
ARG_UNUSED(unused);
233233
ARG_UNUSED(user_data);
234234

235-
if (!(uart_irq_rx_ready(hci_uart_dev) ||
236-
uart_irq_tx_ready(hci_uart_dev))) {
237-
LOG_DBG("spurious interrupt");
238-
}
235+
while (uart_irq_update(hci_uart_dev) && uart_irq_is_pending(hci_uart_dev)) {
236+
if (!(uart_irq_rx_ready(hci_uart_dev) ||
237+
uart_irq_tx_ready(hci_uart_dev))) {
238+
LOG_DBG("spurious interrupt");
239+
}
239240

240-
if (uart_irq_tx_ready(hci_uart_dev)) {
241-
tx_isr();
242-
}
241+
if (uart_irq_tx_ready(hci_uart_dev)) {
242+
tx_isr();
243+
}
243244

244-
if (uart_irq_rx_ready(hci_uart_dev)) {
245-
rx_isr();
245+
if (uart_irq_rx_ready(hci_uart_dev)) {
246+
rx_isr();
247+
}
246248
}
247249
}
248250

0 commit comments

Comments
 (0)