rename tusbh_hid_keyboard/mouse_is_supported to tusbh_hid_keyboard/mouse_is_mounted
This commit is contained in:
parent
5cd8f3ad00
commit
f8d1c3da3e
|
@ -0,0 +1 @@
|
||||||
|
# Board Supported Package (BSP) #
|
|
@ -102,20 +102,20 @@ void test_keyboard_init(void)
|
||||||
void test_keyboard_is_supported_fail_unplug(void)
|
void test_keyboard_is_supported_fail_unplug(void)
|
||||||
{
|
{
|
||||||
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_UNPLUG);
|
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_UNPLUG);
|
||||||
TEST_ASSERT_FALSE( tusbh_hid_keyboard_is_supported(dev_addr) );
|
TEST_ASSERT_FALSE( tusbh_hid_keyboard_is_mounted(dev_addr) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_keyboard_is_supported_fail_not_opened(void)
|
void test_keyboard_is_supported_fail_not_opened(void)
|
||||||
{
|
{
|
||||||
hidh_init();
|
hidh_init();
|
||||||
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
|
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
|
||||||
TEST_ASSERT_FALSE( tusbh_hid_keyboard_is_supported(dev_addr) );
|
TEST_ASSERT_FALSE( tusbh_hid_keyboard_is_mounted(dev_addr) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_keyboard_is_supported_ok(void)
|
void test_keyboard_is_supported_ok(void)
|
||||||
{
|
{
|
||||||
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
|
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
|
||||||
TEST_ASSERT_TRUE( tusbh_hid_keyboard_is_supported(dev_addr) );
|
TEST_ASSERT_TRUE( tusbh_hid_keyboard_is_mounted(dev_addr) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_keyboard_open_ok(void)
|
void test_keyboard_open_ok(void)
|
||||||
|
@ -137,7 +137,7 @@ void test_keyboard_open_ok(void)
|
||||||
length);
|
length);
|
||||||
|
|
||||||
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
|
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
|
||||||
TEST_ASSERT_TRUE( tusbh_hid_keyboard_is_supported(dev_addr) );
|
TEST_ASSERT_TRUE( tusbh_hid_keyboard_is_mounted(dev_addr) );
|
||||||
TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_READY, p_hidh_kbd->status);
|
TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_READY, p_hidh_kbd->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,20 +91,20 @@ void test_mouse_init(void)
|
||||||
void test_mouse_is_supported_fail_unplug(void)
|
void test_mouse_is_supported_fail_unplug(void)
|
||||||
{
|
{
|
||||||
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_UNPLUG);
|
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_UNPLUG);
|
||||||
TEST_ASSERT_FALSE( tusbh_hid_mouse_is_supported(dev_addr) );
|
TEST_ASSERT_FALSE( tusbh_hid_mouse_is_mounted(dev_addr) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_mouse_is_supported_fail_not_opened(void)
|
void test_mouse_is_supported_fail_not_opened(void)
|
||||||
{
|
{
|
||||||
hidh_init();
|
hidh_init();
|
||||||
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
|
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
|
||||||
TEST_ASSERT_FALSE( tusbh_hid_mouse_is_supported(dev_addr) );
|
TEST_ASSERT_FALSE( tusbh_hid_mouse_is_mounted(dev_addr) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_mouse_is_supported_ok(void)
|
void test_mouse_is_supported_ok(void)
|
||||||
{
|
{
|
||||||
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
|
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
|
||||||
TEST_ASSERT_TRUE( tusbh_hid_mouse_is_supported(dev_addr) );
|
TEST_ASSERT_TRUE( tusbh_hid_mouse_is_mounted(dev_addr) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_mouse_open_ok(void)
|
void test_mouse_open_ok(void)
|
||||||
|
@ -118,7 +118,7 @@ void test_mouse_open_ok(void)
|
||||||
tusbh_hid_mouse_isr_Expect(dev_addr, 0, TUSB_EVENT_INTERFACE_OPEN);
|
tusbh_hid_mouse_isr_Expect(dev_addr, 0, TUSB_EVENT_INTERFACE_OPEN);
|
||||||
|
|
||||||
//------------- Code Under TEST -------------//
|
//------------- Code Under TEST -------------//
|
||||||
TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, hidh_open_subtask(dev_addr, p_mouse_interface_desc, &length));
|
TEST_ASSERT_STATUS( hidh_open_subtask(dev_addr, p_mouse_interface_desc, &length));
|
||||||
|
|
||||||
TEST_ASSERT_PIPE_HANDLE(pipe_hdl, p_hidh_mouse->pipe_hdl);
|
TEST_ASSERT_PIPE_HANDLE(pipe_hdl, p_hidh_mouse->pipe_hdl);
|
||||||
TEST_ASSERT_EQUAL(8, p_hidh_mouse->report_size);
|
TEST_ASSERT_EQUAL(8, p_hidh_mouse->report_size);
|
||||||
|
@ -126,7 +126,7 @@ void test_mouse_open_ok(void)
|
||||||
length);
|
length);
|
||||||
|
|
||||||
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
|
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
|
||||||
TEST_ASSERT_TRUE( tusbh_hid_mouse_is_supported(dev_addr) );
|
TEST_ASSERT_TRUE( tusbh_hid_mouse_is_mounted(dev_addr) );
|
||||||
TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_READY, p_hidh_mouse->status);
|
TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_READY, p_hidh_mouse->status);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ void test_mouse_get_ok()
|
||||||
hcd_pipe_xfer_ExpectAndReturn(p_hidh_mouse->pipe_hdl, (uint8_t*) &report, p_hidh_mouse->report_size, true, TUSB_ERROR_NONE);
|
hcd_pipe_xfer_ExpectAndReturn(p_hidh_mouse->pipe_hdl, (uint8_t*) &report, p_hidh_mouse->report_size, true, TUSB_ERROR_NONE);
|
||||||
|
|
||||||
//------------- Code Under TEST -------------//
|
//------------- Code Under TEST -------------//
|
||||||
TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, tusbh_hid_mouse_get_report(dev_addr, 0, &report));
|
TEST_ASSERT_STATUS( tusbh_hid_mouse_get_report(dev_addr, 0, &report));
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_BUSY, tusbh_hid_mouse_status(dev_addr, 0));
|
TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_BUSY, tusbh_hid_mouse_status(dev_addr, 0));
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ uint8_t const hid_keycode_to_ascii_tbl[2][128] =
|
||||||
STATIC_ hidh_interface_info_t keyboard_data[TUSB_CFG_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1
|
STATIC_ hidh_interface_info_t keyboard_data[TUSB_CFG_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1
|
||||||
|
|
||||||
//------------- KEYBOARD PUBLIC API (parameter validation required) -------------//
|
//------------- KEYBOARD PUBLIC API (parameter validation required) -------------//
|
||||||
bool tusbh_hid_keyboard_is_supported(uint8_t dev_addr)
|
bool tusbh_hid_keyboard_is_mounted(uint8_t dev_addr)
|
||||||
{
|
{
|
||||||
return tusbh_device_is_configured(dev_addr) && pipehandle_is_valid(keyboard_data[dev_addr-1].pipe_hdl);
|
return tusbh_device_is_configured(dev_addr) && pipehandle_is_valid(keyboard_data[dev_addr-1].pipe_hdl);
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ tusb_interface_status_t tusbh_hid_keyboard_status(uint8_t dev_addr, uint8_t inst
|
||||||
STATIC_ hidh_interface_info_t mouse_data[TUSB_CFG_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1
|
STATIC_ hidh_interface_info_t mouse_data[TUSB_CFG_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1
|
||||||
|
|
||||||
//------------- Public API -------------//
|
//------------- Public API -------------//
|
||||||
bool tusbh_hid_mouse_is_supported(uint8_t dev_addr)
|
bool tusbh_hid_mouse_is_mounted(uint8_t dev_addr)
|
||||||
{
|
{
|
||||||
return tusbh_device_is_configured(dev_addr) && pipehandle_is_valid(mouse_data[dev_addr-1].pipe_hdl);
|
return tusbh_device_is_configured(dev_addr) && pipehandle_is_valid(mouse_data[dev_addr-1].pipe_hdl);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,19 +57,18 @@
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// KEYBOARD Application API
|
// KEYBOARD Application API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
bool tusbh_hid_keyboard_is_supported(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
|
|
||||||
tusb_error_t tusbh_hid_keyboard_get_report(uint8_t dev_addr, uint8_t instance_num, void * report) ATTR_WARN_UNUSED_RESULT;
|
|
||||||
tusb_interface_status_t tusbh_hid_keyboard_status(uint8_t dev_addr, uint8_t instance_num) ATTR_WARN_UNUSED_RESULT;
|
|
||||||
|
|
||||||
extern uint8_t const hid_keycode_to_ascii_tbl[2][128]; // TODO used weak attr if build failed without KEYBOARD enabled
|
extern uint8_t const hid_keycode_to_ascii_tbl[2][128]; // TODO used weak attr if build failed without KEYBOARD enabled
|
||||||
|
|
||||||
|
bool tusbh_hid_keyboard_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
|
||||||
|
tusb_error_t tusbh_hid_keyboard_get_report(uint8_t dev_addr, uint8_t instance_num, void * report) ATTR_WARN_UNUSED_RESULT;
|
||||||
|
tusb_interface_status_t tusbh_hid_keyboard_status(uint8_t dev_addr, uint8_t instance_num) ATTR_WARN_UNUSED_RESULT;
|
||||||
//------------- Application Callback -------------//
|
//------------- Application Callback -------------//
|
||||||
void tusbh_hid_keyboard_isr(uint8_t dev_addr, uint8_t instance_num, tusb_event_t event) ATTR_WEAK;
|
void tusbh_hid_keyboard_isr(uint8_t dev_addr, uint8_t instance_num, tusb_event_t event) ATTR_WEAK;
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// MOUSE Application API
|
// MOUSE Application API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
bool tusbh_hid_mouse_is_supported(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
|
bool tusbh_hid_mouse_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
|
||||||
tusb_error_t tusbh_hid_mouse_get_report(uint8_t dev_addr, uint8_t instance_num, void* report) ATTR_WARN_UNUSED_RESULT;
|
tusb_error_t tusbh_hid_mouse_get_report(uint8_t dev_addr, uint8_t instance_num, void* report) ATTR_WARN_UNUSED_RESULT;
|
||||||
tusb_interface_status_t tusbh_hid_mouse_status(uint8_t dev_addr, uint8_t instance_num) ATTR_WARN_UNUSED_RESULT;
|
tusb_interface_status_t tusbh_hid_mouse_status(uint8_t dev_addr, uint8_t instance_num) ATTR_WARN_UNUSED_RESULT;
|
||||||
//------------- Application Callback -------------//
|
//------------- Application Callback -------------//
|
||||||
|
@ -78,6 +77,12 @@ void tusbh_hid_mouse_isr(uint8_t dev_addr, uint8_t instance_num, tusb_event_t ev
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// GENERIC Application API
|
// GENERIC Application API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
bool tusbh_hid_generic_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
|
||||||
|
tusb_error_t tusbh_hid_generic_get_report(uint8_t dev_addr, uint8_t instance_num, void* report) ATTR_WARN_UNUSED_RESULT;
|
||||||
|
tusb_error_t tusbh_hid_generic_set_report(uint8_t dev_addr, uint8_t instance_num, void* report) ATTR_WARN_UNUSED_RESULT;
|
||||||
|
tusb_interface_status_t tusbh_hid_generic_status(uint8_t dev_addr, uint8_t instance_num) ATTR_WARN_UNUSED_RESULT;
|
||||||
|
//------------- Application Callback -------------//
|
||||||
|
void tusbh_hid_generic_isr(uint8_t dev_addr, uint8_t instance_num, tusb_event_t event) ATTR_WEAK;
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// USBH-CLASS DRIVER API
|
// USBH-CLASS DRIVER API
|
||||||
|
|
Loading…
Reference in New Issue