drivers: uart_xmc4xxx: Check that receive buffers have data in poll_in

As per XMCLib documentation we need to check that data has been received
before reading the buffers.

Fixes test_uart_poll_in test in tests/drivers/uart/uart_basic_api.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
This commit is contained in:
Andriy Gelman 2022-05-15 14:49:22 -04:00 committed by Carles Cufí
commit aa91500aee

View file

@ -23,6 +23,10 @@ static int uart_xmc4xxx_poll_in(const struct device *dev, unsigned char *c)
{
const struct uart_xmc4xx_config *config = dev->config;
if (!XMC_USIC_CH_GetReceiveBufferStatus(config->uart)) {
return -1;
}
*c = (unsigned char)XMC_UART_CH_GetReceivedData(config->uart);
return 0;