From 7961f04e17e4988db3e4ceafd57e2e02ae2d7d1f Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 6 Feb 2013 13:50:17 +0700 Subject: [PATCH] remove hcd_addr0_close_Ignore add code to check error handling from enum task --- tests/test/host/test_enum_task.c | 18 ++++++++++++++---- tinyusb/common/errors.h | 2 +- tinyusb/host/usbh.c | 9 +++------ tinyusb/host/usbh_hcd.h | 2 +- tinyusb/osal/osal_freeRTOS.h | 1 + 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/tests/test/host/test_enum_task.c b/tests/test/host/test_enum_task.c index 8c57cc85b..7bb10466e 100644 --- a/tests/test/host/test_enum_task.c +++ b/tests/test/host/test_enum_task.c @@ -46,6 +46,8 @@ extern usbh_device_info_t usbh_device_info_pool[TUSB_CFG_HOST_DEVICE_MAX]; 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; 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_addr0_open_IgnoreAndReturn(TUSB_ERROR_NONE); - hcd_addr0_close_IgnoreAndReturn(TUSB_ERROR_NONE); } 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 //--------------------------------------------------------------------+ -void test_failed_get_first_dev_desc(void) +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_FAILED, NULL); + tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL); 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) { - usbh_enumeration_task(); TEST_ASSERT_EQUAL(TUSB_DEVICE_STATUS_ADDRESSED, usbh_device_info_pool[0].status); diff --git a/tinyusb/common/errors.h b/tinyusb/common/errors.h index 42a7a3975..57de5cea4 100644 --- a/tinyusb/common/errors.h +++ b/tinyusb/common/errors.h @@ -66,7 +66,7 @@ ENTRY(TUSB_ERROR_CLASS_DEVICE_DONT_SUPPORT)\ ENTRY(TUSB_ERROR_CLASS_DATA_NOT_AVAILABLE)\ 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_TASK_FAILED)\ ENTRY(TUSB_ERROR_OSAL_QUEUE_FAILED)\ diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c index 371514748..fd2f94ce6 100644 --- a/tinyusb/host/usbh.c +++ b/tinyusb/host/usbh.c @@ -79,7 +79,7 @@ OSAL_QUEUE_DEF(enum_queue, ENUM_QUEUE_DEPTH, uin32_t); osal_queue_handle_t enum_queue_hdl; 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) @@ -108,7 +108,7 @@ void usbh_enumeration_task(void) 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 - 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(); @@ -123,7 +123,7 @@ void usbh_enumeration_task(void) 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 - 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 @@ -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].status = TUSB_DEVICE_STATUS_ADDRESSED; - hcd_addr0_close(&device_addr0); - - }else // device connect via a hub { ASSERT_MESSAGE("%s", "Hub is not supported yet"); diff --git a/tinyusb/host/usbh_hcd.h b/tinyusb/host/usbh_hcd.h index 310de2060..111afeae6 100644 --- a/tinyusb/host/usbh_hcd.h +++ b/tinyusb/host/usbh_hcd.h @@ -110,7 +110,7 @@ typedef struct { // TODO internal structure, re-order members // ADDRESS 0 API //--------------------------------------------------------------------+ 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 } diff --git a/tinyusb/osal/osal_freeRTOS.h b/tinyusb/osal/osal_freeRTOS.h index b1f16adf0..ed167e688 100644 --- a/tinyusb/osal/osal_freeRTOS.h +++ b/tinyusb/osal/osal_freeRTOS.h @@ -76,6 +76,7 @@ #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_STATUS(sts)