]> git.donarmstrong.com Git - qmk_firmware.git/blob - tmk_core/protocol/arm_atsam/usb/udi_device_conf.h
Merge branch 'master' of https://github.com/qmk/qmk_firmware
[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 //rules.mk
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 CON_INTERFACE               NEXT_INTERFACE_4
114 #define NEXT_INTERFACE_5            (CON_INTERFACE + 1)
115 #define UDI_HID_CON_IFACE_NUMBER    CON_INTERFACE
116 #else
117 #define NEXT_INTERFACE_5            NEXT_INTERFACE_4
118 #endif
119
120 #ifdef NKRO
121 #define NKRO_INTERFACE              NEXT_INTERFACE_5
122 #define NEXT_INTERFACE_6            (NKRO_INTERFACE + 1)
123 #define UDI_HID_NKRO_IFACE_NUMBER   NKRO_INTERFACE
124 #else
125 #define NEXT_INTERFACE_6            NEXT_INTERFACE_5
126 #endif
127
128 #ifdef MIDI
129 #define AC_INTERFACE                NEXT_INTERFACE_6
130 #define AS_INTERFACE                (AC_INTERFACE + 1)
131 #define NEXT_INTERFACE_7            (AS_INTERFACE + 1)
132 #else
133 #define NEXT_INTERFACE_7            NEXT_INTERFACE_6
134 #endif
135
136 #ifdef CDC
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
142 #else
143 #define NEXT_INTERFACE_8            NEXT_INTERFACE_7
144 #endif
145
146 /* nubmer of interfaces */
147 #define TOTAL_INTERFACES            NEXT_INTERFACE_8
148 #define USB_DEVICE_NB_INTERFACE     TOTAL_INTERFACES
149
150
151 // **********************************************************************
152 // Endopoint number and size
153 // **********************************************************************
154 #define USB_DEVICE_EP_CTRL_SIZE     8
155
156 #define NEXT_IN_EPNUM_0             1
157 #define NEXT_OUT_EPNUM_0            1
158
159 #ifdef KBD
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
167 #endif
168 #else
169 #define NEXT_IN_EPNUM_1             NEXT_IN_EPNUM_0
170 #endif
171
172 #ifdef MOU
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
180 #endif
181 #else
182 #define NEXT_IN_EPNUM_2             NEXT_IN_EPNUM_1
183 #endif
184
185 #ifdef EXK
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
193 #endif
194 #else
195 #define NEXT_IN_EPNUM_3             NEXT_IN_EPNUM_2
196 #endif
197
198 #ifdef RAW
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
208 #endif
209 #else
210 #define NEXT_IN_EPNUM_4             NEXT_IN_EPNUM_3
211 #define NEXT_OUT_EPNUM_1            NEXT_OUT_EPNUM_0
212 #endif
213
214 #ifdef CON
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
224 #endif
225 #else
226 #define NEXT_IN_EPNUM_5             NEXT_IN_EPNUM_4
227 #define NEXT_OUT_EPNUM_2            NEXT_OUT_EPNUM_1
228 #endif
229
230 #ifdef NKRO
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
238 #endif
239 #else
240 #define NEXT_IN_EPNUM_6             NEXT_IN_EPNUM_5
241 #endif
242
243 #ifdef MIDI
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
249 #else
250 #define NEXT_IN_EPNUM_7             NEXT_IN_EPNUM_6
251 #define NEXT_OUT_EPNUM_3            NEXT_OUT_EPNUM_2
252 #endif
253
254 #ifdef CDC
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)
259
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)
263
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"
273 #else
274 #define NEXT_IN_EPNUM_8             NEXT_IN_EPNUM_7
275 #define NEXT_OUT_EPNUM_4            NEXT_OUT_EPNUM_3
276 #endif
277
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))
281
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)"
284 #endif
285
286
287 // **********************************************************************
288 // KBD Descriptor structure and content
289 // **********************************************************************
290 #ifdef KBD
291
292 COMPILER_PACK_SET(1)
293
294 typedef struct {
295     usb_iface_desc_t iface;
296     usb_hid_descriptor_t hid;
297     usb_ep_desc_t ep;
298 } udi_hid_kbd_desc_t;
299
300 typedef struct {
301     uint8_t array[59];
302 } udi_hid_kbd_report_desc_t;
303
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,\
327 }
328
329 //set report buffer (from host)
330 extern uint8_t udi_hid_kbd_report_set;
331
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];
335
336 COMPILER_PACK_RESET()
337
338 #endif //KBD
339
340 // **********************************************************************
341 // EXK Descriptor structure and content
342 // **********************************************************************
343 #ifdef EXK
344
345 COMPILER_PACK_SET(1)
346
347 typedef struct {
348     usb_iface_desc_t iface;
349     usb_hid_descriptor_t hid;
350     usb_ep_desc_t ep;
351 } udi_hid_exk_desc_t;
352
353 typedef struct {
354     uint8_t array[54];
355 } udi_hid_exk_report_desc_t;
356
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,\
380 }
381
382 //set report buffer (from host)
383 extern uint8_t udi_hid_exk_report_set;
384
385 //report buffer
386 #define UDI_HID_EXK_REPORT_SIZE 3
387
388 typedef union {
389   struct {
390     uint8_t report_id;
391     uint16_t report_data;
392  } desc;
393  uint8_t raw[UDI_HID_EXK_REPORT_SIZE];
394 } udi_hid_exk_report_t;
395
396 extern udi_hid_exk_report_t udi_hid_exk_report;
397
398 COMPILER_PACK_RESET()
399
400 #endif //EXK
401
402 // **********************************************************************
403 // NKRO Descriptor structure and content
404 // **********************************************************************
405 #ifdef NKRO
406
407 COMPILER_PACK_SET(1)
408
409 typedef struct {
410     usb_iface_desc_t iface;
411     usb_hid_descriptor_t hid;
412     usb_ep_desc_t ep;
413 } udi_hid_nkro_desc_t;
414
415 typedef struct {
416     uint8_t array[57];
417 } udi_hid_nkro_report_desc_t;
418
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,\
442 }
443
444 //set report buffer
445 extern uint8_t udi_hid_nkro_report_set;
446
447 //report buffer
448 #define UDI_HID_NKRO_REPORT_SIZE 32
449 extern uint8_t udi_hid_nkro_report[UDI_HID_NKRO_REPORT_SIZE];
450
451 COMPILER_PACK_RESET()
452
453 #endif //NKRO
454
455 // **********************************************************************
456 // MOU Descriptor structure and content
457 // **********************************************************************
458 #ifdef MOU
459
460 COMPILER_PACK_SET(1)
461
462 typedef struct {
463     usb_iface_desc_t iface;
464     usb_hid_descriptor_t hid;
465     usb_ep_desc_t ep;
466 } udi_hid_mou_desc_t;
467
468 typedef struct {
469     uint8_t array[77];//MOU PDS
470 } udi_hid_mou_report_desc_t;
471
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,\
495 }
496
497 //no set report buffer
498
499 //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];
502
503 COMPILER_PACK_RESET()
504
505 #endif //MOU
506
507 // **********************************************************************
508 // RAW Descriptor structure and content
509 // **********************************************************************
510 #ifdef RAW
511
512 COMPILER_PACK_SET(1)
513
514 typedef struct {
515     usb_iface_desc_t iface;
516     usb_hid_descriptor_t hid;
517     usb_ep_desc_t ep_out;
518     usb_ep_desc_t ep_in;
519 } udi_hid_raw_desc_t;
520
521 typedef struct {
522     uint8_t array[27];
523 } udi_hid_raw_report_desc_t;
524
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,\
554 }
555
556 #define UDI_HID_RAW_REPORT_SIZE RAW_EPSIZE
557
558 extern uint8_t udi_hid_raw_report_set[UDI_HID_RAW_REPORT_SIZE];
559
560 //report buffer
561 extern uint8_t udi_hid_raw_report[UDI_HID_RAW_REPORT_SIZE];
562
563 COMPILER_PACK_RESET()
564
565 #endif //RAW
566
567 // **********************************************************************
568 // CON Descriptor structure and content
569 // **********************************************************************
570 #ifdef CON
571
572 COMPILER_PACK_SET(1)
573
574 typedef struct {
575     usb_iface_desc_t iface;
576     usb_hid_descriptor_t hid;
577     usb_ep_desc_t ep_out;
578     usb_ep_desc_t ep_in;
579 } udi_hid_con_desc_t;
580
581 typedef struct {
582     uint8_t array[34];
583 } udi_hid_con_report_desc_t;
584
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,\
614 }
615
616 #define UDI_HID_CON_REPORT_SIZE CONSOLE_EPSIZE
617
618 extern uint8_t udi_hid_con_report_set[UDI_HID_CON_REPORT_SIZE];
619
620 //report buffer
621 extern uint8_t udi_hid_con_report[UDI_HID_CON_REPORT_SIZE];
622
623 COMPILER_PACK_RESET()
624
625 #endif //CON
626
627 // **********************************************************************
628 // CDC Descriptor structure and content
629 // **********************************************************************
630 #ifdef CDC
631
632 COMPILER_PACK_SET(1)
633
634 typedef struct {
635     uint8_t bFunctionLength;
636     uint8_t bDescriptorType;
637     uint8_t bDescriptorSubtype;
638     le16_t  bcdCDC;
639 } usb_cdc_hdr_desc_t;
640
641 typedef struct {
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;
648
649 typedef struct {
650     uint8_t bFunctionLength;
651     uint8_t bDescriptorType;
652     uint8_t bDescriptorSubtype;
653     uint8_t bmCapabilities;
654 } usb_cdc_acm_desc_t;
655
656 typedef struct {
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;
663
664 typedef struct {
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;
671     usb_ep_desc_t ep_c;
672     usb_iface_desc_t iface_d;
673     usb_ep_desc_t ep_tx;
674     usb_ep_desc_t ep_rx;
675 } udi_cdc_desc_t;
676
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,\
740 }
741
742 COMPILER_PACK_RESET()
743
744 #endif //CDC
745
746 // **********************************************************************
747 // CONFIGURATION Descriptor structure and content
748 // **********************************************************************
749 COMPILER_PACK_SET(1)
750
751 typedef struct {
752     usb_conf_desc_t conf;
753 #ifdef KBD
754     udi_hid_kbd_desc_t hid_kbd;
755 #endif
756 #ifdef MOU
757     udi_hid_mou_desc_t hid_mou;
758 #endif
759 #ifdef EXK
760     udi_hid_exk_desc_t hid_exk;
761 #endif
762 #ifdef RAW
763     udi_hid_raw_desc_t hid_raw;
764 #endif
765 #ifdef CON
766     udi_hid_con_desc_t hid_con;
767 #endif
768 #ifdef NKRO
769     udi_hid_nkro_desc_t hid_nkro;
770 #endif
771 #ifdef MIDI
772     udi_hid_midi_desc_t hid_midi;
773 #endif
774 #ifdef CDC
775     udi_cdc_desc_t cdc_serial;
776 #endif
777 } udc_desc_t;
778
779 COMPILER_PACK_RESET()
780
781 #endif //_UDI_DEVICE_CONF_H_