diff --git a/.cproject b/.cproject index 9725f3c2f..e3fc65a97 100644 --- a/.cproject +++ b/.cproject @@ -1,7 +1,5 @@ - - - + @@ -47,646 +45,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - make - - all - true - true - true - - - make - - clean - true - true - true - - - rake.bat - clean - true - false - true - - - rake.bat - release - true - false - true - - - rake.bat - - test:all - true - false - true - - - rake.bat - - test:delta - true - false - true - - - rake.bat - - clobber - true - false - true - - - rake.bat - - verbosity[4] test:all - true - false - true - - - rake.bat - - verbosity[4] test:delta - true - false - true - - - @@ -736,4 +95,624 @@ </infoList> </TargetConfig> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rake.bat + + clean + true + false + true + + + rake.bat + + release + true + false + true + + + rake.bat + test:all + true + false + true + + + rake.bat + test:delta + true + false + true + + + rake.bat + clobber + true + false + true + + + rake.bat + verbosity[4] test:all + true + false + true + + + rake.bat + verbosity[4] test:delta + true + false + true + + + diff --git a/tests/test/host/test_hid_host_keyboard.c b/tests/test/host/test_hid_host_keyboard.c index 5cb91926c..1ee09c7a4 100644 --- a/tests/test/host/test_hid_host_keyboard.c +++ b/tests/test/host/test_hid_host_keyboard.c @@ -190,34 +190,3 @@ void test_keyboard_get_ok() TEST_ASSERT_EQUAL_MEMORY(&sample_key[1], &report, sizeof(tusb_keyboard_report_t)); } -#if 0 -void test_keyboard_open_invalid_para() -{ - tusb_handle_keyboard_t keyboard_handle; - - TEST_ASSERT_EQUAL(TUSB_ERROR_INVALID_PARA, tusbh_keyboard_open(TUSB_CFG_HOST_DEVICE_MAX, 1, &keyboard_handle) ); - TEST_ASSERT_EQUAL(TUSB_ERROR_INVALID_PARA, tusbh_keyboard_open(0, 0, &keyboard_handle) ); - TEST_ASSERT_EQUAL(TUSB_ERROR_INVALID_PARA, tusbh_keyboard_open(0, TUSB_CFG_CONFIGURATION_MAX+1, &keyboard_handle) ); - TEST_ASSERT_EQUAL(TUSB_ERROR_INVALID_PARA, tusbh_keyboard_open(0, 1, NULL) ); -} - -void test_keyboard_open_succeed() -{ - tusb_handle_keyboard_t keyboard_handle = 0; - - TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, tusbh_keyboard_open(0, 1, &keyboard_handle)); - TEST_ASSERT_TRUE( 0 != keyboard_handle); -} - -void test_keyboard_callback__() -{ - TEST_IGNORE(); - tusb_handle_device_t device_handle = __LINE__; - tusb_handle_configure_t configure_handle = __LINE__; - tusb_handle_interface_t interface_handle = __LINE__; - uint32_t configure_flags = BIT_(TUSB_CLASS_HID); - tusbh_usbd_device_mounted_cb_ExpectWithArray(TUSB_ERROR_NONE, device_handle, &configure_flags, 1, 1); -} -#endif - - diff --git a/tests/test/host/test_usbd_host.c b/tests/test/host/test_usbd_host.c index 195f2817c..e9af68d91 100644 --- a/tests/test/host/test_usbd_host.c +++ b/tests/test/host/test_usbd_host.c @@ -37,6 +37,7 @@ #include "unity.h" #include "usbd_host.h" +#include "mock_osal.h" extern usbh_device_info_t device_info_pool[TUSB_CFG_HOST_DEVICE_MAX]; tusb_handle_device_t dev_hdl; @@ -50,16 +51,26 @@ void tearDown(void) { } -void test_usbh_init(void) +//--------------------------------------------------------------------+ +// init, get_status +//--------------------------------------------------------------------+ +void test_usbh_init_checkmem(void) { usbh_device_info_t device_info_zero[TUSB_CFG_HOST_DEVICE_MAX]; memset(device_info_zero, 0, sizeof(usbh_device_info_t)*TUSB_CFG_HOST_DEVICE_MAX); - usbh_init(); + osal_queue_create_IgnoreAndReturn(TUSB_ERROR_NONE); + TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, usbh_init()); TEST_ASSERT_EQUAL_MEMORY(device_info_zero, device_info_pool, sizeof(usbh_device_info_t)*TUSB_CFG_HOST_DEVICE_MAX); } +void test_usbh_init_queue_create_fail(void) +{ + osal_queue_create_IgnoreAndReturn(TUSB_ERROR_OSAL_QUEUE_FAILED); + TEST_ASSERT_EQUAL(TUSB_ERROR_OSAL_QUEUE_FAILED, usbh_init()); +} + void test_usbh_status_get_fail(void) { usbh_init(); @@ -73,3 +84,43 @@ void test_usbh_status_get_succeed(void) TEST_ASSERT_EQUAL( TUSB_DEVICE_STATUS_READY, tusbh_device_status_get(dev_hdl) ); } +//--------------------------------------------------------------------+ +// enum task +//--------------------------------------------------------------------+ +void test_enum_task(void) +{ +// osal_queue_ + TEST_IGNORE(); + usbh_enumerate_task(); +} + + +#if 0 +void test_keyboard_open_invalid_para() +{ + tusb_handle_keyboard_t keyboard_handle; + + TEST_ASSERT_EQUAL(TUSB_ERROR_INVALID_PARA, tusbh_keyboard_open(TUSB_CFG_HOST_DEVICE_MAX, 1, &keyboard_handle) ); + TEST_ASSERT_EQUAL(TUSB_ERROR_INVALID_PARA, tusbh_keyboard_open(0, 0, &keyboard_handle) ); + TEST_ASSERT_EQUAL(TUSB_ERROR_INVALID_PARA, tusbh_keyboard_open(0, TUSB_CFG_CONFIGURATION_MAX+1, &keyboard_handle) ); + TEST_ASSERT_EQUAL(TUSB_ERROR_INVALID_PARA, tusbh_keyboard_open(0, 1, NULL) ); +} + +void test_keyboard_open_succeed() +{ + tusb_handle_keyboard_t keyboard_handle = 0; + + TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, tusbh_keyboard_open(0, 1, &keyboard_handle)); + TEST_ASSERT_TRUE( 0 != keyboard_handle); +} + +void test_keyboard_callback__() +{ + TEST_IGNORE(); + tusb_handle_device_t device_handle = __LINE__; + tusb_handle_configure_t configure_handle = __LINE__; + tusb_handle_interface_t interface_handle = __LINE__; + uint32_t configure_flags = BIT_(TUSB_CLASS_HID); + tusbh_usbd_device_mounted_cb_ExpectWithArray(TUSB_ERROR_NONE, device_handle, &configure_flags, 1, 1); +} +#endif diff --git a/tinyusb/common/errors.h b/tinyusb/common/errors.h index b96bb5997..a39e99b27 100644 --- a/tinyusb/common/errors.h +++ b/tinyusb/common/errors.h @@ -66,6 +66,7 @@ ENTRY(TUSB_ERROR_CLASS_DEVICE_DONT_SUPPORT)\ ENTRY(TUSB_ERROR_CLASS_DATA_NOT_AVAILABLE)\ ENTRY(TUSB_ERROR_OSAL_TIMEOUT)\ + ENTRY(TUSB_ERROR_OSAL_QUEUE_FAILED)\ ENTRY(TUSB_ERROR_FAILED)\ diff --git a/tinyusb/host/usbd_host.c b/tinyusb/host/usbd_host.c index adf741548..134bdc038 100644 --- a/tinyusb/host/usbd_host.c +++ b/tinyusb/host/usbd_host.c @@ -46,6 +46,7 @@ //--------------------------------------------------------------------+ #include "common/common.h" #include "usbd_host.h" +#include "osal/osal.h" //--------------------------------------------------------------------+ // MACRO CONSTANT TYPEDEF @@ -57,6 +58,10 @@ //--------------------------------------------------------------------+ STATIC_ usbh_device_info_t device_info_pool[TUSB_CFG_HOST_DEVICE_MAX]; +#define ENUM_DEPTH 2 +STATIC_ osal_queue_t queue_enumerate; +STATIC_ uint8_t queue_enumerate_buffer[ENUM_DEPTH*sizeof(usbh_enumerate_t)]; + //--------------------------------------------------------------------+ // PUBLIC API (Parameter Verification is required) //--------------------------------------------------------------------+ @@ -69,21 +74,16 @@ tusbh_device_status_t tusbh_device_status_get (tusb_handle_device_t const device //--------------------------------------------------------------------+ // CLASS-USBD API (don't require to verify parameters) //--------------------------------------------------------------------+ -void usbh_init(void) +tusb_error_t usbh_init(void) { memset(device_info_pool, 0, sizeof(usbh_device_info_t)*TUSB_CFG_HOST_DEVICE_MAX); -} - -#if 0 -tusb_error_t tusbh_keyboard_open(tusb_handle_device_t device_hdl, uint8_t configure_num, tusb_handle_keyboard_t *keyboard_hdl) -{ - ASSERT(device_hdl < TUSB_CFG_HOST_DEVICE_MAX, TUSB_ERROR_INVALID_PARA); - ASSERT_INT_WITHIN(1, TUSB_CFG_CONFIGURATION_MAX, configure_num, TUSB_ERROR_INVALID_PARA); - ASSERT_PTR(keyboard_hdl, TUSB_ERROR_INVALID_PARA); - +// ASSERT_STATUS(osal_queue_create()); return TUSB_ERROR_NONE; } -#endif +void usbh_enumerate_task(void) +{ + +} #endif diff --git a/tinyusb/host/usbd_host.h b/tinyusb/host/usbd_host.h index ece9930cd..d218fbd15 100644 --- a/tinyusb/host/usbd_host.h +++ b/tinyusb/host/usbd_host.h @@ -135,6 +135,13 @@ typedef enum { } pipe_status_t; typedef uint32_t tusb_handle_device_t; + +typedef struct { + uint8_t core_id; + uint8_t hub_address; + uint8_t hub_port; +} usbh_enumerate_t; + //--------------------------------------------------------------------+ // INTERNAL OBJECT & FUNCTION DECLARATION //--------------------------------------------------------------------+ @@ -153,8 +160,9 @@ tusbh_device_status_t tusbh_device_status_get (tusb_handle_device_t const device //--------------------------------------------------------------------+ #ifdef _TINY_USB_SOURCE_FILE_ -void usbh_init(void); +tusb_error_t usbh_init(void); pipe_status_t usbh_pipe_status_get(pipe_handle_t pipe_hdl) ATTR_WARN_UNUSED_RESULT; +void usbh_enum_task(void); #endif diff --git a/tinyusb/osal/osal.h b/tinyusb/osal/osal.h index 8284ae6f8..844c3c083 100644 --- a/tinyusb/osal/osal.h +++ b/tinyusb/osal/osal.h @@ -80,8 +80,8 @@ enum // QUEUE API //--------------------------------------------------------------------+ typedef uint32_t osal_queue_id_t; - -tusb_error_t osal_queue_create(osal_queue_id_t qid, uint8_t *buffer); +//osal_queue_id_t osal_queue_create(osal_queue_t *queue, uint8_t *buffer); +osal_queue_id_t osal_queue_create(osal_queue_id_t *queue, uint8_t *buffer); tusb_error_t osal_queue_put(osal_queue_id_t qid, uint32_t data, osal_timeout_t msec); tusb_error_t osal_queue_get(osal_queue_id_t qid, uint32_t *data, osal_timeout_t msec); diff --git a/tinyusb/osal/osal_none.h b/tinyusb/osal/osal_none.h index c7b9acae0..c3be90fad 100644 --- a/tinyusb/osal/osal_none.h +++ b/tinyusb/osal/osal_none.h @@ -68,6 +68,8 @@ typedef struct{ volatile uint16_t rd_ptr ; ///< read pointer } osal_queue_t; +//typedef osal_queue_t osal_queue_id_t*; + #define OSAL_DEF_QUEUE(name, size)\ osal_queue_t name;\ uint8_t buffer_##name[size]