add callback for hcd when it cleaned up all cache data for a device (previously mark as removing).

This commit is contained in:
hathach 2013-03-22 18:55:45 +07:00
parent 6b276d09bf
commit f6acca6664
4 changed files with 12 additions and 7 deletions

View File

@ -184,12 +184,10 @@ void test_device_unplugged_status(void)
{ {
ehci_controller_device_unplug(hostid); ehci_controller_device_unplug(hostid);
hcd_isr(hostid); hcd_isr(hostid);
TEST_ASSERT_EQUAL(TUSB_DEVICE_STATUS_REMOVING, usbh_device_info_pool[dev_addr].status);
regs->usb_sts_bit.async_advance = 1; regs->usb_sts_bit.async_advance = 1;
hcd_isr(hostid); // async advance hcd_isr(hostid); // async advance
//------------- Code Under Test -------------// TEST_ASSERT_EQUAL(TUSB_DEVICE_STATUS_UNPLUG, usbh_device_info_pool[dev_addr].status);
TEST_ASSERT_EQUAL(TUSB_DEVICE_STATUS_REMOVING, usbh_device_info_pool[dev_addr].status);
} }

View File

@ -183,6 +183,9 @@ void async_advance_isr(ehci_qhd_t * const async_head)
p_control_qhd->is_removing = 0; p_control_qhd->is_removing = 0;
p_control_qhd->used = 0; p_control_qhd->used = 0;
p_control_qhd->p_qtd_list_head = p_control_qhd->p_qtd_list_tail = NULL; p_control_qhd->p_qtd_list_head = p_control_qhd->p_qtd_list_tail = NULL;
// TODO abstract: Host Controller has cleaned up its data for this device, notify usbh
usbh_device_hcd_data_cleaned_up_cb(relative_dev_addr+1);
} }
// check if any other endpoints in pool is removing // check if any other endpoints in pool is removing

View File

@ -225,11 +225,15 @@ void usbh_device_unplugged_isr(uint8_t hostid)
usbh_pipe_control_close(dev_addr); usbh_pipe_control_close(dev_addr);
// set to REMOVING to prevent allocate to other new device // set to REMOVING to end wait for HCD to clean up its cached data for this device
// need to set to UNPLUGGED by HCD after freeing all resources
usbh_device_info_pool[dev_addr].status = TUSB_DEVICE_STATUS_REMOVING; usbh_device_info_pool[dev_addr].status = TUSB_DEVICE_STATUS_REMOVING;
} }
// HCD cleaned up cached data for this device
void usbh_device_hcd_data_cleaned_up_cb(uint8_t dev_addr)
{
usbh_device_info_pool[dev_addr].status = TUSB_DEVICE_STATUS_UNPLUG;
}
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// ENUMERATION TASK // ENUMERATION TASK

View File

@ -103,7 +103,7 @@ extern usbh_device_info_t usbh_device_info_pool[TUSB_CFG_HOST_DEVICE_MAX+1]; //
void usbh_isr(pipe_handle_t pipe_hdl, uint8_t class_code); void usbh_isr(pipe_handle_t pipe_hdl, uint8_t class_code);
void usbh_device_plugged_isr(uint8_t hostid, tusb_speed_t speed); void usbh_device_plugged_isr(uint8_t hostid, tusb_speed_t speed);
void usbh_device_unplugged_isr(uint8_t hostid); void usbh_device_unplugged_isr(uint8_t hostid);
void usbh_device_hcd_data_cleaned_up_cb(uint8_t dev_addr); // hcd called this function when it cleaned all its cached data for this device
#ifdef __cplusplus #ifdef __cplusplus
} }