summaryrefslogtreecommitdiff
path: root/tinyusb/class
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-03-26 13:45:14 +0700
committerhathach <[email protected]>2013-03-26 13:45:14 +0700
commit205a21ff045087214afebd593134ed325138e6fd (patch)
tree21576692a0c2688274e4215b298fc5e81a216598 /tinyusb/class
parent3c767e9f44ff6e430f85f7fae7c38ee8aca3b6e2 (diff)
add code for hidh close
refractor the full configure descriptor parsing in enum task
Diffstat (limited to 'tinyusb/class')
-rw-r--r--tinyusb/class/hid_host.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/tinyusb/class/hid_host.c b/tinyusb/class/hid_host.c
index 6665d2320..723fd64f1 100644
--- a/tinyusb/class/hid_host.c
+++ b/tinyusb/class/hid_host.c
@@ -73,6 +73,18 @@ bool tusbh_hid_keyboard_is_supported(uint8_t dev_addr)
return tusbh_device_is_configured(dev_addr) && pipehandle_is_valid(keyboard_data[dev_addr-1].pipe_hdl);
}
+tusb_error_t hidh_keyboard_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const *p_endpoint_desc)
+{
+ hidh_keyboard_info_t *p_keyboard = get_kbd_data(dev_addr);
+
+ p_keyboard->pipe_hdl = hcd_pipe_open(dev_addr, p_endpoint_desc, TUSB_CLASS_HID);
+ p_keyboard->report_size = p_endpoint_desc->wMaxPacketSize.size; // TODO get size from report descriptor
+
+ ASSERT (pipehandle_is_valid(p_keyboard->pipe_hdl), TUSB_ERROR_HCD_FAILED);
+
+ return TUSB_ERROR_NONE;
+}
+
tusb_error_t tusbh_hid_keyboard_get_report(uint8_t dev_addr, uint8_t instance_num, tusb_keyboard_report_t * const report)
{
//------------- parameters validation -------------//
@@ -89,6 +101,16 @@ tusb_error_t tusbh_hid_keyboard_get_report(uint8_t dev_addr, uint8_t instance_nu
return TUSB_ERROR_NONE;
}
+void hidh_keyboard_close(uint8_t dev_addr)
+{
+ pipe_handle_t pipe_hdl = keyboard_data[dev_addr-1].pipe_hdl;
+ if ( pipehandle_is_valid(pipe_hdl) )
+ {
+ memclr_(&keyboard_data[dev_addr-1], sizeof(hidh_keyboard_info_t));
+ ASSERT_INT( TUSB_ERROR_NONE, hcd_pipe_close(pipe_hdl), (void) 0 );
+ }
+}
+
#endif
//--------------------------------------------------------------------+
@@ -109,18 +131,6 @@ void hidh_init(void)
#endif
}
-tusb_error_t hidh_keyboard_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const *p_endpoint_desc)
-{
- hidh_keyboard_info_t *p_keyboard = get_kbd_data(dev_addr);
-
- p_keyboard->pipe_hdl = hcd_pipe_open(dev_addr, p_endpoint_desc, TUSB_CLASS_HID);
- p_keyboard->report_size = p_endpoint_desc->wMaxPacketSize.size; // TODO get size from report descriptor
-
- ASSERT (pipehandle_is_valid(p_keyboard->pipe_hdl), TUSB_ERROR_HCD_FAILED);
-
- return TUSB_ERROR_NONE;
-}
-
tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t const *p_interface_desc, uint16_t *p_length)
{
uint8_t const *p_desc = (uint8_t const *) p_interface_desc;
@@ -174,7 +184,7 @@ void hidh_isr(pipe_handle_t pipe_hdl, tusb_bus_event_t event)
void hidh_close(uint8_t dev_addr)
{
#if TUSB_CFG_HOST_HID_KEYBOARD
-// hidh_keyboard_close(dev_addr);
+ hidh_keyboard_close(dev_addr);
#endif
#if TUSB_CFG_HOST_HID_MOUSE