summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <thach@tinyusb.org>2018-08-01 08:20:20 +0700
committerhathach <thach@tinyusb.org>2018-08-01 08:20:20 +0700
commit6ddd8583da6993c61f56ec6cbb908fac16924acd (patch)
treedfabae767f1db051e8060fc83097ad4c1746c700
parent1e524f1b9800b4d734e0c3db0fb6434176c4d7a8 (diff)
clean up
-rw-r--r--ports/nrf/common-hal/usb_hid/__init__.c72
-rw-r--r--ports/nrf/usb/usb_desc.c34
2 files changed, 56 insertions, 50 deletions
diff --git a/ports/nrf/common-hal/usb_hid/__init__.c b/ports/nrf/common-hal/usb_hid/__init__.c
index 0085d688e..00fc8bd00 100644
--- a/ports/nrf/common-hal/usb_hid/__init__.c
+++ b/ports/nrf/common-hal/usb_hid/__init__.c
@@ -66,67 +66,67 @@ static uint8_t digitizer_report_buffer[USB_HID_REPORT_LENGTH_DIGITIZER];
usb_hid_device_obj_t usb_hid_devices[] = {
#if USB_HID_DEVICE_KEYBOARD
{
- .base = { .type = &usb_hid_device_type },
- .report_buffer = keyboard_report_buffer,
- .report_id = USB_HID_REPORT_ID_KEYBOARD,
- .report_length = USB_HID_REPORT_LENGTH_KEYBOARD,
- .usage_page = HID_USAGE_PAGE_DESKTOP,
- .usage = HID_USAGE_DESKTOP_KEYBOARD,
+ .base = { .type = &usb_hid_device_type } ,
+ .report_buffer = keyboard_report_buffer ,
+ .report_id = USB_HID_REPORT_ID_KEYBOARD ,
+ .report_length = USB_HID_REPORT_LENGTH_KEYBOARD ,
+ .usage_page = HID_USAGE_PAGE_DESKTOP ,
+ .usage = HID_USAGE_DESKTOP_KEYBOARD ,
},
#endif
#if USB_HID_DEVICE_MOUSE
{
- .base = { .type = &usb_hid_device_type },
- .report_buffer = mouse_report_buffer,
- .report_id = USB_HID_REPORT_ID_MOUSE,
- .report_length = USB_HID_REPORT_LENGTH_MOUSE,
- .usage_page = HID_USAGE_PAGE_DESKTOP,
- .usage = HID_USAGE_DESKTOP_MOUSE,
+ .base = { .type = &usb_hid_device_type } ,
+ .report_buffer = mouse_report_buffer ,
+ .report_id = USB_HID_REPORT_ID_MOUSE ,
+ .report_length = USB_HID_REPORT_LENGTH_MOUSE ,
+ .usage_page = HID_USAGE_PAGE_DESKTOP ,
+ .usage = HID_USAGE_DESKTOP_MOUSE ,
},
#endif
#if USB_HID_DEVICE_CONSUMER
{
- .base = { .type = &usb_hid_device_type },
- .report_buffer = consumer_report_buffer,
- .report_id = USB_HID_REPORT_ID_CONSUMER,
- .report_length = USB_HID_REPORT_LENGTH_CONSUMER,
- .usage_page = HID_USAGE_PAGE_CONSUMER,
- .usage = HID_USAGE_CONSUMER_CONTROL,
+ .base = { .type = &usb_hid_device_type } ,
+ .report_buffer = consumer_report_buffer ,
+ .report_id = USB_HID_REPORT_ID_CONSUMER ,
+ .report_length = USB_HID_REPORT_LENGTH_CONSUMER ,
+ .usage_page = HID_USAGE_PAGE_CONSUMER ,
+ .usage = HID_USAGE_CONSUMER_CONTROL ,
},
#endif
#if USB_HID_DEVICE_SYS_CONTROL
{
- .base = { .type = &usb_hid_device_type },
- .report_buffer = sys_control_report_buffer,
- .report_id = USB_HID_REPORT_ID_SYS_CONTROL,
- .report_length = USB_HID_REPORT_LENGTH_SYS_CONTROL,
- .usage_page = HID_USAGE_PAGE_DESKTOP,
- .usage = HID_USAGE_DESKTOP_SYSTEM_CONTROL,
+ .base = { .type = &usb_hid_device_type } ,
+ .report_buffer = sys_control_report_buffer ,
+ .report_id = USB_HID_REPORT_ID_SYS_CONTROL ,
+ .report_length = USB_HID_REPORT_LENGTH_SYS_CONTROL ,
+ .usage_page = HID_USAGE_PAGE_DESKTOP ,
+ .usage = HID_USAGE_DESKTOP_SYSTEM_CONTROL ,
},
#endif
#if USB_HID_DEVICE_GAMEPAD
{
- .base = { .type = &usb_hid_device_type },
- .report_buffer = gamepad_report_buffer,
- .report_id = USB_HID_REPORT_ID_GAMEPAD,
- .report_length = USB_HID_REPORT_LENGTH_GAMEPAD,
- .usage_page = HID_USAGE_PAGE_DESKTOP,
- .usage = HID_USAGE_DESKTOP_GAMEPAD,
+ .base = { .type = &usb_hid_device_type } ,
+ .report_buffer = gamepad_report_buffer ,
+ .report_id = USB_HID_REPORT_ID_GAMEPAD ,
+ .report_length = USB_HID_REPORT_LENGTH_GAMEPAD ,
+ .usage_page = HID_USAGE_PAGE_DESKTOP ,
+ .usage = HID_USAGE_DESKTOP_GAMEPAD ,
},
#endif
#if USB_HID_DEVICE_DIGITIZER
{
- .base = { .type = &usb_hid_device_type },
- .report_buffer = digitizer_report_buffer,
- .report_id = USB_HID_REPORT_ID_DIGITIZER,
- .report_length = USB_HID_REPORT_LENGTH_DIGITIZER,
- .usage_page = 0x0D,
- .usage = 0x02,
+ .base = { .type = &usb_hid_device_type } ,
+ .report_buffer = digitizer_report_buffer ,
+ .report_id = USB_HID_REPORT_ID_DIGITIZER ,
+ .report_length = USB_HID_REPORT_LENGTH_DIGITIZER ,
+ .usage_page = 0x0D ,
+ .usage = 0x02 ,
},
#endif
};
diff --git a/ports/nrf/usb/usb_desc.c b/ports/nrf/usb/usb_desc.c
index 20557cc02..3f64956d2 100644
--- a/ports/nrf/usb/usb_desc.c
+++ b/ports/nrf/usb/usb_desc.c
@@ -37,15 +37,23 @@
#define USB_PID 0x802A
/*------------- Interface Numbering -------------*/
-#define ITF_NUM_CDC 0
-#define ITF_NUM_MSC 2
-#define ITF_NUM_HID_GEN 3
-#define ITF_TOTAL 4
-
+enum {
+ ITF_NUM_CDC = 0 ,
+ ITF_NUM_CDC_DATA ,
+ ITF_NUM_MSC ,
+ ITF_NUM_HID_GEN ,
+ ITF_NUM_TOTAL
+};
-#define ITF_STR_CDC 4
-#define ITF_STR_MSC 5
-#define ITF_STR_HID 6
+enum {
+ ITF_STR_LANGUAGE = 0 ,
+ ITF_STR_MANUFACTURER ,
+ ITF_STR_PRODUCT ,
+ ITF_STR_SERIAL ,
+ ITF_STR_CDC ,
+ ITF_STR_MSC ,
+ ITF_STR_HID
+};
/*------------- Endpoint Numbering & Size -------------*/
#define _EP_IN(x) (0x80 | (x))
@@ -169,10 +177,8 @@ usb_desc_cfg_t const usb_desc_cfg =
{
.bLength = sizeof(tusb_desc_configuration_t),
.bDescriptorType = TUSB_DESC_CONFIGURATION,
-
.wTotalLength = sizeof(usb_desc_cfg_t),
- .bNumInterfaces = ITF_TOTAL,
-
+ .bNumInterfaces = ITF_NUM_TOTAL,
.bConfigurationValue = 1,
.iConfiguration = 0x00,
.bmAttributes = TUSB_DESC_CONFIG_ATT_BUS_POWER,
@@ -371,9 +377,9 @@ usb_desc_cfg_t const usb_desc_cfg =
// tud_desc_set is required by tinyusb stack
tud_desc_set_t tud_desc_set =
{
- .device = (uint8_t const*) &usb_desc_dev,
- .config = (uint8_t const*) &usb_desc_cfg,
- .string_arr = (uint8_t const **) string_desc_arr,
+ .device = &usb_desc_dev,
+ .config = &usb_desc_cfg,
+ .string_arr = (uint8_t const **) string_desc_arr,
.string_count = sizeof(string_desc_arr)/sizeof(string_desc_arr[0]),
.hid_report =