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

View File

@@ -250,8 +250,8 @@ OSAL_TASK_DECLARE(usbh_enumeration_task)
// for OSAL_NONE local variable won't retain value after blocking service sem_wait/queue_recv
static uint8_t new_addr;
static uint8_t configure_selected = 1;
static uint8_t *p_desc = NULL;
static uint8_t configure_selected = 1; // TODO move
static uint8_t *p_desc = NULL; // TODO move
OSAL_TASK_LOOP_BEGIN
@@ -385,9 +385,9 @@ OSAL_TASK_DECLARE(usbh_enumeration_task)
TASK_ASSERT( false ); // corrupted data, abort enumeration
}
// supported class
else if ( class_code < TUSB_CLASS_MAX_CONSEC_NUMBER && usbh_class_drivers[class_code].open_subtask)
else if ( class_code < TUSB_CLASS_MAX_CONSEC_NUMBER && usbh_class_drivers[class_code].open_subtask) // TODO custom class
{
uint16_t length;
uint16_t length=0;
OSAL_SUBTASK_INVOKED_AND_WAIT ( // parameters in task/sub_task must be static storage (static or global)
usbh_class_drivers[ ((tusb_descriptor_interface_t*) p_desc)->bInterfaceClass ].open_subtask(new_addr, p_desc, &length) );
p_desc += length;

View File

@@ -126,11 +126,6 @@
//------------- HID CLASS -------------//
#define HOST_CLASS_HID ( TUSB_CFG_HOST_HID_KEYBOARD )
#if TUSB_CFG_HOST_HID_KEYBOARD
#if !defined(TUSB_CFG_HOST_HID_KEYBOARD_ENDPOINT_SIZE)
#define TUSB_CFG_HOST_HID_KEYBOARD_ENDPOINT_SIZE 64
#warning TUSB_CFG_HOST_HID_KEYBOARD_ENDPOINT_SIZE is not defined, default value is 64
#endif
#if !defined(TUSB_CFG_HOST_HID_KEYBOARD_NO_INSTANCES_PER_DEVICE)
#define TUSB_CFG_HOST_HID_KEYBOARD_NO_INSTANCES_PER_DEVICE 1
#endif