allow a limited model to deal with stalled pipe/transaction

added stall clear & able to mount the stupid toshiba thumb drive

add HCD pipe API
- bool hcd_pipe_is_busy(pipe_handle_t pipe_hdl);
- bool hcd_pipe_is_stalled(pipe_handle_t pipe_hdl);
- uint8_t hcd_pipe_get_endpoint_addr(pipe_handle_t pipe_hdl);
- tusb_error_t hcd_pipe_clear_stall(pipe_handle_t pipe_hdl);

remove tusbh_device_mount_failed_cb (not neccessary for user)
This commit is contained in:
hathach
2013-09-24 18:23:34 +07:00
parent 63b776f7cf
commit bbfa85aa08
11 changed files with 187 additions and 53 deletions

View File

@@ -210,7 +210,7 @@ void test_addr0_failed_dev_desc(void)
{
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(0));
tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL);
// tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL);
usbh_enumeration_task(NULL);
@@ -222,7 +222,7 @@ 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);
// tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL);
usbh_enumeration_task(NULL);
@@ -239,7 +239,7 @@ void test_enum_failed_get_full_dev_desc(void)
osal_semaphore_reset_Expect( usbh_devices[0].control.sem_hdl );
osal_mutex_reset_Expect( usbh_devices[0].control.mutex_hdl );
hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE);
tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL);
// tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL);
usbh_enumeration_task(NULL);
@@ -261,7 +261,7 @@ void test_enum_failed_get_9byte_config_desc(void)
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);
tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL);
// tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL);
usbh_enumeration_task(NULL);
@@ -279,7 +279,7 @@ void test_enum_failed_get_full_config_desc(void)
osal_mutex_reset_Expect( usbh_devices[0].control.mutex_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);
tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL);
// tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL);
usbh_enumeration_task(NULL);
}
@@ -294,7 +294,7 @@ void test_enum_parse_config_desc(void)
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);
tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL); // fail to set configure
// tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL); // fail to set configure
usbh_enumeration_task(NULL);

View File

@@ -49,6 +49,7 @@
#include "mock_tusb_callback.h"
#include "mock_hid_host.h"
#include "mock_cdc_host.h"
#include "mock_msc_host.h"
#include "host_helper.h"
uint8_t dev_addr;
@@ -161,7 +162,7 @@ void test_usbh_device_unplugged_isr(void)
usbh_devices[dev_addr].hub_port = 0;
usbh_devices[dev_addr].flag_supported_class = TUSB_CLASS_FLAG_HID;
helper_class_close_expect(dev_addr);
hidh_close_Expect(dev_addr);
hcd_pipe_control_close_ExpectAndReturn(dev_addr, TUSB_ERROR_NONE);
//------------- Code Under Test -------------//
@@ -170,6 +171,29 @@ void test_usbh_device_unplugged_isr(void)
TEST_ASSERT_EQUAL(TUSB_DEVICE_STATE_REMOVING, usbh_devices[dev_addr].state);
}
void test_usbh_device_unplugged_multple_class(void)
{
uint8_t dev_addr = 1;
usbh_devices[dev_addr].state = TUSB_DEVICE_STATE_CONFIGURED;
usbh_devices[dev_addr].core_id = 0;
usbh_devices[dev_addr].hub_addr = 0;
usbh_devices[dev_addr].hub_port = 0;
usbh_devices[dev_addr].flag_supported_class = TUSB_CLASS_FLAG_HID | TUSB_CLASS_FLAG_MSC | TUSB_CLASS_FLAG_CDC;
cdch_close_Expect(dev_addr);
hidh_close_Expect(dev_addr);
msch_close_Expect(dev_addr);
hcd_pipe_control_close_ExpectAndReturn(dev_addr, TUSB_ERROR_NONE);
//------------- Code Under Test -------------//
usbh_device_unplugged_isr(0);
TEST_ASSERT_EQUAL(TUSB_DEVICE_STATE_REMOVING, usbh_devices[dev_addr].state);
}
void semaphore_wait_success_stub(osal_mutex_handle_t const sem_hdl, uint32_t msec, tusb_error_t *p_error, int num_call)
{
(*p_error) = TUSB_ERROR_NONE;
@@ -219,3 +243,8 @@ void test_usbh_control_xfer_ok(void)
//------------- Code Under Test -------------//
usbh_control_xfer_subtask(dev_addr, 1, 2, 3, 4, 0, NULL);
}
//void test_usbh_xfer_isr_non_control_stalled(void) // do nothing for stall on control
//{
//
//}