mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
remove hcd_addr0_close_Ignore
add code to check error handling from enum task
This commit is contained in:
parent
a253e4d648
commit
7961f04e17
@ -46,6 +46,8 @@
|
|||||||
|
|
||||||
extern usbh_device_info_t usbh_device_info_pool[TUSB_CFG_HOST_DEVICE_MAX];
|
extern usbh_device_info_t usbh_device_info_pool[TUSB_CFG_HOST_DEVICE_MAX];
|
||||||
extern usbh_device_addr0_t device_addr0;
|
extern usbh_device_addr0_t device_addr0;
|
||||||
|
extern uint8_t enum_data_buffer[TUSB_CFG_HOST_ENUM_BUFFER_SIZE];
|
||||||
|
|
||||||
tusb_handle_device_t dev_hdl;
|
tusb_handle_device_t dev_hdl;
|
||||||
pipe_handle_t pipe_addr0 = 12;
|
pipe_handle_t pipe_addr0 = 12;
|
||||||
|
|
||||||
@ -72,7 +74,6 @@ void setUp(void)
|
|||||||
hcd_port_speed_ExpectAndReturn(enum_connect.core_id, TUSB_SPEED_FULL);
|
hcd_port_speed_ExpectAndReturn(enum_connect.core_id, TUSB_SPEED_FULL);
|
||||||
|
|
||||||
hcd_addr0_open_IgnoreAndReturn(TUSB_ERROR_NONE);
|
hcd_addr0_open_IgnoreAndReturn(TUSB_ERROR_NONE);
|
||||||
hcd_addr0_close_IgnoreAndReturn(TUSB_ERROR_NONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tearDown(void)
|
void tearDown(void)
|
||||||
@ -152,17 +153,26 @@ tusb_error_t control_xfer_stub(pipe_handle_t pipe_hdl, const tusb_std_request_t
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// enum connect directed
|
// enum connect directed
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void test_failed_get_first_dev_desc(void)
|
void test_addr0_failed_dev_desc(void)
|
||||||
{
|
{
|
||||||
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(0));
|
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(0));
|
||||||
tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_FAILED, NULL);
|
tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL);
|
||||||
|
|
||||||
usbh_enumeration_task();
|
usbh_enumeration_task();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_addr0_failed_set_address(void)
|
||||||
|
{
|
||||||
|
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(1));
|
||||||
|
tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL);
|
||||||
|
|
||||||
|
usbh_enumeration_task();
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_MEMORY(&desc_device, enum_data_buffer, 8);
|
||||||
|
}
|
||||||
|
|
||||||
void test_enum_task_connect(void)
|
void test_enum_task_connect(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
usbh_enumeration_task();
|
usbh_enumeration_task();
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL(TUSB_DEVICE_STATUS_ADDRESSED, usbh_device_info_pool[0].status);
|
TEST_ASSERT_EQUAL(TUSB_DEVICE_STATUS_ADDRESSED, usbh_device_info_pool[0].status);
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
ENTRY(TUSB_ERROR_CLASS_DEVICE_DONT_SUPPORT)\
|
ENTRY(TUSB_ERROR_CLASS_DEVICE_DONT_SUPPORT)\
|
||||||
ENTRY(TUSB_ERROR_CLASS_DATA_NOT_AVAILABLE)\
|
ENTRY(TUSB_ERROR_CLASS_DATA_NOT_AVAILABLE)\
|
||||||
ENTRY(TUSB_ERROR_HCD_FAILED)\
|
ENTRY(TUSB_ERROR_HCD_FAILED)\
|
||||||
ENTRY(TUSB_ERROR_USBH_MOUNT_FAILED)\
|
ENTRY(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND)\
|
||||||
ENTRY(TUSB_ERROR_OSAL_TIMEOUT)\
|
ENTRY(TUSB_ERROR_OSAL_TIMEOUT)\
|
||||||
ENTRY(TUSB_ERROR_OSAL_TASK_FAILED)\
|
ENTRY(TUSB_ERROR_OSAL_TASK_FAILED)\
|
||||||
ENTRY(TUSB_ERROR_OSAL_QUEUE_FAILED)\
|
ENTRY(TUSB_ERROR_OSAL_QUEUE_FAILED)\
|
||||||
|
@ -79,7 +79,7 @@ OSAL_QUEUE_DEF(enum_queue, ENUM_QUEUE_DEPTH, uin32_t);
|
|||||||
osal_queue_handle_t enum_queue_hdl;
|
osal_queue_handle_t enum_queue_hdl;
|
||||||
|
|
||||||
usbh_device_addr0_t device_addr0 TUSB_CFG_ATTR_USBRAM;
|
usbh_device_addr0_t device_addr0 TUSB_CFG_ATTR_USBRAM;
|
||||||
uint8_t enum_data_buffer[TUSB_CFG_HOST_ENUM_BUFFER_SIZE] TUSB_CFG_ATTR_USBRAM;
|
STATIC_ uint8_t enum_data_buffer[TUSB_CFG_HOST_ENUM_BUFFER_SIZE] TUSB_CFG_ATTR_USBRAM;
|
||||||
|
|
||||||
|
|
||||||
void usbh_enumeration_task(void)
|
void usbh_enumeration_task(void)
|
||||||
@ -108,7 +108,7 @@ void usbh_enumeration_task(void)
|
|||||||
|
|
||||||
hcd_pipe_control_xfer(device_addr0.pipe_hdl, &request_device_desc, enum_data_buffer);
|
hcd_pipe_control_xfer(device_addr0.pipe_hdl, &request_device_desc, enum_data_buffer);
|
||||||
osal_semaphore_wait(device_addr0.sem_hdl, OSAL_TIMEOUT_NORMAL, &error); // careful of local variable without static
|
osal_semaphore_wait(device_addr0.sem_hdl, OSAL_TIMEOUT_NORMAL, &error); // careful of local variable without static
|
||||||
TASK_ASSERT_STATUS_HANDLER(error, tusbh_device_mount_failed_cb(TUSB_ERROR_USBH_MOUNT_FAILED, NULL));
|
TASK_ASSERT_STATUS_HANDLER(error, tusbh_device_mount_failed_cb(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL) );
|
||||||
}
|
}
|
||||||
|
|
||||||
new_addr = get_new_address();
|
new_addr = get_new_address();
|
||||||
@ -123,7 +123,7 @@ void usbh_enumeration_task(void)
|
|||||||
|
|
||||||
hcd_pipe_control_xfer(device_addr0.pipe_hdl, &request_set_address, NULL);
|
hcd_pipe_control_xfer(device_addr0.pipe_hdl, &request_set_address, NULL);
|
||||||
osal_semaphore_wait(device_addr0.sem_hdl, OSAL_TIMEOUT_NORMAL, &error); // careful of local variable without static
|
osal_semaphore_wait(device_addr0.sem_hdl, OSAL_TIMEOUT_NORMAL, &error); // careful of local variable without static
|
||||||
TASK_ASSERT_STATUS(error);
|
TASK_ASSERT_STATUS_HANDLER(error, tusbh_device_mount_failed_cb(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// update data for the new device
|
// update data for the new device
|
||||||
@ -133,9 +133,6 @@ void usbh_enumeration_task(void)
|
|||||||
usbh_device_info_pool[new_addr].speed = device_addr0.speed;
|
usbh_device_info_pool[new_addr].speed = device_addr0.speed;
|
||||||
usbh_device_info_pool[new_addr].status = TUSB_DEVICE_STATUS_ADDRESSED;
|
usbh_device_info_pool[new_addr].status = TUSB_DEVICE_STATUS_ADDRESSED;
|
||||||
|
|
||||||
hcd_addr0_close(&device_addr0);
|
|
||||||
|
|
||||||
|
|
||||||
}else // device connect via a hub
|
}else // device connect via a hub
|
||||||
{
|
{
|
||||||
ASSERT_MESSAGE("%s", "Hub is not supported yet");
|
ASSERT_MESSAGE("%s", "Hub is not supported yet");
|
||||||
|
@ -110,7 +110,7 @@ typedef struct { // TODO internal structure, re-order members
|
|||||||
// ADDRESS 0 API
|
// ADDRESS 0 API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
tusb_error_t hcd_addr0_open(usbh_device_addr0_t *dev_addr0) ATTR_WARN_UNUSED_RESULT;
|
tusb_error_t hcd_addr0_open(usbh_device_addr0_t *dev_addr0) ATTR_WARN_UNUSED_RESULT;
|
||||||
tusb_error_t hcd_addr0_close(usbh_device_addr0_t *dev_addr0) ATTR_WARN_UNUSED_RESULT;
|
//NOTE addr0 close is not needed tusb_error_t hcd_addr0_close(usbh_device_addr0_t *dev_addr0) ATTR_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,7 @@
|
|||||||
#define OSAL_TASK_LOOP_END \
|
#define OSAL_TASK_LOOP_END \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO FreeRTOS TASK_ASSERT need to omit do while to get continue statement works.
|
||||||
#define TASK_ASSERT(condition)
|
#define TASK_ASSERT(condition)
|
||||||
#define TASK_ASSERT_STATUS(sts)
|
#define TASK_ASSERT_STATUS(sts)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user