summaryrefslogtreecommitdiff
path: root/tinyusb
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-10-27 21:33:06 +0700
committerhathach <[email protected]>2013-10-27 21:33:06 +0700
commitd9250260896e556c4707df5e9afccbd9dcc16d08 (patch)
tree8bcece3b94cf4e6902cd613ac0a3817145c1fb62 /tinyusb
parenta98bae0d1908625852feb32406c59cec60d3f403 (diff)
make device keyboard buildable & runnable with ea4357
Diffstat (limited to 'tinyusb')
-rw-r--r--tinyusb/class/hid_device.c199
-rw-r--r--tinyusb/mcu_capacity.h2
2 files changed, 101 insertions, 100 deletions
diff --git a/tinyusb/class/hid_device.c b/tinyusb/class/hid_device.c
index d779e4117..e2950b093 100644
--- a/tinyusb/class/hid_device.c
+++ b/tinyusb/class/hid_device.c
@@ -67,102 +67,6 @@ STATIC_ hidd_interface_t keyboard_intf =
};
#endif
-tusb_error_t hidd_control_request(uint8_t coreid, tusb_control_request_t const * p_request)
-{
-#if TUSB_CFG_DEVICE_HID_KEYBOARD
- if (p_request->bmRequestType.type == TUSB_REQUEST_TYPE_STANDARD) // standard request to hid
- {
- uint8_t const desc_type = u16_high_u8(p_request->wValue);
- uint8_t const desc_index = u16_low_u8 (p_request->wValue);
-
- if ( p_request->bRequest == TUSB_REQUEST_GET_DESCRIPTOR &&
- desc_type == HID_DESC_TYPE_REPORT)
- {
- dcd_pipe_control_write(coreid, keyboard_intf.p_report_desc,
- keyboard_intf.p_hid_desc->wReportLength);
- }else
- {
- ASSERT_STATUS(TUSB_ERROR_FAILED);
- }
- }else if ( p_request->wIndex == keyboard_intf.p_interface_desc->bInterfaceNumber) // class request
- {
- switch(p_request->bRequest)
- {
- case HID_REQUEST_CONTROL_SET_IDLE:
- // TODO hidd idle rate, no data phase
- break;
-
- case HID_REQUEST_CONTROL_SET_REPORT:
- // TODO hidd set report, has data phase
-// TODO verify data read from control pipe
-// ; uint8_t hehe[10]= { 0 };
-// dcd_pipe_control_read(coreid, hehe, p_request->wLength);
- break;
-
- case HID_REQUEST_CONTROL_GET_REPORT:
- case HID_REQUEST_CONTROL_GET_IDLE:
- case HID_REQUEST_CONTROL_GET_PROTOCOL:
- case HID_REQUEST_CONTROL_SET_PROTOCOL:
- default:
- ASSERT_STATUS(TUSB_ERROR_NOT_SUPPORTED_YET);
- return TUSB_ERROR_NOT_SUPPORTED_YET;
- }
- }else
- {
- ASSERT_STATUS(TUSB_ERROR_FAILED);
- }
-#endif
-
- return TUSB_ERROR_NONE;
-}
-
-tusb_error_t hidd_init(uint8_t coreid, tusb_descriptor_interface_t const * p_interface_desc, uint16_t *p_length)
-{
- uint8_t const *p_desc = (uint8_t const *) p_interface_desc;
-
- //------------- HID descriptor -------------//
- p_desc += p_desc[DESCRIPTOR_OFFSET_LENGTH];
- tusb_hid_descriptor_hid_t const *p_desc_hid = (tusb_hid_descriptor_hid_t const *) p_desc;
- ASSERT_INT(HID_DESC_TYPE_HID, p_desc_hid->bDescriptorType, TUSB_ERROR_HIDD_DESCRIPTOR_INTERFACE);
-
- //------------- Endpoint Descriptor -------------//
- p_desc += p_desc[DESCRIPTOR_OFFSET_LENGTH];
- tusb_descriptor_endpoint_t const *p_desc_endpoint = (tusb_descriptor_endpoint_t const *) p_desc;
- ASSERT_INT(TUSB_DESC_TYPE_ENDPOINT, p_desc_endpoint->bDescriptorType, TUSB_ERROR_HIDD_DESCRIPTOR_INTERFACE);
-
- if (p_interface_desc->bInterfaceSubClass == HID_SUBCLASS_BOOT)
- {
- switch(p_interface_desc->bInterfaceProtocol)
- {
- #if TUSB_CFG_DEVICE_HID_KEYBOARD
- case HID_PROTOCOL_KEYBOARD:
- ASSERT_STATUS( dcd_pipe_open(coreid, p_desc_endpoint) );
- break;
- #endif
-
- #if TUSB_CFG_DEVICE_HID_MOUSE
- case HID_PROTOCOL_MOUSE:
- ASSERT_STATUS( hidd_interface_init(p_interface_desc,
- app_tusb_mouse_desc_report, p_desc_hid->wReportLength,
- hidd_mouse_buffer , sizeof(hidd_mouse_buffer)) );
- break;
- #endif
-
- default: // TODO unknown, unsupported protocol --> skip this interface
- return TUSB_ERROR_HIDD_DESCRIPTOR_INTERFACE;
- }
- *p_length = sizeof(tusb_descriptor_interface_t) + sizeof(tusb_hid_descriptor_hid_t) + sizeof(tusb_descriptor_endpoint_t);
- }else
- {
- // open generic
- *p_length = 0;
- return TUSB_ERROR_HIDD_DESCRIPTOR_INTERFACE;
- }
-
-
- return TUSB_ERROR_NONE;
-}
-
#if defined(CAP_DEVICE_ROMDRIVER) && TUSB_CFG_DEVICE_USE_ROM_DRIVER
#include "device/dcd_nxp_romdriver.h" // TODO remove rom driver dependency
@@ -256,8 +160,7 @@ tusb_error_t hidd_configured(void)
return TUSB_ERROR_NONE;
}
-
-tusb_error_t hidd_init(tusb_descriptor_interface_t const * p_interface_desc, uint16_t *p_length)
+tusb_error_t hidd_init(uint8_t coreid, tusb_descriptor_interface_t const * p_interface_desc, uint16_t *p_length)
{
uint8_t const *p_desc = (uint8_t const *) p_interface_desc;
@@ -266,7 +169,7 @@ tusb_error_t hidd_init(tusb_descriptor_interface_t const * p_interface_desc, uin
tusb_hid_descriptor_hid_t const *p_desc_hid = (tusb_hid_descriptor_hid_t const *) p_desc;
ASSERT_INT(HID_DESC_TYPE_HID, p_desc_hid->bDescriptorType, TUSB_ERROR_HIDD_DESCRIPTOR_INTERFACE);
- if (p_interface_desc->bInterfaceSubClass == HID_SUBCLASS_BOOT)
+ if (p_interface_desc->bInterfaceSubClass == HID_SUBCLASS_BOOT)
{
switch(p_interface_desc->bInterfaceProtocol)
{
@@ -439,6 +342,104 @@ ErrorCode_t HID_EpOut_Hdlr (USBD_HANDLE_T hUsb, void* data, uint32_t event)
}
return LPC_OK;
}
+
+#else // not use the rom driver
+
+tusb_error_t hidd_control_request(uint8_t coreid, tusb_control_request_t const * p_request)
+{
+#if TUSB_CFG_DEVICE_HID_KEYBOARD
+ if (p_request->bmRequestType_bit.type == TUSB_REQUEST_TYPE_STANDARD) // standard request to hid
+ {
+ uint8_t const desc_type = u16_high_u8(p_request->wValue);
+ uint8_t const desc_index = u16_low_u8 (p_request->wValue);
+
+ if ( p_request->bRequest == TUSB_REQUEST_GET_DESCRIPTOR &&
+ desc_type == HID_DESC_TYPE_REPORT)
+ {
+ dcd_pipe_control_write(coreid, keyboard_intf.p_report_desc,
+ keyboard_intf.p_hid_desc->wReportLength);
+ }else
+ {
+ ASSERT_STATUS(TUSB_ERROR_FAILED);
+ }
+ }else if ( p_request->wIndex == keyboard_intf.p_interface_desc->bInterfaceNumber) // class request
+ {
+ switch(p_request->bRequest)
+ {
+ case HID_REQUEST_CONTROL_SET_IDLE:
+ // TODO hidd idle rate, no data phase
+ break;
+
+ case HID_REQUEST_CONTROL_SET_REPORT:
+ // TODO hidd set report, has data phase
+// TODO verify data read from control pipe
+// ; uint8_t hehe[10]= { 0 };
+// dcd_pipe_control_read(coreid, hehe, p_request->wLength);
+ break;
+
+ case HID_REQUEST_CONTROL_GET_REPORT:
+ case HID_REQUEST_CONTROL_GET_IDLE:
+ case HID_REQUEST_CONTROL_GET_PROTOCOL:
+ case HID_REQUEST_CONTROL_SET_PROTOCOL:
+ default:
+ ASSERT_STATUS(TUSB_ERROR_NOT_SUPPORTED_YET);
+ return TUSB_ERROR_NOT_SUPPORTED_YET;
+ }
+ }else
+ {
+ ASSERT_STATUS(TUSB_ERROR_FAILED);
+ }
+#endif
+
+ return TUSB_ERROR_NONE;
+}
+
+tusb_error_t hidd_init(uint8_t coreid, tusb_descriptor_interface_t const * p_interface_desc, uint16_t *p_length)
+{
+ uint8_t const *p_desc = (uint8_t const *) p_interface_desc;
+
+ //------------- HID descriptor -------------//
+ p_desc += p_desc[DESCRIPTOR_OFFSET_LENGTH];
+ tusb_hid_descriptor_hid_t const *p_desc_hid = (tusb_hid_descriptor_hid_t const *) p_desc;
+ ASSERT_INT(HID_DESC_TYPE_HID, p_desc_hid->bDescriptorType, TUSB_ERROR_HIDD_DESCRIPTOR_INTERFACE);
+
+ //------------- Endpoint Descriptor -------------//
+ p_desc += p_desc[DESCRIPTOR_OFFSET_LENGTH];
+ tusb_descriptor_endpoint_t const *p_desc_endpoint = (tusb_descriptor_endpoint_t const *) p_desc;
+ ASSERT_INT(TUSB_DESC_TYPE_ENDPOINT, p_desc_endpoint->bDescriptorType, TUSB_ERROR_HIDD_DESCRIPTOR_INTERFACE);
+
+ if (p_interface_desc->bInterfaceSubClass == HID_SUBCLASS_BOOT)
+ {
+ switch(p_interface_desc->bInterfaceProtocol)
+ {
+ #if TUSB_CFG_DEVICE_HID_KEYBOARD
+ case HID_PROTOCOL_KEYBOARD:
+ ASSERT_STATUS( dcd_pipe_open(coreid, p_desc_endpoint) );
+ break;
+ #endif
+
+ #if TUSB_CFG_DEVICE_HID_MOUSE
+ case HID_PROTOCOL_MOUSE:
+ ASSERT_STATUS( hidd_interface_init(p_interface_desc,
+ app_tusb_mouse_desc_report, p_desc_hid->wReportLength,
+ hidd_mouse_buffer , sizeof(hidd_mouse_buffer)) );
+ break;
+ #endif
+
+ default: // TODO unknown, unsupported protocol --> skip this interface
+ return TUSB_ERROR_HIDD_DESCRIPTOR_INTERFACE;
+ }
+ *p_length = sizeof(tusb_descriptor_interface_t) + sizeof(tusb_hid_descriptor_hid_t) + sizeof(tusb_descriptor_endpoint_t);
+ }else
+ {
+ // open generic
+ *p_length = 0;
+ return TUSB_ERROR_HIDD_DESCRIPTOR_INTERFACE;
+ }
+
+
+ return TUSB_ERROR_NONE;
+}
#endif
#endif
diff --git a/tinyusb/mcu_capacity.h b/tinyusb/mcu_capacity.h
index 958a71f01..56ac850a0 100644
--- a/tinyusb/mcu_capacity.h
+++ b/tinyusb/mcu_capacity.h
@@ -78,7 +78,7 @@
#define CAP_MODE_HOST
#endif
-#if MCU == MCU_LPC43XX || MCU == MCU_LPC18XX || MCU == MCU_LPC11UXX || MCU == MCU_LPC13UXX
+#if MCU == MCU_LPC43XX || MCU == MCU_LPC18XX || MCU == MCU_LPC11UXX || MCU == MCU_LPC13XX_12ADC
#define CAP_DEVICE_ROMDRIVER
#endif