Skip to content

Commit 77635ff

Browse files
HiFiPhileroma-jam
authored andcommitted
fix(dcd/dwc2): Fixed recurrent suspend ISR.
1 parent b2342be commit 77635ff

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/portable/synopsys/dwc2/dcd_dwc2.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
437437

438438

439439
// Enable required interrupts
440-
dwc2->gintmsk |= GINTMSK_OTGINT | GINTMSK_USBSUSPM | GINTMSK_USBRST | GINTMSK_ENUMDNEM | GINTMSK_WUIM;
440+
dwc2->gintmsk |= GINTMSK_OTGINT | GINTMSK_USBRST | GINTMSK_ENUMDNEM | GINTMSK_WUIM;
441441

442442
// TX FIFO empty level for interrupt is complete empty
443443
uint32_t gahbcfg = dwc2->gahbcfg;
@@ -1021,16 +1021,19 @@ void dcd_int_handler(uint8_t rhport) {
10211021
if (gintsts & GINTSTS_ENUMDNE) {
10221022
// ENUMDNE is the end of reset where speed of the link is detected
10231023
dwc2->gintsts = GINTSTS_ENUMDNE;
1024+
dwc2->gintmsk |= GINTMSK_USBSUSPM;
10241025
handle_enum_done(rhport);
10251026
}
10261027

10271028
if (gintsts & GINTSTS_USBSUSP) {
10281029
dwc2->gintsts = GINTSTS_USBSUSP;
1030+
dwc2->gintmsk &= ~GINTMSK_USBSUSPM;
10291031
dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true);
10301032
}
10311033

10321034
if (gintsts & GINTSTS_WKUINT) {
10331035
dwc2->gintsts = GINTSTS_WKUINT;
1036+
dwc2->gintmsk |= GINTMSK_USBSUSPM;
10341037
dcd_event_bus_signal(rhport, DCD_EVENT_RESUME, true);
10351038
}
10361039

@@ -1050,6 +1053,7 @@ void dcd_int_handler(uint8_t rhport) {
10501053

10511054
if(gintsts & GINTSTS_SOF) {
10521055
dwc2->gintsts = GINTSTS_SOF;
1056+
dwc2->gintmsk |= GINTMSK_USBSUSPM;
10531057
const uint32_t frame = (dwc2->dsts & DSTS_FNSOF) >> DSTS_FNSOF_Pos;
10541058

10551059
// Disable SOF interrupt if SOF was not explicitly enabled since SOF was used for remote wakeup detection

0 commit comments

Comments
 (0)