8000 clean up · sparkfun/circuitpython@6ddd858 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6ddd858

Browse files
committed
clean up
1 parent 1e524f1 commit 6ddd858

File tree

2 files changed

+56
-50
lines changed

2 files changed

+56
-50
lines changed

ports/nrf/common-hal/usb_hid/__init__.c

Lines changed: 36 additions & 36 deletions
10000
Original file line numberDiff line numberDiff line change
@@ -66,67 +66,67 @@ static uint8_t digitizer_report_buffer[USB_HID_REPORT_LENGTH_DIGITIZER];
6666
usb_hid_device_obj_t usb_hid_devices[] = {
6767
#if USB_HID_DEVICE_KEYBOARD
6868
{
69-
.base = { .type = &usb_hid_device_type },
70-
.report_buffer = keyboard_report_buffer,
71-
.report_id = USB_HID_REPORT_ID_KEYBOARD,
72-
.report_length = USB_HID_REPORT_LENGTH_KEYBOARD,
73-
.usage_page = HID_USAGE_PAGE_DESKTOP,
74-
.usage = HID_USAGE_DESKTOP_KEYBOARD,
69+
.base = { .type = &usb_hid_device_type } ,
70+
.report_buffer = keyboard_report_buffer ,
71+
.report_id = USB_HID_REPORT_ID_KEYBOARD ,
72+
.report_length = USB_HID_REPORT_LENGTH_KEYBOARD ,
73+
.usage_page = HID_USAGE_PAGE_DESKTOP ,
74+
.usage = HID_USAGE_DESKTOP_KEYBOARD ,
7575
},
7676
#endif
7777

7878
#if USB_HID_DEVICE_MOUSE
7979
{
80-
.base = { .type = &usb_hid_device_type },
81-
.report_buffer = mouse_report_buffer,
82-
.report_id = USB_HID_REPORT_ID_MOUSE,
83-
.report_length = USB_HID_REPORT_LENGTH_MOUSE,
84-
.usage_page = HID_USAGE_PAGE_DESKTOP,
85-
.usage = HID_USAGE_DESKTOP_MOUSE,
80+
.base = { .type = &usb_hid_device_type } ,
81+
.report_buffer = mouse_report_buffer ,
82+
.report_id = USB_HID_REPORT_ID_MOUSE ,
83+
.report_length = USB_HID_REPORT_LENGTH_MOUSE ,
84+
.usage_page = HID_USAGE_PAGE_DESKTOP ,
85+
.usage = HID_USAGE_DESKTOP_MOUSE ,
8686
},
8787
#endif
8888

8989
#if USB_HID_DEVICE_CONSUMER
9090
{
91-
.base = { .type = &usb_hid_device_type },
92-
.report_buffer = consumer_report_buffer,
93-
.report_id = USB_HID_REPORT_ID_CONSUMER,
94-
.report_length = USB_HID_REPORT_LENGTH_CONSUMER,
95-
.usage_page = HID_USAGE_PAGE_CONSUMER,
96-
.usage = HID_USAGE_CONSUMER_CONTROL,
91+
.base = { .type = &usb_hid_device_type } ,
92+
.report_buffer = consumer_report_buffer ,
93+
.report_id = USB_HID_REPORT_ID_CONSUMER ,
94+
.report_length = USB_HID_REPORT_LENGTH_CONSUMER ,
95+
.usage_page = HID_USAGE_PAGE_CONSUMER ,
96+
.usage = HID_USAGE_CONSUMER_CONTROL ,
9797
},
9898
#endif
9999

100100
#if USB_HID_DEVICE_SYS_CONTROL
101101
{
102-
.base = { .type = &usb_hid_device_type },
103-
.report_buffer = sys_control_report_buffer,
104-
.report_id = USB_HID_REPORT_ID_SYS_CONTROL,
105-
.report_length = USB_HID_REPORT_LENGTH_SYS_CONTROL,
106-
.usage_page = HID_USAGE_PAGE_DESKTOP,
107-
.usage = HID_USAGE_DESKTOP_SYSTEM_CONTROL,
102+
.base = { .type = &usb_hid_device_type } ,
103+
.report_buffer = sys_control_report_buffer ,
104+
.report_id = USB_HID_REPORT_ID_SYS_CONTROL ,
105+
.report_length = USB_HID_REPORT_LENGTH_SYS_CONTROL ,
106+
.usage_page = HID_USAGE_PAGE_DESKTOP ,
107+
.usage = HID_USAGE_DESKTOP_SYSTEM_CONTROL ,
108108
},
109109
#endif
110110

111111
#if USB_HID_DEVICE_GAMEPAD
112112
{
113-
.base = { .type = &usb_hid_device_type },
114-
.report_buffer = gamepad_report_buffer,
115-
.report_id = USB_HID_REPORT_ID_GAMEPAD,
116-
.report_length = USB_HID_REPORT_LENGTH_GAMEPAD,
117-
.usage_page = HID_USAGE_PAGE_DESKTOP,
118-
.usage = HID_USAGE_DESKTOP_GAMEPAD,
113+
.base = { .type = &usb_hid_device_type } ,
114+
.report_buffer = gamepad_report_buffer ,
115+
.report_id = USB_HID_REPORT_ID_GAMEPAD ,
116+
.report_length = USB_HID_REPORT_LENGTH_GAMEPAD ,
117+
.usage_page = HID_USAGE_PAGE_DESKTOP ,
118+
.usage = HID_USAGE_DESKTOP_GAMEPAD ,
119119
},
120120
#endif
121121

122122
#if USB_HID_DEVICE_DIGITIZER
123123
{
124-
.base = { .type = &usb_hid_device_type },
125-
.report_buffer = digitizer_report_buffer,
126-
.report_id = USB_HID_REPORT_ID_DIGITIZER,
127-
.report_length = USB_HID_REPORT_LENGTH_DIGITIZER,
128-
.usage_page = 0x0D,
129-
.usage = 0x02,
124+
.base = { .type = &usb_hid_device_type } ,
125+
.report_buffer = digitizer_report_buffer ,
126+
.report_id = USB_HID_REPORT_ID_DIGITIZER ,
127+
.report_length = USB_HID_REPORT_LENGTH_DIGITIZER ,
128+
.usage_page = 0x0D ,
129+
.usage = 0x02 ,
130130
},
131131
#endif
132132
};

ports/nrf/usb/usb_desc.c

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,23 @@
3737
#define USB_PID 0x802A
3838

3939
/*------------- Interface Numbering -------------*/
40-
#define ITF_NUM_CDC 0
41-
#define ITF_NUM_MSC 2
42-
#define ITF_NUM_HID_GEN 3
43-
#define ITF_TOTAL 4
44-
40+
enum {
41+
ITF_NUM_CDC = 0 ,
42+
ITF_NUM_CDC_DATA ,
43+
ITF_NUM_MSC ,
44+
ITF_NUM_HID_GEN ,
45+
ITF_NUM_TOTAL
46+
};
4547

46-
#define ITF_STR_CDC 4
47-
#define ITF_STR_MSC 5
48-
#define ITF_STR_HID 6
48+
enum {
49+
ITF_STR_LANGUAGE = 0 ,
50+
ITF_STR_MANUFACTURER ,
51+
ITF_STR_PRODUCT ,
52+
ITF_STR_SERIAL ,
53+
ITF_STR_CDC ,
54+
ITF_STR_MSC ,
55+
ITF_STR_HID
56+
};
4957

5058
/*------------- Endpoint Numbering & Size -------------*/
5159
#define _EP_IN(x) (0x80 | (x))
@@ -169,10 +177,8 @@ usb_desc_cfg_t const usb_desc_cfg =
169177
{
170178
.bLength = sizeof(tusb_desc_configuration_t),
171179
.bDescriptorType = TUSB_DESC_CONFIGURATION,
172-
173180
.wTotalLength = sizeof(usb_desc_cfg_t),
174-
.bNumInterfaces = ITF_TOTAL,
175-
181+
.bNumInterfaces = ITF_NUM_TOTAL,
176182
.bConfigurationValue = 1,
177183
.iConfiguration = 0x00,
178184
.bmAttributes = TUSB_DESC_CONFIG_ATT_BUS_POWER,
@@ -371,9 +377,9 @@ usb_desc_cfg_t const usb_desc_cfg =
371377
// tud_desc_set is required by tinyusb stack
87D9
372378
tud_desc_set_t tud_desc_set =
373379
{
374-
.device = (uint8_t const*) &usb_desc_dev,
375-
.config = (uint8_t const*) &usb_desc_cfg,
376-
.string_arr = (uint8_t const **) string_desc_arr,
380+
.device = &usb_desc_dev,
381+
.config = &usb_desc_cfg,
382+
.string_arr = (uint8_t const **) string_desc_arr,
377383
.string_count = sizeof(string_desc_arr)/sizeof(string_desc_arr[0]),
378384

379385
.hid_report =

0 commit comments

Comments
 (0)
0