Skip to content

Commit 8f53407

Browse files
JordanYateskartben
authored andcommitted
serial: cmsdk_apb: fix irq_is_pending
Implement `irq_is_pending` in terms of the `irq_rx_ready` and `irq_tx_ready` function calls. Using `intstatus` directly results in an implementation that does not conform to the interrupt driven UART API. Since `intstatus` bits are only only set when a buffer transitions from full to empty, any calls to `irq_is_pending` before any bytes have been sent will return 0. This is problematic since the documented implementation for the API IRQ handler is: ``` while (uart_irq_update(dev) && uart_irq_is_pending(dev)) { if (uart_irq_rx_ready(dev)) { ... } if (uart_irq_tx_ready(dev)) { uart_fifo_fill(dev, ...); } } ``` If `uart_irq_is_pending` does not return 1 until the first byte is sent, we never end up pushing data to be transmitted into the `uart_fifo_full` function. Signed-off-by: Jordan Yates <[email protected]>
1 parent ba1ad38 commit 8f53407

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/serial/uart_cmsdk_apb.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,7 @@ static void uart_cmsdk_apb_irq_err_disable(const struct device *dev)
401401
*/
402402
static int uart_cmsdk_apb_irq_is_pending(const struct device *dev)
403403
{
404-
const struct uart_cmsdk_apb_config *dev_cfg = dev->config;
405-
406-
return (dev_cfg->uart->intstatus & (UART_RX_IN | UART_TX_IN));
404+
return uart_cmsdk_apb_irq_rx_ready(dev) || uart_cmsdk_apb_irq_tx_ready(dev);
407405
}
408406

409407
/**

0 commit comments

Comments
 (0)