fix: possible endless loop in case some error flag is set but RXNE is not

Fixes #3482
This commit is contained in:
raphaelcoeffic
2023-04-28 13:05:31 +02:00
parent 438fd0bd73
commit 53f172bb07
@@ -557,15 +557,15 @@ void stm32_usart_isr(const stm32_usart_t* usart, etx_serial_callbacks_t* cb)
// Drain RX
while (status & (LL_USART_SR_RXNE | USART_FLAG_ERRORS)) {
// This will clear the RXNE/error bits in USART_SR register
uint8_t data = LL_USART_ReadReg(usart->USARTx, DR);
if (status & USART_FLAG_ERRORS) {
if (cb->on_error)
cb->on_error();
}
if (status & LL_USART_SR_RXNE) {
// This will clear the RXNE bit in USART_DR register
uint8_t data = LL_USART_ReadReg(usart->USARTx, DR);
if (cb->on_receive)
cb->on_receive(data);
}