From 2610c11a3d786779b678a83b8f1d561e03db3369 Mon Sep 17 00:00:00 2001 From: "S.J.R. van Schaik" Date: Tue, 18 Jul 2017 15:29:50 +0200 Subject: [PATCH] stm32f0: usart: simplify while loop in interrupt handler --- source/drivers/usart_console.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/source/drivers/usart_console.c b/source/drivers/usart_console.c index 57f5deb..51c4458 100644 --- a/source/drivers/usart_console.c +++ b/source/drivers/usart_console.c @@ -33,12 +33,7 @@ static void usart_isr(struct usart_console *console) if (!console) return; - do { - reg = USART_ISR(console->dev); - - if (!(reg & USART_ISR_RXNE)) - continue; - + while (usart_get_flag(console->dev, USART_ISR_RXNE)) { console->recv_buf[console->next] = usart_recv(console->dev); if (console->recv_buf[console->next] == '\003') @@ -48,7 +43,7 @@ static void usart_isr(struct usart_console *console) if (i != console->cur) console->next = i; - } while (usart_get_flag(console->dev, USART_ISR_RXNE)); + } } void usart1_isr(void)