summaryrefslogtreecommitdiff
path: root/tinyusb/host
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-12-19 13:55:22 +0700
committerhathach <[email protected]>2013-12-19 13:55:22 +0700
commitd020c2f609750fd82a31cb91f3e35f3dd87d2ef7 (patch)
treef1ea58956058a92b80b74d3b890352c10dd61e57 /tinyusb/host
parentcfcef0558a5b8ab797408f998074fa0ba6703ece (diff)
remove immediately reset when device plug.
check to make sure device is still plug after initial delay (200ms) before reset remove blocking waiting when reset in ehci.c
Diffstat (limited to 'tinyusb/host')
-rw-r--r--tinyusb/host/ehci/ehci.c11
-rw-r--r--tinyusb/host/ohci/ohci.c2
-rw-r--r--tinyusb/host/usbh.c18
3 files changed, 19 insertions, 12 deletions
diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c
index 9ba0871bf..b918c7131 100644
--- a/tinyusb/host/ehci/ehci.c
+++ b/tinyusb/host/ehci/ehci.c
@@ -154,11 +154,11 @@ void hcd_port_reset(uint8_t hostid)
regs->portsc_bit.port_enable = 0; // disable port before reset
regs->portsc_bit.port_reset = 1;
-#ifndef _TEST_
- // NXP specific, port reset will automatically be 0 when reset sequence complete
- // there is chance device is unplugged while reset sequence is not complete
- while( regs->portsc_bit.port_reset) {} // TODO use task delay to remove blocking
-#endif
+//#ifndef _TEST_
+// // NXP specific, port reset will automatically be 0 when reset sequence complete
+// // there is chance device is unplugged while reset sequence is not complete
+// while( regs->portsc_bit.port_reset) {} // TODO use task delay to remove blocking
+//#endif
}
bool hcd_port_connect_status(uint8_t hostid)
@@ -570,6 +570,7 @@ static void port_connect_status_change_isr(uint8_t hostid)
// NOTE There is an sequence plug->unplug->…..-> plug if device is powering with pre-plugged device
if (regs->portsc_bit.current_connect_status)
{
+// hcd_port_reset(hostid);
usbh_hcd_rhport_plugged_isr(hostid);
}else // device unplugged
{
diff --git a/tinyusb/host/ohci/ohci.c b/tinyusb/host/ohci/ohci.c
index 68954f83e..75688cfca 100644
--- a/tinyusb/host/ohci/ohci.c
+++ b/tinyusb/host/ohci/ohci.c
@@ -666,7 +666,7 @@ void hcd_isr(uint8_t hostid)
{
if ( OHCI_REG->rhport_status_bit[0].current_connect_status )
{
- OHCI_REG->rhport_status[0] = OHCI_RHPORT_PORT_RESET_STATUS_MASK;
+// OHCI_REG->rhport_status[0] = OHCI_RHPORT_PORT_RESET_STATUS_MASK; // reset port immediately
usbh_hcd_rhport_plugged_isr(0);
}else
{
diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c
index 7b358e2f2..de9e15164 100644
--- a/tinyusb/host/usbh.c
+++ b/tinyusb/host/usbh.c
@@ -370,14 +370,19 @@ tusb_error_t enumeration_body_subtask(void)
usbh_devices[0].hub_port = enum_entry.hub_port;
usbh_devices[0].state = TUSB_DEVICE_STATE_UNPLUG;
+ //------------- connected/disconnected directly with roothub -------------//
if ( usbh_devices[0].hub_addr == 0)
- { // connected/disconnected directly with roothub
+ {
if( hcd_port_connect_status(usbh_devices[0].core_id) )
{ // connection event
- osal_task_delay(200); // wait for port reset is complete & device is stable
-// hcd_port_reset( usbh_devices[0].core_id ); // port must be reset to have correct speed operation
-// osal_task_delay(50); // TODO reset is recommended to last 50 ms (NXP EHCI passes this)
- usbh_devices[0].speed = hcd_port_speed_get( usbh_devices[0].core_id );
+ osal_task_delay(200); // wait until device is stable
+
+ if ( !hcd_port_connect_status(usbh_devices[0].core_id) ) SUBTASK_EXIT(TUSB_ERROR_NONE); // exit if device unplugged while delaying
+
+ hcd_port_reset( usbh_devices[0].core_id ); // port must be reset to have correct speed operation
+ osal_task_delay(50); // USB Specs: reset is recommended to last 50 ms
+
+ usbh_devices[0].speed = hcd_port_speed_get( usbh_devices[0].core_id );
}
else
{ // disconnection event
@@ -386,8 +391,9 @@ tusb_error_t enumeration_body_subtask(void)
}
}
#if TUSB_CFG_HOST_HUB
+ //------------- connected/disconnected via hub -------------//
else
- { // connected/disconnected via hub
+ {
//------------- Get Port Status -------------//
OSAL_SUBTASK_INVOKED_AND_WAIT(
usbh_control_xfer_subtask( usbh_devices[0].hub_addr, bm_request_type(TUSB_DIR_DEV_TO_HOST, TUSB_REQUEST_TYPE_CLASS, TUSB_REQUEST_RECIPIENT_OTHER),