diff options
| author | hathach <[email protected]> | 2024-10-21 17:45:40 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2024-10-21 18:18:33 +0700 |
| commit | 8461525d48cb4a97a7b18816f65b548a875ffe50 (patch) | |
| tree | ed958a56ef483492ab332aad6c47f601af03fe5a /src/host | |
| parent | f5978876d2a5d8cdc6cfd3bf99f9b820c5a6ac8a (diff) | |
add tusb_time_millis(), able to reset and enable dwc2 port and get SOF active
Diffstat (limited to 'src/host')
| -rw-r--r-- | src/host/usbh.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/host/usbh.c b/src/host/usbh.c index b5df29f50..8bf40a607 100644 --- a/src/host/usbh.c +++ b/src/host/usbh.c @@ -447,9 +447,9 @@ bool tuh_deinit(uint8_t rhport) { } bool tuh_task_event_ready(void) { - // Skip if stack is not initialized - if ( !tuh_inited() ) return false; - + if (!tuh_inited()) { + return false; // Skip if stack is not initialized + } return !osal_queue_empty(_usbh_q); } @@ -1520,10 +1520,17 @@ static bool enum_new_device(hcd_event_t* event) { _dev0.hub_port = event->connection.hub_port; if (_dev0.hub_addr == 0) { - // connected/disconnected directly with roothub + // connected directly to roothub hcd_port_reset(_dev0.rhport); - osal_task_delay(ENUM_RESET_DELAY); // TODO may not work for no-OS on MCU that require reset_end() since - // sof of controller may not running while resetting +#if CFG_TUSB_OS == OPT_OS_NONE + // Since we are in middle of rhport reset, frame number is not available for time delay + // need to depend on tusb_time_millis() instead + const uint32_t start_reset = tusb_time_millis(); + while ((tusb_time_millis() - start_reset) < ENUM_RESET_DELAY) {} +#else + osal_task_delay(ENUM_RESET_DELAY); +#endif + hcd_port_reset_end(_dev0.rhport); // wait until device connection is stable TODO non blocking @@ -1548,7 +1555,7 @@ static bool enum_new_device(hcd_event_t* event) { } #if CFG_TUH_HUB else { - // connected/disconnected via external hub + // connected via external hub // wait until device connection is stable TODO non blocking osal_task_delay(ENUM_CONTACT_DEBOUNCING_DELAY); |
