remove obsolete TUSB_CFG_HOST_HID_KEYBOARD_ENDPOINT_SIZE

temporarily ignore test for hid_host.c due to ceedling linking issue with weak symbol
implement hidh_open_subtask driver to subclass open
rename hidh_keyboard_install to hidh_keyboard_open_subtask
This commit is contained in:
hathach
2013-03-25 16:02:24 +07:00
parent 45db7b4a53
commit c026a9f2e0
9 changed files with 65 additions and 27 deletions

View File

@@ -75,7 +75,33 @@ void hidh_init(void)
tusb_error_t hidh_open_subtask(uint8_t dev_addr, uint8_t const *descriptor, uint16_t *p_length)
{
return TUSB_ERROR_NONE;
tusb_descriptor_interface_t* p_interface = (tusb_descriptor_interface_t*) descriptor;
if (p_interface->bInterfaceSubClass == HID_SUBCLASS_BOOT)
{
switch(p_interface->bInterfaceProtocol)
{
#if TUSB_CFG_HOST_HID_KEYBOARD
case HID_PROTOCOL_KEYBOARD:
return hidh_keyboard_open_subtask(dev_addr, descriptor, p_length);
break;
#endif
#if TUSB_CFG_HOST_HID_MOUSE
case HID_PROTOCOL_MOUSE:
return hidh_keyboard_open_subtask(dev_addr, descriptor, p_length);
break;
#endif
default: // unknown protocol --> skip this interface
*p_length = p_interface->bLength;
return TUSB_ERROR_NONE;
}
}else
{
// open generic
*p_length = p_interface->bLength;
return TUSB_ERROR_NONE;
}
}
void hidh_isr(pipe_handle_t pipe_hdl, tusb_bus_event_t event)

View File

@@ -97,7 +97,7 @@ void hidh_keyboard_init(void)
memclr_(&keyboard_data, sizeof(hidh_keyboard_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
}
tusb_error_t hidh_keyboard_install(uint8_t const dev_addr, uint8_t const *descriptor)
tusb_error_t hidh_keyboard_open_subtask(uint8_t dev_addr, uint8_t const *descriptor, uint16_t *p_length)
{
keyboard_data[dev_addr-1].instance_count++;

View File

@@ -52,7 +52,7 @@
#define _TUSB_HID_HOST_KEYBOARD_H_
#include "common/common.h"
#include "usbh.h" // TODO refractor
#include "host/usbh.h" // TODO refractor
#include "hid.h"
#ifdef __cplusplus
@@ -87,8 +87,10 @@ typedef struct {
keyboard_interface_t instance[TUSB_CFG_HOST_HID_KEYBOARD_NO_INSTANCES_PER_DEVICE];
} hidh_keyboard_info_t;
void hidh_keyboard_init(void);
void hidh_keyboard_init(void);
tusb_error_t hidh_keyboard_install(uint8_t dev_addr, uint8_t const *descriptor) ATTR_WARN_UNUSED_RESULT;
tusb_error_t hidh_keyboard_open_subtask(uint8_t dev_addr, uint8_t const *descriptor, uint16_t *p_length) ATTR_WARN_UNUSED_RESULT;
void hidh_keyboard_close(uint8_t dev_addr);
#endif