|
1 | | ---- a/components/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dcd_dwc2.c 2024-06-10 22:10:55.000000000 +0300 |
2 | | -+++ b/components/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dcd_dwc2.c 2024-06-10 22:20:01.000000000 +0300 |
3 | | -@@ -186,6 +186,18 @@ |
4 | | - return true; |
5 | | - } |
6 | | - |
7 | | -+#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3) |
| 1 | +--- a/components/arduino_tinyusb/src/dcd_dwc2.c 2024-10-02 12:17:40.000000000 +0300 |
| 2 | ++++ b/components/arduino_tinyusb/src/dcd_dwc2.c 2024-10-02 12:19:48.000000000 +0300 |
| 3 | +@@ -316,6 +316,16 @@ |
| 4 | + //-------------------------------------------------------------------- |
| 5 | + // Endpoint |
| 6 | + //-------------------------------------------------------------------- |
| 7 | ++#if defined(TUP_USBIP_DWC2_ESP32) |
8 | 8 | +// Keep count of how many FIFOs are in use |
9 | 9 | +static uint8_t _allocated_fifos = 1; //FIFO0 is always in use |
10 | 10 | + |
11 | 11 | +// Will either return an unused FIFO number, or 0 if all are used. |
12 | | -+static uint8_t get_free_fifo(void) |
13 | | -+{ |
| 12 | ++static uint8_t get_free_fifo(void) { |
14 | 13 | + if (_allocated_fifos < 5) return _allocated_fifos++; |
15 | 14 | + return 0; |
16 | 15 | +} |
17 | 16 | +#endif |
18 | | -+ |
| 17 | + |
19 | 18 | static void edpt_activate(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc) { |
20 | 19 | dwc2_regs_t* dwc2 = DWC2_REG(rhport); |
21 | | - uint8_t const epnum = tu_edpt_number(p_endpoint_desc->bEndpointAddress); |
22 | | -@@ -205,7 +217,18 @@ |
| 20 | +@@ -336,7 +346,18 @@ |
23 | 21 | dwc2->epout[epnum].doepctl = dxepctl; |
24 | 22 | dwc2->daintmsk |= TU_BIT(DAINTMSK_OEPM_Pos + epnum); |
25 | 23 | } else { |
26 | 24 | - dwc2->epin[epnum].diepctl = dxepctl | (epnum << DIEPCTL_TXFNUM_Pos); |
27 | 25 | + uint8_t fifo_num = epnum; |
28 | | -+#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3) |
| 26 | ++#if defined(TUP_USBIP_DWC2_ESP32) |
29 | 27 | + // Special Case for EP5, which is used by CDC but not actually called by the driver |
30 | 28 | + // we can give it a fake FIFO |
31 | 29 | + if (epnum == 5) { |
32 | 30 | + fifo_num = epnum; |
33 | 31 | + } else { |
34 | 32 | + fifo_num = get_free_fifo(); |
35 | 33 | + } |
36 | | -+ TU_ASSERT(fifo_num != 0); |
| 34 | ++ //TU_ASSERT(fifo_num != 0); |
37 | 35 | +#endif |
38 | 36 | + dwc2->epin[epnum].diepctl = dxepctl | (fifo_num << DIEPCTL_TXFNUM_Pos); |
39 | | - dwc2->daintmsk |= (1 << (DAINTMSK_IEPM_Pos + epnum)); |
| 37 | + dwc2->daintmsk |= TU_BIT(DAINTMSK_IEPM_Pos + epnum); |
40 | 38 | } |
41 | 39 | } |
42 | | -@@ -728,6 +751,10 @@ |
43 | | - // reset allocated fifo IN |
44 | | - _allocated_fifo_words_tx = 16; |
| 40 | +@@ -850,6 +871,10 @@ |
| 41 | + xfer_status[n][TUSB_DIR_IN].max_size = 0; |
| 42 | + } |
45 | 43 |
|
46 | | -+#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3) |
| 44 | ++#if defined(TUP_USBIP_DWC2_ESP32) |
47 | 45 | + _allocated_fifos = 1; |
48 | 46 | +#endif |
49 | 47 | + |
50 | | - fifo_flush_tx(dwc2, 0x10); // all tx fifo |
51 | | - fifo_flush_rx(dwc2); |
52 | | - } |
53 | | -@@ -1096,6 +1123,9 @@ |
| 48 | + dfifo_flush_tx(dwc2, 0x10); // all tx fifo |
| 49 | + dfifo_flush_rx(dwc2); |
| 50 | + |
| 51 | +@@ -1204,6 +1229,9 @@ |
54 | 52 | if (int_status & GINTSTS_USBRST) { |
55 | 53 | // USBRST is start of reset. |
56 | 54 | dwc2->gintsts = GINTSTS_USBRST; |
57 | | -+#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3) |
| 55 | ++#if defined(TUP_USBIP_DWC2_ESP32) |
58 | 56 | + _allocated_fifos = 1; |
59 | 57 | +#endif |
60 | 58 | bus_reset(rhport); |
61 | 59 | } |
62 | 60 |
|
63 | | -@@ -1127,7 +1157,11 @@ |
| 61 | +@@ -1235,7 +1263,11 @@ |
64 | 62 |
|
65 | 63 | if (int_status & GINTSTS_USBSUSP) { |
66 | 64 | dwc2->gintsts = GINTSTS_USBSUSP; |
67 | 65 | - dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true); |
68 | 66 | + //dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true); |
69 | 67 | + dcd_event_bus_signal(rhport, DCD_EVENT_UNPLUGGED, true); |
70 | | -+#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3) |
| 68 | ++#if defined(TUP_USBIP_DWC2_ESP32) |
71 | 69 | + _allocated_fifos = 1; |
72 | 70 | +#endif |
73 | 71 | } |
74 | 72 |
|
75 | 73 | if (int_status & GINTSTS_WKUINT) { |
76 | | -@@ -1144,6 +1178,9 @@ |
| 74 | +@@ -1252,6 +1284,9 @@ |
77 | 75 |
|
78 | 76 | if (otg_int & GOTGINT_SEDET) { |
79 | 77 | dcd_event_bus_signal(rhport, DCD_EVENT_UNPLUGGED, true); |
80 | | -+#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3) |
| 78 | ++#if defined(TUP_USBIP_DWC2_ESP32) |
81 | 79 | + _allocated_fifos = 1; |
82 | 80 | +#endif |
83 | 81 | } |
|
0 commit comments