| 
1 | 1 | --- a/components/arduino_tinyusb/src/dcd_dwc2.c	2024-10-02 12:17:40.000000000 +0300  | 
2 | 2 | +++ 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 @@  | 
4 | 4 |  //--------------------------------------------------------------------  | 
5 | 5 |  // Endpoint  | 
6 | 6 |  //--------------------------------------------------------------------  | 
 | 
17 | 17 | +   | 
18 | 18 |  static void edpt_activate(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc) {  | 
19 | 19 |    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 | +   }  | 
24 | 24 |    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;  | 
27 | 27 | +    uint8_t fifo_num = epnum;  | 
28 | 28 | +#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)  | 
29 | 29 | +    // Special Case for EP5, which is used by CDC but not actually called by the driver  | 
 | 
33 | 33 | +    } else {  | 
34 | 34 | +      fifo_num = get_free_fifo();  | 
35 | 35 | +    }  | 
36 |  | -+    //TU_ASSERT(fifo_num != 0);  | 
37 | 36 | +#endif  | 
38 |  | -+    epctl |= (fifo_num << DIEPCTL_TXFNUM_Pos);  | 
 | 37 | ++    depctl.bm.tx_fifo_num = fifo_num;  | 
39 | 38 |    }  | 
40 | 39 | 
 
  | 
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 @@  | 
43 | 42 |      }  | 
44 | 43 |    }  | 
45 | 44 | 
 
  | 
 | 
50 | 49 |    dfifo_flush_tx(dwc2, 0x10); // all tx fifo  | 
51 | 50 |    dfifo_flush_rx(dwc2);  | 
52 | 51 | 
 
  | 
53 |  | -@@ -908,6 +935,9 @@  | 
54 |  | -   if (int_status & GINTSTS_USBRST) {  | 
 | 52 | +@@ -959,6 +985,9 @@  | 
 | 53 | +   if (gintsts & GINTSTS_USBRST) {  | 
55 | 54 |      // USBRST is start of reset.  | 
56 | 55 |      dwc2->gintsts = GINTSTS_USBRST;  | 
57 | 56 | +#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)  | 
58 |  | -+    _allocated_fifos = 1;  | 
 | 57 | ++    allocated_fifos = 1;  | 
59 | 58 | +#endif  | 
60 |  | -     bus_reset(rhport);  | 
 | 59 | +     handle_bus_reset(rhport);  | 
61 | 60 |    }  | 
62 | 61 | 
 
  | 
63 |  | -@@ -939,7 +969,11 @@  | 
 | 62 | +@@ -970,7 +999,11 @@  | 
64 | 63 | 
 
  | 
65 |  | -   if (int_status & GINTSTS_USBSUSP) {  | 
 | 64 | +   if (gintsts & GINTSTS_USBSUSP) {  | 
66 | 65 |      dwc2->gintsts = GINTSTS_USBSUSP;  | 
67 | 66 | -    dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true);  | 
68 | 67 | +    //dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true);  | 
69 | 68 | +    dcd_event_bus_signal(rhport, DCD_EVENT_UNPLUGGED, true);  | 
70 | 69 | +#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)  | 
71 |  | -+    _allocated_fifos = 1;  | 
 | 70 | ++    allocated_fifos = 1;  | 
72 | 71 | +#endif  | 
73 | 72 |    }  | 
74 | 73 | 
 
  | 
75 |  | -   if (int_status & GINTSTS_WKUINT) {  | 
76 |  | -@@ -956,6 +990,9 @@  | 
 | 74 | +   if (gintsts & GINTSTS_WKUINT) {  | 
 | 75 | +@@ -987,6 +1020,9 @@  | 
77 | 76 | 
 
  | 
78 | 77 |      if (otg_int & GOTGINT_SEDET) {  | 
79 | 78 |        dcd_event_bus_signal(rhport, DCD_EVENT_UNPLUGGED, true);  | 
80 | 79 | +#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)  | 
81 |  | -+      _allocated_fifos = 1;  | 
 | 80 | ++      allocated_fifos = 1;  | 
82 | 81 | +#endif  | 
83 | 82 |      }  | 
84 | 83 | 
 
  | 
 | 
0 commit comments