From 7f1a560288a09ffc559f8571e3568b3cc10b28d2 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Tue, 11 May 2021 11:21:27 +0200 Subject: [PATCH] stm32/usbuart: Clear USART_ICR if provided. Otherwise endless interrupts happened. --- src/platforms/stm32/usbuart.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/platforms/stm32/usbuart.c b/src/platforms/stm32/usbuart.c index 4775e1d3..8c04db7b 100644 --- a/src/platforms/stm32/usbuart.c +++ b/src/platforms/stm32/usbuart.c @@ -399,8 +399,15 @@ void USBUSART_ISR(void) usart_recv(USBUSART); /* If line is now idle, then transmit a packet */ - if (isIdle) + if (isIdle) { +#if defined(USART_ICR) + USART_ICR(USBUSART) = USART_ICR_IDLECF; +#else + /* On the older uarts, the sequence "read flags", "read DR" + * as above cleared the flags */ +#endif usbuart_run(); + } nvic_enable_irq(USBUSART_DMA_RX_IRQ); }