Skip to content

Commit 594b7a4

Browse files
committed
fix(dcd_dwc2): Reset opened EP counters on bus_reset event
1 parent adcd9f6 commit 594b7a4

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/portable/synopsys/dwc2/dcd_dwc2.c

+12-2
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,13 @@ void dcd_sof_enable(uint8_t rhport, bool en)
632632

633633
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32P4)
634634

635+
// Reset opened IN/OUT opeded endpoint counter
636+
static void dcd_edpt_reset(uint8_t rhport)
637+
{
638+
dwc_ep_config[rhport].in_ep = 0;
639+
dwc_ep_config[rhport].out_ep = 0;
640+
}
641+
635642
// Check if IN/OUT endpoint is available before opening it
636643
static bool dcd_edpt_available(uint8_t rhport, uint8_t dir)
637644
{
@@ -671,7 +678,7 @@ static bool dcd_edpt_release(uint8_t rhport, uint8_t dir)
671678
}
672679
return true;
673680
}
674-
#endif
681+
#endif // OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32P4
675682

676683
bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * desc_edpt)
677684
{
@@ -688,7 +695,7 @@ bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * desc_edpt)
688695
TU_LOG(1, "No endpoints available (ep_max=%d) \r\n", dwc_ep_config[rhport].ep_max_count);
689696
return false;
690697
}
691-
#endif
698+
#endif // OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32P4
692699

693700
xfer_ctl_t * xfer = XFER_CTL_BASE(epnum, dir);
694701
xfer->max_size = tu_edpt_packet_size(desc_edpt);
@@ -1290,6 +1297,9 @@ void dcd_int_handler(uint8_t rhport)
12901297
// USBRST is start of reset.
12911298
dwc2->gintsts = GINTSTS_USBRST;
12921299
bus_reset(rhport);
1300+
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32P4)
1301+
dcd_edpt_reset(rhport);
1302+
#endif // OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32P4
12931303
}
12941304

12951305
if(int_status & GINTSTS_ENUMDNE)

0 commit comments

Comments
 (0)