From 8b2074e068b661fcc91ba7d70fe239a4b08fa0e5 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Fri, 14 Apr 2023 23:59:34 -0400 Subject: [PATCH] stm32: Fix usbotg irq wakeup notification The DAINTMSK prevents irqs but does not prevent the status reporting in the GINTSTS and DAINT fields. Thus, the mask bits should be checked prior to sending a wakeup notification. Signed-off-by: Kevin O'Connor --- src/stm32/usbotg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/stm32/usbotg.c b/src/stm32/usbotg.c index b61c99ca..74829256 100644 --- a/src/stm32/usbotg.c +++ b/src/stm32/usbotg.c @@ -397,11 +397,11 @@ OTG_FS_IRQHandler(void) } if (sts & USB_OTG_GINTSTS_IEPINT) { // Can transmit data - disable irq and notify endpoint - uint32_t daint = OTGD->DAINT; - OTGD->DAINTMSK &= ~daint; - if (daint & (1 << 0)) + uint32_t daint = OTGD->DAINT, msk = OTGD->DAINTMSK, pend = daint & msk; + OTGD->DAINTMSK = msk & ~daint; + if (pend & (1 << 0)) usb_notify_ep0(); - if (daint & (1 << USB_CDC_EP_BULK_IN)) + if (pend & (1 << USB_CDC_EP_BULK_IN)) usb_notify_bulk_in(); } }