blob: cf8edcceff53eec1561ebf9fd5d1a278cd3f51ac [file] [log] [blame]
Brian Silverman099196d2017-06-21 23:26:02 -07001/* Teensyduino Core Library
2 * http://www.pjrc.com/teensy/
3 * Copyright (c) 2017 PJRC.COM, LLC.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * 1. The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * 2. If the Software is incorporated into a build system that allows
17 * selection among a list of target devices, then similar target
18 * devices manufactured by PJRC.COM must be included in the list of
19 * target devices and selectable in the same manner.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
25 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
26 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 * SOFTWARE.
29 */
30
31#if F_CPU >= 20000000
32
33#define USB_DESC_LIST_DEFINE
Brian Silvermanb79af7c2017-06-21 23:48:02 -070034#include "motors/usb/usb_desc.h"
Brian Silverman099196d2017-06-21 23:26:02 -070035#ifdef NUM_ENDPOINTS
Brian Silvermanb79af7c2017-06-21 23:48:02 -070036#include "motors/usb/usb_names.h"
37#include "motors/core/kinetis.h"
38#include "motors/core/nonstd.h"
Brian Silverman099196d2017-06-21 23:26:02 -070039
40// USB Descriptors are binary data which the USB host reads to
41// automatically detect a USB device's capabilities. The format
42// and meaning of every field is documented in numerous USB
43// standards. When working with USB descriptors, despite the
44// complexity of the standards and poor writing quality in many
45// of those documents, remember descriptors are nothing more
46// than constant binary data that tells the USB host what the
47// device can do. Computers will load drivers based on this data.
48// Those drivers then communicate on the endpoints specified by
49// the descriptors.
50
51// To configure a new combination of interfaces or make minor
52// changes to existing configuration (eg, change the name or ID
53// numbers), usually you would edit "usb_desc.h". This file
54// is meant to be configured by the header, so generally it is
55// only edited to add completely new USB interfaces or features.
56
57
58
59// **************************************************************
60// USB Device
61// **************************************************************
62
63#define LSB(n) ((n) & 255)
64#define MSB(n) (((n) >> 8) & 255)
65
66// USB Device Descriptor. The USB host reads this first, to learn
67// what type of device is connected.
68static uint8_t device_descriptor[] = {
69 18, // bLength
70 1, // bDescriptorType
71 0x01, 0x01, // bcdUSB
72#ifdef DEVICE_CLASS
73 DEVICE_CLASS, // bDeviceClass
74#else
75 0,
76#endif
77#ifdef DEVICE_SUBCLASS
78 DEVICE_SUBCLASS, // bDeviceSubClass
79#else
80 0,
81#endif
82#ifdef DEVICE_PROTOCOL
83 DEVICE_PROTOCOL, // bDeviceProtocol
84#else
85 0,
86#endif
87 EP0_SIZE, // bMaxPacketSize0
88 LSB(VENDOR_ID), MSB(VENDOR_ID), // idVendor
89 LSB(PRODUCT_ID), MSB(PRODUCT_ID), // idProduct
90 0x00, 0x02, // bcdDevice
91 1, // iManufacturer
92 2, // iProduct
93 3, // iSerialNumber
94 1 // bNumConfigurations
95};
96
97// These descriptors must NOT be "const", because the USB DMA
98// has trouble accessing flash memory with enough bandwidth
99// while the processor is executing from flash.
100
101
102
103// **************************************************************
104// HID Report Descriptors
105// **************************************************************
106
107// Each HID interface needs a special report descriptor that tells
108// the meaning and format of the data.
109
110#ifdef KEYBOARD_INTERFACE
111// Keyboard Protocol 1, HID 1.11 spec, Appendix B, page 59-60
112static uint8_t keyboard_report_desc[] = {
113 0x05, 0x01, // Usage Page (Generic Desktop),
114 0x09, 0x06, // Usage (Keyboard),
115 0xA1, 0x01, // Collection (Application),
116 0x75, 0x01, // Report Size (1),
117 0x95, 0x08, // Report Count (8),
118 0x05, 0x07, // Usage Page (Key Codes),
119 0x19, 0xE0, // Usage Minimum (224),
120 0x29, 0xE7, // Usage Maximum (231),
121 0x15, 0x00, // Logical Minimum (0),
122 0x25, 0x01, // Logical Maximum (1),
123 0x81, 0x02, // Input (Data, Variable, Absolute), ;Modifier keys
124 0x95, 0x01, // Report Count (1),
125 0x75, 0x08, // Report Size (8),
126 0x81, 0x03, // Input (Constant), ;Reserved byte
127 0x95, 0x05, // Report Count (5),
128 0x75, 0x01, // Report Size (1),
129 0x05, 0x08, // Usage Page (LEDs),
130 0x19, 0x01, // Usage Minimum (1),
131 0x29, 0x05, // Usage Maximum (5),
132 0x91, 0x02, // Output (Data, Variable, Absolute), ;LED report
133 0x95, 0x01, // Report Count (1),
134 0x75, 0x03, // Report Size (3),
135 0x91, 0x03, // Output (Constant), ;LED report padding
136 0x95, 0x06, // Report Count (6),
137 0x75, 0x08, // Report Size (8),
138 0x15, 0x00, // Logical Minimum (0),
139 0x25, 0x7F, // Logical Maximum(104),
140 0x05, 0x07, // Usage Page (Key Codes),
141 0x19, 0x00, // Usage Minimum (0),
142 0x29, 0x7F, // Usage Maximum (104),
143 0x81, 0x00, // Input (Data, Array), ;Normal keys
144 0xC0 // End Collection
145};
146#endif
147
148#ifdef KEYMEDIA_INTERFACE
149static uint8_t keymedia_report_desc[] = {
150 0x05, 0x0C, // Usage Page (Consumer)
151 0x09, 0x01, // Usage (Consumer Controls)
152 0xA1, 0x01, // Collection (Application)
153 0x75, 0x0A, // Report Size (10)
154 0x95, 0x04, // Report Count (4)
155 0x19, 0x00, // Usage Minimum (0)
156 0x2A, 0x9C, 0x02, // Usage Maximum (0x29C)
157 0x15, 0x00, // Logical Minimum (0)
158 0x26, 0x9C, 0x02, // Logical Maximum (0x29C)
159 0x81, 0x00, // Input (Data, Array)
160 0x05, 0x01, // Usage Page (Generic Desktop)
161 0x75, 0x08, // Report Size (8)
162 0x95, 0x03, // Report Count (3)
163 0x19, 0x00, // Usage Minimum (0)
164 0x29, 0xB7, // Usage Maximum (0xB7)
165 0x15, 0x00, // Logical Minimum (0)
166 0x26, 0xB7, 0x00, // Logical Maximum (0xB7)
167 0x81, 0x00, // Input (Data, Array)
168 0xC0 // End Collection
169};
170#endif
171
172#ifdef MOUSE_INTERFACE
173// Mouse Protocol 1, HID 1.11 spec, Appendix B, page 59-60, with wheel extension
174static uint8_t mouse_report_desc[] = {
175 0x05, 0x01, // Usage Page (Generic Desktop)
176 0x09, 0x02, // Usage (Mouse)
177 0xA1, 0x01, // Collection (Application)
178 0x85, 0x01, // REPORT_ID (1)
179 0x05, 0x09, // Usage Page (Button)
180 0x19, 0x01, // Usage Minimum (Button #1)
181 0x29, 0x08, // Usage Maximum (Button #8)
182 0x15, 0x00, // Logical Minimum (0)
183 0x25, 0x01, // Logical Maximum (1)
184 0x95, 0x08, // Report Count (8)
185 0x75, 0x01, // Report Size (1)
186 0x81, 0x02, // Input (Data, Variable, Absolute)
187 0x05, 0x01, // Usage Page (Generic Desktop)
188 0x09, 0x30, // Usage (X)
189 0x09, 0x31, // Usage (Y)
190 0x09, 0x38, // Usage (Wheel)
191 0x15, 0x81, // Logical Minimum (-127)
192 0x25, 0x7F, // Logical Maximum (127)
193 0x75, 0x08, // Report Size (8),
194 0x95, 0x03, // Report Count (3),
195 0x81, 0x06, // Input (Data, Variable, Relative)
196 0x05, 0x0C, // Usage Page (Consumer)
197 0x0A, 0x38, 0x02, // Usage (AC Pan)
198 0x15, 0x81, // Logical Minimum (-127)
199 0x25, 0x7F, // Logical Maximum (127)
200 0x75, 0x08, // Report Size (8),
201 0x95, 0x01, // Report Count (1),
202 0x81, 0x06, // Input (Data, Variable, Relative)
203 0xC0, // End Collection
204 0x05, 0x01, // Usage Page (Generic Desktop)
205 0x09, 0x02, // Usage (Mouse)
206 0xA1, 0x01, // Collection (Application)
207 0x85, 0x02, // REPORT_ID (2)
208 0x05, 0x01, // Usage Page (Generic Desktop)
209 0x09, 0x30, // Usage (X)
210 0x09, 0x31, // Usage (Y)
211 0x15, 0x00, // Logical Minimum (0)
212 0x26, 0xFF, 0x7F, // Logical Maximum (32767)
213 0x75, 0x10, // Report Size (16),
214 0x95, 0x02, // Report Count (2),
215 0x81, 0x02, // Input (Data, Variable, Absolute)
216 0xC0 // End Collection
217};
218#endif
219
220#ifdef JOYSTICK_INTERFACE
221#if JOYSTICK_SIZE == 12
222static uint8_t joystick_report_desc[] = {
223 0x05, 0x01, // Usage Page (Generic Desktop)
224 0x09, 0x04, // Usage (Joystick)
225 0xA1, 0x01, // Collection (Application)
226 0x15, 0x00, // Logical Minimum (0)
227 0x25, 0x01, // Logical Maximum (1)
228 0x75, 0x01, // Report Size (1)
229 0x95, 0x20, // Report Count (32)
230 0x05, 0x09, // Usage Page (Button)
231 0x19, 0x01, // Usage Minimum (Button #1)
232 0x29, 0x20, // Usage Maximum (Button #32)
233 0x81, 0x02, // Input (variable,absolute)
234 0x15, 0x00, // Logical Minimum (0)
235 0x25, 0x07, // Logical Maximum (7)
236 0x35, 0x00, // Physical Minimum (0)
237 0x46, 0x3B, 0x01, // Physical Maximum (315)
238 0x75, 0x04, // Report Size (4)
239 0x95, 0x01, // Report Count (1)
240 0x65, 0x14, // Unit (20)
241 0x05, 0x01, // Usage Page (Generic Desktop)
242 0x09, 0x39, // Usage (Hat switch)
243 0x81, 0x42, // Input (variable,absolute,null_state)
244 0x05, 0x01, // Usage Page (Generic Desktop)
245 0x09, 0x01, // Usage (Pointer)
246 0xA1, 0x00, // Collection ()
247 0x15, 0x00, // Logical Minimum (0)
248 0x26, 0xFF, 0x03, // Logical Maximum (1023)
249 0x75, 0x0A, // Report Size (10)
250 0x95, 0x04, // Report Count (4)
251 0x09, 0x30, // Usage (X)
252 0x09, 0x31, // Usage (Y)
253 0x09, 0x32, // Usage (Z)
254 0x09, 0x35, // Usage (Rz)
255 0x81, 0x02, // Input (variable,absolute)
256 0xC0, // End Collection
257 0x15, 0x00, // Logical Minimum (0)
258 0x26, 0xFF, 0x03, // Logical Maximum (1023)
259 0x75, 0x0A, // Report Size (10)
260 0x95, 0x02, // Report Count (2)
261 0x09, 0x36, // Usage (Slider)
262 0x09, 0x36, // Usage (Slider)
263 0x81, 0x02, // Input (variable,absolute)
264 0xC0 // End Collection
265};
266#elif JOYSTICK_SIZE == 64
267// extreme joystick (to use this, edit JOYSTICK_SIZE to 64 in usb_desc.h)
268// 128 buttons 16
269// 6 axes 12
270// 17 sliders 34
271// 4 pov 2
272static uint8_t joystick_report_desc[] = {
273 0x05, 0x01, // Usage Page (Generic Desktop)
274 0x09, 0x04, // Usage (Joystick)
275 0xA1, 0x01, // Collection (Application)
276 0x15, 0x00, // Logical Minimum (0)
277 0x25, 0x01, // Logical Maximum (1)
278 0x75, 0x01, // Report Size (1)
279 0x95, 0x80, // Report Count (128)
280 0x05, 0x09, // Usage Page (Button)
281 0x19, 0x01, // Usage Minimum (Button #1)
282 0x29, 0x80, // Usage Maximum (Button #128)
283 0x81, 0x02, // Input (variable,absolute)
284 0x05, 0x01, // Usage Page (Generic Desktop)
285 0x09, 0x01, // Usage (Pointer)
286 0xA1, 0x00, // Collection ()
287 0x15, 0x00, // Logical Minimum (0)
288 0x27, 0xFF, 0xFF, 0, 0, // Logical Maximum (65535)
289 0x75, 0x10, // Report Size (16)
290 0x95, 23, // Report Count (23)
291 0x09, 0x30, // Usage (X)
292 0x09, 0x31, // Usage (Y)
293 0x09, 0x32, // Usage (Z)
294 0x09, 0x33, // Usage (Rx)
295 0x09, 0x34, // Usage (Ry)
296 0x09, 0x35, // Usage (Rz)
297 0x09, 0x36, // Usage (Slider)
298 0x09, 0x36, // Usage (Slider)
299 0x09, 0x36, // Usage (Slider)
300 0x09, 0x36, // Usage (Slider)
301 0x09, 0x36, // Usage (Slider)
302 0x09, 0x36, // Usage (Slider)
303 0x09, 0x36, // Usage (Slider)
304 0x09, 0x36, // Usage (Slider)
305 0x09, 0x36, // Usage (Slider)
306 0x09, 0x36, // Usage (Slider)
307 0x09, 0x36, // Usage (Slider)
308 0x09, 0x36, // Usage (Slider)
309 0x09, 0x36, // Usage (Slider)
310 0x09, 0x36, // Usage (Slider)
311 0x09, 0x36, // Usage (Slider)
312 0x09, 0x36, // Usage (Slider)
313 0x09, 0x36, // Usage (Slider)
314 0x81, 0x02, // Input (variable,absolute)
315 0xC0, // End Collection
316 0x15, 0x00, // Logical Minimum (0)
317 0x25, 0x07, // Logical Maximum (7)
318 0x35, 0x00, // Physical Minimum (0)
319 0x46, 0x3B, 0x01, // Physical Maximum (315)
320 0x75, 0x04, // Report Size (4)
321 0x95, 0x04, // Report Count (4)
322 0x65, 0x14, // Unit (20)
323 0x05, 0x01, // Usage Page (Generic Desktop)
324 0x09, 0x39, // Usage (Hat switch)
325 0x09, 0x39, // Usage (Hat switch)
326 0x09, 0x39, // Usage (Hat switch)
327 0x09, 0x39, // Usage (Hat switch)
328 0x81, 0x42, // Input (variable,absolute,null_state)
329 0xC0 // End Collection
330};
331#endif // JOYSTICK_SIZE
332#endif // JOYSTICK_INTERFACE
333
334#ifdef MULTITOUCH_INTERFACE
335// https://forum.pjrc.com/threads/32331-USB-HID-Touchscreen-support-needed
336// https://msdn.microsoft.com/en-us/library/windows/hardware/jj151563%28v=vs.85%29.aspx
337// https://msdn.microsoft.com/en-us/library/windows/hardware/jj151565%28v=vs.85%29.aspx
338// https://msdn.microsoft.com/en-us/library/windows/hardware/ff553734%28v=vs.85%29.aspx
339// https://msdn.microsoft.com/en-us/library/windows/hardware/jj151564%28v=vs.85%29.aspx
340// download.microsoft.com/download/a/d/f/adf1347d-08dc-41a4-9084-623b1194d4b2/digitizerdrvs_touch.docx
341static uint8_t multitouch_report_desc[] = {
342 0x05, 0x0D, // Usage Page (Digitizer)
343 0x09, 0x04, // Usage (Touch Screen)
344 0xa1, 0x01, // Collection (Application)
345 0x09, 0x22, // Usage (Finger)
346 0xA1, 0x02, // Collection (Logical)
347 0x09, 0x42, // Usage (Tip Switch)
348 0x15, 0x00, // Logical Minimum (0)
349 0x25, 0x01, // Logical Maximum (1)
350 0x75, 0x01, // Report Size (1)
351 0x95, 0x01, // Report Count (1)
352 0x81, 0x02, // Input (variable,absolute)
353 0x09, 0x30, // Usage (Pressure)
354 0x25, 0x7F, // Logical Maximum (127)
355 0x75, 0x07, // Report Size (7)
356 0x95, 0x01, // Report Count (1)
357 0x81, 0x02, // Input (variable,absolute)
358 0x09, 0x51, // Usage (Contact Identifier)
359 0x26, 0xFF, 0x00, // Logical Maximum (255)
360 0x75, 0x08, // Report Size (8)
361 0x95, 0x01, // Report Count (1)
362 0x81, 0x02, // Input (variable,absolute)
363 0x05, 0x01, // Usage Page (Generic Desktop)
364 0x09, 0x30, // Usage (X)
365 0x09, 0x31, // Usage (Y)
366 0x26, 0xFF, 0x7F, // Logical Maximum (32767)
367 0x65, 0x00, // Unit (None) <-- probably needs real units?
368 0x75, 0x10, // Report Size (16)
369 0x95, 0x02, // Report Count (2)
370 0x81, 0x02, // Input (variable,absolute)
371 0xC0, // End Collection
372 0x05, 0x0D, // Usage Page (Digitizer)
373 0x27, 0xFF, 0xFF, 0, 0, // Logical Maximum (65535)
374 0x75, 0x10, // Report Size (16)
375 0x95, 0x01, // Report Count (1)
376 0x09, 0x56, // Usage (Scan Time)
377 0x81, 0x02, // Input (variable,absolute)
378 0x09, 0x54, // Usage (Contact Count)
379 0x25, MULTITOUCH_FINGERS, // Logical Maximum (10)
380 0x75, 0x08, // Report Size (8)
381 0x95, 0x01, // Report Count (1)
382 0x81, 0x02, // Input (variable,absolute)
383 0x05, 0x0D, // Usage Page (Digitizers)
384 0x09, 0x55, // Usage (Contact Count Maximum)
385 0x25, MULTITOUCH_FINGERS, // Logical Maximum (10)
386 0x75, 0x08, // Report Size (8)
387 0x95, 0x01, // Report Count (1)
388 0xB1, 0x02, // Feature (variable,absolute)
389 0xC0 // End Collection
390};
391#endif
392
393#ifdef SEREMU_INTERFACE
394static uint8_t seremu_report_desc[] = {
395 0x06, 0xC9, 0xFF, // Usage Page 0xFFC9 (vendor defined)
396 0x09, 0x04, // Usage 0x04
397 0xA1, 0x5C, // Collection 0x5C
398 0x75, 0x08, // report size = 8 bits (global)
399 0x15, 0x00, // logical minimum = 0 (global)
400 0x26, 0xFF, 0x00, // logical maximum = 255 (global)
401 0x95, SEREMU_TX_SIZE, // report count (global)
402 0x09, 0x75, // usage (local)
403 0x81, 0x02, // Input
404 0x95, SEREMU_RX_SIZE, // report count (global)
405 0x09, 0x76, // usage (local)
406 0x91, 0x02, // Output
407 0x95, 0x04, // report count (global)
408 0x09, 0x76, // usage (local)
409 0xB1, 0x02, // Feature
410 0xC0 // end collection
411};
412#endif
413
414#ifdef RAWHID_INTERFACE
415static uint8_t rawhid_report_desc[] = {
416 0x06, LSB(RAWHID_USAGE_PAGE), MSB(RAWHID_USAGE_PAGE),
417 0x0A, LSB(RAWHID_USAGE), MSB(RAWHID_USAGE),
418 0xA1, 0x01, // Collection 0x01
419 0x75, 0x08, // report size = 8 bits
420 0x15, 0x00, // logical minimum = 0
421 0x26, 0xFF, 0x00, // logical maximum = 255
422 0x95, RAWHID_TX_SIZE, // report count
423 0x09, 0x01, // usage
424 0x81, 0x02, // Input (array)
425 0x95, RAWHID_RX_SIZE, // report count
426 0x09, 0x02, // usage
427 0x91, 0x02, // Output (array)
428 0xC0 // end collection
429};
430#endif
431
432#ifdef FLIGHTSIM_INTERFACE
433static uint8_t flightsim_report_desc[] = {
434 0x06, 0x1C, 0xFF, // Usage page = 0xFF1C
435 0x0A, 0x39, 0xA7, // Usage = 0xA739
436 0xA1, 0x01, // Collection 0x01
437 0x75, 0x08, // report size = 8 bits
438 0x15, 0x00, // logical minimum = 0
439 0x26, 0xFF, 0x00, // logical maximum = 255
440 0x95, FLIGHTSIM_TX_SIZE, // report count
441 0x09, 0x01, // usage
442 0x81, 0x02, // Input (array)
443 0x95, FLIGHTSIM_RX_SIZE, // report count
444 0x09, 0x02, // usage
445 0x91, 0x02, // Output (array)
446 0xC0 // end collection
447};
448#endif
449
450
451// **************************************************************
452// USB Descriptor Sizes
453// **************************************************************
454
455// pre-compute the size and position of everything in the config descriptor
456//
457#define CONFIG_HEADER_DESCRIPTOR_SIZE 9
458
459#define CDC_IAD_DESCRIPTOR_POS CONFIG_HEADER_DESCRIPTOR_SIZE
460#ifdef CDC_IAD_DESCRIPTOR
461#define CDC_IAD_DESCRIPTOR_SIZE 8
462#else
463#define CDC_IAD_DESCRIPTOR_SIZE 0
464#endif
465
466#define CDC_DATA_INTERFACE_DESC_POS CDC_IAD_DESCRIPTOR_POS+CDC_IAD_DESCRIPTOR_SIZE
467#ifdef CDC_DATA_INTERFACE
468#define CDC_DATA_INTERFACE_DESC_SIZE 9+5+5+4+5+7+9+7+7
469#else
470#define CDC_DATA_INTERFACE_DESC_SIZE 0
471#endif
472
Brian Silvermanb79af7c2017-06-21 23:48:02 -0700473#define CDC2_DATA_INTERFACE_DESC_POS CDC_DATA_INTERFACE_DESC_POS+CDC_DATA_INTERFACE_DESC_SIZE
474#ifdef CDC2_DATA_INTERFACE
475#define CDC2_DATA_INTERFACE_DESC_SIZE 9+5+5+4+5+7+9+7+7
476#else
477#define CDC2_DATA_INTERFACE_DESC_SIZE 0
478#endif
479
480#define MIDI_INTERFACE_DESC_POS CDC2_DATA_INTERFACE_DESC_POS+CDC2_DATA_INTERFACE_DESC_SIZE
Brian Silverman099196d2017-06-21 23:26:02 -0700481#ifdef MIDI_INTERFACE
482#define MIDI_INTERFACE_DESC_SIZE 9+7+6+6+9+9+9+5+9+5
483#else
484#define MIDI_INTERFACE_DESC_SIZE 0
485#endif
486
487#define KEYBOARD_INTERFACE_DESC_POS MIDI_INTERFACE_DESC_POS+MIDI_INTERFACE_DESC_SIZE
488#ifdef KEYBOARD_INTERFACE
489#define KEYBOARD_INTERFACE_DESC_SIZE 9+9+7
490#define KEYBOARD_HID_DESC_OFFSET KEYBOARD_INTERFACE_DESC_POS+9
491#else
492#define KEYBOARD_INTERFACE_DESC_SIZE 0
493#endif
494
495#define MOUSE_INTERFACE_DESC_POS KEYBOARD_INTERFACE_DESC_POS+KEYBOARD_INTERFACE_DESC_SIZE
496#ifdef MOUSE_INTERFACE
497#define MOUSE_INTERFACE_DESC_SIZE 9+9+7
498#define MOUSE_HID_DESC_OFFSET MOUSE_INTERFACE_DESC_POS+9
499#else
500#define MOUSE_INTERFACE_DESC_SIZE 0
501#endif
502
503#define RAWHID_INTERFACE_DESC_POS MOUSE_INTERFACE_DESC_POS+MOUSE_INTERFACE_DESC_SIZE
504#ifdef RAWHID_INTERFACE
505#define RAWHID_INTERFACE_DESC_SIZE 9+9+7+7
506#define RAWHID_HID_DESC_OFFSET RAWHID_INTERFACE_DESC_POS+9
507#else
508#define RAWHID_INTERFACE_DESC_SIZE 0
509#endif
510
511#define FLIGHTSIM_INTERFACE_DESC_POS RAWHID_INTERFACE_DESC_POS+RAWHID_INTERFACE_DESC_SIZE
512#ifdef FLIGHTSIM_INTERFACE
513#define FLIGHTSIM_INTERFACE_DESC_SIZE 9+9+7+7
514#define FLIGHTSIM_HID_DESC_OFFSET FLIGHTSIM_INTERFACE_DESC_POS+9
515#else
516#define FLIGHTSIM_INTERFACE_DESC_SIZE 0
517#endif
518
519#define SEREMU_INTERFACE_DESC_POS FLIGHTSIM_INTERFACE_DESC_POS+FLIGHTSIM_INTERFACE_DESC_SIZE
520#ifdef SEREMU_INTERFACE
521#define SEREMU_INTERFACE_DESC_SIZE 9+9+7+7
522#define SEREMU_HID_DESC_OFFSET SEREMU_INTERFACE_DESC_POS+9
523#else
524#define SEREMU_INTERFACE_DESC_SIZE 0
525#endif
526
527#define JOYSTICK_INTERFACE_DESC_POS SEREMU_INTERFACE_DESC_POS+SEREMU_INTERFACE_DESC_SIZE
528#ifdef JOYSTICK_INTERFACE
529#define JOYSTICK_INTERFACE_DESC_SIZE 9+9+7
530#define JOYSTICK_HID_DESC_OFFSET JOYSTICK_INTERFACE_DESC_POS+9
531#else
532#define JOYSTICK_INTERFACE_DESC_SIZE 0
533#endif
534
535#define MTP_INTERFACE_DESC_POS JOYSTICK_INTERFACE_DESC_POS+JOYSTICK_INTERFACE_DESC_SIZE
536#ifdef MTP_INTERFACE
537#define MTP_INTERFACE_DESC_SIZE 9+7+7+7
538#else
539#define MTP_INTERFACE_DESC_SIZE 0
540#endif
541
542#define KEYMEDIA_INTERFACE_DESC_POS MTP_INTERFACE_DESC_POS+MTP_INTERFACE_DESC_SIZE
543#ifdef KEYMEDIA_INTERFACE
544#define KEYMEDIA_INTERFACE_DESC_SIZE 9+9+7
545#define KEYMEDIA_HID_DESC_OFFSET KEYMEDIA_INTERFACE_DESC_POS+9
546#else
547#define KEYMEDIA_INTERFACE_DESC_SIZE 0
548#endif
549
550#define AUDIO_INTERFACE_DESC_POS KEYMEDIA_INTERFACE_DESC_POS+KEYMEDIA_INTERFACE_DESC_SIZE
551#ifdef AUDIO_INTERFACE
552#define AUDIO_INTERFACE_DESC_SIZE 8 + 9+10+12+9+12+10+9 + 9+9+7+11+9+7 + 9+9+7+11+9+7+9
553#else
554#define AUDIO_INTERFACE_DESC_SIZE 0
555#endif
556
557#define MULTITOUCH_INTERFACE_DESC_POS AUDIO_INTERFACE_DESC_POS+AUDIO_INTERFACE_DESC_SIZE
558#ifdef MULTITOUCH_INTERFACE
559#define MULTITOUCH_INTERFACE_DESC_SIZE 9+9+7
560#define MULTITOUCH_HID_DESC_OFFSET MULTITOUCH_INTERFACE_DESC_POS+9
561#else
562#define MULTITOUCH_INTERFACE_DESC_SIZE 0
563#endif
564
565#define CONFIG_DESC_SIZE MULTITOUCH_INTERFACE_DESC_POS+MULTITOUCH_INTERFACE_DESC_SIZE
566
567
568
569// **************************************************************
570// USB Configuration
571// **************************************************************
572
573// USB Configuration Descriptor. This huge descriptor tells all
574// of the devices capbilities.
575static uint8_t config_descriptor[CONFIG_DESC_SIZE] = {
576 // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
577 9, // bLength;
578 2, // bDescriptorType;
579 LSB(CONFIG_DESC_SIZE), // wTotalLength
580 MSB(CONFIG_DESC_SIZE),
581 NUM_INTERFACE, // bNumInterfaces
582 1, // bConfigurationValue
583 0, // iConfiguration
584 0xC0, // bmAttributes
585 50, // bMaxPower
586
587#ifdef CDC_IAD_DESCRIPTOR
588 // interface association descriptor, USB ECN, Table 9-Z
589 8, // bLength
590 11, // bDescriptorType
591 CDC_STATUS_INTERFACE, // bFirstInterface
592 2, // bInterfaceCount
593 0x02, // bFunctionClass
594 0x02, // bFunctionSubClass
595 0x01, // bFunctionProtocol
596 4, // iFunction
597#endif
598
599#ifdef CDC_DATA_INTERFACE
600 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
601 9, // bLength
602 4, // bDescriptorType
603 CDC_STATUS_INTERFACE, // bInterfaceNumber
604 0, // bAlternateSetting
605 1, // bNumEndpoints
606 0x02, // bInterfaceClass
607 0x02, // bInterfaceSubClass
608 0x01, // bInterfaceProtocol
609 0, // iInterface
610 // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26
611 5, // bFunctionLength
612 0x24, // bDescriptorType
613 0x00, // bDescriptorSubtype
614 0x10, 0x01, // bcdCDC
615 // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27
616 5, // bFunctionLength
617 0x24, // bDescriptorType
618 0x01, // bDescriptorSubtype
619 0x01, // bmCapabilities
620 1, // bDataInterface
621 // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28
622 4, // bFunctionLength
623 0x24, // bDescriptorType
624 0x02, // bDescriptorSubtype
625 0x06, // bmCapabilities
626 // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33
627 5, // bFunctionLength
628 0x24, // bDescriptorType
629 0x06, // bDescriptorSubtype
630 CDC_STATUS_INTERFACE, // bMasterInterface
631 CDC_DATA_INTERFACE, // bSlaveInterface0
632 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
633 7, // bLength
634 5, // bDescriptorType
635 CDC_ACM_ENDPOINT | 0x80, // bEndpointAddress
636 0x03, // bmAttributes (0x03=intr)
637 CDC_ACM_SIZE, 0, // wMaxPacketSize
638 64, // bInterval
639 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
640 9, // bLength
641 4, // bDescriptorType
642 CDC_DATA_INTERFACE, // bInterfaceNumber
643 0, // bAlternateSetting
644 2, // bNumEndpoints
645 0x0A, // bInterfaceClass
646 0x00, // bInterfaceSubClass
647 0x00, // bInterfaceProtocol
648 0, // iInterface
649 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
650 7, // bLength
651 5, // bDescriptorType
652 CDC_RX_ENDPOINT, // bEndpointAddress
653 0x02, // bmAttributes (0x02=bulk)
654 CDC_RX_SIZE, 0, // wMaxPacketSize
655 0, // bInterval
656 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
657 7, // bLength
658 5, // bDescriptorType
659 CDC_TX_ENDPOINT | 0x80, // bEndpointAddress
660 0x02, // bmAttributes (0x02=bulk)
661 CDC_TX_SIZE, 0, // wMaxPacketSize
662 0, // bInterval
663#endif // CDC_DATA_INTERFACE
664
Brian Silvermanb79af7c2017-06-21 23:48:02 -0700665#ifdef CDC2_DATA_INTERFACE
666 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
667 9, // bLength
668 4, // bDescriptorType
669 CDC2_STATUS_INTERFACE, // bInterfaceNumber
670 0, // bAlternateSetting
671 1, // bNumEndpoints
672 0x02, // bInterfaceClass
673 0x02, // bInterfaceSubClass
674 0x01, // bInterfaceProtocol
675 0, // iInterface
676 // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26
677 5, // bFunctionLength
678 0x24, // bDescriptorType
679 0x00, // bDescriptorSubtype
680 0x10, 0x01, // bcdCDC
681 // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27
682 5, // bFunctionLength
683 0x24, // bDescriptorType
684 0x01, // bDescriptorSubtype
685 0x01, // bmCapabilities
686 1, // bDataInterface
687 // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28
688 4, // bFunctionLength
689 0x24, // bDescriptorType
690 0x02, // bDescriptorSubtype
691 0x06, // bmCapabilities
692 // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33
693 5, // bFunctionLength
694 0x24, // bDescriptorType
695 0x06, // bDescriptorSubtype
696 CDC2_STATUS_INTERFACE, // bMasterInterface
697 CDC2_DATA_INTERFACE, // bSlaveInterface0
698 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
699 7, // bLength
700 5, // bDescriptorType
701 CDC2_ACM_ENDPOINT | 0x80, // bEndpointAddress
702 0x03, // bmAttributes (0x03=intr)
703 CDC_ACM_SIZE, 0, // wMaxPacketSize
704 64, // bInterval
705 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
706 9, // bLength
707 4, // bDescriptorType
708 CDC2_DATA_INTERFACE, // bInterfaceNumber
709 0, // bAlternateSetting
710 2, // bNumEndpoints
711 0x0A, // bInterfaceClass
712 0x00, // bInterfaceSubClass
713 0x00, // bInterfaceProtocol
714 0, // iInterface
715 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
716 7, // bLength
717 5, // bDescriptorType
718 CDC2_RX_ENDPOINT, // bEndpointAddress
719 0x02, // bmAttributes (0x02=bulk)
720 CDC_RX_SIZE, 0, // wMaxPacketSize
721 0, // bInterval
722 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
723 7, // bLength
724 5, // bDescriptorType
725 CDC2_TX_ENDPOINT | 0x80, // bEndpointAddress
726 0x02, // bmAttributes (0x02=bulk)
727 CDC_TX_SIZE, 0, // wMaxPacketSize
728 0, // bInterval
729#endif // CDC_DATA_INTERFACE
730
Brian Silverman099196d2017-06-21 23:26:02 -0700731#ifdef MIDI_INTERFACE
732 // Standard MS Interface Descriptor,
733 9, // bLength
734 4, // bDescriptorType
735 MIDI_INTERFACE, // bInterfaceNumber
736 0, // bAlternateSetting
737 2, // bNumEndpoints
738 0x01, // bInterfaceClass (0x01 = Audio)
739 0x03, // bInterfaceSubClass (0x03 = MIDI)
740 0x00, // bInterfaceProtocol (unused for MIDI)
741 0, // iInterface
742 // MIDI MS Interface Header, USB MIDI 6.1.2.1, page 21, Table 6-2
743 7, // bLength
744 0x24, // bDescriptorType = CS_INTERFACE
745 0x01, // bDescriptorSubtype = MS_HEADER
746 0x00, 0x01, // bcdMSC = revision 01.00
747 0x41, 0x00, // wTotalLength
748 // MIDI IN Jack Descriptor, B.4.3, Table B-7 (embedded), page 40
749 6, // bLength
750 0x24, // bDescriptorType = CS_INTERFACE
751 0x02, // bDescriptorSubtype = MIDI_IN_JACK
752 0x01, // bJackType = EMBEDDED
753 1, // bJackID, ID = 1
754 0, // iJack
755 // MIDI IN Jack Descriptor, B.4.3, Table B-8 (external), page 40
756 6, // bLength
757 0x24, // bDescriptorType = CS_INTERFACE
758 0x02, // bDescriptorSubtype = MIDI_IN_JACK
759 0x02, // bJackType = EXTERNAL
760 2, // bJackID, ID = 2
761 0, // iJack
762 // MIDI OUT Jack Descriptor, B.4.4, Table B-9, page 41
763 9,
764 0x24, // bDescriptorType = CS_INTERFACE
765 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
766 0x01, // bJackType = EMBEDDED
767 3, // bJackID, ID = 3
768 1, // bNrInputPins = 1 pin
769 2, // BaSourceID(1) = 2
770 1, // BaSourcePin(1) = first pin
771 0, // iJack
772 // MIDI OUT Jack Descriptor, B.4.4, Table B-10, page 41
773 9,
774 0x24, // bDescriptorType = CS_INTERFACE
775 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
776 0x02, // bJackType = EXTERNAL
777 4, // bJackID, ID = 4
778 1, // bNrInputPins = 1 pin
779 1, // BaSourceID(1) = 1
780 1, // BaSourcePin(1) = first pin
781 0, // iJack
782 // Standard Bulk OUT Endpoint Descriptor, B.5.1, Table B-11, pae 42
783 9, // bLength
784 5, // bDescriptorType = ENDPOINT
785 MIDI_RX_ENDPOINT, // bEndpointAddress
786 0x02, // bmAttributes (0x02=bulk)
787 MIDI_RX_SIZE, 0, // wMaxPacketSize
788 0, // bInterval
789 0, // bRefresh
790 0, // bSynchAddress
791 // Class-specific MS Bulk OUT Endpoint Descriptor, B.5.2, Table B-12, page 42
792 5, // bLength
793 0x25, // bDescriptorSubtype = CS_ENDPOINT
794 0x01, // bJackType = MS_GENERAL
795 1, // bNumEmbMIDIJack = 1 jack
796 1, // BaAssocJackID(1) = jack ID #1
797 // Standard Bulk IN Endpoint Descriptor, B.5.1, Table B-11, pae 42
798 9, // bLength
799 5, // bDescriptorType = ENDPOINT
800 MIDI_TX_ENDPOINT | 0x80, // bEndpointAddress
801 0x02, // bmAttributes (0x02=bulk)
802 MIDI_TX_SIZE, 0, // wMaxPacketSize
803 0, // bInterval
804 0, // bRefresh
805 0, // bSynchAddress
806 // Class-specific MS Bulk IN Endpoint Descriptor, B.5.2, Table B-12, page 42
807 5, // bLength
808 0x25, // bDescriptorSubtype = CS_ENDPOINT
809 0x01, // bJackType = MS_GENERAL
810 1, // bNumEmbMIDIJack = 1 jack
811 3, // BaAssocJackID(1) = jack ID #3
812#endif // MIDI_INTERFACE
813
814#ifdef KEYBOARD_INTERFACE
815 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
816 9, // bLength
817 4, // bDescriptorType
818 KEYBOARD_INTERFACE, // bInterfaceNumber
819 0, // bAlternateSetting
820 1, // bNumEndpoints
821 0x03, // bInterfaceClass (0x03 = HID)
822 0x01, // bInterfaceSubClass (0x01 = Boot)
823 0x01, // bInterfaceProtocol (0x01 = Keyboard)
824 0, // iInterface
825 // HID interface descriptor, HID 1.11 spec, section 6.2.1
826 9, // bLength
827 0x21, // bDescriptorType
828 0x11, 0x01, // bcdHID
829 0, // bCountryCode
830 1, // bNumDescriptors
831 0x22, // bDescriptorType
832 LSB(sizeof(keyboard_report_desc)), // wDescriptorLength
833 MSB(sizeof(keyboard_report_desc)),
834 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
835 7, // bLength
836 5, // bDescriptorType
837 KEYBOARD_ENDPOINT | 0x80, // bEndpointAddress
838 0x03, // bmAttributes (0x03=intr)
839 KEYBOARD_SIZE, 0, // wMaxPacketSize
840 KEYBOARD_INTERVAL, // bInterval
841#endif // KEYBOARD_INTERFACE
842
843#ifdef MOUSE_INTERFACE
844 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
845 9, // bLength
846 4, // bDescriptorType
847 MOUSE_INTERFACE, // bInterfaceNumber
848 0, // bAlternateSetting
849 1, // bNumEndpoints
850 0x03, // bInterfaceClass (0x03 = HID)
851 0x00, // bInterfaceSubClass (0x01 = Boot)
852 0x00, // bInterfaceProtocol (0x02 = Mouse)
853 0, // iInterface
854 // HID interface descriptor, HID 1.11 spec, section 6.2.1
855 9, // bLength
856 0x21, // bDescriptorType
857 0x11, 0x01, // bcdHID
858 0, // bCountryCode
859 1, // bNumDescriptors
860 0x22, // bDescriptorType
861 LSB(sizeof(mouse_report_desc)), // wDescriptorLength
862 MSB(sizeof(mouse_report_desc)),
863 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
864 7, // bLength
865 5, // bDescriptorType
866 MOUSE_ENDPOINT | 0x80, // bEndpointAddress
867 0x03, // bmAttributes (0x03=intr)
868 MOUSE_SIZE, 0, // wMaxPacketSize
869 MOUSE_INTERVAL, // bInterval
870#endif // MOUSE_INTERFACE
871
872#ifdef RAWHID_INTERFACE
873 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
874 9, // bLength
875 4, // bDescriptorType
876 RAWHID_INTERFACE, // bInterfaceNumber
877 0, // bAlternateSetting
878 2, // bNumEndpoints
879 0x03, // bInterfaceClass (0x03 = HID)
880 0x00, // bInterfaceSubClass
881 0x00, // bInterfaceProtocol
882 0, // iInterface
883 // HID interface descriptor, HID 1.11 spec, section 6.2.1
884 9, // bLength
885 0x21, // bDescriptorType
886 0x11, 0x01, // bcdHID
887 0, // bCountryCode
888 1, // bNumDescriptors
889 0x22, // bDescriptorType
890 LSB(sizeof(rawhid_report_desc)), // wDescriptorLength
891 MSB(sizeof(rawhid_report_desc)),
892 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
893 7, // bLength
894 5, // bDescriptorType
895 RAWHID_TX_ENDPOINT | 0x80, // bEndpointAddress
896 0x03, // bmAttributes (0x03=intr)
897 RAWHID_TX_SIZE, 0, // wMaxPacketSize
898 RAWHID_TX_INTERVAL, // bInterval
899 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
900 7, // bLength
901 5, // bDescriptorType
902 RAWHID_RX_ENDPOINT, // bEndpointAddress
903 0x03, // bmAttributes (0x03=intr)
904 RAWHID_RX_SIZE, 0, // wMaxPacketSize
905 RAWHID_RX_INTERVAL, // bInterval
906#endif // RAWHID_INTERFACE
907
908#ifdef FLIGHTSIM_INTERFACE
909 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
910 9, // bLength
911 4, // bDescriptorType
912 FLIGHTSIM_INTERFACE, // bInterfaceNumber
913 0, // bAlternateSetting
914 2, // bNumEndpoints
915 0x03, // bInterfaceClass (0x03 = HID)
916 0x00, // bInterfaceSubClass
917 0x00, // bInterfaceProtocol
918 0, // iInterface
919 // HID interface descriptor, HID 1.11 spec, section 6.2.1
920 9, // bLength
921 0x21, // bDescriptorType
922 0x11, 0x01, // bcdHID
923 0, // bCountryCode
924 1, // bNumDescriptors
925 0x22, // bDescriptorType
926 LSB(sizeof(flightsim_report_desc)), // wDescriptorLength
927 MSB(sizeof(flightsim_report_desc)),
928 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
929 7, // bLength
930 5, // bDescriptorType
931 FLIGHTSIM_TX_ENDPOINT | 0x80, // bEndpointAddress
932 0x03, // bmAttributes (0x03=intr)
933 FLIGHTSIM_TX_SIZE, 0, // wMaxPacketSize
934 FLIGHTSIM_TX_INTERVAL, // bInterval
935 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
936 7, // bLength
937 5, // bDescriptorType
938 FLIGHTSIM_RX_ENDPOINT, // bEndpointAddress
939 0x03, // bmAttributes (0x03=intr)
940 FLIGHTSIM_RX_SIZE, 0, // wMaxPacketSize
941 FLIGHTSIM_RX_INTERVAL, // bInterval
942#endif // FLIGHTSIM_INTERFACE
943
944#ifdef SEREMU_INTERFACE
945 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
946 9, // bLength
947 4, // bDescriptorType
948 SEREMU_INTERFACE, // bInterfaceNumber
949 0, // bAlternateSetting
950 2, // bNumEndpoints
951 0x03, // bInterfaceClass (0x03 = HID)
952 0x00, // bInterfaceSubClass
953 0x00, // bInterfaceProtocol
954 0, // iInterface
955 // HID interface descriptor, HID 1.11 spec, section 6.2.1
956 9, // bLength
957 0x21, // bDescriptorType
958 0x11, 0x01, // bcdHID
959 0, // bCountryCode
960 1, // bNumDescriptors
961 0x22, // bDescriptorType
962 LSB(sizeof(seremu_report_desc)), // wDescriptorLength
963 MSB(sizeof(seremu_report_desc)),
964 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
965 7, // bLength
966 5, // bDescriptorType
967 SEREMU_TX_ENDPOINT | 0x80, // bEndpointAddress
968 0x03, // bmAttributes (0x03=intr)
969 SEREMU_TX_SIZE, 0, // wMaxPacketSize
970 SEREMU_TX_INTERVAL, // bInterval
971 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
972 7, // bLength
973 5, // bDescriptorType
974 SEREMU_RX_ENDPOINT, // bEndpointAddress
975 0x03, // bmAttributes (0x03=intr)
976 SEREMU_RX_SIZE, 0, // wMaxPacketSize
977 SEREMU_RX_INTERVAL, // bInterval
978#endif // SEREMU_INTERFACE
979
980#ifdef JOYSTICK_INTERFACE
981 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
982 9, // bLength
983 4, // bDescriptorType
984 JOYSTICK_INTERFACE, // bInterfaceNumber
985 0, // bAlternateSetting
986 1, // bNumEndpoints
987 0x03, // bInterfaceClass (0x03 = HID)
988 0x00, // bInterfaceSubClass
989 0x00, // bInterfaceProtocol
990 0, // iInterface
991 // HID interface descriptor, HID 1.11 spec, section 6.2.1
992 9, // bLength
993 0x21, // bDescriptorType
994 0x11, 0x01, // bcdHID
995 0, // bCountryCode
996 1, // bNumDescriptors
997 0x22, // bDescriptorType
998 LSB(sizeof(joystick_report_desc)), // wDescriptorLength
999 MSB(sizeof(joystick_report_desc)),
1000 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
1001 7, // bLength
1002 5, // bDescriptorType
1003 JOYSTICK_ENDPOINT | 0x80, // bEndpointAddress
1004 0x03, // bmAttributes (0x03=intr)
1005 JOYSTICK_SIZE, 0, // wMaxPacketSize
1006 JOYSTICK_INTERVAL, // bInterval
1007#endif // JOYSTICK_INTERFACE
1008
1009#ifdef MTP_INTERFACE
1010 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
1011 9, // bLength
1012 4, // bDescriptorType
1013 MTP_INTERFACE, // bInterfaceNumber
1014 0, // bAlternateSetting
1015 3, // bNumEndpoints
1016 0x06, // bInterfaceClass (0x06 = still image)
1017 0x01, // bInterfaceSubClass
1018 0x01, // bInterfaceProtocol
1019 4, // iInterface
1020 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
1021 7, // bLength
1022 5, // bDescriptorType
1023 MTP_TX_ENDPOINT | 0x80, // bEndpointAddress
1024 0x02, // bmAttributes (0x02=bulk)
1025 MTP_TX_SIZE, 0, // wMaxPacketSize
1026 0, // bInterval
1027 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
1028 7, // bLength
1029 5, // bDescriptorType
1030 MTP_RX_ENDPOINT, // bEndpointAddress
1031 0x02, // bmAttributes (0x02=bulk)
1032 MTP_RX_SIZE, 0, // wMaxPacketSize
1033 0, // bInterval
1034 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
1035 7, // bLength
1036 5, // bDescriptorType
1037 MTP_EVENT_ENDPOINT | 0x80, // bEndpointAddress
1038 0x03, // bmAttributes (0x03=intr)
1039 MTP_EVENT_SIZE, 0, // wMaxPacketSize
1040 MTP_EVENT_INTERVAL, // bInterval
1041#endif // MTP_INTERFACE
1042
1043#ifdef KEYMEDIA_INTERFACE
1044 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
1045 9, // bLength
1046 4, // bDescriptorType
1047 KEYMEDIA_INTERFACE, // bInterfaceNumber
1048 0, // bAlternateSetting
1049 1, // bNumEndpoints
1050 0x03, // bInterfaceClass (0x03 = HID)
1051 0x00, // bInterfaceSubClass
1052 0x00, // bInterfaceProtocol
1053 0, // iInterface
1054 // HID interface descriptor, HID 1.11 spec, section 6.2.1
1055 9, // bLength
1056 0x21, // bDescriptorType
1057 0x11, 0x01, // bcdHID
1058 0, // bCountryCode
1059 1, // bNumDescriptors
1060 0x22, // bDescriptorType
1061 LSB(sizeof(keymedia_report_desc)), // wDescriptorLength
1062 MSB(sizeof(keymedia_report_desc)),
1063 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
1064 7, // bLength
1065 5, // bDescriptorType
1066 KEYMEDIA_ENDPOINT | 0x80, // bEndpointAddress
1067 0x03, // bmAttributes (0x03=intr)
1068 KEYMEDIA_SIZE, 0, // wMaxPacketSize
1069 KEYMEDIA_INTERVAL, // bInterval
1070#endif // KEYMEDIA_INTERFACE
1071
1072#ifdef AUDIO_INTERFACE
1073 // interface association descriptor, USB ECN, Table 9-Z
1074 8, // bLength
1075 11, // bDescriptorType
1076 AUDIO_INTERFACE, // bFirstInterface
1077 3, // bInterfaceCount
1078 0x01, // bFunctionClass
1079 0x01, // bFunctionSubClass
1080 0x00, // bFunctionProtocol
1081 0, // iFunction
1082 // Standard AudioControl (AC) Interface Descriptor
1083 // USB DCD for Audio Devices 1.0, Table 4-1, page 36
1084 9, // bLength
1085 4, // bDescriptorType, 4 = INTERFACE
1086 AUDIO_INTERFACE, // bInterfaceNumber
1087 0, // bAlternateSetting
1088 0, // bNumEndpoints
1089 1, // bInterfaceClass, 1 = AUDIO
1090 1, // bInterfaceSubclass, 1 = AUDIO_CONTROL
1091 0, // bInterfaceProtocol
1092 0, // iInterface
1093 // Class-specific AC Interface Header Descriptor
1094 // USB DCD for Audio Devices 1.0, Table 4-2, page 37-38
1095 10, // bLength
1096 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
1097 0x01, // bDescriptorSubtype, 1 = HEADER
1098 0x00, 0x01, // bcdADC (version 1.0)
1099 LSB(62), MSB(62), // wTotalLength
1100 2, // bInCollection
1101 AUDIO_INTERFACE+1, // baInterfaceNr(1) - Transmit to PC
1102 AUDIO_INTERFACE+2, // baInterfaceNr(2) - Receive from PC
1103 // Input Terminal Descriptor
1104 // USB DCD for Audio Devices 1.0, Table 4-3, page 39
1105 12, // bLength
1106 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
1107 0x02, // bDescriptorSubType, 2 = INPUT_TERMINAL
1108 1, // bTerminalID
1109 //0x01, 0x02, // wTerminalType, 0x0201 = MICROPHONE
1110 //0x03, 0x06, // wTerminalType, 0x0603 = Line Connector
1111 0x02, 0x06, // wTerminalType, 0x0602 = Digital Audio
1112 0, // bAssocTerminal, 0 = unidirectional
1113 2, // bNrChannels
1114 0x03, 0x00, // wChannelConfig, 0x0003 = Left & Right Front
1115 0, // iChannelNames
1116 0, // iTerminal
1117 // Output Terminal Descriptor
1118 // USB DCD for Audio Devices 1.0, Table 4-4, page 40
1119 9, // bLength
1120 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
1121 3, // bDescriptorSubtype, 3 = OUTPUT_TERMINAL
1122 2, // bTerminalID
1123 0x01, 0x01, // wTerminalType, 0x0101 = USB_STREAMING
1124 0, // bAssocTerminal, 0 = unidirectional
1125 1, // bCSourceID, connected to input terminal, ID=1
1126 0, // iTerminal
1127 // Input Terminal Descriptor
1128 // USB DCD for Audio Devices 1.0, Table 4-3, page 39
1129 12, // bLength
1130 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
1131 2, // bDescriptorSubType, 2 = INPUT_TERMINAL
1132 3, // bTerminalID
1133 0x01, 0x01, // wTerminalType, 0x0101 = USB_STREAMING
1134 0, // bAssocTerminal, 0 = unidirectional
1135 2, // bNrChannels
1136 0x03, 0x00, // wChannelConfig, 0x0003 = Left & Right Front
1137 0, // iChannelNames
1138 0, // iTerminal
1139 // Volume feature descriptor
1140 10, // bLength
1141 0x24, // bDescriptorType = CS_INTERFACE
1142 0x06, // bDescriptorSubType = FEATURE_UNIT
1143 0x31, // bUnitID
1144 0x03, // bSourceID (Input Terminal)
1145 0x01, // bControlSize (each channel is 1 byte, 3 channels)
1146 0x01, // bmaControls(0) Master: Mute
1147 0x02, // bmaControls(1) Left: Volume
1148 0x02, // bmaControls(2) Right: Volume
1149 0x00, // iFeature
1150 // Output Terminal Descriptor
1151 // USB DCD for Audio Devices 1.0, Table 4-4, page 40
1152 9, // bLength
1153 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
1154 3, // bDescriptorSubtype, 3 = OUTPUT_TERMINAL
1155 4, // bTerminalID
1156 //0x02, 0x03, // wTerminalType, 0x0302 = Headphones
1157 0x02, 0x06, // wTerminalType, 0x0602 = Digital Audio
1158 0, // bAssocTerminal, 0 = unidirectional
1159 0x31, // bCSourceID, connected to feature, ID=31
1160 0, // iTerminal
1161 // Standard AS Interface Descriptor
1162 // USB DCD for Audio Devices 1.0, Section 4.5.1, Table 4-18, page 59
1163 // Alternate 0: default setting, disabled zero bandwidth
1164 9, // bLenght
1165 4, // bDescriptorType = INTERFACE
1166 AUDIO_INTERFACE+1, // bInterfaceNumber
1167 0, // bAlternateSetting
1168 0, // bNumEndpoints
1169 1, // bInterfaceClass, 1 = AUDIO
1170 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
1171 0, // bInterfaceProtocol
1172 0, // iInterface
1173 // Alternate 1: streaming data
1174 9, // bLenght
1175 4, // bDescriptorType = INTERFACE
1176 AUDIO_INTERFACE+1, // bInterfaceNumber
1177 1, // bAlternateSetting
1178 1, // bNumEndpoints
1179 1, // bInterfaceClass, 1 = AUDIO
1180 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
1181 0, // bInterfaceProtocol
1182 0, // iInterface
1183 // Class-Specific AS Interface Descriptor
1184 // USB DCD for Audio Devices 1.0, Section 4.5.2, Table 4-19, page 60
1185 7, // bLength
1186 0x24, // bDescriptorType = CS_INTERFACE
1187 1, // bDescriptorSubtype, 1 = AS_GENERAL
1188 2, // bTerminalLink: Terminal ID = 2
1189 3, // bDelay (approx 3ms delay, audio lib updates)
1190 0x01, 0x00, // wFormatTag, 0x0001 = PCM
1191 // Type I Format Descriptor
1192 // USB DCD for Audio Data Formats 1.0, Section 2.2.5, Table 2-1, page 10
1193 11, // bLength
1194 0x24, // bDescriptorType = CS_INTERFACE
1195 2, // bDescriptorSubtype = FORMAT_TYPE
1196 1, // bFormatType = FORMAT_TYPE_I
1197 2, // bNrChannels = 2
1198 2, // bSubFrameSize = 2 byte
1199 16, // bBitResolution = 16 bits
1200 1, // bSamFreqType = 1 frequency
1201 LSB(44100), MSB(44100), 0, // tSamFreq
1202 // Standard AS Isochronous Audio Data Endpoint Descriptor
1203 // USB DCD for Audio Devices 1.0, Section 4.6.1.1, Table 4-20, page 61-62
1204 9, // bLength
1205 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
1206 AUDIO_TX_ENDPOINT | 0x80, // bEndpointAddress
1207 0x09, // bmAttributes = isochronous, adaptive
1208 LSB(AUDIO_TX_SIZE), MSB(AUDIO_TX_SIZE), // wMaxPacketSize
1209 1, // bInterval, 1 = every frame
1210 0, // bRefresh
1211 0, // bSynchAddress
1212 // Class-Specific AS Isochronous Audio Data Endpoint Descriptor
1213 // USB DCD for Audio Devices 1.0, Section 4.6.1.2, Table 4-21, page 62-63
1214 7, // bLength
1215 0x25, // bDescriptorType, 0x25 = CS_ENDPOINT
1216 1, // bDescriptorSubtype, 1 = EP_GENERAL
1217 0x00, // bmAttributes
1218 0, // bLockDelayUnits, 1 = ms
1219 0x00, 0x00, // wLockDelay
1220 // Standard AS Interface Descriptor
1221 // USB DCD for Audio Devices 1.0, Section 4.5.1, Table 4-18, page 59
1222 // Alternate 0: default setting, disabled zero bandwidth
1223 9, // bLenght
1224 4, // bDescriptorType = INTERFACE
1225 AUDIO_INTERFACE+2, // bInterfaceNumber
1226 0, // bAlternateSetting
1227 0, // bNumEndpoints
1228 1, // bInterfaceClass, 1 = AUDIO
1229 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
1230 0, // bInterfaceProtocol
1231 0, // iInterface
1232 // Alternate 1: streaming data
1233 9, // bLenght
1234 4, // bDescriptorType = INTERFACE
1235 AUDIO_INTERFACE+2, // bInterfaceNumber
1236 1, // bAlternateSetting
1237 2, // bNumEndpoints
1238 1, // bInterfaceClass, 1 = AUDIO
1239 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
1240 0, // bInterfaceProtocol
1241 0, // iInterface
1242 // Class-Specific AS Interface Descriptor
1243 // USB DCD for Audio Devices 1.0, Section 4.5.2, Table 4-19, page 60
1244 7, // bLength
1245 0x24, // bDescriptorType = CS_INTERFACE
1246 1, // bDescriptorSubtype, 1 = AS_GENERAL
1247 3, // bTerminalLink: Terminal ID = 3
1248 3, // bDelay (approx 3ms delay, audio lib updates)
1249 0x01, 0x00, // wFormatTag, 0x0001 = PCM
1250 // Type I Format Descriptor
1251 // USB DCD for Audio Data Formats 1.0, Section 2.2.5, Table 2-1, page 10
1252 11, // bLength
1253 0x24, // bDescriptorType = CS_INTERFACE
1254 2, // bDescriptorSubtype = FORMAT_TYPE
1255 1, // bFormatType = FORMAT_TYPE_I
1256 2, // bNrChannels = 2
1257 2, // bSubFrameSize = 2 byte
1258 16, // bBitResolution = 16 bits
1259 1, // bSamFreqType = 1 frequency
1260 LSB(44100), MSB(44100), 0, // tSamFreq
1261 // Standard AS Isochronous Audio Data Endpoint Descriptor
1262 // USB DCD for Audio Devices 1.0, Section 4.6.1.1, Table 4-20, page 61-62
1263 9, // bLength
1264 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
1265 AUDIO_RX_ENDPOINT, // bEndpointAddress
1266 0x05, // bmAttributes = isochronous, asynchronous
1267 LSB(AUDIO_RX_SIZE), MSB(AUDIO_RX_SIZE), // wMaxPacketSize
1268 1, // bInterval, 1 = every frame
1269 0, // bRefresh
1270 AUDIO_SYNC_ENDPOINT | 0x80, // bSynchAddress
1271 // Class-Specific AS Isochronous Audio Data Endpoint Descriptor
1272 // USB DCD for Audio Devices 1.0, Section 4.6.1.2, Table 4-21, page 62-63
1273 7, // bLength
1274 0x25, // bDescriptorType, 0x25 = CS_ENDPOINT
1275 1, // bDescriptorSubtype, 1 = EP_GENERAL
1276 0x00, // bmAttributes
1277 0, // bLockDelayUnits, 1 = ms
1278 0x00, 0x00, // wLockDelay
1279 // Standard AS Isochronous Audio Synch Endpoint Descriptor
1280 // USB DCD for Audio Devices 1.0, Section 4.6.2.1, Table 4-22, page 63-64
1281 9, // bLength
1282 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
1283 AUDIO_SYNC_ENDPOINT | 0x80, // bEndpointAddress
1284 0x11, // bmAttributes = isochronous, feedback
1285 3, 0, // wMaxPacketSize, 3 bytes
1286 1, // bInterval, 1 = every frame
1287 5, // bRefresh, 5 = 32ms
1288 0, // bSynchAddress
1289#endif
1290
1291#ifdef MULTITOUCH_INTERFACE
1292 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
1293 9, // bLength
1294 4, // bDescriptorType
1295 MULTITOUCH_INTERFACE, // bInterfaceNumber
1296 0, // bAlternateSetting
1297 1, // bNumEndpoints
1298 0x03, // bInterfaceClass (0x03 = HID)
1299 0x00, // bInterfaceSubClass
1300 0x00, // bInterfaceProtocol
1301 0, // iInterface
1302 // HID interface descriptor, HID 1.11 spec, section 6.2.1
1303 9, // bLength
1304 0x21, // bDescriptorType
1305 0x11, 0x01, // bcdHID
1306 0, // bCountryCode
1307 1, // bNumDescriptors
1308 0x22, // bDescriptorType
1309 LSB(sizeof(multitouch_report_desc)), // wDescriptorLength
1310 MSB(sizeof(multitouch_report_desc)),
1311 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
1312 7, // bLength
1313 5, // bDescriptorType
1314 MULTITOUCH_ENDPOINT | 0x80, // bEndpointAddress
1315 0x03, // bmAttributes (0x03=intr)
1316 MULTITOUCH_SIZE, 0, // wMaxPacketSize
1317 1, // bInterval
1318#endif // KEYMEDIA_INTERFACE
1319};
1320
1321
1322// **************************************************************
1323// String Descriptors
1324// **************************************************************
1325
1326// The descriptors above can provide human readable strings,
1327// referenced by index numbers. These descriptors are the
1328// actual string data
1329
1330/* defined in usb_names.h
1331struct usb_string_descriptor_struct {
1332 uint8_t bLength;
1333 uint8_t bDescriptorType;
1334 uint16_t wString[];
1335};
1336*/
1337
1338extern struct usb_string_descriptor_struct usb_string_manufacturer_name
1339 __attribute__ ((weak, alias("usb_string_manufacturer_name_default")));
1340extern struct usb_string_descriptor_struct usb_string_product_name
1341 __attribute__ ((weak, alias("usb_string_product_name_default")));
1342extern struct usb_string_descriptor_struct usb_string_serial_number
1343 __attribute__ ((weak, alias("usb_string_serial_number_default")));
1344
1345struct usb_string_descriptor_struct string0 = {
1346 4,
1347 3,
1348 {0x0409}
1349};
1350
1351struct usb_string_descriptor_struct usb_string_manufacturer_name_default = {
1352 2 + MANUFACTURER_NAME_LEN * 2,
1353 3,
1354 MANUFACTURER_NAME
1355};
1356struct usb_string_descriptor_struct usb_string_product_name_default = {
1357 2 + PRODUCT_NAME_LEN * 2,
1358 3,
1359 PRODUCT_NAME
1360};
1361struct usb_string_descriptor_struct usb_string_serial_number_default = {
1362 12,
1363 3,
1364 {0,0,0,0,0,0,0,0,0,0}
1365};
1366#ifdef MTP_INTERFACE
1367struct usb_string_descriptor_struct usb_string_mtp = {
1368 2 + 3 * 2,
1369 3,
1370 {'M','T','P'}
1371};
1372#endif
1373
Brian Silverman099196d2017-06-21 23:26:02 -07001374// **************************************************************
1375// Descriptors List
1376// **************************************************************
1377
1378// This table provides access to all the descriptor data above.
1379
1380const usb_descriptor_list_t usb_descriptor_list[] = {
1381 //wValue, wIndex, address, length
1382 {0x0100, 0x0000, device_descriptor, sizeof(device_descriptor)},
1383 {0x0200, 0x0000, config_descriptor, sizeof(config_descriptor)},
1384#ifdef SEREMU_INTERFACE
1385 {0x2200, SEREMU_INTERFACE, seremu_report_desc, sizeof(seremu_report_desc)},
1386 {0x2100, SEREMU_INTERFACE, config_descriptor+SEREMU_HID_DESC_OFFSET, 9},
1387#endif
1388#ifdef KEYBOARD_INTERFACE
1389 {0x2200, KEYBOARD_INTERFACE, keyboard_report_desc, sizeof(keyboard_report_desc)},
1390 {0x2100, KEYBOARD_INTERFACE, config_descriptor+KEYBOARD_HID_DESC_OFFSET, 9},
1391#endif
1392#ifdef MOUSE_INTERFACE
1393 {0x2200, MOUSE_INTERFACE, mouse_report_desc, sizeof(mouse_report_desc)},
1394 {0x2100, MOUSE_INTERFACE, config_descriptor+MOUSE_HID_DESC_OFFSET, 9},
1395#endif
1396#ifdef JOYSTICK_INTERFACE
1397 {0x2200, JOYSTICK_INTERFACE, joystick_report_desc, sizeof(joystick_report_desc)},
1398 {0x2100, JOYSTICK_INTERFACE, config_descriptor+JOYSTICK_HID_DESC_OFFSET, 9},
1399#endif
1400#ifdef RAWHID_INTERFACE
1401 {0x2200, RAWHID_INTERFACE, rawhid_report_desc, sizeof(rawhid_report_desc)},
1402 {0x2100, RAWHID_INTERFACE, config_descriptor+RAWHID_HID_DESC_OFFSET, 9},
1403#endif
1404#ifdef FLIGHTSIM_INTERFACE
1405 {0x2200, FLIGHTSIM_INTERFACE, flightsim_report_desc, sizeof(flightsim_report_desc)},
1406 {0x2100, FLIGHTSIM_INTERFACE, config_descriptor+FLIGHTSIM_HID_DESC_OFFSET, 9},
1407#endif
1408#ifdef KEYMEDIA_INTERFACE
1409 {0x2200, KEYMEDIA_INTERFACE, keymedia_report_desc, sizeof(keymedia_report_desc)},
1410 {0x2100, KEYMEDIA_INTERFACE, config_descriptor+KEYMEDIA_HID_DESC_OFFSET, 9},
1411#endif
1412#ifdef MULTITOUCH_INTERFACE
1413 {0x2200, MULTITOUCH_INTERFACE, multitouch_report_desc, sizeof(multitouch_report_desc)},
1414 {0x2100, MULTITOUCH_INTERFACE, config_descriptor+MULTITOUCH_HID_DESC_OFFSET, 9},
1415#endif
1416#ifdef MTP_INTERFACE
1417 {0x0304, 0x0409, (const uint8_t *)&usb_string_mtp, 0},
1418#endif
1419 {0x0300, 0x0000, (const uint8_t *)&string0, 0},
1420 {0x0301, 0x0409, (const uint8_t *)&usb_string_manufacturer_name, 0},
1421 {0x0302, 0x0409, (const uint8_t *)&usb_string_product_name, 0},
1422 {0x0303, 0x0409, (const uint8_t *)&usb_string_serial_number, 0},
1423 {0, 0, NULL, 0}
1424};
1425
1426
1427// **************************************************************
1428// Endpoint Configuration
1429// **************************************************************
1430
1431#if 0
1432// 0x00 = not used
1433// 0x19 = Recieve only
1434// 0x15 = Transmit only
1435// 0x1D = Transmit & Recieve
1436//
1437const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS] =
1438{
1439 0x00, 0x15, 0x19, 0x15, 0x00, 0x00, 0x00, 0x00,
1440 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1441};
1442#endif
1443
1444
1445const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS] =
1446{
1447#if (defined(ENDPOINT1_CONFIG) && NUM_ENDPOINTS >= 1)
1448 ENDPOINT1_CONFIG,
1449#elif (NUM_ENDPOINTS >= 1)
1450 ENDPOINT_UNUSED,
1451#endif
1452#if (defined(ENDPOINT2_CONFIG) && NUM_ENDPOINTS >= 2)
1453 ENDPOINT2_CONFIG,
1454#elif (NUM_ENDPOINTS >= 2)
1455 ENDPOINT_UNUSED,
1456#endif
1457#if (defined(ENDPOINT3_CONFIG) && NUM_ENDPOINTS >= 3)
1458 ENDPOINT3_CONFIG,
1459#elif (NUM_ENDPOINTS >= 3)
1460 ENDPOINT_UNUSED,
1461#endif
1462#if (defined(ENDPOINT4_CONFIG) && NUM_ENDPOINTS >= 4)
1463 ENDPOINT4_CONFIG,
1464#elif (NUM_ENDPOINTS >= 4)
1465 ENDPOINT_UNUSED,
1466#endif
1467#if (defined(ENDPOINT5_CONFIG) && NUM_ENDPOINTS >= 5)
1468 ENDPOINT5_CONFIG,
1469#elif (NUM_ENDPOINTS >= 5)
1470 ENDPOINT_UNUSED,
1471#endif
1472#if (defined(ENDPOINT6_CONFIG) && NUM_ENDPOINTS >= 6)
1473 ENDPOINT6_CONFIG,
1474#elif (NUM_ENDPOINTS >= 6)
1475 ENDPOINT_UNUSED,
1476#endif
1477#if (defined(ENDPOINT7_CONFIG) && NUM_ENDPOINTS >= 7)
1478 ENDPOINT7_CONFIG,
1479#elif (NUM_ENDPOINTS >= 7)
1480 ENDPOINT_UNUSED,
1481#endif
1482#if (defined(ENDPOINT8_CONFIG) && NUM_ENDPOINTS >= 8)
1483 ENDPOINT8_CONFIG,
1484#elif (NUM_ENDPOINTS >= 8)
1485 ENDPOINT_UNUSED,
1486#endif
1487#if (defined(ENDPOINT9_CONFIG) && NUM_ENDPOINTS >= 9)
1488 ENDPOINT9_CONFIG,
1489#elif (NUM_ENDPOINTS >= 9)
1490 ENDPOINT_UNUSED,
1491#endif
1492#if (defined(ENDPOINT10_CONFIG) && NUM_ENDPOINTS >= 10)
1493 ENDPOINT10_CONFIG,
1494#elif (NUM_ENDPOINTS >= 10)
1495 ENDPOINT_UNUSED,
1496#endif
1497#if (defined(ENDPOINT11_CONFIG) && NUM_ENDPOINTS >= 11)
1498 ENDPOINT11_CONFIG,
1499#elif (NUM_ENDPOINTS >= 11)
1500 ENDPOINT_UNUSED,
1501#endif
1502#if (defined(ENDPOINT12_CONFIG) && NUM_ENDPOINTS >= 12)
1503 ENDPOINT12_CONFIG,
1504#elif (NUM_ENDPOINTS >= 12)
1505 ENDPOINT_UNUSED,
1506#endif
1507#if (defined(ENDPOINT13_CONFIG) && NUM_ENDPOINTS >= 13)
1508 ENDPOINT13_CONFIG,
1509#elif (NUM_ENDPOINTS >= 13)
1510 ENDPOINT_UNUSED,
1511#endif
1512#if (defined(ENDPOINT14_CONFIG) && NUM_ENDPOINTS >= 14)
1513 ENDPOINT14_CONFIG,
1514#elif (NUM_ENDPOINTS >= 14)
1515 ENDPOINT_UNUSED,
1516#endif
1517#if (defined(ENDPOINT15_CONFIG) && NUM_ENDPOINTS >= 15)
1518 ENDPOINT15_CONFIG,
1519#elif (NUM_ENDPOINTS >= 15)
1520 ENDPOINT_UNUSED,
1521#endif
1522};
1523
Brian Silvermanb79af7c2017-06-21 23:48:02 -07001524void usb_descriptor_set_product_id(uint16_t product_id) {
1525 device_descriptor[10] = LSB(product_id);
1526 device_descriptor[11] = MSB(product_id);
1527}
Brian Silverman099196d2017-06-21 23:26:02 -07001528
1529#endif // NUM_ENDPOINTS
1530#endif // F_CPU >= 20 MHz