This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit fc05091e18f1e2492e8dc7683f2dd68b80ba0e91
Author: jsanchez-2g <[email protected]>
AuthorDate: Tue Aug 18 16:12:37 2026 -0500

    arm/stm32: Enable and acknowledge USB error interrupts on M0 parts.
    
    The initial interrupt mask enabled only reset, suspend and correct
    transfer.  Error conditions reported by the controller, USB_ISTR_ERR and
    USB_ISTR_PMAOVRN, were neither enabled nor acknowledged.
    
    Because the status bits are never cleared, an error condition latched in
    USB_ISTR remains set and is re-evaluated on every subsequent interrupt,
    which makes the reported status misleading when debugging transfer
    problems.
    
    Add ERRM and PMAOVRN to the initial mask and clear the corresponding
    status bits when they are seen.
    
    Assisted-by: GitHub Copilot:claude-opus-5
    Signed-off-by: jsanchez-2g <[email protected]>
---
 arch/arm/src/common/stm32/stm32_usbdev_m0_v1.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/arm/src/common/stm32/stm32_usbdev_m0_v1.c 
b/arch/arm/src/common/stm32/stm32_usbdev_m0_v1.c
index a63f5b9c06f..ef5c19aa9ce 100644
--- a/arch/arm/src/common/stm32/stm32_usbdev_m0_v1.c
+++ b/arch/arm/src/common/stm32/stm32_usbdev_m0_v1.c
@@ -81,7 +81,8 @@
 
 /* Initial interrupt mask: Reset + Suspend + Correct Transfer */
 
-#define STM32_CNTR_SETUP     (USB_CNTR_RESETM|USB_CNTR_SUSPM|USB_CNTR_CTRM)
+#define STM32_CNTR_SETUP     (USB_CNTR_RESETM|USB_CNTR_SUSPM|USB_CNTR_ERRM|\
+                              USB_CNTR_PMAOVRN|USB_CNTR_CTRM)
 
 /* Endpoint identifiers. The STM32 supports up to 16 mono-directional or 8
  * bidirectional endpoints.  However, when you take into account PMA buffer
@@ -2424,6 +2425,13 @@ static int stm32_usb_interrupt(int irq, void *context, 
void *arg)
       goto exit_interrupt;
     }
 
+  if ((istr & (USB_ISTR_ERR | USB_ISTR_PMAOVRN)) != 0)
+    {
+      uint16_t errors = istr & (USB_ISTR_ERR | USB_ISTR_PMAOVRN);
+
+      stm32_putreg((uint16_t)~errors, STM32_USB_ISTR);
+    }
+
   /* Handle Wakeup interrupts.
    * This interrupt is only enable while the USB is suspended.
    */

Reply via email to