summaryrefslogtreecommitdiff
path: root/tinyusb/host/usbh.c
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-09-20 23:53:48 +0700
committerhathach <[email protected]>2013-09-20 23:53:48 +0700
commitf8f398a6813567306acd2e9dcfae199c3ecbad3a (patch)
tree2a0acf048ae44a4ee439c3928a8f74f91ea30bf5 /tinyusb/host/usbh.c
parent52ae0afeb6dc781b82e6e71b864a02184eaf62bf (diff)
start to add msc host, fix dangerous problem with unstable device when plugged --> 200 ms delay. 50ms delay after each port reset
Diffstat (limited to 'tinyusb/host/usbh.c')
-rw-r--r--tinyusb/host/usbh.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c
index 3b9af5801..e95012f01 100644
--- a/tinyusb/host/usbh.c
+++ b/tinyusb/host/usbh.c
@@ -345,17 +345,15 @@ tusb_error_t enumeration_body_subtask(void)
usbh_devices[0].hub_addr = enum_entry.hub_addr;
usbh_devices[0].hub_port = enum_entry.hub_port;
+ osal_task_delay(200); // wait for device is stable
+
hcd_port_reset( usbh_devices[0].core_id ); // port must be reset to have correct speed operation
+ osal_task_delay(50); // reset is recommended to last 50 ms
usbh_devices[0].speed = hcd_port_speed_get( usbh_devices[0].core_id );
SUBTASK_ASSERT_STATUS( usbh_pipe_control_open(0, 8) );
usbh_devices[0].state = TUSB_DEVICE_STATE_ADDRESSED;
-#ifndef _TEST_
- // TODO hack delay 20 ms for slow device (use retry on the 1st xfer instead later)
- osal_task_delay(50);
-#endif
-
//------------- Get first 8 bytes of device descriptor to get Control Endpoint Size -------------//
OSAL_SUBTASK_INVOKED_AND_WAIT(
usbh_control_xfer_subtask( 0, bm_request_type(TUSB_DIR_DEV_TO_HOST, TUSB_REQUEST_TYPE_STANDARD, TUSB_REQUEST_RECIPIENT_DEVICE),
@@ -363,10 +361,10 @@ tusb_error_t enumeration_body_subtask(void)
8, enum_data_buffer ),
error
);
-
- SUBTASK_ASSERT_STATUS(error); // TODO some slow device is observed to fail the very fist controler xfer, can try more times
+ SUBTASK_ASSERT_STATUS(error); // TODO some slow device is observed to fail the very fist controller xfer, can try more times
hcd_port_reset( usbh_devices[0].core_id ); // reset port after 8 byte descriptor
+ osal_task_delay(50); // reset is recommended to last 50 ms
//------------- Set new address -------------//
new_addr = get_new_address();