summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/host/usbh.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/host/usbh.c b/src/host/usbh.c
index 69784ed47..c38afa3be 100644
--- a/src/host/usbh.c
+++ b/src/host/usbh.c
@@ -1692,6 +1692,15 @@ static bool enum_new_device(hcd_event_t* event) {
_dev0.hub_port = event->connection.hub_port;
if (_dev0.hub_addr == 0) {
+ // wait until device connection is stable TODO non blocking
+ tusb_time_delay_ms_api(ENUM_DEBOUNCING_DELAY_MS);
+
+ // device unplugged while delaying
+ if (!hcd_port_connect_status(_dev0.rhport)) {
+ enum_full_complete();
+ return true;
+ }
+
// connected directly to roothub
hcd_port_reset(_dev0.rhport);
@@ -1701,9 +1710,6 @@ static bool enum_new_device(hcd_event_t* event) {
hcd_port_reset_end(_dev0.rhport);
- // wait until device connection is stable TODO non blocking
- tusb_time_delay_ms_api(ENUM_DEBOUNCING_DELAY_MS);
-
// device unplugged while delaying
if (!hcd_port_connect_status(_dev0.rhport)) {
enum_full_complete();