summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-01-23 14:57:12 +0700
committerhathach <[email protected]>2013-01-23 15:01:17 +0700
commitfdc9a82e8c3dcce08613f0c0e1a773f0c39381e0 (patch)
tree772cae317e01118f28085375d7f6339af41630b7
parent3015776078a336a4245fd480fdead17d34906b69 (diff)
change configure handle to device handle
change test case accordingly
-rw-r--r--tests/test/host/test_hid_host_keyboard.c48
-rw-r--r--tinyusb/class/hid_host.c11
-rw-r--r--tinyusb/class/hid_host.h2
-rw-r--r--tinyusb/host/usbd_host.c2
-rw-r--r--tinyusb/host/usbd_host.h38
-rw-r--r--tinyusb/osal/osal_none.c1
-rw-r--r--tinyusb/osal/osal_none.h2
7 files changed, 40 insertions, 64 deletions
diff --git a/tests/test/host/test_hid_host_keyboard.c b/tests/test/host/test_hid_host_keyboard.c
index fa639abbe..679916900 100644
--- a/tests/test/host/test_hid_host_keyboard.c
+++ b/tests/test/host/test_hid_host_keyboard.c
@@ -41,7 +41,7 @@
#include "mock_osal.h"
#include "mock_usbd_host.h"
-tusb_device_info_t usbh_device_pool [2];
+usbh_device_info_t usbh_device_pool [2];
tusb_keyboard_report_t sample_key[2] =
{
@@ -55,21 +55,16 @@ tusb_keyboard_report_t sample_key[2] =
}
};
-tusb_handle_configure_t config_hdl;
+tusb_handle_device_t device_hdl;
tusb_keyboard_report_t report;
-tusb_configure_info_t *p_cfg_info;
void setUp(void)
{
- config_hdl = 1; // deviceID = 0 ; Configure = 1
+ device_hdl = 0; // deviceID = 0 ; Configure = 1
memset(&report, 0, sizeof(tusb_keyboard_report_t));
- p_cfg_info = NULL;
- usbh_device_pool[0].configuration[0].classes.hid_keyboard.pipe_in = 1;
- usbh_device_pool[0].configuration[0].classes.hid_keyboard.qid = 1;
-
- usbh_device_pool[0].configuration[1].classes.hid_keyboard.pipe_in = 0;
- usbh_device_pool[0].configuration[1].classes.hid_keyboard.qid = 0;
+ usbh_device_pool[0].configuration.classes.hid_keyboard.pipe_in = 1;
+ usbh_device_pool[0].configuration.classes.hid_keyboard.qid = 1;
}
void tearDown(void)
@@ -82,50 +77,51 @@ tusb_error_t queue_get_stub(osal_queue_id_t qid, uint32_t *data, osal_timeout_t
return TUSB_ERROR_NONE;
}
-tusb_error_t get_configure_class_not_support_stub(tusb_handle_configure_t configure_hdl, tusb_configure_info_t **pp_configure_info, int num_call)
+usbh_device_info_t* get_device_class_not_support_stub(tusb_handle_device_t device_hdl, int num_call)
{
- (*pp_configure_info) = &(usbh_device_pool[0].configuration[1]);
- return TUSB_ERROR_NONE;
+ usbh_device_pool[0].configuration.classes.hid_keyboard.pipe_in = 0;
+ usbh_device_pool[0].configuration.classes.hid_keyboard.qid = 0;
+
+ return &(usbh_device_pool[0]);
}
-tusb_error_t get_configure_stub(tusb_handle_configure_t configure_hdl, tusb_configure_info_t **pp_configure_info, int num_call)
+usbh_device_info_t* get_device_stub(tusb_handle_device_t device_hdl, int num_call)
{
- (*pp_configure_info) = &(usbh_device_pool[0].configuration[0]);
- return TUSB_ERROR_NONE;
+ return &(usbh_device_pool[0]);
}
void test_keyboard_get_invalid_para()
{
- usbh_configure_info_get_IgnoreAndReturn(TUSB_ERROR_INVALID_PARA);
- TEST_ASSERT_EQUAL(TUSB_ERROR_INVALID_PARA, tusbh_keyboard_get(config_hdl, NULL));
- TEST_ASSERT_EQUAL(TUSB_ERROR_INVALID_PARA, tusbh_keyboard_get(config_hdl, &report));
+ usbh_device_info_get_IgnoreAndReturn(NULL);
+ TEST_ASSERT_EQUAL(TUSB_ERROR_INVALID_PARA, tusbh_keyboard_get(device_hdl, NULL));
+ TEST_ASSERT_EQUAL(TUSB_ERROR_INVALID_PARA, tusbh_keyboard_get(device_hdl, &report));
}
void test_keyboard_get_class_not_supported()
{
- usbh_configure_info_get_StubWithCallback(get_configure_class_not_support_stub);
+ usbh_device_info_get_StubWithCallback(get_device_class_not_support_stub);
- TEST_ASSERT_EQUAL(TUSB_ERROR_CLASS_DEVICE_DONT_SUPPORT, tusbh_keyboard_get(config_hdl, &report));
+ TEST_ASSERT_EQUAL(TUSB_ERROR_CLASS_DEVICE_DONT_SUPPORT, tusbh_keyboard_get(device_hdl, &report));
}
void test_keyboard_get_from_empty_queue()
{
- usbh_configure_info_get_StubWithCallback(get_configure_stub);
+ usbh_device_info_get_StubWithCallback(get_device_stub);
osal_queue_get_IgnoreAndReturn(TUSB_ERROR_OSAL_TIMEOUT);
// osal_queue_get_ExpectAndReturn( usbh_device_pool[0].configuration[0].classes.hid_keyboard.qid, );
- TEST_ASSERT_EQUAL(TUSB_ERROR_OSAL_TIMEOUT, tusbh_keyboard_get(config_hdl, &report));
+ TEST_ASSERT_EQUAL(TUSB_ERROR_OSAL_TIMEOUT, tusbh_keyboard_get(device_hdl, &report));
}
void test_keyboard_get_ok()
{
- usbh_configure_info_get_StubWithCallback(get_configure_stub);
+ usbh_device_info_get_StubWithCallback(get_device_stub);
osal_queue_get_StubWithCallback(queue_get_stub);
- TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, tusbh_keyboard_get(config_hdl, &report));
+ TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, tusbh_keyboard_get(device_hdl, &report));
TEST_ASSERT_EQUAL_MEMORY(&sample_key[0], &report, sizeof(tusb_keyboard_report_t));
- TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, tusbh_keyboard_get(config_hdl, &report));
+ TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, tusbh_keyboard_get(device_hdl, &report));
TEST_ASSERT_EQUAL_MEMORY(&sample_key[1], &report, sizeof(tusb_keyboard_report_t));
}
diff --git a/tinyusb/class/hid_host.c b/tinyusb/class/hid_host.c
index c4ae20008..21bc1a93b 100644
--- a/tinyusb/class/hid_host.c
+++ b/tinyusb/class/hid_host.c
@@ -41,18 +41,19 @@
#include "hid_host.h"
-tusb_error_t tusbh_keyboard_get(tusb_handle_configure_t const config_hdl, tusb_keyboard_report_t * const report)
+tusb_error_t tusbh_keyboard_get(tusb_handle_device_t const device_hdl, tusb_keyboard_report_t * const report)
{
- tusb_configure_info_t *p_cfg_info;
+ usbh_device_info_t *p_device_info;
pipe_handle_t pipe_in;
osal_queue_id_t qid;
ASSERT_PTR(report, TUSB_ERROR_INVALID_PARA);
- ASSERT_STATUS( usbh_configure_info_get(config_hdl, &p_cfg_info) );
+ p_device_info = usbh_device_info_get(device_hdl);
+ ASSERT_PTR(p_device_info, TUSB_ERROR_INVALID_PARA);
- pipe_in = p_cfg_info->classes.hid_keyboard.pipe_in;
- qid = p_cfg_info->classes.hid_keyboard.qid;
+ pipe_in = p_device_info->configuration.classes.hid_keyboard.pipe_in;
+ qid = p_device_info->configuration.classes.hid_keyboard.qid;
ASSERT(0 != pipe_in, TUSB_ERROR_CLASS_DEVICE_DONT_SUPPORT);
ASSERT_STATUS( osal_queue_get(qid, (uint32_t*)report, OSAL_TIMEOUT_WAIT_FOREVER) );
diff --git a/tinyusb/class/hid_host.h b/tinyusb/class/hid_host.h
index d6be47e1e..7a8c9887e 100644
--- a/tinyusb/class/hid_host.h
+++ b/tinyusb/class/hid_host.h
@@ -57,7 +57,7 @@
#include "hid.h"
-tusb_error_t tusbh_keyboard_get(tusb_handle_configure_t const handle, tusb_keyboard_report_t * const report);
+tusb_error_t tusbh_keyboard_get(tusb_handle_device_t const handle, tusb_keyboard_report_t * const report);
#ifdef __cplusplus
}
diff --git a/tinyusb/host/usbd_host.c b/tinyusb/host/usbd_host.c
index 1f05fbcfb..f39ecf799 100644
--- a/tinyusb/host/usbd_host.c
+++ b/tinyusb/host/usbd_host.c
@@ -50,6 +50,6 @@ tusb_error_t tusbh_keyboard_open(tusb_handle_device_t device_hdl, uint8_t config
}
#endif
-tusb_device_info_t usbh_device_pool[TUSB_CFG_HOST_DEVICE_MAX];
+usbh_device_info_t usbh_device_pool[TUSB_CFG_HOST_DEVICE_MAX];
#endif
diff --git a/tinyusb/host/usbd_host.h b/tinyusb/host/usbd_host.h
index e6ac3c2da..926d586b0 100644
--- a/tinyusb/host/usbd_host.h
+++ b/tinyusb/host/usbd_host.h
@@ -71,61 +71,37 @@ typedef struct {
// hid_info_t hid_mouse;
// hid_info_t hid_generic;
} classes;
-} tusb_configure_info_t;
+} usbh_configure_info_t;
typedef struct {
uint8_t core_id;
- uint8_t configure_num;
- uint8_t configure_active; // TODO CONFIG multiple only
-
#if 0 // TODO allow configure for vendor/product
uint16_t vendor_id;
uint16_t product_id;
#endif
- tusb_configure_info_t configuration[TUSB_CFG_CONFIGURATION_MAX];
-} tusb_device_info_t;
+ usbh_configure_info_t configuration;
+} usbh_device_info_t;
+
+
//--------------------------------------------------------------------+
// Structures & Types
//--------------------------------------------------------------------+
typedef uint32_t tusb_handle_device_t;
-typedef uint32_t tusb_handle_configure_t;
-
-typedef struct {
- uint8_t device_id;
- uint8_t configure_num;
-} _tusb_handle_configure_t;
//--------------------------------------------------------------------+
// APPLICATION API
//--------------------------------------------------------------------+
void tusbh_device_mounted_cb (tusb_error_t error, tusb_handle_device_t device_hdl, uint32_t *configure_flags, uint8_t number_of_configure);
+tusb_error_t tusbh_configuration_set (tusb_handle_device_t const device_hdl, uint8_t const configure_number);
-tusb_error_t tusbh_configuration_set (tusb_handle_device_t const device_hdl, uint8_t const configure_number, tusb_handle_configure_t *configure_hdl);
-
-//tusb_error_t tusbh_configure_get (tusb_handle_device_t device_hdl, uint8_t configure_number, tusb_handle_configure_t *configure_handle);
-//tusb_error_t tusbh_class_open (tusb_handle_device_t device_hdl, uint8_t class, tusb_handle_class_t *interface_handle);
-//tusb_error_t tusbh_interface_get_info(tusb_handle_interface_t interface_handle, tusb_descriptor_interface_t *interface_desc);
// TODO hiding from application include
//--------------------------------------------------------------------+
// CLASS API
//--------------------------------------------------------------------+
-tusb_error_t usbh_configure_info_get (tusb_handle_configure_t configure_hdl, tusb_configure_info_t **pp_configure_info);
-
-#if 0
-void tusbh_usbd_mounted(tusb_error_t error, tusb_handle_device_t device_hdl);
-
-tusb_error_t tusbh_usbd_get_configiure (tusb_handle_device_t device_hdl , tusb_handle_configure_t *configure_hdl);
-tusb_error_t tusbh_usbd_get_configiure_next (tusb_handle_configure_t prev_hdl , tusb_handle_configure_t *next_hdl);
-
-tusb_error_t tusbh_usbd_get_interface (tusb_handle_configure_t configure_hdl , tusb_handle_interface_t *interface_hdl);
-tusb_error_t tusbh_usbd_get_interface_next (tusb_handle_interface_t prev_hdl , tusb_handle_interface_t *next_hdl);
-tusb_error_t tusbh_usbd_get_interface_alternate (tusb_handle_interface_t current_hdl , tusb_handle_interface_t *alternate_hdl);
-#endif
-
-
+usbh_device_info_t* usbh_device_info_get (tusb_handle_device_t device_hdl);
#ifdef __cplusplus
}
diff --git a/tinyusb/osal/osal_none.c b/tinyusb/osal/osal_none.c
index 4e18a80ee..ee9aa76bf 100644
--- a/tinyusb/osal/osal_none.c
+++ b/tinyusb/osal/osal_none.c
@@ -40,4 +40,5 @@
#if TUSB_CFG_OS == TUSB_OS_NONE
+
#endif
diff --git a/tinyusb/osal/osal_none.h b/tinyusb/osal/osal_none.h
index 5b69cd717..d14277f39 100644
--- a/tinyusb/osal/osal_none.h
+++ b/tinyusb/osal/osal_none.h
@@ -55,6 +55,8 @@
extern "C" {
#endif
+#include "osal.h"
+
//--------------------------------------------------------------------+
// QUEUE API
//--------------------------------------------------------------------+