diff options
| author | hathach <[email protected]> | 2013-09-20 23:53:48 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-09-20 23:53:48 +0700 |
| commit | f8f398a6813567306acd2e9dcfae199c3ecbad3a (patch) | |
| tree | 2a0acf048ae44a4ee439c3928a8f74f91ea30bf5 /tinyusb/host | |
| parent | 52ae0afeb6dc781b82e6e71b864a02184eaf62bf (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')
| -rw-r--r-- | tinyusb/host/ehci/ehci.c | 1 | ||||
| -rw-r--r-- | tinyusb/host/hcd.h | 2 | ||||
| -rw-r--r-- | tinyusb/host/usbh.c | 12 |
3 files changed, 7 insertions, 8 deletions
diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c index 4bc69a51b..4d1a2ebd9 100644 --- a/tinyusb/host/ehci/ehci.c +++ b/tinyusb/host/ehci/ehci.c @@ -613,6 +613,7 @@ static void qhd_xfer_error_isr(ehci_qhd_t * p_qhd) tusb_xfer_type_t const xfer_type = qhd_get_xfer_type(p_qhd); tusb_event_t error_event; + // TODO allow stall with control pipe // no error bits are set, endpoint is halted due to STALL error_event = ( !(p_qhd->qtd_overlay.buffer_err || p_qhd->qtd_overlay.babble_err || p_qhd->qtd_overlay.xact_err) ) ? TUSB_EVENT_XFER_STALLED : TUSB_EVENT_XFER_ERROR; diff --git a/tinyusb/host/hcd.h b/tinyusb/host/hcd.h index bb6b40455..b37378ac7 100644 --- a/tinyusb/host/hcd.h +++ b/tinyusb/host/hcd.h @@ -96,7 +96,7 @@ tusb_error_t hcd_pipe_control_close(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT; pipe_handle_t hcd_pipe_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const * endpoint_desc, uint8_t class_code) ATTR_WARN_UNUSED_RESULT; tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t total_bytes, bool int_on_complete) ATTR_WARN_UNUSED_RESULT; -tusb_error_t hcd_pipe_close(pipe_handle_t pipe_hdl) ATTR_WARN_UNUSED_RESULT; +tusb_error_t hcd_pipe_close(pipe_handle_t pipe_hdl) /*ATTR_WARN_UNUSED_RESULT*/; bool hcd_pipe_is_idle(pipe_handle_t pipe_hdl); #if 0 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(); |
