This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 27b3f870477a7912ac6431b7a330d30985e1b47d Author: Brijesh Thakkar <[email protected]> AuthorDate: Tue Oct 20 18:16:35 2026 +0530 drivers/serial/uart_16550: Add u16550_rxpoll() Add a helper that checks the Data Ready bit of the Line Status Register and, if it is set, passes the received data to the upper half with uart_recvchars(). A board that uses a UART without an interrupt can call it from a thread or a timer instead of reading the LSR with a hard coded address and having to know how the driver is structured. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Brijesh Thakkar <[email protected]> --- drivers/serial/uart_16550.c | 23 +++++++++++++++++++++++ include/nuttx/serial/uart_16550.h | 12 ++++++++++++ 2 files changed, 35 insertions(+) diff --git a/drivers/serial/uart_16550.c b/drivers/serial/uart_16550.c index ea2000a760d..00649ed029b 100644 --- a/drivers/serial/uart_16550.c +++ b/drivers/serial/uart_16550.c @@ -1925,4 +1925,27 @@ void u16550_putc(FAR struct u16550_s *priv, int ch) u16550_serialout(priv, UART_THR_OFFSET, (uart_datawidth_t)ch); } +/**************************************************************************** + * Name: u16550_rxpoll + * + * Description: + * Poll the UART for received data. If the Data Ready bit is set in the + * Line Status Register, pass the received characters to the upper half + * with uart_recvchars(), exactly as the RX interrupt would do. + * + ****************************************************************************/ + +void u16550_rxpoll(FAR uart_dev_t *dev) +{ + FAR struct u16550_s *priv; + + DEBUGASSERT(dev != NULL && dev->priv != NULL); + priv = (FAR struct u16550_s *)dev->priv; + + if ((u16550_serialin(priv, UART_LSR_OFFSET) & UART_LSR_DR) != 0) + { + uart_recvchars(dev); + } +} + #endif /* CONFIG_16550_UART */ diff --git a/include/nuttx/serial/uart_16550.h b/include/nuttx/serial/uart_16550.h index b58f8e6a8fd..8b05d158d83 100644 --- a/include/nuttx/serial/uart_16550.h +++ b/include/nuttx/serial/uart_16550.h @@ -457,6 +457,18 @@ int u16550_interrupt(int irq, FAR void *context, FAR void *arg); void u16550_putc(FAR struct u16550_s *priv, int ch); +/**************************************************************************** + * Name: u16550_rxpoll + * + * Description: + * Poll the UART for received data and pass it to the upper half, like the + * RX interrupt does. Intended for a UART without an interrupt (see + * struct u16550_s::irq). Call it periodically from a thread or a timer. + * + ****************************************************************************/ + +void u16550_rxpoll(FAR uart_dev_t *dev); + /**************************************************************************** * Name: uart_getreg(), uart_putreg(), uart_ioctl() *
