- add control_pipe_status for usbh_device_info_t to reflect the status transfer of control pipe

- fix bug with hcd_port_reset
  + remove regs->portsc_bit.port_enable in the wait loop as device unplugged can cause this to always fails
- correct the timeout for hcd_controll_stop/reset 16 uframes ~ 2 ms
- potentially fix bugs device unplugged when new address is not assigned
This commit is contained in:
hathach
2013-03-23 18:36:43 +07:00
parent 44e09cc397
commit 0c5e0ef0f3
6 changed files with 20 additions and 13 deletions

View File

@@ -135,7 +135,8 @@ void hcd_port_reset(uint8_t hostid)
#ifndef _TEST_
// NXP specific, port reset will automatically be 0 when reset sequence complete
while( regs->portsc_bit.port_reset || !regs->portsc_bit.port_enable){} // FIXME trapped here once
// there is chance device is unplugged while reset sequence is not complete
while( regs->portsc_bit.port_reset /*&& regs->portsc_bit.current_connect_status*/ ) {}
#endif
}
@@ -385,7 +386,7 @@ static tusb_error_t hcd_controller_stop(uint8_t hostid)
regs->usb_cmd_bit.run_stop = 0;
timeout_set(&timeout, 16); // USB Spec: controller has to stop within 16 uframe
timeout_set(&timeout, 2); // USB Spec: controller has to stop within 16 uframe = 2 frames
while( regs->usb_sts_bit.hc_halted == 0 && !timeout_expired(&timeout)) {}
return timeout_expired(&timeout) ? TUSB_ERROR_OSAL_TIMEOUT : TUSB_ERROR_NONE;
@@ -404,7 +405,7 @@ tusb_error_t hcd_controller_reset(uint8_t hostid)
regs->usb_cmd_bit.reset = 1;
timeout_set(&timeout, 16); // should not take longer the time to stop controller
timeout_set(&timeout, 2); // should not take longer the time to stop controller
while( regs->usb_cmd_bit.reset && !timeout_expired(&timeout)) {}
return timeout_expired(&timeout) ? TUSB_ERROR_OSAL_TIMEOUT : TUSB_ERROR_NONE;