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
This commit is contained in:
hathach 2013-12-19 13:55:22 +07:00
parent cfcef0558a
commit d020c2f609
4 changed files with 21 additions and 14 deletions

View File

@ -60,14 +60,14 @@
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// HOST CONFIGURATION // HOST CONFIGURATION
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#define TUSB_CFG_HOST_DEVICE_MAX 1 #define TUSB_CFG_HOST_DEVICE_MAX 3 // TODO be a part of HUB config
#define TUSB_CFG_CONFIGURATION_MAX 1 #define TUSB_CFG_CONFIGURATION_MAX 1
//------------- USBD -------------// //------------- USBD -------------//
#define TUSB_CFG_HOST_ENUM_BUFFER_SIZE 255 #define TUSB_CFG_HOST_ENUM_BUFFER_SIZE 255
//------------- CLASS -------------// //------------- CLASS -------------//
#define TUSB_CFG_HOST_HUB 0 #define TUSB_CFG_HOST_HUB 1
#define TUSB_CFG_HOST_HID_KEYBOARD 0 #define TUSB_CFG_HOST_HID_KEYBOARD 0
#define TUSB_CFG_HOST_HID_MOUSE 1 #define TUSB_CFG_HOST_HID_MOUSE 1
#define TUSB_CFG_HOST_HID_GENERIC 0 #define TUSB_CFG_HOST_HID_GENERIC 0

View File

@ -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_enable = 0; // disable port before reset
regs->portsc_bit.port_reset = 1; regs->portsc_bit.port_reset = 1;
#ifndef _TEST_ //#ifndef _TEST_
// NXP specific, port reset will automatically be 0 when reset sequence complete // // NXP specific, port reset will automatically be 0 when reset sequence complete
// there is chance device is unplugged while reset sequence is not 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 // while( regs->portsc_bit.port_reset) {} // TODO use task delay to remove blocking
#endif //#endif
} }
bool hcd_port_connect_status(uint8_t hostid) 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 // NOTE There is an sequence plug->unplug->…..-> plug if device is powering with pre-plugged device
if (regs->portsc_bit.current_connect_status) if (regs->portsc_bit.current_connect_status)
{ {
// hcd_port_reset(hostid);
usbh_hcd_rhport_plugged_isr(hostid); usbh_hcd_rhport_plugged_isr(hostid);
}else // device unplugged }else // device unplugged
{ {

View File

@ -666,7 +666,7 @@ void hcd_isr(uint8_t hostid)
{ {
if ( OHCI_REG->rhport_status_bit[0].current_connect_status ) 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); usbh_hcd_rhport_plugged_isr(0);
}else }else
{ {

View File

@ -370,14 +370,19 @@ tusb_error_t enumeration_body_subtask(void)
usbh_devices[0].hub_port = enum_entry.hub_port; usbh_devices[0].hub_port = enum_entry.hub_port;
usbh_devices[0].state = TUSB_DEVICE_STATE_UNPLUG; usbh_devices[0].state = TUSB_DEVICE_STATE_UNPLUG;
//------------- connected/disconnected directly with roothub -------------//
if ( usbh_devices[0].hub_addr == 0) if ( usbh_devices[0].hub_addr == 0)
{ // connected/disconnected directly with roothub {
if( hcd_port_connect_status(usbh_devices[0].core_id) ) if( hcd_port_connect_status(usbh_devices[0].core_id) )
{ // connection event { // connection event
osal_task_delay(200); // wait for port reset is complete & device is stable osal_task_delay(200); // wait until 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) if ( !hcd_port_connect_status(usbh_devices[0].core_id) ) SUBTASK_EXIT(TUSB_ERROR_NONE); // exit if device unplugged while delaying
usbh_devices[0].speed = hcd_port_speed_get( usbh_devices[0].core_id );
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 else
{ // disconnection event { // disconnection event
@ -386,8 +391,9 @@ tusb_error_t enumeration_body_subtask(void)
} }
} }
#if TUSB_CFG_HOST_HUB #if TUSB_CFG_HOST_HUB
//------------- connected/disconnected via hub -------------//
else else
{ // connected/disconnected via hub {
//------------- Get Port Status -------------// //------------- Get Port Status -------------//
OSAL_SUBTASK_INVOKED_AND_WAIT( 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), 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),