Skip to content

Commit 2b0d5f7

Browse files
committed
dcd/dwc2: fix suspend interrupt indefinitely disabled on AT32F405
1 parent ac37176 commit 2b0d5f7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/portable/synopsys/dwc2/dcd_dwc2.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,8 @@ static void handle_ep_irq(uint8_t rhport, uint8_t dir) {
10251025
}
10261026
}
10271027

1028+
extern bool tud_connected(void);
1029+
10281030
/* Interrupt Hierarchy
10291031
DIEPINT DIEPINT
10301032
\ /
@@ -1060,8 +1062,12 @@ void dcd_int_handler(uint8_t rhport) {
10601062

10611063
if (gintsts & GINTSTS_USBSUSP) {
10621064
dwc2->gintsts = GINTSTS_USBSUSP;
1063-
dwc2->gintmsk &= ~GINTMSK_USBSUSPM;
1064-
dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true);
1065+
// Some MCUs such as AT32F405 receives SUSPEND event before the device is
1066+
// connected. We should skip handling the event if not currently connected.
1067+
if (tud_connected()) {
1068+
dwc2->gintmsk &= ~GINTMSK_USBSUSPM;
1069+
dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true);
1070+
}
10651071
}
10661072

10671073
if (gintsts & GINTSTS_WKUINT) {

0 commit comments

Comments
 (0)