2 Copyright 2018 Massdrop Inc.
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.
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.
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/>.
18 #ifndef _UDI_DEVICE_CONF_H_
19 #define _UDI_DEVICE_CONF_H_
21 #include "udi_device_epsize.h"
22 #include "usb_protocol.h"
24 #include "usb_protocol_hid.h"
26 #define DEVICE_CLASS 0
27 #define DEVICE_SUBCLASS 0
28 #define DEVICE_PROTOCOL 0
32 //#define MOUSE_ENABLE //rules.mk
37 //#define EXTRAKEY_ENABLE //rules.mk
38 #ifdef EXTRAKEY_ENABLE
42 //#define RAW_ENABLE //rules.mk
47 //#define CONSOLE_ENABLE //rules.mk
52 //#define NKRO_ENABLE //rules.mk
57 //#define MIDI_ENABLE //deferred implementation
62 //#define VIRTSER_ENABLE //rules.mk
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)
68 #define DEVICE_CLASS 0xEF
69 #undef DEVICE_SUBCLASS
70 #define DEVICE_SUBCLASS 0x02
71 #undef DEVICE_PROTOCOL
72 #define DEVICE_PROTOCOL 0x01
75 /* number of interfaces */
76 #define NEXT_INTERFACE_0 0
79 #define KEYBOARD_INTERFACE NEXT_INTERFACE_0
80 #define NEXT_INTERFACE_1 (KEYBOARD_INTERFACE + 1)
81 #define UDI_HID_KBD_IFACE_NUMBER KEYBOARD_INTERFACE
83 #define NEXT_INTERFACE_1 NEXT_INTERFACE_0
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.
90 #define RAW_INTERFACE NEXT_INTERFACE_1
91 #define NEXT_INTERFACE_2 (RAW_INTERFACE + 1)
93 #define NEXT_INTERFACE_2 NEXT_INTERFACE_1
97 #define MOUSE_INTERFACE NEXT_INTERFACE_2
98 #define UDI_HID_MOU_IFACE_NUMBER MOUSE_INTERFACE
99 #define NEXT_INTERFACE_3 (MOUSE_INTERFACE + 1)
101 #define NEXT_INTERFACE_3 NEXT_INTERFACE_2
105 #define EXTRAKEY_INTERFACE NEXT_INTERFACE_3
106 #define NEXT_INTERFACE_4 (EXTRAKEY_INTERFACE + 1)
107 #define UDI_HID_EXK_IFACE_NUMBER EXTRAKEY_INTERFACE
109 #define NEXT_INTERFACE_4 NEXT_INTERFACE_3
113 #define CON_INTERFACE NEXT_INTERFACE_4
114 #define NEXT_INTERFACE_5 (CON_INTERFACE + 1)
115 #define UDI_HID_CON_IFACE_NUMBER CON_INTERFACE
117 #define NEXT_INTERFACE_5 NEXT_INTERFACE_4
121 #define NKRO_INTERFACE NEXT_INTERFACE_5
122 #define NEXT_INTERFACE_6 (NKRO_INTERFACE + 1)
123 #define UDI_HID_NKRO_IFACE_NUMBER NKRO_INTERFACE
125 #define NEXT_INTERFACE_6 NEXT_INTERFACE_5
129 #define AC_INTERFACE NEXT_INTERFACE_6
130 #define AS_INTERFACE (AC_INTERFACE + 1)
131 #define NEXT_INTERFACE_7 (AS_INTERFACE + 1)
133 #define NEXT_INTERFACE_7 NEXT_INTERFACE_6
137 #define CCI_INTERFACE NEXT_INTERFACE_7
138 #define CDI_INTERFACE (CCI_INTERFACE + 1)
139 #define NEXT_INTERFACE_8 (CDI_INTERFACE + 1)
140 #define CDC_STATUS_INTERFACE CCI_INTERFACE
141 #define CDC_DATA_INTERFACE CDI_INTERFACE
143 #define NEXT_INTERFACE_8 NEXT_INTERFACE_7
146 /* nubmer of interfaces */
147 #define TOTAL_INTERFACES NEXT_INTERFACE_8
148 #define USB_DEVICE_NB_INTERFACE TOTAL_INTERFACES
151 // **********************************************************************
152 // Endopoint number and size
153 // **********************************************************************
154 #define USB_DEVICE_EP_CTRL_SIZE 8
156 #define NEXT_IN_EPNUM_0 1
157 #define NEXT_OUT_EPNUM_0 1
160 #define KEYBOARD_IN_EPNUM NEXT_IN_EPNUM_0
161 #define UDI_HID_KBD_EP_IN KEYBOARD_IN_EPNUM
162 #define NEXT_IN_EPNUM_1 (KEYBOARD_IN_EPNUM + 1)
163 #define UDI_HID_KBD_EP_SIZE KEYBOARD_EPSIZE
164 #define KBD_POLLING_INTERVAL 10
165 #ifndef UDI_HID_KBD_STRING_ID
166 #define UDI_HID_KBD_STRING_ID 0
169 #define NEXT_IN_EPNUM_1 NEXT_IN_EPNUM_0
173 #define MOUSE_IN_EPNUM NEXT_IN_EPNUM_1
174 #define NEXT_IN_EPNUM_2 (MOUSE_IN_EPNUM + 1)
175 #define UDI_HID_MOU_EP_IN MOUSE_IN_EPNUM
176 #define UDI_HID_MOU_EP_SIZE MOUSE_EPSIZE
177 #define MOU_POLLING_INTERVAL 10
178 #ifndef UDI_HID_MOU_STRING_ID
179 #define UDI_HID_MOU_STRING_ID 0
182 #define NEXT_IN_EPNUM_2 NEXT_IN_EPNUM_1
186 #define EXTRAKEY_IN_EPNUM NEXT_IN_EPNUM_2
187 #define UDI_HID_EXK_EP_IN EXTRAKEY_IN_EPNUM
188 #define NEXT_IN_EPNUM_3 (EXTRAKEY_IN_EPNUM + 1)
189 #define UDI_HID_EXK_EP_SIZE EXTRAKEY_EPSIZE
190 #define EXTRAKEY_POLLING_INTERVAL 10
191 #ifndef UDI_HID_EXK_STRING_ID
192 #define UDI_HID_EXK_STRING_ID 0
195 #define NEXT_IN_EPNUM_3 NEXT_IN_EPNUM_2
199 #define RAW_IN_EPNUM NEXT_IN_EPNUM_3
200 #define UDI_HID_RAW_EP_IN RAW_IN_EPNUM
201 #define NEXT_IN_EPNUM_4 (RAW_IN_EPNUM + 1)
202 #define RAW_OUT_EPNUM NEXT_OUT_EPNUM_0
203 #define UDI_HID_RAW_EP_OUT RAW_OUT_EPNUM
204 #define NEXT_OUT_EPNUM_1 (RAW_OUT_EPNUM + 1)
205 #define RAW_POLLING_INTERVAL 1
206 #ifndef UDI_HID_RAW_STRING_ID
207 #define UDI_HID_RAW_STRING_ID 0
210 #define NEXT_IN_EPNUM_4 NEXT_IN_EPNUM_3
211 #define NEXT_OUT_EPNUM_1 NEXT_OUT_EPNUM_0
215 #define CON_IN_EPNUM NEXT_IN_EPNUM_4
216 #define UDI_HID_CON_EP_IN CON_IN_EPNUM
217 #define NEXT_IN_EPNUM_5 (CON_IN_EPNUM + 1)
218 #define CON_OUT_EPNUM NEXT_OUT_EPNUM_1
219 #define UDI_HID_CON_EP_OUT CON_OUT_EPNUM
220 #define NEXT_OUT_EPNUM_2 (CON_OUT_EPNUM + 1)
221 #define CON_POLLING_INTERVAL 1
222 #ifndef UDI_HID_CON_STRING_ID
223 #define UDI_HID_CON_STRING_ID 0
226 #define NEXT_IN_EPNUM_5 NEXT_IN_EPNUM_4
227 #define NEXT_OUT_EPNUM_2 NEXT_OUT_EPNUM_1
231 #define NKRO_IN_EPNUM NEXT_IN_EPNUM_5
232 #define UDI_HID_NKRO_EP_IN NKRO_IN_EPNUM
233 #define NEXT_IN_EPNUM_6 (NKRO_IN_EPNUM + 1)
234 #define UDI_HID_NKRO_EP_SIZE NKRO_EPSIZE
235 #define NKRO_POLLING_INTERVAL 1
236 #ifndef UDI_HID_NKRO_STRING_ID
237 #define UDI_HID_NKRO_STRING_ID 0
240 #define NEXT_IN_EPNUM_6 NEXT_IN_EPNUM_5
244 #define MIDI_STREAM_IN_EPNUM NEXT_IN_EPNUM_6
245 #define NEXT_IN_EPNUM_7 (MIDI_STREAM_IN_EPNUM + 1)
246 #define MIDI_STREAM_OUT_EPNUM NEXT_OUT_EPNUM_2
247 #define NEXT_OUT_EPNUM_3 (MIDI_STREAM_OUT_EPNUM + 1)
248 #define MIDI_POLLING_INTERVAL 5
250 #define NEXT_IN_EPNUM_7 NEXT_IN_EPNUM_6
251 #define NEXT_OUT_EPNUM_3 NEXT_OUT_EPNUM_2
255 #define CDC_NOTIFICATION_EPNUM NEXT_IN_EPNUM_7
256 #define CDC_ACM_ENDPOINT CDC_NOTIFICATION_EPNUM
257 #define CDC_TX_ENDPOINT (CDC_NOTIFICATION_EPNUM + 1)
258 #define NEXT_IN_EPNUM_8 (CDC_TX_ENDPOINT + 1)
260 #define CDC_OUT_EPNUM NEXT_OUT_EPNUM_3
261 #define CDC_RX_ENDPOINT CDC_OUT_EPNUM
262 #define NEXT_OUT_EPNUM_4 (CDC_OUT_EPNUM + 1)
264 #define CDC_ACM_SIZE CDC_NOTIFICATION_EPSIZE
265 #define CDC_RX_SIZE CDC_EPSIZE //KFSMOD was 64
266 #define CDC_TX_SIZE CDC_RX_SIZE
267 #define CDC_ACM_POLLING_INTERVAL 255
268 #define CDC_EP_INTERVAL_STATUS CDC_ACM_POLLING_INTERVAL
269 #define CDC_DATA_POLLING_INTERVAL 5
270 #define CDC_EP_INTERVAL_DATA CDC_DATA_POLLING_INTERVAL
271 #define CDC_STATUS_NAME L"Virtual Serial Port - Status"
272 #define CDC_DATA_NAME L"Virtual Serial Port - Data"
274 #define NEXT_IN_EPNUM_8 NEXT_IN_EPNUM_7
275 #define NEXT_OUT_EPNUM_4 NEXT_OUT_EPNUM_3
278 #define TOTAL_OUT_EP NEXT_OUT_EPNUM_4
279 #define TOTAL_IN_EP NEXT_IN_EPNUM_8
280 #define USB_DEVICE_MAX_EP (max(NEXT_OUT_EPNUM_4, NEXT_IN_EPNUM_8))
282 #if USB_DEVICE_MAX_EP > 8
283 #error "There are not enough available endpoints to support all functions. Remove some in the rules.mk file.(MOUSEKEY, EXTRAKEY, CONSOLE, NKRO, MIDI, VIRTSER)"
287 // **********************************************************************
288 // KBD Descriptor structure and content
289 // **********************************************************************
295 usb_iface_desc_t iface;
296 usb_hid_descriptor_t hid;
298 } udi_hid_kbd_desc_t;
302 } udi_hid_kbd_report_desc_t;
304 #define UDI_HID_KBD_DESC {\
305 .iface.bLength = sizeof(usb_iface_desc_t),\
306 .iface.bDescriptorType = USB_DT_INTERFACE,\
307 .iface.bInterfaceNumber = UDI_HID_KBD_IFACE_NUMBER,\
308 .iface.bAlternateSetting = 0,\
309 .iface.bNumEndpoints = 1,\
310 .iface.bInterfaceClass = HID_CLASS,\
311 .iface.bInterfaceSubClass = HID_SUB_CLASS_BOOT,\
312 .iface.bInterfaceProtocol = HID_PROTOCOL_KEYBOARD,\
313 .iface.iInterface = UDI_HID_KBD_STRING_ID,\
314 .hid.bLength = sizeof(usb_hid_descriptor_t),\
315 .hid.bDescriptorType = USB_DT_HID,\
316 .hid.bcdHID = LE16(USB_HID_BDC_V1_11),\
317 .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE,\
318 .hid.bNumDescriptors = USB_HID_NUM_DESC,\
319 .hid.bRDescriptorType = USB_DT_HID_REPORT,\
320 .hid.wDescriptorLength = LE16(sizeof(udi_hid_kbd_report_desc_t)),\
321 .ep.bLength = sizeof(usb_ep_desc_t),\
322 .ep.bDescriptorType = USB_DT_ENDPOINT,\
323 .ep.bEndpointAddress = UDI_HID_KBD_EP_IN | USB_EP_DIR_IN,\
324 .ep.bmAttributes = USB_EP_TYPE_INTERRUPT,\
325 .ep.wMaxPacketSize = LE16(UDI_HID_KBD_EP_SIZE),\
326 .ep.bInterval = KBD_POLLING_INTERVAL,\
329 //set report buffer (from host)
330 extern uint8_t udi_hid_kbd_report_set;
332 //report buffer (to host)
333 #define UDI_HID_KBD_REPORT_SIZE 8
334 extern uint8_t udi_hid_kbd_report[UDI_HID_KBD_REPORT_SIZE];
336 COMPILER_PACK_RESET()
340 // **********************************************************************
341 // EXK Descriptor structure and content
342 // **********************************************************************
348 usb_iface_desc_t iface;
349 usb_hid_descriptor_t hid;
351 } udi_hid_exk_desc_t;
355 } udi_hid_exk_report_desc_t;
357 #define UDI_HID_EXK_DESC {\
358 .iface.bLength = sizeof(usb_iface_desc_t),\
359 .iface.bDescriptorType = USB_DT_INTERFACE,\
360 .iface.bInterfaceNumber = UDI_HID_EXK_IFACE_NUMBER,\
361 .iface.bAlternateSetting = 0,\
362 .iface.bNumEndpoints = 1,\
363 .iface.bInterfaceClass = HID_CLASS,\
364 .iface.bInterfaceSubClass = HID_SUB_CLASS_BOOT,\
365 .iface.bInterfaceProtocol = HID_PROTOCOL_GENERIC,\
366 .iface.iInterface = UDI_HID_EXK_STRING_ID,\
367 .hid.bLength = sizeof(usb_hid_descriptor_t),\
368 .hid.bDescriptorType = USB_DT_HID,\
369 .hid.bcdHID = LE16(USB_HID_BDC_V1_11),\
370 .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE,\
371 .hid.bNumDescriptors = USB_HID_NUM_DESC,\
372 .hid.bRDescriptorType = USB_DT_HID_REPORT,\
373 .hid.wDescriptorLength = LE16(sizeof(udi_hid_exk_report_desc_t)),\
374 .ep.bLength = sizeof(usb_ep_desc_t),\
375 .ep.bDescriptorType = USB_DT_ENDPOINT,\
376 .ep.bEndpointAddress = UDI_HID_EXK_EP_IN | USB_EP_DIR_IN,\
377 .ep.bmAttributes = USB_EP_TYPE_INTERRUPT,\
378 .ep.wMaxPacketSize = LE16(UDI_HID_EXK_EP_SIZE),\
379 .ep.bInterval = EXTRAKEY_POLLING_INTERVAL,\
382 //set report buffer (from host)
383 extern uint8_t udi_hid_exk_report_set;
386 #define UDI_HID_EXK_REPORT_SIZE 3
391 uint16_t report_data;
393 uint8_t raw[UDI_HID_EXK_REPORT_SIZE];
394 } udi_hid_exk_report_t;
396 extern udi_hid_exk_report_t udi_hid_exk_report;
398 COMPILER_PACK_RESET()
402 // **********************************************************************
403 // NKRO Descriptor structure and content
404 // **********************************************************************
410 usb_iface_desc_t iface;
411 usb_hid_descriptor_t hid;
413 } udi_hid_nkro_desc_t;
417 } udi_hid_nkro_report_desc_t;
419 #define UDI_HID_NKRO_DESC {\
420 .iface.bLength = sizeof(usb_iface_desc_t),\
421 .iface.bDescriptorType = USB_DT_INTERFACE,\
422 .iface.bInterfaceNumber = UDI_HID_NKRO_IFACE_NUMBER,\
423 .iface.bAlternateSetting = 0,\
424 .iface.bNumEndpoints = 1,\
425 .iface.bInterfaceClass = HID_CLASS,\
426 .iface.bInterfaceSubClass = HID_SUB_CLASS_NOBOOT,\
427 .iface.bInterfaceProtocol = HID_PROTOCOL_KEYBOARD,\
428 .iface.iInterface = UDI_HID_NKRO_STRING_ID,\
429 .hid.bLength = sizeof(usb_hid_descriptor_t),\
430 .hid.bDescriptorType = USB_DT_HID,\
431 .hid.bcdHID = LE16(USB_HID_BDC_V1_11),\
432 .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE,\
433 .hid.bNumDescriptors = USB_HID_NUM_DESC,\
434 .hid.bRDescriptorType = USB_DT_HID_REPORT,\
435 .hid.wDescriptorLength = LE16(sizeof(udi_hid_nkro_report_desc_t)),\
436 .ep.bLength = sizeof(usb_ep_desc_t),\
437 .ep.bDescriptorType = USB_DT_ENDPOINT,\
438 .ep.bEndpointAddress = UDI_HID_NKRO_EP_IN | USB_EP_DIR_IN,\
439 .ep.bmAttributes = USB_EP_TYPE_INTERRUPT,\
440 .ep.wMaxPacketSize = LE16(UDI_HID_NKRO_EP_SIZE),\
441 .ep.bInterval = NKRO_POLLING_INTERVAL,\
445 extern uint8_t udi_hid_nkro_report_set;
448 #define UDI_HID_NKRO_REPORT_SIZE 32
449 extern uint8_t udi_hid_nkro_report[UDI_HID_NKRO_REPORT_SIZE];
451 COMPILER_PACK_RESET()
455 // **********************************************************************
456 // MOU Descriptor structure and content
457 // **********************************************************************
463 usb_iface_desc_t iface;
464 usb_hid_descriptor_t hid;
466 } udi_hid_mou_desc_t;
469 uint8_t array[77];//MOU PDS
470 } udi_hid_mou_report_desc_t;
472 #define UDI_HID_MOU_DESC {\
473 .iface.bLength = sizeof(usb_iface_desc_t),\
474 .iface.bDescriptorType = USB_DT_INTERFACE,\
475 .iface.bInterfaceNumber = MOUSE_INTERFACE,\
476 .iface.bAlternateSetting = 0,\
477 .iface.bNumEndpoints = 1,\
478 .iface.bInterfaceClass = HID_CLASS,\
479 .iface.bInterfaceSubClass = HID_SUB_CLASS_BOOT,\
480 .iface.bInterfaceProtocol = HID_PROTOCOL_MOUSE,\
481 .iface.iInterface = UDI_HID_MOU_STRING_ID,\
482 .hid.bLength = sizeof(usb_hid_descriptor_t),\
483 .hid.bDescriptorType = USB_DT_HID,\
484 .hid.bcdHID = LE16(USB_HID_BDC_V1_11),\
485 .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE,\
486 .hid.bNumDescriptors = USB_HID_NUM_DESC,\
487 .hid.bRDescriptorType = USB_DT_HID_REPORT,\
488 .hid.wDescriptorLength = LE16(sizeof(udi_hid_mou_report_desc_t)),\
489 .ep.bLength = sizeof(usb_ep_desc_t),\
490 .ep.bDescriptorType = USB_DT_ENDPOINT,\
491 .ep.bEndpointAddress = UDI_HID_MOU_EP_IN | USB_EP_DIR_IN,\
492 .ep.bmAttributes = USB_EP_TYPE_INTERRUPT,\
493 .ep.wMaxPacketSize = LE16(UDI_HID_MOU_EP_SIZE),\
494 .ep.bInterval = MOU_POLLING_INTERVAL,\
497 //no set report buffer
500 #define UDI_HID_MOU_REPORT_SIZE 5 //MOU PDS
501 extern uint8_t udi_hid_mou_report[UDI_HID_MOU_REPORT_SIZE];
503 COMPILER_PACK_RESET()
507 // **********************************************************************
508 // RAW Descriptor structure and content
509 // **********************************************************************
515 usb_iface_desc_t iface;
516 usb_hid_descriptor_t hid;
517 usb_ep_desc_t ep_out;
519 } udi_hid_raw_desc_t;
523 } udi_hid_raw_report_desc_t;
525 #define UDI_HID_RAW_DESC {\
526 .iface.bLength = sizeof(usb_iface_desc_t),\
527 .iface.bDescriptorType = USB_DT_INTERFACE,\
528 .iface.bInterfaceNumber = RAW_INTERFACE,\
529 .iface.bAlternateSetting = 0,\
530 .iface.bNumEndpoints = 2,\
531 .iface.bInterfaceClass = HID_CLASS,\
532 .iface.bInterfaceSubClass = HID_SUB_CLASS_NOBOOT,\
533 .iface.bInterfaceProtocol = HID_SUB_CLASS_NOBOOT,\
534 .iface.iInterface = UDI_HID_RAW_STRING_ID,\
535 .hid.bLength = sizeof(usb_hid_descriptor_t),\
536 .hid.bDescriptorType = USB_DT_HID,\
537 .hid.bcdHID = LE16(USB_HID_BDC_V1_11),\
538 .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE,\
539 .hid.bNumDescriptors = USB_HID_NUM_DESC,\
540 .hid.bRDescriptorType = USB_DT_HID_REPORT,\
541 .hid.wDescriptorLength = LE16(sizeof(udi_hid_raw_report_desc_t)),\
542 .ep_out.bLength = sizeof(usb_ep_desc_t),\
543 .ep_out.bDescriptorType = USB_DT_ENDPOINT,\
544 .ep_out.bEndpointAddress = UDI_HID_RAW_EP_OUT | USB_EP_DIR_OUT,\
545 .ep_out.bmAttributes = USB_EP_TYPE_INTERRUPT,\
546 .ep_out.wMaxPacketSize = LE16(RAW_EPSIZE),\
547 .ep_out.bInterval = RAW_POLLING_INTERVAL,\
548 .ep_in.bLength = sizeof(usb_ep_desc_t),\
549 .ep_in.bDescriptorType = USB_DT_ENDPOINT,\
550 .ep_in.bEndpointAddress = UDI_HID_RAW_EP_IN | USB_EP_DIR_IN,\
551 .ep_in.bmAttributes = USB_EP_TYPE_INTERRUPT,\
552 .ep_in.wMaxPacketSize = LE16(RAW_EPSIZE),\
553 .ep_in.bInterval = RAW_POLLING_INTERVAL,\
556 #define UDI_HID_RAW_REPORT_SIZE RAW_EPSIZE
558 extern uint8_t udi_hid_raw_report_set[UDI_HID_RAW_REPORT_SIZE];
561 extern uint8_t udi_hid_raw_report[UDI_HID_RAW_REPORT_SIZE];
563 COMPILER_PACK_RESET()
567 // **********************************************************************
568 // CON Descriptor structure and content
569 // **********************************************************************
575 usb_iface_desc_t iface;
576 usb_hid_descriptor_t hid;
577 usb_ep_desc_t ep_out;
579 } udi_hid_con_desc_t;
583 } udi_hid_con_report_desc_t;
585 #define UDI_HID_CON_DESC {\
586 .iface.bLength = sizeof(usb_iface_desc_t),\
587 .iface.bDescriptorType = USB_DT_INTERFACE,\
588 .iface.bInterfaceNumber = UDI_HID_CON_IFACE_NUMBER,\
589 .iface.bAlternateSetting = 0,\
590 .iface.bNumEndpoints = 2,\
591 .iface.bInterfaceClass = HID_CLASS,\
592 .iface.bInterfaceSubClass = HID_SUB_CLASS_NOBOOT,\
593 .iface.bInterfaceProtocol = HID_SUB_CLASS_NOBOOT,\
594 .iface.iInterface = UDI_HID_CON_STRING_ID,\
595 .hid.bLength = sizeof(usb_hid_descriptor_t),\
596 .hid.bDescriptorType = USB_DT_HID,\
597 .hid.bcdHID = LE16(USB_HID_BDC_V1_11),\
598 .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE,\
599 .hid.bNumDescriptors = USB_HID_NUM_DESC,\
600 .hid.bRDescriptorType = USB_DT_HID_REPORT,\
601 .hid.wDescriptorLength = LE16(sizeof(udi_hid_con_report_desc_t)),\
602 .ep_out.bLength = sizeof(usb_ep_desc_t),\
603 .ep_out.bDescriptorType = USB_DT_ENDPOINT,\
604 .ep_out.bEndpointAddress = UDI_HID_CON_EP_OUT | USB_EP_DIR_OUT,\
605 .ep_out.bmAttributes = USB_EP_TYPE_INTERRUPT,\
606 .ep_out.wMaxPacketSize = LE16(CONSOLE_EPSIZE),\
607 .ep_out.bInterval = CON_POLLING_INTERVAL,\
608 .ep_in.bLength = sizeof(usb_ep_desc_t),\
609 .ep_in.bDescriptorType = USB_DT_ENDPOINT,\
610 .ep_in.bEndpointAddress = UDI_HID_CON_EP_IN | USB_EP_DIR_IN,\
611 .ep_in.bmAttributes = USB_EP_TYPE_INTERRUPT,\
612 .ep_in.wMaxPacketSize = LE16(CONSOLE_EPSIZE),\
613 .ep_in.bInterval = CON_POLLING_INTERVAL,\
616 #define UDI_HID_CON_REPORT_SIZE CONSOLE_EPSIZE
618 extern uint8_t udi_hid_con_report_set[UDI_HID_CON_REPORT_SIZE];
621 extern uint8_t udi_hid_con_report[UDI_HID_CON_REPORT_SIZE];
623 COMPILER_PACK_RESET()
627 // **********************************************************************
628 // CDC Descriptor structure and content
629 // **********************************************************************
635 uint8_t bFunctionLength;
636 uint8_t bDescriptorType;
637 uint8_t bDescriptorSubtype;
639 } usb_cdc_hdr_desc_t;
642 uint8_t bFunctionLength;
643 uint8_t bDescriptorType;
644 uint8_t bDescriptorSubtype;
645 uint8_t bmCapabilities;
646 uint8_t bDataInterface;
647 } usb_cdc_call_mgmt_desc_t;
650 uint8_t bFunctionLength;
651 uint8_t bDescriptorType;
652 uint8_t bDescriptorSubtype;
653 uint8_t bmCapabilities;
654 } usb_cdc_acm_desc_t;
657 uint8_t bFunctionLength;
658 uint8_t bDescriptorType;
659 uint8_t bDescriptorSubtype;
660 uint8_t bMasterInterface;
661 uint8_t bSlaveInterface0;
662 } usb_cdc_union_desc_t;
665 usb_association_desc_t iaface;
666 usb_iface_desc_t iface_c;
667 usb_cdc_hdr_desc_t fd;
668 usb_cdc_call_mgmt_desc_t mfd;
669 usb_cdc_acm_desc_t acmd;
670 usb_cdc_union_desc_t ufd;
672 usb_iface_desc_t iface_d;
677 #define CDC_DESCRIPTOR {\
678 .iaface.bLength = sizeof(usb_association_desc_t),\
679 .iaface.bDescriptorType = USB_DT_IAD,\
680 .iaface.bFirstInterface = CDC_STATUS_INTERFACE,\
681 .iaface.bInterfaceCount = 2,\
682 .iaface.bFunctionClass = CDC_CLASS_DEVICE,\
683 .iaface.bFunctionSubClass = CDC_SUBCLASS_ACM,\
684 .iaface.bFunctionProtocol = CDC_PROTOCOL_V25TER,\
685 .iaface.iFunction = 0,\
686 .iface_c.bLength = sizeof(usb_iface_desc_t),\
687 .iface_c.bDescriptorType = USB_DT_INTERFACE,\
688 .iface_c.bInterfaceNumber = CDC_STATUS_INTERFACE,\
689 .iface_c.bAlternateSetting = 0,\
690 .iface_c.bNumEndpoints = 1,\
691 .iface_c.bInterfaceClass = 0x02,\
692 .iface_c.bInterfaceSubClass = 0x02,\
693 .iface_c.bInterfaceProtocol = CDC_PROTOCOL_V25TER,\
694 .iface_c.iInterface = 0,\
695 .fd.bFunctionLength = sizeof(usb_cdc_hdr_desc_t),\
696 .fd.bDescriptorType = CDC_CS_INTERFACE,\
697 .fd.bDescriptorSubtype = CDC_SCS_HEADER,\
698 .fd.bcdCDC = 0x0110,\
699 .mfd.bFunctionLength = sizeof(usb_cdc_call_mgmt_desc_t),\
700 .mfd.bDescriptorType = CDC_CS_INTERFACE,\
701 .mfd.bDescriptorSubtype = CDC_SCS_CALL_MGMT,\
702 .mfd.bmCapabilities = CDC_CALL_MGMT_SUPPORTED,\
703 .mfd.bDataInterface = CDC_DATA_INTERFACE,\
704 .acmd.bFunctionLength = sizeof(usb_cdc_acm_desc_t),\
705 .acmd.bDescriptorType = CDC_CS_INTERFACE,\
706 .acmd.bDescriptorSubtype = CDC_SCS_ACM,\
707 .acmd.bmCapabilities = CDC_ACM_SUPPORT_LINE_REQUESTS,\
708 .ufd.bFunctionLength = sizeof(usb_cdc_union_desc_t),\
709 .ufd.bDescriptorType = CDC_CS_INTERFACE,\
710 .ufd.bDescriptorSubtype = CDC_SCS_UNION,\
711 .ufd.bMasterInterface = CDC_STATUS_INTERFACE,\
712 .ufd.bSlaveInterface0 = CDC_DATA_INTERFACE,\
713 .ep_c.bLength = sizeof(usb_ep_desc_t),\
714 .ep_c.bDescriptorType = USB_DT_ENDPOINT,\
715 .ep_c.bEndpointAddress = CDC_ACM_ENDPOINT | USB_EP_DIR_IN,\
716 .ep_c.bmAttributes = USB_EP_TYPE_INTERRUPT,\
717 .ep_c.wMaxPacketSize = LE16(CDC_ACM_SIZE),\
718 .ep_c.bInterval = CDC_EP_INTERVAL_STATUS,\
719 .iface_d.bLength = sizeof(usb_iface_desc_t),\
720 .iface_d.bDescriptorType = USB_DT_INTERFACE,\
721 .iface_d.bInterfaceNumber = CDC_DATA_INTERFACE,\
722 .iface_d.bAlternateSetting = 0,\
723 .iface_d.bNumEndpoints = 2,\
724 .iface_d.bInterfaceClass = CDC_CLASS_DATA,\
725 .iface_d.bInterfaceSubClass = 0,\
726 .iface_d.bInterfaceProtocol = 0,\
727 .iface_d.iInterface = 0,\
728 .ep_rx.bLength = sizeof(usb_ep_desc_t),\
729 .ep_rx.bDescriptorType = USB_DT_ENDPOINT,\
730 .ep_rx.bEndpointAddress = CDC_RX_ENDPOINT | USB_EP_DIR_OUT,\
731 .ep_rx.bmAttributes = USB_EP_TYPE_BULK,\
732 .ep_rx.wMaxPacketSize = LE16(CDC_RX_SIZE),\
733 .ep_rx.bInterval = CDC_EP_INTERVAL_DATA,\
734 .ep_tx.bLength = sizeof(usb_ep_desc_t),\
735 .ep_tx.bDescriptorType = USB_DT_ENDPOINT,\
736 .ep_tx.bEndpointAddress = CDC_TX_ENDPOINT | USB_EP_DIR_IN,\
737 .ep_tx.bmAttributes = USB_EP_TYPE_BULK,\
738 .ep_tx.wMaxPacketSize = LE16(CDC_TX_SIZE),\
739 .ep_tx.bInterval = CDC_EP_INTERVAL_DATA,\
742 COMPILER_PACK_RESET()
746 // **********************************************************************
747 // CONFIGURATION Descriptor structure and content
748 // **********************************************************************
752 usb_conf_desc_t conf;
754 udi_hid_kbd_desc_t hid_kbd;
757 udi_hid_mou_desc_t hid_mou;
760 udi_hid_exk_desc_t hid_exk;
763 udi_hid_raw_desc_t hid_raw;
766 udi_hid_con_desc_t hid_con;
769 udi_hid_nkro_desc_t hid_nkro;
772 udi_hid_midi_desc_t hid_midi;
775 udi_cdc_desc_t cdc_serial;
779 COMPILER_PACK_RESET()
781 #endif //_UDI_DEVICE_CONF_H_