Skip to content

Commit 8bcf3eb

Browse files
committed
Update TinyUSB DCD
1 parent 94d6ca7 commit 8bcf3eb

File tree

2 files changed

+402
-377
lines changed

2 files changed

+402
-377
lines changed

Diff for: components/arduino_tinyusb/patches/dcd_dwc2.patch

+20-21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--- a/components/arduino_tinyusb/src/dcd_dwc2.c 2024-10-02 12:17:40.000000000 +0300
22
+++ b/components/arduino_tinyusb/src/dcd_dwc2.c 2024-10-02 12:19:48.000000000 +0300
3-
@@ -209,6 +209,17 @@
3+
@@ -215,6 +215,17 @@
44
//--------------------------------------------------------------------
55
// Endpoint
66
//--------------------------------------------------------------------
@@ -17,13 +17,13 @@
1717
+
1818
static void edpt_activate(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc) {
1919
dwc2_regs_t* dwc2 = DWC2_REG(rhport);
20-
uint8_t const epnum = tu_edpt_number(p_endpoint_desc->bEndpointAddress);
21-
@@ -224,7 +235,19 @@
22-
(p_endpoint_desc->bmAttributes.xfer != TUSB_XFER_ISOCHRONOUS ? DOEPCTL_SD0PID_SEVNFRM : 0) |
23-
(xfer->max_size << DOEPCTL_MPSIZ_Pos);
20+
const uint8_t epnum = tu_edpt_number(p_endpoint_desc->bEndpointAddress);
21+
@@ -238,7 +249,18 @@
22+
depctl.bm.set_data0_iso_even = 1;
23+
}
2424
if (dir == TUSB_DIR_IN) {
25-
- epctl |= (epnum << DIEPCTL_TXFNUM_Pos);
26-
+ //epctl |= (epnum << DIEPCTL_TXFNUM_Pos);
25+
- depctl.bm.tx_fifo_num = epnum;
26+
+ //depctl.bm.tx_fifo_num = epnum;
2727
+ uint8_t fifo_num = epnum;
2828
+#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
2929
+ // Special Case for EP5, which is used by CDC but not actually called by the driver
@@ -33,13 +33,12 @@
3333
+ } else {
3434
+ fifo_num = get_free_fifo();
3535
+ }
36-
+ //TU_ASSERT(fifo_num != 0);
3736
+#endif
38-
+ epctl |= (fifo_num << DIEPCTL_TXFNUM_Pos);
37+
+ depctl.bm.tx_fifo_num = fifo_num;
3938
}
4039

41-
dwc2_dep_t* dep = &dwc2->ep[1 - dir][epnum];
42-
@@ -304,6 +327,10 @@
40+
dwc2_dep_t* dep = &dwc2->ep[dir == TUSB_DIR_IN ? 0 : 1][epnum];
41+
@@ -523,6 +545,10 @@
4342
}
4443
}
4544

@@ -50,35 +49,35 @@
5049
dfifo_flush_tx(dwc2, 0x10); // all tx fifo
5150
dfifo_flush_rx(dwc2);
5251

53-
@@ -908,6 +935,9 @@
54-
if (int_status & GINTSTS_USBRST) {
52+
@@ -959,6 +985,9 @@
53+
if (gintsts & GINTSTS_USBRST) {
5554
// USBRST is start of reset.
5655
dwc2->gintsts = GINTSTS_USBRST;
5756
+#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
58-
+ _allocated_fifos = 1;
57+
+ allocated_fifos = 1;
5958
+#endif
60-
bus_reset(rhport);
59+
handle_bus_reset(rhport);
6160
}
6261

63-
@@ -939,7 +969,11 @@
62+
@@ -970,7 +999,11 @@
6463

65-
if (int_status & GINTSTS_USBSUSP) {
64+
if (gintsts & GINTSTS_USBSUSP) {
6665
dwc2->gintsts = GINTSTS_USBSUSP;
6766
- dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true);
6867
+ //dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true);
6968
+ dcd_event_bus_signal(rhport, DCD_EVENT_UNPLUGGED, true);
7069
+#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
71-
+ _allocated_fifos = 1;
70+
+ allocated_fifos = 1;
7271
+#endif
7372
}
7473

75-
if (int_status & GINTSTS_WKUINT) {
76-
@@ -956,6 +990,9 @@
74+
if (gintsts & GINTSTS_WKUINT) {
75+
@@ -987,6 +1020,9 @@
7776

7877
if (otg_int & GOTGINT_SEDET) {
7978
dcd_event_bus_signal(rhport, DCD_EVENT_UNPLUGGED, true);
8079
+#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
81-
+ _allocated_fifos = 1;
80+
+ allocated_fifos = 1;
8281
+#endif
8382
}
8483

0 commit comments

Comments
 (0)