clean up, update tests for hcd_port_reset after 8 byte descriptor & set configure before open class driver

This commit is contained in:
hathach 2013-03-29 23:37:59 +07:00
parent e658e67ebe
commit fcb8e295ec
4 changed files with 14 additions and 28 deletions

View File

@ -156,7 +156,7 @@ tusb_error_t control_xfer_stub(uint8_t dev_addr, const tusb_std_request_t * cons
return TUSB_ERROR_NONE;
}
tusb_error_t hidh_install_stub(uint8_t dev_addr, uint8_t const *descriptor, uint16_t *p_length, int num_call)
tusb_error_t hidh_install_stub(uint8_t dev_addr, tusb_descriptor_interface_t const *descriptor, uint16_t *p_length, int num_call)
{
*p_length = sizeof(tusb_descriptor_interface_t) + sizeof(tusb_hid_descriptor_hid_t) + sizeof(tusb_descriptor_endpoint_t);
return TUSB_ERROR_NONE;
@ -179,6 +179,7 @@ void test_addr0_failed_dev_desc(void)
void test_addr0_failed_set_address(void)
{
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(1));
hcd_port_reset_Expect( usbh_devices[0].core_id );
tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL);
usbh_enumeration_task();
@ -190,7 +191,7 @@ void test_addr0_failed_set_address(void)
void test_enum_failed_get_full_dev_desc(void)
{
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(2));
hcd_port_reset_Expect( usbh_devices[0].core_id );
hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE);
osal_semaphore_reset_Expect( usbh_devices[0].control.sem_hdl );
@ -199,8 +200,6 @@ void test_enum_failed_get_full_dev_desc(void)
usbh_enumeration_task();
TEST_ASSERT_EQUAL(TUSB_DEVICE_STATE_UNPLUG, usbh_devices[0].state);
TEST_ASSERT_EQUAL(TUSB_DEVICE_STATE_ADDRESSED, usbh_devices[1].state);
TEST_ASSERT_EQUAL(TUSB_SPEED_FULL, usbh_devices[1].speed);
TEST_ASSERT_EQUAL(enum_connect.core_id, usbh_devices[1].core_id);
@ -211,7 +210,7 @@ void test_enum_failed_get_full_dev_desc(void)
void test_enum_failed_get_9byte_config_desc(void)
{
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(3));
hcd_port_reset_Expect( usbh_devices[0].core_id );
hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE);
osal_semaphore_reset_Expect( usbh_devices[0].control.sem_hdl );
hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE);
@ -228,6 +227,7 @@ void test_enum_failed_get_9byte_config_desc(void)
void test_enum_failed_get_full_config_desc(void)
{
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(4));
hcd_port_reset_Expect( usbh_devices[0].core_id );
hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE);
osal_semaphore_reset_Expect( usbh_devices[0].control.sem_hdl );
hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE);
@ -245,23 +245,23 @@ void class_install_expect(void)
void test_enum_parse_config_desc(void)
{
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(5));
hcd_port_reset_Expect( usbh_devices[0].core_id );
hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE);
osal_semaphore_reset_Expect( usbh_devices[0].control.sem_hdl );
hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE);
tusbh_device_attached_cb_ExpectAndReturn((tusb_descriptor_device_t*) enum_data_buffer, 1);
class_install_expect();
tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL); // fail to set configure
usbh_enumeration_task();
TEST_ASSERT_EQUAL(desc_configuration.configuration.bNumInterfaces, usbh_devices[1].interface_count);
TEST_ASSERT_EQUAL(TUSB_CLASS_FLAG_HID, usbh_devices[1].flag_supported_class); // TODO change later
}
void test_enum_set_configure(void)
{
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(6));
hcd_port_reset_Expect( usbh_devices[0].core_id );
hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE);
osal_semaphore_reset_Expect( usbh_devices[0].control.sem_hdl );
hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE);
@ -271,4 +271,6 @@ void test_enum_set_configure(void)
tusbh_device_mount_succeed_cb_Expect(1);
usbh_enumeration_task();
TEST_ASSERT_EQUAL(TUSB_CLASS_FLAG_HID, usbh_devices[1].flag_supported_class); // TODO change later
}

View File

@ -414,6 +414,8 @@ void async_advance_isr(ehci_qhd_t * const async_head)
async_head->is_removing = 0;
async_head->p_qtd_list_head = async_head->p_qtd_list_tail = NULL;
async_head->qtd_overlay.halted = 1;
usbh_devices[0].state = TUSB_DEVICE_STATE_UNPLUG;
}
for(uint8_t relative_dev_addr=0; relative_dev_addr < TUSB_CFG_HOST_DEVICE_MAX; relative_dev_addr++)
@ -439,23 +441,6 @@ void async_advance_isr(ehci_qhd_t * const async_head)
}
// TODO free all itd & sitd
}
// // check if any other endpoints in pool is removing
// for (uint8_t i=0; i<EHCI_MAX_QHD; i++)
// {
// ehci_qhd_t *p_qhd = &ehci_data.device[relative_dev_addr].qhd[i];
// if (p_qhd->is_removing)
// {
// p_qhd->used = 0;
// p_qhd->is_removing = 0;
//
// while(p_qhd->p_qtd_list_head != NULL) // remove all TDs
// {
// p_qhd->p_qtd_list_head->used = 0; // free QTD
// qtd_remove_1st_from_qhd(p_qhd);
// }
// }
// }// end qhd list loop
} // end for device[] loop
}

View File

@ -314,10 +314,9 @@ OSAL_TASK_DECLARE(usbh_enumeration_task)
usbh_devices[new_addr].hub_addr = usbh_devices[0].hub_addr;
usbh_devices[new_addr].hub_port = usbh_devices[0].hub_port;
usbh_devices[new_addr].speed = usbh_devices[0].speed;
usbh_devices[new_addr].state = TUSB_DEVICE_STATE_ADDRESSED;
usbh_devices[new_addr].state = TUSB_DEVICE_STATE_ADDRESSED;
usbh_pipe_control_close(0);
usbh_devices[0].state = TUSB_DEVICE_STATE_UNPLUG;
// open control pipe for new address
TASK_ASSERT_STATUS ( usbh_pipe_control_open(new_addr, ((tusb_descriptor_device_t*) enum_data_buffer)->bMaxPacketSize0 ) );

View File

@ -59,8 +59,8 @@
enum
{
OSAL_TIMEOUT_NOTIMEOUT = 0, // for use within ISR, return immediately
OSAL_TIMEOUT_NORMAL = 10, // default is 10 msec
OSAL_TIMEOUT_NOTIMEOUT = 0, // for use within ISR, return immediately
OSAL_TIMEOUT_NORMAL = 10, // default is 10 msec
OSAL_TIMEOUT_WAIT_FOREVER = 0x0EEEEEEE
};