drivers: uart_imx: Fix the poll_in function
Current poll_in function implementation blocks when there is no data available. The Zephyr documentation for poll_in expects the function to return -1 when no data is available. Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
This commit is contained in:
parent
a8c7f82510
commit
70dbf7e695
|
@ -113,16 +113,18 @@ static void uart_imx_poll_out(const struct device *dev, unsigned char c)
|
|||
static int uart_imx_poll_in(const struct device *dev, unsigned char *c)
|
||||
{
|
||||
UART_Type *uart = UART_STRUCT(dev);
|
||||
int ret = -1;
|
||||
|
||||
while (!UART_GetStatusFlag(uart, uartStatusRxDataReady)) {
|
||||
}
|
||||
*c = UART_Getchar(uart);
|
||||
if (UART_GetStatusFlag(uart, uartStatusRxDataReady)) {
|
||||
*c = UART_Getchar(uart);
|
||||
|
||||
if (UART_GetStatusFlag(uart, uartStatusRxOverrun)) {
|
||||
UART_ClearStatusFlag(uart, uartStatusRxOverrun);
|
||||
if (UART_GetStatusFlag(uart, uartStatusRxOverrun)) {
|
||||
UART_ClearStatusFlag(uart, uartStatusRxOverrun);
|
||||
}
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
|
|
Loading…
Reference in a new issue