-
Notifications
You must be signed in to change notification settings - Fork 7
/
tinyusb1.patch
43 lines (38 loc) · 1.83 KB
/
tinyusb1.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
diff --git a/.pio/libdeps/pico/Adafruit TinyUSB Library/src/host/usbh.c b/.pio/libdeps/pico/Adafruit TinyUSB Library/src/host/usbh.c
index 9d618db9..5d6066fe 100644
--- a/.pio/libdeps/pico/Adafruit TinyUSB Library/src/host/usbh.c
+++ b/.pio/libdeps/pico/Adafruit TinyUSB Library/src/host/usbh.c
@@ -243,7 +243,8 @@ static osal_queue_t _usbh_q;
CFG_TUSB_MEM_SECTION CFG_TUSB_MEM_ALIGN
static uint8_t _usbh_ctrl_buf[CFG_TUH_ENUMERATION_BUFSIZE];
+static bool _usbh_enumerating = false;
// Control transfers: since most controllers do not support multiple control transfers
// on multiple devices concurrently and control transfers are not used much except for
// enumeration, we will only execute control transfers one at a time.
@@ -417,10 +418,18 @@ void tuh_task_ext(uint32_t timeout_ms, bool in_isr)
switch (event.event_id)
{
case HCD_EVENT_DEVICE_ATTACH:
- // TODO due to the shared _usbh_ctrl_buf, we must complete enumerating
+ // due to the shared _usbh_ctrl_buf, we must complete enumerating
// one device before enumerating another one.
- TU_LOG_USBH("[%u:] USBH DEVICE ATTACH\r\n", event.rhport);
- enum_new_device(&event);
+ if (_usbh_enumerating) {
+ // send event to back of queue, so we can continue enumerating
+ // the current device
+ TU_LOG_USBH("[%u:] defer attach until enumeration complete\r\n", event.rhport);
+ osal_queue_send(_usbh_q, &event, in_isr);
+ } else {
+ _usbh_enumerating = true;
+ TU_LOG_USBH("[%u:] USBH DEVICE ATTACH\r\n", event.rhport);
+ enum_new_device(&event);
+ }
break;
case HCD_EVENT_DEVICE_REMOVE:
@@ -1610,6 +1619,7 @@ static void enum_full_complete(void)
if (_dev0.hub_addr) hub_edpt_status_xfer(_dev0.hub_addr);
#endif
+ _usbh_enumerating = false;
}
#endif