Massdrop keyboard support (#3780)
[jackhill/qmk/firmware.git] / tmk_core / protocol / arm_atsam / usb / udi_device_conf.h
1 /*
2 Copyright 2018 Massdrop Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef _UDI_DEVICE_CONF_H_
19 #define _UDI_DEVICE_CONF_H_
20
21 #include "udi_device_epsize.h"
22 #include "usb_protocol.h"
23 #include "compiler.h"
24 #include "usb_protocol_hid.h"
25
26 #define DEVICE_CLASS 0
27 #define DEVICE_SUBCLASS 0
28 #define DEVICE_PROTOCOL 0
29
30 #define KBD
31
32 //#define MOUSE_ENABLE //rules.mk
33 #ifdef MOUSE_ENABLE
34 #define MOU
35 #endif
36
37 //#define EXTRAKEY_ENABLE //rules.mk
38 #ifdef EXTRAKEY_ENABLE
39 #define EXK
40 #endif
41
42 //#define RAW_ENABLE //rules.mk
43 #ifdef RAW_ENABLE
44 #define RAW
45 #endif
46
47 //#define CONSOLE_ENABLE //deferred implementation
48 //#ifdef CONSOLE_ENABLE
49 //#define CON
50 //#endif
51
52 //#define NKRO_ENABLE //rules.mk
53 #ifdef NKRO_ENABLE
54 #define NKRO
55 #endif
56
57 //#define MIDI_ENABLE //deferred implementation
58 //#ifdef MIDI_ENABLE
59 //#define MIDI
60 //#endif
61
62 //#define VIRTSER_ENABLE //rules.mk
63 #ifdef VIRTSER_ENABLE
64 #define CDC
65 //because CDC uses IAD (interface association descriptor
66 //per USB Interface Association Descriptor Device Class Code and Use Model 7/23/2003 Rev 1.0)
67 #undef DEVICE_CLASS
68 #define DEVICE_CLASS 0xEF
69 #undef DEVICE_SUBCLASS
70 #define DEVICE_SUBCLASS 0x02
71 #undef DEVICE_PROTOCOL
72 #define DEVICE_PROTOCOL 0x01
73 #endif
74
75 /* number of interfaces */
76 #define NEXT_INTERFACE_0 0
77
78 #ifdef KBD
79 #define KEYBOARD_INTERFACE NEXT_INTERFACE_0
80 #define NEXT_INTERFACE_1 (KEYBOARD_INTERFACE + 1)
81 #define UDI_HID_KBD_IFACE_NUMBER KEYBOARD_INTERFACE
82 #else
83 #define NEXT_INTERFACE_1 NEXT_INTERFACE_0
84 #endif
85
86 // It is important that the Raw HID interface is at a constant
87 // interface number, to support Linux/OSX platforms and chrome.hid
88 // If Raw HID is enabled, let it be always 1.
89 #ifdef RAW
90 #define RAW_INTERFACE NEXT_INTERFACE_1
91 #define NEXT_INTERFACE_2 (RAW_INTERFACE + 1)
92 #else
93 #define NEXT_INTERFACE_2 NEXT_INTERFACE_1
94 #endif
95
96 #ifdef MOU
97 #define MOUSE_INTERFACE NEXT_INTERFACE_2
98 #define UDI_HID_MOU_IFACE_NUMBER MOUSE_INTERFACE
99 #define NEXT_INTERFACE_3 (MOUSE_INTERFACE + 1)
100 #else
101 #define NEXT_INTERFACE_3 NEXT_INTERFACE_2
102 #endif
103
104 #ifdef EXK
105 #define EXTRAKEY_INTERFACE NEXT_INTERFACE_3
106 #define NEXT_INTERFACE_4 (EXTRAKEY_INTERFACE + 1)
107 #define UDI_HID_EXK_IFACE_NUMBER EXTRAKEY_INTERFACE
108 #else
109 #define NEXT_INTERFACE_4 NEXT_INTERFACE_3
110 #endif
111
112 #ifdef CON
113 #define CONSOLE_INTERFACE NEXT_INTERFACE_4
114 #define NEXT_INTERFACE_5 (CONSOLE_INTERFACE + 1)
115 #else
116 #define NEXT_INTERFACE_5 NEXT_INTERFACE_4
117 #endif
118
119 #ifdef NKRO
120 #define NKRO_INTERFACE NEXT_INTERFACE_5
121 #define NEXT_INTERFACE_6 (NKRO_INTERFACE + 1)
122 #define UDI_HID_NKRO_IFACE_NUMBER NKRO_INTERFACE
123 #else
124 #define NEXT_INTERFACE_6 NEXT_INTERFACE_5
125 #endif
126
127 #ifdef MIDI
128 #define AC_INTERFACE NEXT_INTERFACE_6
129 #define AS_INTERFACE (AC_INTERFACE + 1)
130 #define NEXT_INTERFACE_7 (AS_INTERFACE + 1)
131 #else
132 #define NEXT_INTERFACE_7 NEXT_INTERFACE_6
133 #endif
134
135 #ifdef CDC
136 #define CCI_INTERFACE NEXT_INTERFACE_7
137 #define CDI_INTERFACE (CCI_INTERFACE + 1)
138 #define NEXT_INTERFACE_8 (CDI_INTERFACE + 1)
139 #define CDC_STATUS_INTERFACE CCI_INTERFACE
140 #define CDC_DATA_INTERFACE CDI_INTERFACE
141 #else
142 #define NEXT_INTERFACE_8 NEXT_INTERFACE_7
143 #endif
144
145 /* nubmer of interfaces */
146 #define TOTAL_INTERFACES NEXT_INTERFACE_8
147 #define USB_DEVICE_NB_INTERFACE TOTAL_INTERFACES
148
149
150 // **********************************************************************
151 // Endopoint number and size
152 // **********************************************************************
153 #define USB_DEVICE_EP_CTRL_SIZE 8
154
155 #define NEXT_IN_EPNUM_0 1
156 #define NEXT_OUT_EPNUM_0 1
157
158 #ifdef KBD
159 #define KEYBOARD_IN_EPNUM NEXT_IN_EPNUM_0
160 #define UDI_HID_KBD_EP_IN KEYBOARD_IN_EPNUM
161 #define NEXT_IN_EPNUM_1 (KEYBOARD_IN_EPNUM + 1)
162 #define UDI_HID_KBD_EP_SIZE KEYBOARD_EPSIZE
163 #define KBD_POLLING_INTERVAL 10
164 #ifndef UDI_HID_KBD_STRING_ID
165 #define UDI_HID_KBD_STRING_ID 0
166 #endif
167 #else
168 #define NEXT_IN_EPNUM_1 NEXT_IN_EPNUM_0
169 #endif
170
171 #ifdef MOU
172 #define MOUSE_IN_EPNUM NEXT_IN_EPNUM_1
173 #define NEXT_IN_EPNUM_2 (MOUSE_IN_EPNUM + 1)
174 #define UDI_HID_MOU_EP_IN MOUSE_IN_EPNUM
175 #define UDI_HID_MOU_EP_SIZE MOUSE_EPSIZE
176 #define MOU_POLLING_INTERVAL 10
177 #ifndef UDI_HID_MOU_STRING_ID
178 #define UDI_HID_MOU_STRING_ID 0
179 #endif
180 #else
181 #define NEXT_IN_EPNUM_2 NEXT_IN_EPNUM_1
182 #endif
183
184 #ifdef EXK
185 #define EXTRAKEY_IN_EPNUM NEXT_IN_EPNUM_2
186 #define UDI_HID_EXK_EP_IN EXTRAKEY_IN_EPNUM
187 #define NEXT_IN_EPNUM_3 (EXTRAKEY_IN_EPNUM + 1)
188 #define UDI_HID_EXK_EP_SIZE EXTRAKEY_EPSIZE
189 #define EXTRAKEY_POLLING_INTERVAL 10
190 #ifndef UDI_HID_EXK_STRING_ID
191 #define UDI_HID_EXK_STRING_ID 0
192 #endif
193 #else
194 #define NEXT_IN_EPNUM_3 NEXT_IN_EPNUM_2
195 #endif
196
197 #ifdef RAW
198 #define RAW_IN_EPNUM NEXT_IN_EPNUM_3
199 #define UDI_HID_RAW_EP_IN RAW_IN_EPNUM
200 #define NEXT_IN_EPNUM_4 (RAW_IN_EPNUM + 1)
201 #define RAW_OUT_EPNUM NEXT_OUT_EPNUM_0
202 #define UDI_HID_RAW_EP_OUT RAW_OUT_EPNUM
203 #define NEXT_OUT_EPNUM_1 (RAW_OUT_EPNUM + 1)
204 #define RAW_POLLING_INTERVAL 1
205 #ifndef UDI_HID_RAW_STRING_ID
206 #define UDI_HID_RAW_STRING_ID 0
207 #endif
208 #else
209 #define NEXT_IN_EPNUM_4 NEXT_IN_EPNUM_3
210 #define NEXT_OUT_EPNUM_1 NEXT_OUT_EPNUM_0
211 #endif
212
213 #ifdef CON
214 #define CONSOLE_IN_EPNUM NEXT_IN_EPNUM_4
215 #define NEXT_IN_EPNUM_5 (CONSOLE_IN_EPNUM + 1)
216 #define CONSOLE_OUT_EPNUM NEXT_OUT_EPNUM_1
217 #define NEXT_OUT_EPNUM_2 (CONSOLE_OUT_EPNUM + 1)
218 #define CONSOLE_POLLING_INTERVAL 1
219 #else
220 #define NEXT_IN_EPNUM_5 NEXT_IN_EPNUM_4
221 #define NEXT_OUT_EPNUM_2 NEXT_OUT_EPNUM_1
222 #endif
223
224 #ifdef NKRO
225 #define NKRO_IN_EPNUM NEXT_IN_EPNUM_5
226 #define UDI_HID_NKRO_EP_IN NKRO_IN_EPNUM
227 #define NEXT_IN_EPNUM_6 (NKRO_IN_EPNUM + 1)
228 #define UDI_HID_NKRO_EP_SIZE NKRO_EPSIZE
229 #define NKRO_POLLING_INTERVAL 1
230 #ifndef UDI_HID_NKRO_STRING_ID
231 #define UDI_HID_NKRO_STRING_ID 0
232 #endif
233 #else
234 #define NEXT_IN_EPNUM_6 NEXT_IN_EPNUM_5
235 #endif
236
237 #ifdef MIDI
238 #define MIDI_STREAM_IN_EPNUM NEXT_IN_EPNUM_6
239 #define NEXT_IN_EPNUM_7 (MIDI_STREAM_IN_EPNUM + 1)
240 #define MIDI_STREAM_OUT_EPNUM NEXT_OUT_EPNUM_2
241 #define NEXT_OUT_EPNUM_3 (MIDI_STREAM_OUT_EPNUM + 1)
242 #define MIDI_POLLING_INTERVAL 5
243 #else
244 #define NEXT_IN_EPNUM_7 NEXT_IN_EPNUM_6
245 #define NEXT_OUT_EPNUM_3 NEXT_OUT_EPNUM_2
246 #endif
247
248 #ifdef CDC
249 #define CDC_NOTIFICATION_EPNUM NEXT_IN_EPNUM_7
250 #define CDC_ACM_ENDPOINT CDC_NOTIFICATION_EPNUM
251 #define CDC_TX_ENDPOINT (CDC_NOTIFICATION_EPNUM + 1)
252 #define NEXT_IN_EPNUM_8 (CDC_TX_ENDPOINT + 1)
253
254 #define CDC_OUT_EPNUM NEXT_OUT_EPNUM_3
255 #define CDC_RX_ENDPOINT CDC_OUT_EPNUM
256 #define NEXT_OUT_EPNUM_4 (CDC_OUT_EPNUM + 1)
257
258 #define CDC_ACM_SIZE CDC_NOTIFICATION_EPSIZE
259 #define CDC_RX_SIZE CDC_EPSIZE //KFSMOD was 64
260 #define CDC_TX_SIZE CDC_RX_SIZE
261 #define CDC_ACM_POLLING_INTERVAL 255
262 #define CDC_EP_INTERVAL_STATUS CDC_ACM_POLLING_INTERVAL
263 #define CDC_DATA_POLLING_INTERVAL 5
264 #define CDC_EP_INTERVAL_DATA CDC_DATA_POLLING_INTERVAL
265 #define CDC_STATUS_NAME L"Virtual Serial Port - Status"
266 #define CDC_DATA_NAME L"Virtual Serial Port - Data"
267 #else
268 #define NEXT_IN_EPNUM_8 NEXT_IN_EPNUM_7
269 #define NEXT_OUT_EPNUM_4 NEXT_OUT_EPNUM_3
270 #endif
271
272 #define TOTAL_OUT_EP NEXT_OUT_EPNUM_4
273 #define TOTAL_IN_EP NEXT_IN_EPNUM_8
274 #define USB_DEVICE_MAX_EP (max(NEXT_OUT_EPNUM_4, NEXT_IN_EPNUM_8))
275
276 #if USB_DEVICE_MAX_EP > 8
277 #error "There are not enough available endpoints to support all functions. Remove some in the rules.mk file.(MOUSEKEY, EXTRAKEY, CONSOLE, NKRO, MIDI, VIRTSER)"
278 #endif
279
280
281 // **********************************************************************
282 // KBD Descriptor structure and content
283 // **********************************************************************
284 #ifdef KBD
285
286 COMPILER_PACK_SET(1)
287
288 typedef struct {
289 usb_iface_desc_t iface;
290 usb_hid_descriptor_t hid;
291 usb_ep_desc_t ep;
292 } udi_hid_kbd_desc_t;
293
294 typedef struct {
295 uint8_t array[59];
296 } udi_hid_kbd_report_desc_t;
297
298 #define UDI_HID_KBD_DESC {\
299 .iface.bLength = sizeof(usb_iface_desc_t),\
300 .iface.bDescriptorType = USB_DT_INTERFACE,\
301 .iface.bInterfaceNumber = UDI_HID_KBD_IFACE_NUMBER,\
302 .iface.bAlternateSetting = 0,\
303 .iface.bNumEndpoints = 1,\
304 .iface.bInterfaceClass = HID_CLASS,\
305 .iface.bInterfaceSubClass = HID_SUB_CLASS_BOOT,\
306 .iface.bInterfaceProtocol = HID_PROTOCOL_KEYBOARD,\
307 .iface.iInterface = UDI_HID_KBD_STRING_ID,\
308 .hid.bLength = sizeof(usb_hid_descriptor_t),\
309 .hid.bDescriptorType = USB_DT_HID,\
310 .hid.bcdHID = LE16(USB_HID_BDC_V1_11),\
311 .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE,\
312 .hid.bNumDescriptors = USB_HID_NUM_DESC,\
313 .hid.bRDescriptorType = USB_DT_HID_REPORT,\
314 .hid.wDescriptorLength = LE16(sizeof(udi_hid_kbd_report_desc_t)),\
315 .ep.bLength = sizeof(usb_ep_desc_t),\
316 .ep.bDescriptorType = USB_DT_ENDPOINT,\
317 .ep.bEndpointAddress = UDI_HID_KBD_EP_IN | USB_EP_DIR_IN,\
318 .ep.bmAttributes = USB_EP_TYPE_INTERRUPT,\
319 .ep.wMaxPacketSize = LE16(UDI_HID_KBD_EP_SIZE),\
320 .ep.bInterval = KBD_POLLING_INTERVAL,\
321 }
322
323 //set report buffer (from host)
324 extern uint8_t udi_hid_kbd_report_set;
325
326 //report buffer (to host)
327 #define UDI_HID_KBD_REPORT_SIZE 8
328 extern uint8_t udi_hid_kbd_report[UDI_HID_KBD_REPORT_SIZE];
329
330 COMPILER_PACK_RESET()
331
332 #endif //KBD
333
334 // **********************************************************************
335 // EXK Descriptor structure and content
336 // **********************************************************************
337 #ifdef EXK
338
339 COMPILER_PACK_SET(1)
340
341 typedef struct {
342 usb_iface_desc_t iface;
343 usb_hid_descriptor_t hid;
344 usb_ep_desc_t ep;
345 } udi_hid_exk_desc_t;
346
347 typedef struct {
348 uint8_t array[54];
349 } udi_hid_exk_report_desc_t;
350
351 #define UDI_HID_EXK_DESC {\
352 .iface.bLength = sizeof(usb_iface_desc_t),\
353 .iface.bDescriptorType = USB_DT_INTERFACE,\
354 .iface.bInterfaceNumber = UDI_HID_EXK_IFACE_NUMBER,\
355 .iface.bAlternateSetting = 0,\
356 .iface.bNumEndpoints = 1,\
357 .iface.bInterfaceClass = HID_CLASS,\
358 .iface.bInterfaceSubClass = HID_SUB_CLASS_BOOT,\
359 .iface.bInterfaceProtocol = HID_PROTOCOL_GENERIC,\
360 .iface.iInterface = UDI_HID_EXK_STRING_ID,\
361 .hid.bLength = sizeof(usb_hid_descriptor_t),\
362 .hid.bDescriptorType = USB_DT_HID,\
363 .hid.bcdHID = LE16(USB_HID_BDC_V1_11),\
364 .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE,\
365 .hid.bNumDescriptors = USB_HID_NUM_DESC,\
366 .hid.bRDescriptorType = USB_DT_HID_REPORT,\
367 .hid.wDescriptorLength = LE16(sizeof(udi_hid_exk_report_desc_t)),\
368 .ep.bLength = sizeof(usb_ep_desc_t),\
369 .ep.bDescriptorType = USB_DT_ENDPOINT,\
370 .ep.bEndpointAddress = UDI_HID_EXK_EP_IN | USB_EP_DIR_IN,\
371 .ep.bmAttributes = USB_EP_TYPE_INTERRUPT,\
372 .ep.wMaxPacketSize = LE16(UDI_HID_EXK_EP_SIZE),\
373 .ep.bInterval = EXTRAKEY_POLLING_INTERVAL,\
374 }
375
376 //set report buffer (from host)
377 extern uint8_t udi_hid_exk_report_set;
378
379 //report buffer
380 #define UDI_HID_EXK_REPORT_SIZE 3
381
382 typedef union {
383 struct {
384 uint8_t report_id;
385 uint16_t report_data;
386 } desc;
387 uint8_t raw[UDI_HID_EXK_REPORT_SIZE];
388 } udi_hid_exk_report_t;
389
390 extern udi_hid_exk_report_t udi_hid_exk_report;
391
392 COMPILER_PACK_RESET()
393
394 #endif //EXK
395
396 // **********************************************************************
397 // NKRO Descriptor structure and content
398 // **********************************************************************
399 #ifdef NKRO
400
401 COMPILER_PACK_SET(1)
402
403 typedef struct {
404 usb_iface_desc_t iface;
405 usb_hid_descriptor_t hid;
406 usb_ep_desc_t ep;
407 } udi_hid_nkro_desc_t;
408
409 typedef struct {
410 uint8_t array[57];
411 } udi_hid_nkro_report_desc_t;
412
413 #define UDI_HID_NKRO_DESC {\
414 .iface.bLength = sizeof(usb_iface_desc_t),\
415 .iface.bDescriptorType = USB_DT_INTERFACE,\
416 .iface.bInterfaceNumber = UDI_HID_NKRO_IFACE_NUMBER,\
417 .iface.bAlternateSetting = 0,\
418 .iface.bNumEndpoints = 1,\
419 .iface.bInterfaceClass = HID_CLASS,\
420 .iface.bInterfaceSubClass = HID_SUB_CLASS_NOBOOT,\
421 .iface.bInterfaceProtocol = HID_PROTOCOL_KEYBOARD,\
422 .iface.iInterface = UDI_HID_NKRO_STRING_ID,\
423 .hid.bLength = sizeof(usb_hid_descriptor_t),\
424 .hid.bDescriptorType = USB_DT_HID,\
425 .hid.bcdHID = LE16(USB_HID_BDC_V1_11),\
426 .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE,\
427 .hid.bNumDescriptors = USB_HID_NUM_DESC,\
428 .hid.bRDescriptorType = USB_DT_HID_REPORT,\
429 .hid.wDescriptorLength = LE16(sizeof(udi_hid_nkro_report_desc_t)),\
430 .ep.bLength = sizeof(usb_ep_desc_t),\
431 .ep.bDescriptorType = USB_DT_ENDPOINT,\
432 .ep.bEndpointAddress = UDI_HID_NKRO_EP_IN | USB_EP_DIR_IN,\
433 .ep.bmAttributes = USB_EP_TYPE_INTERRUPT,\
434 .ep.wMaxPacketSize = LE16(UDI_HID_NKRO_EP_SIZE),\
435 .ep.bInterval = NKRO_POLLING_INTERVAL,\
436 }
437
438 //set report buffer
439 extern uint8_t udi_hid_nkro_report_set;
440
441 //report buffer
442 #define UDI_HID_NKRO_REPORT_SIZE 32
443 extern uint8_t udi_hid_nkro_report[UDI_HID_NKRO_REPORT_SIZE];
444
445 COMPILER_PACK_RESET()
446
447 #endif //NKRO
448
449 // **********************************************************************
450 // MOU Descriptor structure and content
451 // **********************************************************************
452 #ifdef MOU
453
454 COMPILER_PACK_SET(1)
455
456 typedef struct {
457 usb_iface_desc_t iface;
458 usb_hid_descriptor_t hid;
459 usb_ep_desc_t ep;
460 } udi_hid_mou_desc_t;
461
462 typedef struct {
463 uint8_t array[77];//MOU PDS
464 } udi_hid_mou_report_desc_t;
465
466 #define UDI_HID_MOU_DESC {\
467 .iface.bLength = sizeof(usb_iface_desc_t),\
468 .iface.bDescriptorType = USB_DT_INTERFACE,\
469 .iface.bInterfaceNumber = MOUSE_INTERFACE,\
470 .iface.bAlternateSetting = 0,\
471 .iface.bNumEndpoints = 1,\
472 .iface.bInterfaceClass = HID_CLASS,\
473 .iface.bInterfaceSubClass = HID_SUB_CLASS_BOOT,\
474 .iface.bInterfaceProtocol = HID_PROTOCOL_MOUSE,\
475 .iface.iInterface = UDI_HID_MOU_STRING_ID,\
476 .hid.bLength = sizeof(usb_hid_descriptor_t),\
477 .hid.bDescriptorType = USB_DT_HID,\
478 .hid.bcdHID = LE16(USB_HID_BDC_V1_11),\
479 .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE,\
480 .hid.bNumDescriptors = USB_HID_NUM_DESC,\
481 .hid.bRDescriptorType = USB_DT_HID_REPORT,\
482 .hid.wDescriptorLength = LE16(sizeof(udi_hid_mou_report_desc_t)),\
483 .ep.bLength = sizeof(usb_ep_desc_t),\
484 .ep.bDescriptorType = USB_DT_ENDPOINT,\
485 .ep.bEndpointAddress = UDI_HID_MOU_EP_IN | USB_EP_DIR_IN,\
486 .ep.bmAttributes = USB_EP_TYPE_INTERRUPT,\
487 .ep.wMaxPacketSize = LE16(UDI_HID_MOU_EP_SIZE),\
488 .ep.bInterval = MOU_POLLING_INTERVAL,\
489 }
490
491 //no set report buffer
492
493 //report buffer
494 #define UDI_HID_MOU_REPORT_SIZE 5 //MOU PDS
495 extern uint8_t udi_hid_mou_report[UDI_HID_MOU_REPORT_SIZE];
496
497 COMPILER_PACK_RESET()
498
499 #endif //MOU
500
501 // **********************************************************************
502 // RAW Descriptor structure and content
503 // **********************************************************************
504 #ifdef RAW
505
506 COMPILER_PACK_SET(1)
507
508 typedef struct {
509 usb_iface_desc_t iface;
510 usb_hid_descriptor_t hid;
511 usb_ep_desc_t ep_out;
512 usb_ep_desc_t ep_in;
513 } udi_hid_raw_desc_t;
514
515 typedef struct {
516 uint8_t array[27];
517 } udi_hid_raw_report_desc_t;
518
519 #define UDI_HID_RAW_DESC {\
520 .iface.bLength = sizeof(usb_iface_desc_t),\
521 .iface.bDescriptorType = USB_DT_INTERFACE,\
522 .iface.bInterfaceNumber = RAW_INTERFACE,\
523 .iface.bAlternateSetting = 0,\
524 .iface.bNumEndpoints = 2,\
525 .iface.bInterfaceClass = HID_CLASS,\
526 .iface.bInterfaceSubClass = HID_SUB_CLASS_NOBOOT,\
527 .iface.bInterfaceProtocol = HID_SUB_CLASS_NOBOOT,\
528 .iface.iInterface = UDI_HID_RAW_STRING_ID,\
529 .hid.bLength = sizeof(usb_hid_descriptor_t),\
530 .hid.bDescriptorType = USB_DT_HID,\
531 .hid.bcdHID = LE16(USB_HID_BDC_V1_11),\
532 .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE,\
533 .hid.bNumDescriptors = USB_HID_NUM_DESC,\
534 .hid.bRDescriptorType = USB_DT_HID_REPORT,\
535 .hid.wDescriptorLength = LE16(sizeof(udi_hid_raw_report_desc_t)),\
536 .ep_out.bLength = sizeof(usb_ep_desc_t),\
537 .ep_out.bDescriptorType = USB_DT_ENDPOINT,\
538 .ep_out.bEndpointAddress = UDI_HID_RAW_EP_OUT | USB_EP_DIR_OUT,\
539 .ep_out.bmAttributes = USB_EP_TYPE_INTERRUPT,\
540 .ep_out.wMaxPacketSize = LE16(RAW_EPSIZE),\
541 .ep_out.bInterval = RAW_POLLING_INTERVAL,\
542 .ep_in.bLength = sizeof(usb_ep_desc_t),\
543 .ep_in.bDescriptorType = USB_DT_ENDPOINT,\
544 .ep_in.bEndpointAddress = UDI_HID_RAW_EP_IN | USB_EP_DIR_IN,\
545 .ep_in.bmAttributes = USB_EP_TYPE_INTERRUPT,\
546 .ep_in.wMaxPacketSize = LE16(RAW_EPSIZE),\
547 .ep_in.bInterval = RAW_POLLING_INTERVAL,\
548 }
549
550 #define UDI_HID_RAW_REPORT_SIZE RAW_EPSIZE
551
552 extern uint8_t udi_hid_raw_report_set[UDI_HID_RAW_REPORT_SIZE];
553
554 //report buffer
555 extern uint8_t udi_hid_raw_report[UDI_HID_RAW_REPORT_SIZE];
556
557 COMPILER_PACK_RESET()
558
559 #endif //RAW
560
561 // **********************************************************************
562 // CDC Descriptor structure and content
563 // **********************************************************************
564 #ifdef CDC
565
566 COMPILER_PACK_SET(1)
567
568 typedef struct {
569 uint8_t bFunctionLength;
570 uint8_t bDescriptorType;
571 uint8_t bDescriptorSubtype;
572 le16_t bcdCDC;
573 } usb_cdc_hdr_desc_t;
574
575 typedef struct {
576 uint8_t bFunctionLength;
577 uint8_t bDescriptorType;
578 uint8_t bDescriptorSubtype;
579 uint8_t bmCapabilities;
580 uint8_t bDataInterface;
581 } usb_cdc_call_mgmt_desc_t;
582
583 typedef struct {
584 uint8_t bFunctionLength;
585 uint8_t bDescriptorType;
586 uint8_t bDescriptorSubtype;
587 uint8_t bmCapabilities;
588 } usb_cdc_acm_desc_t;
589
590 typedef struct {
591 uint8_t bFunctionLength;
592 uint8_t bDescriptorType;
593 uint8_t bDescriptorSubtype;
594 uint8_t bMasterInterface;
595 uint8_t bSlaveInterface0;
596 } usb_cdc_union_desc_t;
597
598 typedef struct {
599 usb_association_desc_t iaface;
600 usb_iface_desc_t iface_c;
601 usb_cdc_hdr_desc_t fd;
602 usb_cdc_call_mgmt_desc_t mfd;
603 usb_cdc_acm_desc_t acmd;
604 usb_cdc_union_desc_t ufd;
605 usb_ep_desc_t ep_c;
606 usb_iface_desc_t iface_d;
607 usb_ep_desc_t ep_tx;
608 usb_ep_desc_t ep_rx;
609 } udi_cdc_desc_t;
610
611 #define CDC_DESCRIPTOR {\
612 .iaface.bLength = sizeof(usb_association_desc_t),\
613 .iaface.bDescriptorType = USB_DT_IAD,\
614 .iaface.bFirstInterface = CDC_STATUS_INTERFACE,\
615 .iaface.bInterfaceCount = 2,\
616 .iaface.bFunctionClass = CDC_CLASS_DEVICE,\
617 .iaface.bFunctionSubClass = CDC_SUBCLASS_ACM,\
618 .iaface.bFunctionProtocol = CDC_PROTOCOL_V25TER,\
619 .iaface.iFunction = 0,\
620 .iface_c.bLength = sizeof(usb_iface_desc_t),\
621 .iface_c.bDescriptorType = USB_DT_INTERFACE,\
622 .iface_c.bInterfaceNumber = CDC_STATUS_INTERFACE,\
623 .iface_c.bAlternateSetting = 0,\
624 .iface_c.bNumEndpoints = 1,\
625 .iface_c.bInterfaceClass = 0x02,\
626 .iface_c.bInterfaceSubClass = 0x02,\
627 .iface_c.bInterfaceProtocol = CDC_PROTOCOL_V25TER,\
628 .iface_c.iInterface = 0,\
629 .fd.bFunctionLength = sizeof(usb_cdc_hdr_desc_t),\
630 .fd.bDescriptorType = CDC_CS_INTERFACE,\
631 .fd.bDescriptorSubtype = CDC_SCS_HEADER,\
632 .fd.bcdCDC = 0x0110,\
633 .mfd.bFunctionLength = sizeof(usb_cdc_call_mgmt_desc_t),\
634 .mfd.bDescriptorType = CDC_CS_INTERFACE,\
635 .mfd.bDescriptorSubtype = CDC_SCS_CALL_MGMT,\
636 .mfd.bmCapabilities = CDC_CALL_MGMT_SUPPORTED,\
637 .mfd.bDataInterface = CDC_DATA_INTERFACE,\
638 .acmd.bFunctionLength = sizeof(usb_cdc_acm_desc_t),\
639 .acmd.bDescriptorType = CDC_CS_INTERFACE,\
640 .acmd.bDescriptorSubtype = CDC_SCS_ACM,\
641 .acmd.bmCapabilities = CDC_ACM_SUPPORT_LINE_REQUESTS,\
642 .ufd.bFunctionLength = sizeof(usb_cdc_union_desc_t),\
643 .ufd.bDescriptorType = CDC_CS_INTERFACE,\
644 .ufd.bDescriptorSubtype = CDC_SCS_UNION,\
645 .ufd.bMasterInterface = CDC_STATUS_INTERFACE,\
646 .ufd.bSlaveInterface0 = CDC_DATA_INTERFACE,\
647 .ep_c.bLength = sizeof(usb_ep_desc_t),\
648 .ep_c.bDescriptorType = USB_DT_ENDPOINT,\
649 .ep_c.bEndpointAddress = CDC_ACM_ENDPOINT | USB_EP_DIR_IN,\
650 .ep_c.bmAttributes = USB_EP_TYPE_INTERRUPT,\
651 .ep_c.wMaxPacketSize = LE16(CDC_ACM_SIZE),\
652 .ep_c.bInterval = CDC_EP_INTERVAL_STATUS,\
653 .iface_d.bLength = sizeof(usb_iface_desc_t),\
654 .iface_d.bDescriptorType = USB_DT_INTERFACE,\
655 .iface_d.bInterfaceNumber = CDC_DATA_INTERFACE,\
656 .iface_d.bAlternateSetting = 0,\
657 .iface_d.bNumEndpoints = 2,\
658 .iface_d.bInterfaceClass = CDC_CLASS_DATA,\
659 .iface_d.bInterfaceSubClass = 0,\
660 .iface_d.bInterfaceProtocol = 0,\
661 .iface_d.iInterface = 0,\
662 .ep_rx.bLength = sizeof(usb_ep_desc_t),\
663 .ep_rx.bDescriptorType = USB_DT_ENDPOINT,\
664 .ep_rx.bEndpointAddress = CDC_RX_ENDPOINT | USB_EP_DIR_OUT,\
665 .ep_rx.bmAttributes = USB_EP_TYPE_BULK,\
666 .ep_rx.wMaxPacketSize = LE16(CDC_RX_SIZE),\
667 .ep_rx.bInterval = CDC_EP_INTERVAL_DATA,\
668 .ep_tx.bLength = sizeof(usb_ep_desc_t),\
669 .ep_tx.bDescriptorType = USB_DT_ENDPOINT,\
670 .ep_tx.bEndpointAddress = CDC_TX_ENDPOINT | USB_EP_DIR_IN,\
671 .ep_tx.bmAttributes = USB_EP_TYPE_BULK,\
672 .ep_tx.wMaxPacketSize = LE16(CDC_TX_SIZE),\
673 .ep_tx.bInterval = CDC_EP_INTERVAL_DATA,\
674 }
675
676 COMPILER_PACK_RESET()
677
678 #endif //CDC
679
680 // **********************************************************************
681 // CONFIGURATION Descriptor structure and content
682 // **********************************************************************
683 COMPILER_PACK_SET(1)
684
685 typedef struct {
686 usb_conf_desc_t conf;
687 #ifdef KBD
688 udi_hid_kbd_desc_t hid_kbd;
689 #endif
690 #ifdef MOU
691 udi_hid_mou_desc_t hid_mou;
692 #endif
693 #ifdef EXK
694 udi_hid_exk_desc_t hid_exk;
695 #endif
696 #ifdef RAW
697 udi_hid_raw_desc_t hid_raw;
698 #endif
699 #ifdef CON
700 udi_hid_con_desc_t hid_con;
701 #endif
702 #ifdef NKRO
703 udi_hid_nkro_desc_t hid_nkro;
704 #endif
705 #ifdef MIDI
706 udi_hid_midi_desc_t hid_midi;
707 #endif
708 #ifdef CDC
709 udi_cdc_desc_t cdc_serial;
710 #endif
711 } udc_desc_t;
712
713 COMPILER_PACK_RESET()
714
715 #endif //_UDI_DEVICE_CONF_H_