You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2741 line
134KB

  1. /* Teensyduino Core Library
  2. * http://www.pjrc.com/teensy/
  3. * Copyright (c) 2019 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. //#if F_CPU >= 20000000
  31. #define USB_DESC_LIST_DEFINE
  32. #include "usb_desc.h"
  33. #ifdef NUM_ENDPOINTS
  34. #include "usb_names.h"
  35. #include "imxrt.h"
  36. #include "avr_functions.h"
  37. #include "avr/pgmspace.h"
  38. // At very slow CPU speeds, the OCRAM just isn't fast enough for
  39. // USB to work reliably. But the precious/limited DTCM is. So
  40. // as an ugly workaround, undefine DMAMEM so all buffers which
  41. // would normally be allocated in OCRAM are placed in DTCM.
  42. #if defined(F_CPU) && F_CPU < 30000000
  43. #undef DMAMEM
  44. #endif
  45. // USB Descriptors are binary data which the USB host reads to
  46. // automatically detect a USB device's capabilities. The format
  47. // and meaning of every field is documented in numerous USB
  48. // standards. When working with USB descriptors, despite the
  49. // complexity of the standards and poor writing quality in many
  50. // of those documents, remember descriptors are nothing more
  51. // than constant binary data that tells the USB host what the
  52. // device can do. Computers will load drivers based on this data.
  53. // Those drivers then communicate on the endpoints specified by
  54. // the descriptors.
  55. // To configure a new combination of interfaces or make minor
  56. // changes to existing configuration (eg, change the name or ID
  57. // numbers), usually you would edit "usb_desc.h". This file
  58. // is meant to be configured by the header, so generally it is
  59. // only edited to add completely new USB interfaces or features.
  60. // **************************************************************
  61. // USB Device
  62. // **************************************************************
  63. #define LSB(n) ((n) & 255)
  64. #define MSB(n) (((n) >> 8) & 255)
  65. // USB Device Descriptor. The USB host reads this first, to learn
  66. // what type of device is connected.
  67. static uint8_t device_descriptor[] = {
  68. 18, // bLength
  69. 1, // bDescriptorType
  70. 0x00, 0x02, // bcdUSB
  71. #ifdef DEVICE_CLASS
  72. DEVICE_CLASS, // bDeviceClass
  73. #else
  74. 0,
  75. #endif
  76. #ifdef DEVICE_SUBCLASS
  77. DEVICE_SUBCLASS, // bDeviceSubClass
  78. #else
  79. 0,
  80. #endif
  81. #ifdef DEVICE_PROTOCOL
  82. DEVICE_PROTOCOL, // bDeviceProtocol
  83. #else
  84. 0,
  85. #endif
  86. EP0_SIZE, // bMaxPacketSize0
  87. LSB(VENDOR_ID), MSB(VENDOR_ID), // idVendor
  88. LSB(PRODUCT_ID), MSB(PRODUCT_ID), // idProduct
  89. #ifdef BCD_DEVICE
  90. LSB(BCD_DEVICE), MSB(BCD_DEVICE), // bcdDevice
  91. #else
  92. // For USB types that don't explicitly define BCD_DEVICE,
  93. // use the minor version number to help teensy_ports
  94. // identify which Teensy model is used.
  95. #if defined(__IMXRT1062__) && defined(ARDUINO_TEENSY40)
  96. 0x79, 0x02, // Teensy 4.0
  97. #elif defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41)
  98. 0x80, 0x02, // Teensy 4.1
  99. #else
  100. 0x00, 0x02,
  101. #endif
  102. #endif
  103. 1, // iManufacturer
  104. 2, // iProduct
  105. 3, // iSerialNumber
  106. 1 // bNumConfigurations
  107. };
  108. PROGMEM static const uint8_t qualifier_descriptor[] = { // 9.6.2 Device_Qualifier, page 264
  109. 10, // bLength
  110. 6, // bDescriptorType
  111. 0x00, 0x02, // bcdUSB
  112. #ifdef DEVICE_CLASS
  113. DEVICE_CLASS, // bDeviceClass
  114. #else
  115. 0,
  116. #endif
  117. #ifdef DEVICE_SUBCLASS
  118. DEVICE_SUBCLASS, // bDeviceSubClass
  119. #else
  120. 0,
  121. #endif
  122. #ifdef DEVICE_PROTOCOL
  123. DEVICE_PROTOCOL, // bDeviceProtocol
  124. #else
  125. 0,
  126. #endif
  127. EP0_SIZE, // bMaxPacketSize0
  128. 1, // bNumConfigurations
  129. 0 // bReserved
  130. };
  131. // These descriptors must NOT be "const", because the USB DMA
  132. // has trouble accessing flash memory with enough bandwidth
  133. // while the processor is executing from flash.
  134. // **************************************************************
  135. // HID Report Descriptors
  136. // **************************************************************
  137. // Each HID interface needs a special report descriptor that tells
  138. // the meaning and format of the data.
  139. #ifdef KEYBOARD_INTERFACE
  140. // Keyboard Protocol 1, HID 1.11 spec, Appendix B, page 59-60
  141. static uint8_t keyboard_report_desc[] = {
  142. 0x05, 0x01, // Usage Page (Generic Desktop),
  143. 0x09, 0x06, // Usage (Keyboard),
  144. 0xA1, 0x01, // Collection (Application),
  145. 0x75, 0x01, // Report Size (1),
  146. 0x95, 0x08, // Report Count (8),
  147. 0x05, 0x07, // Usage Page (Key Codes),
  148. 0x19, 0xE0, // Usage Minimum (224),
  149. 0x29, 0xE7, // Usage Maximum (231),
  150. 0x15, 0x00, // Logical Minimum (0),
  151. 0x25, 0x01, // Logical Maximum (1),
  152. 0x81, 0x02, // Input (Data, Variable, Absolute), ;Modifier keys
  153. 0x95, 0x01, // Report Count (1),
  154. 0x75, 0x08, // Report Size (8),
  155. 0x81, 0x03, // Input (Constant), ;Reserved byte
  156. 0x95, 0x05, // Report Count (5),
  157. 0x75, 0x01, // Report Size (1),
  158. 0x05, 0x08, // Usage Page (LEDs),
  159. 0x19, 0x01, // Usage Minimum (1),
  160. 0x29, 0x05, // Usage Maximum (5),
  161. 0x91, 0x02, // Output (Data, Variable, Absolute), ;LED report
  162. 0x95, 0x01, // Report Count (1),
  163. 0x75, 0x03, // Report Size (3),
  164. 0x91, 0x03, // Output (Constant), ;LED report padding
  165. 0x95, 0x06, // Report Count (6),
  166. 0x75, 0x08, // Report Size (8),
  167. 0x15, 0x00, // Logical Minimum (0),
  168. 0x25, 0x7F, // Logical Maximum(104),
  169. 0x05, 0x07, // Usage Page (Key Codes),
  170. 0x19, 0x00, // Usage Minimum (0),
  171. 0x29, 0x7F, // Usage Maximum (104),
  172. 0x81, 0x00, // Input (Data, Array), ;Normal keys
  173. 0xC0 // End Collection
  174. };
  175. #endif
  176. #ifdef KEYMEDIA_INTERFACE
  177. static uint8_t keymedia_report_desc[] = {
  178. 0x05, 0x0C, // Usage Page (Consumer)
  179. 0x09, 0x01, // Usage (Consumer Controls)
  180. 0xA1, 0x01, // Collection (Application)
  181. 0x75, 0x0A, // Report Size (10)
  182. 0x95, 0x04, // Report Count (4)
  183. 0x19, 0x00, // Usage Minimum (0)
  184. 0x2A, 0x9C, 0x02, // Usage Maximum (0x29C)
  185. 0x15, 0x00, // Logical Minimum (0)
  186. 0x26, 0x9C, 0x02, // Logical Maximum (0x29C)
  187. 0x81, 0x00, // Input (Data, Array)
  188. 0x05, 0x01, // Usage Page (Generic Desktop)
  189. 0x75, 0x08, // Report Size (8)
  190. 0x95, 0x03, // Report Count (3)
  191. 0x19, 0x00, // Usage Minimum (0)
  192. 0x29, 0xB7, // Usage Maximum (0xB7)
  193. 0x15, 0x00, // Logical Minimum (0)
  194. 0x26, 0xB7, 0x00, // Logical Maximum (0xB7)
  195. 0x81, 0x00, // Input (Data, Array)
  196. 0xC0 // End Collection
  197. };
  198. #endif
  199. #ifdef MOUSE_INTERFACE
  200. // Mouse Protocol 1, HID 1.11 spec, Appendix B, page 59-60, with wheel extension
  201. static uint8_t mouse_report_desc[] = {
  202. 0x05, 0x01, // Usage Page (Generic Desktop)
  203. 0x09, 0x02, // Usage (Mouse)
  204. 0xA1, 0x01, // Collection (Application)
  205. 0x85, 0x01, // REPORT_ID (1)
  206. 0x05, 0x09, // Usage Page (Button)
  207. 0x19, 0x01, // Usage Minimum (Button #1)
  208. 0x29, 0x08, // Usage Maximum (Button #8)
  209. 0x15, 0x00, // Logical Minimum (0)
  210. 0x25, 0x01, // Logical Maximum (1)
  211. 0x95, 0x08, // Report Count (8)
  212. 0x75, 0x01, // Report Size (1)
  213. 0x81, 0x02, // Input (Data, Variable, Absolute)
  214. 0x05, 0x01, // Usage Page (Generic Desktop)
  215. 0x09, 0x30, // Usage (X)
  216. 0x09, 0x31, // Usage (Y)
  217. 0x09, 0x38, // Usage (Wheel)
  218. 0x15, 0x81, // Logical Minimum (-127)
  219. 0x25, 0x7F, // Logical Maximum (127)
  220. 0x75, 0x08, // Report Size (8),
  221. 0x95, 0x03, // Report Count (3),
  222. 0x81, 0x06, // Input (Data, Variable, Relative)
  223. 0x05, 0x0C, // Usage Page (Consumer)
  224. 0x0A, 0x38, 0x02, // Usage (AC Pan)
  225. 0x15, 0x81, // Logical Minimum (-127)
  226. 0x25, 0x7F, // Logical Maximum (127)
  227. 0x75, 0x08, // Report Size (8),
  228. 0x95, 0x01, // Report Count (1),
  229. 0x81, 0x06, // Input (Data, Variable, Relative)
  230. 0xC0, // End Collection
  231. 0x05, 0x01, // Usage Page (Generic Desktop)
  232. 0x09, 0x02, // Usage (Mouse)
  233. 0xA1, 0x01, // Collection (Application)
  234. 0x85, 0x02, // REPORT_ID (2)
  235. 0x05, 0x01, // Usage Page (Generic Desktop)
  236. 0x09, 0x30, // Usage (X)
  237. 0x09, 0x31, // Usage (Y)
  238. 0x15, 0x00, // Logical Minimum (0)
  239. 0x26, 0xFF, 0x7F, // Logical Maximum (32767)
  240. 0x75, 0x10, // Report Size (16),
  241. 0x95, 0x02, // Report Count (2),
  242. 0x81, 0x02, // Input (Data, Variable, Absolute)
  243. 0xC0 // End Collection
  244. };
  245. #endif
  246. #ifdef JOYSTICK_INTERFACE
  247. #if JOYSTICK_SIZE == 12
  248. static uint8_t joystick_report_desc[] = {
  249. 0x05, 0x01, // Usage Page (Generic Desktop)
  250. 0x09, 0x04, // Usage (Joystick)
  251. 0xA1, 0x01, // Collection (Application)
  252. 0x15, 0x00, // Logical Minimum (0)
  253. 0x25, 0x01, // Logical Maximum (1)
  254. 0x75, 0x01, // Report Size (1)
  255. 0x95, 0x20, // Report Count (32)
  256. 0x05, 0x09, // Usage Page (Button)
  257. 0x19, 0x01, // Usage Minimum (Button #1)
  258. 0x29, 0x20, // Usage Maximum (Button #32)
  259. 0x81, 0x02, // Input (variable,absolute)
  260. 0x15, 0x00, // Logical Minimum (0)
  261. 0x25, 0x07, // Logical Maximum (7)
  262. 0x35, 0x00, // Physical Minimum (0)
  263. 0x46, 0x3B, 0x01, // Physical Maximum (315)
  264. 0x75, 0x04, // Report Size (4)
  265. 0x95, 0x01, // Report Count (1)
  266. 0x65, 0x14, // Unit (20)
  267. 0x05, 0x01, // Usage Page (Generic Desktop)
  268. 0x09, 0x39, // Usage (Hat switch)
  269. 0x81, 0x42, // Input (variable,absolute,null_state)
  270. 0x05, 0x01, // Usage Page (Generic Desktop)
  271. 0x09, 0x01, // Usage (Pointer)
  272. 0xA1, 0x00, // Collection ()
  273. 0x15, 0x00, // Logical Minimum (0)
  274. 0x26, 0xFF, 0x03, // Logical Maximum (1023)
  275. 0x75, 0x0A, // Report Size (10)
  276. 0x95, 0x04, // Report Count (4)
  277. 0x09, 0x30, // Usage (X)
  278. 0x09, 0x31, // Usage (Y)
  279. 0x09, 0x32, // Usage (Z)
  280. 0x09, 0x35, // Usage (Rz)
  281. 0x81, 0x02, // Input (variable,absolute)
  282. 0xC0, // End Collection
  283. 0x15, 0x00, // Logical Minimum (0)
  284. 0x26, 0xFF, 0x03, // Logical Maximum (1023)
  285. 0x75, 0x0A, // Report Size (10)
  286. 0x95, 0x02, // Report Count (2)
  287. 0x09, 0x36, // Usage (Slider)
  288. 0x09, 0x36, // Usage (Slider)
  289. 0x81, 0x02, // Input (variable,absolute)
  290. 0xC0 // End Collection
  291. };
  292. #elif JOYSTICK_SIZE == 64
  293. // extreme joystick (to use this, edit JOYSTICK_SIZE to 64 in usb_desc.h)
  294. // 128 buttons 16
  295. // 6 axes 12
  296. // 17 sliders 34
  297. // 4 pov 2
  298. static uint8_t joystick_report_desc[] = {
  299. 0x05, 0x01, // Usage Page (Generic Desktop)
  300. 0x09, 0x04, // Usage (Joystick)
  301. 0xA1, 0x01, // Collection (Application)
  302. 0x15, 0x00, // Logical Minimum (0)
  303. 0x25, 0x01, // Logical Maximum (1)
  304. 0x75, 0x01, // Report Size (1)
  305. 0x95, 0x80, // Report Count (128)
  306. 0x05, 0x09, // Usage Page (Button)
  307. 0x19, 0x01, // Usage Minimum (Button #1)
  308. 0x29, 0x80, // Usage Maximum (Button #128)
  309. 0x81, 0x02, // Input (variable,absolute)
  310. 0x05, 0x01, // Usage Page (Generic Desktop)
  311. 0x09, 0x01, // Usage (Pointer)
  312. 0xA1, 0x00, // Collection ()
  313. 0x15, 0x00, // Logical Minimum (0)
  314. 0x27, 0xFF, 0xFF, 0, 0, // Logical Maximum (65535)
  315. 0x75, 0x10, // Report Size (16)
  316. 0x95, 23, // Report Count (23)
  317. 0x09, 0x30, // Usage (X)
  318. 0x09, 0x31, // Usage (Y)
  319. 0x09, 0x32, // Usage (Z)
  320. 0x09, 0x33, // Usage (Rx)
  321. 0x09, 0x34, // Usage (Ry)
  322. 0x09, 0x35, // Usage (Rz)
  323. 0x09, 0x36, // Usage (Slider)
  324. 0x09, 0x36, // Usage (Slider)
  325. 0x09, 0x36, // Usage (Slider)
  326. 0x09, 0x36, // Usage (Slider)
  327. 0x09, 0x36, // Usage (Slider)
  328. 0x09, 0x36, // Usage (Slider)
  329. 0x09, 0x36, // Usage (Slider)
  330. 0x09, 0x36, // Usage (Slider)
  331. 0x09, 0x36, // Usage (Slider)
  332. 0x09, 0x36, // Usage (Slider)
  333. 0x09, 0x36, // Usage (Slider)
  334. 0x09, 0x36, // Usage (Slider)
  335. 0x09, 0x36, // Usage (Slider)
  336. 0x09, 0x36, // Usage (Slider)
  337. 0x09, 0x36, // Usage (Slider)
  338. 0x09, 0x36, // Usage (Slider)
  339. 0x09, 0x36, // Usage (Slider)
  340. 0x81, 0x02, // Input (variable,absolute)
  341. 0xC0, // End Collection
  342. 0x15, 0x00, // Logical Minimum (0)
  343. 0x25, 0x07, // Logical Maximum (7)
  344. 0x35, 0x00, // Physical Minimum (0)
  345. 0x46, 0x3B, 0x01, // Physical Maximum (315)
  346. 0x75, 0x04, // Report Size (4)
  347. 0x95, 0x04, // Report Count (4)
  348. 0x65, 0x14, // Unit (20)
  349. 0x05, 0x01, // Usage Page (Generic Desktop)
  350. 0x09, 0x39, // Usage (Hat switch)
  351. 0x09, 0x39, // Usage (Hat switch)
  352. 0x09, 0x39, // Usage (Hat switch)
  353. 0x09, 0x39, // Usage (Hat switch)
  354. 0x81, 0x42, // Input (variable,absolute,null_state)
  355. 0xC0 // End Collection
  356. };
  357. #endif // JOYSTICK_SIZE
  358. #endif // JOYSTICK_INTERFACE
  359. #ifdef MULTITOUCH_INTERFACE
  360. // https://forum.pjrc.com/threads/32331-USB-HID-Touchscreen-support-needed
  361. // https://msdn.microsoft.com/en-us/library/windows/hardware/jj151563%28v=vs.85%29.aspx
  362. // https://msdn.microsoft.com/en-us/library/windows/hardware/jj151565%28v=vs.85%29.aspx
  363. // https://msdn.microsoft.com/en-us/library/windows/hardware/ff553734%28v=vs.85%29.aspx
  364. // https://msdn.microsoft.com/en-us/library/windows/hardware/jj151564%28v=vs.85%29.aspx
  365. // download.microsoft.com/download/a/d/f/adf1347d-08dc-41a4-9084-623b1194d4b2/digitizerdrvs_touch.docx
  366. static uint8_t multitouch_report_desc[] = {
  367. 0x05, 0x0D, // Usage Page (Digitizer)
  368. 0x09, 0x04, // Usage (Touch Screen)
  369. 0xa1, 0x01, // Collection (Application)
  370. 0x09, 0x22, // Usage (Finger)
  371. 0xA1, 0x02, // Collection (Logical)
  372. 0x09, 0x42, // Usage (Tip Switch)
  373. 0x15, 0x00, // Logical Minimum (0)
  374. 0x25, 0x01, // Logical Maximum (1)
  375. 0x75, 0x01, // Report Size (1)
  376. 0x95, 0x01, // Report Count (1)
  377. 0x81, 0x02, // Input (variable,absolute)
  378. 0x09, 0x51, // Usage (Contact Identifier)
  379. 0x25, 0x7F, // Logical Maximum (127)
  380. 0x75, 0x07, // Report Size (7)
  381. 0x95, 0x01, // Report Count (1)
  382. 0x81, 0x02, // Input (variable,absolute)
  383. 0x09, 0x30, // Usage (Pressure)
  384. 0x26, 0xFF, 0x00, // Logical Maximum (255)
  385. 0x75, 0x08, // Report Size (8)
  386. 0x95, 0x01, // Report Count (1)
  387. 0x81, 0x02, // Input (variable,absolute)
  388. 0x05, 0x01, // Usage Page (Generic Desktop)
  389. 0x09, 0x30, // Usage (X)
  390. 0x09, 0x31, // Usage (Y)
  391. 0x26, 0xFF, 0x7F, // Logical Maximum (32767)
  392. 0x65, 0x00, // Unit (None) <-- probably needs real units?
  393. 0x75, 0x10, // Report Size (16)
  394. 0x95, 0x02, // Report Count (2)
  395. 0x81, 0x02, // Input (variable,absolute)
  396. 0xC0, // End Collection
  397. 0x05, 0x0D, // Usage Page (Digitizer)
  398. 0x27, 0xFF, 0xFF, 0, 0, // Logical Maximum (65535)
  399. 0x75, 0x10, // Report Size (16)
  400. 0x95, 0x01, // Report Count (1)
  401. 0x09, 0x56, // Usage (Scan Time)
  402. 0x81, 0x02, // Input (variable,absolute)
  403. 0x09, 0x54, // USAGE (Contact count)
  404. 0x25, 0x7f, // LOGICAL_MAXIMUM (127)
  405. 0x95, 0x01, // REPORT_COUNT (1)
  406. 0x75, 0x08, // REPORT_SIZE (8)
  407. 0x81, 0x02, // INPUT (Data,Var,Abs)
  408. 0x05, 0x0D, // Usage Page (Digitizers)
  409. 0x09, 0x55, // Usage (Contact Count Maximum)
  410. 0x25, MULTITOUCH_FINGERS, // Logical Maximum (10)
  411. 0x75, 0x08, // Report Size (8)
  412. 0x95, 0x01, // Report Count (1)
  413. 0xB1, 0x02, // Feature (variable,absolute)
  414. 0xC0 // End Collection
  415. };
  416. #endif
  417. #ifdef SEREMU_INTERFACE
  418. static uint8_t seremu_report_desc[] = {
  419. 0x06, 0xC9, 0xFF, // Usage Page 0xFFC9 (vendor defined)
  420. 0x09, 0x04, // Usage 0x04
  421. 0xA1, 0x5C, // Collection 0x5C
  422. 0x75, 0x08, // report size = 8 bits (global)
  423. 0x15, 0x00, // logical minimum = 0 (global)
  424. 0x26, 0xFF, 0x00, // logical maximum = 255 (global)
  425. 0x95, SEREMU_TX_SIZE, // report count (global)
  426. 0x09, 0x75, // usage (local)
  427. 0x81, 0x02, // Input
  428. 0x95, SEREMU_RX_SIZE, // report count (global)
  429. 0x09, 0x76, // usage (local)
  430. 0x91, 0x02, // Output
  431. 0x95, 0x04, // report count (global)
  432. 0x09, 0x76, // usage (local)
  433. 0xB1, 0x02, // Feature
  434. 0xC0 // end collection
  435. };
  436. #endif
  437. #ifdef RAWHID_INTERFACE
  438. static uint8_t rawhid_report_desc[] = {
  439. 0x06, LSB(RAWHID_USAGE_PAGE), MSB(RAWHID_USAGE_PAGE),
  440. 0x0A, LSB(RAWHID_USAGE), MSB(RAWHID_USAGE),
  441. 0xA1, 0x01, // Collection 0x01
  442. 0x75, 0x08, // report size = 8 bits
  443. 0x15, 0x00, // logical minimum = 0
  444. 0x26, 0xFF, 0x00, // logical maximum = 255
  445. 0x95, RAWHID_TX_SIZE, // report count
  446. 0x09, 0x01, // usage
  447. 0x81, 0x02, // Input (array)
  448. 0x95, RAWHID_RX_SIZE, // report count
  449. 0x09, 0x02, // usage
  450. 0x91, 0x02, // Output (array)
  451. 0xC0 // end collection
  452. };
  453. #endif
  454. #ifdef FLIGHTSIM_INTERFACE
  455. static uint8_t flightsim_report_desc[] = {
  456. 0x06, 0x1C, 0xFF, // Usage page = 0xFF1C
  457. 0x0A, 0x39, 0xA7, // Usage = 0xA739
  458. 0xA1, 0x01, // Collection 0x01
  459. 0x75, 0x08, // report size = 8 bits
  460. 0x15, 0x00, // logical minimum = 0
  461. 0x26, 0xFF, 0x00, // logical maximum = 255
  462. 0x95, FLIGHTSIM_TX_SIZE, // report count
  463. 0x09, 0x01, // usage
  464. 0x81, 0x02, // Input (array)
  465. 0x95, FLIGHTSIM_RX_SIZE, // report count
  466. 0x09, 0x02, // usage
  467. 0x91, 0x02, // Output (array)
  468. 0xC0 // end collection
  469. };
  470. #endif
  471. // **************************************************************
  472. // USB Descriptor Sizes
  473. // **************************************************************
  474. // pre-compute the size and position of everything in the config descriptor
  475. //
  476. #define CONFIG_HEADER_DESCRIPTOR_SIZE 9
  477. #define CDC_IAD_DESCRIPTOR_POS CONFIG_HEADER_DESCRIPTOR_SIZE
  478. #ifdef CDC_IAD_DESCRIPTOR
  479. #define CDC_IAD_DESCRIPTOR_SIZE 8
  480. #else
  481. #define CDC_IAD_DESCRIPTOR_SIZE 0
  482. #endif
  483. #define CDC_DATA_INTERFACE_DESC_POS CDC_IAD_DESCRIPTOR_POS+CDC_IAD_DESCRIPTOR_SIZE
  484. #ifdef CDC_DATA_INTERFACE
  485. #define CDC_DATA_INTERFACE_DESC_SIZE 9+5+5+4+5+7+9+7+7
  486. #else
  487. #define CDC_DATA_INTERFACE_DESC_SIZE 0
  488. #endif
  489. #define CDC2_DATA_INTERFACE_DESC_POS CDC_DATA_INTERFACE_DESC_POS+CDC_DATA_INTERFACE_DESC_SIZE
  490. #ifdef CDC2_DATA_INTERFACE
  491. #define CDC2_DATA_INTERFACE_DESC_SIZE 8 + 9+5+5+4+5+7+9+7+7
  492. #else
  493. #define CDC2_DATA_INTERFACE_DESC_SIZE 0
  494. #endif
  495. #define CDC3_DATA_INTERFACE_DESC_POS CDC2_DATA_INTERFACE_DESC_POS+CDC2_DATA_INTERFACE_DESC_SIZE
  496. #ifdef CDC3_DATA_INTERFACE
  497. #define CDC3_DATA_INTERFACE_DESC_SIZE 8 + 9+5+5+4+5+7+9+7+7
  498. #else
  499. #define CDC3_DATA_INTERFACE_DESC_SIZE 0
  500. #endif
  501. #define MIDI_INTERFACE_DESC_POS CDC3_DATA_INTERFACE_DESC_POS+CDC3_DATA_INTERFACE_DESC_SIZE
  502. #ifdef MIDI_INTERFACE
  503. #if !defined(MIDI_NUM_CABLES) || MIDI_NUM_CABLES < 1 || MIDI_NUM_CABLES > 16
  504. #error "MIDI_NUM_CABLES must be defined between 1 to 16"
  505. #endif
  506. #define MIDI_INTERFACE_DESC_SIZE 9+7+((6+6+9+9)*MIDI_NUM_CABLES)+(9+4+MIDI_NUM_CABLES)*2
  507. #else
  508. #define MIDI_INTERFACE_DESC_SIZE 0
  509. #endif
  510. #define KEYBOARD_INTERFACE_DESC_POS MIDI_INTERFACE_DESC_POS+MIDI_INTERFACE_DESC_SIZE
  511. #ifdef KEYBOARD_INTERFACE
  512. #define KEYBOARD_INTERFACE_DESC_SIZE 9+9+7
  513. #define KEYBOARD_HID_DESC_OFFSET KEYBOARD_INTERFACE_DESC_POS+9
  514. #else
  515. #define KEYBOARD_INTERFACE_DESC_SIZE 0
  516. #endif
  517. #define MOUSE_INTERFACE_DESC_POS KEYBOARD_INTERFACE_DESC_POS+KEYBOARD_INTERFACE_DESC_SIZE
  518. #ifdef MOUSE_INTERFACE
  519. #define MOUSE_INTERFACE_DESC_SIZE 9+9+7
  520. #define MOUSE_HID_DESC_OFFSET MOUSE_INTERFACE_DESC_POS+9
  521. #else
  522. #define MOUSE_INTERFACE_DESC_SIZE 0
  523. #endif
  524. #define RAWHID_INTERFACE_DESC_POS MOUSE_INTERFACE_DESC_POS+MOUSE_INTERFACE_DESC_SIZE
  525. #ifdef RAWHID_INTERFACE
  526. #define RAWHID_INTERFACE_DESC_SIZE 9+9+7+7
  527. #define RAWHID_HID_DESC_OFFSET RAWHID_INTERFACE_DESC_POS+9
  528. #else
  529. #define RAWHID_INTERFACE_DESC_SIZE 0
  530. #endif
  531. #define FLIGHTSIM_INTERFACE_DESC_POS RAWHID_INTERFACE_DESC_POS+RAWHID_INTERFACE_DESC_SIZE
  532. #ifdef FLIGHTSIM_INTERFACE
  533. #define FLIGHTSIM_INTERFACE_DESC_SIZE 9+9+7+7
  534. #define FLIGHTSIM_HID_DESC_OFFSET FLIGHTSIM_INTERFACE_DESC_POS+9
  535. #else
  536. #define FLIGHTSIM_INTERFACE_DESC_SIZE 0
  537. #endif
  538. #define SEREMU_INTERFACE_DESC_POS FLIGHTSIM_INTERFACE_DESC_POS+FLIGHTSIM_INTERFACE_DESC_SIZE
  539. #ifdef SEREMU_INTERFACE
  540. #define SEREMU_INTERFACE_DESC_SIZE 9+9+7+7
  541. #define SEREMU_HID_DESC_OFFSET SEREMU_INTERFACE_DESC_POS+9
  542. #else
  543. #define SEREMU_INTERFACE_DESC_SIZE 0
  544. #endif
  545. #define JOYSTICK_INTERFACE_DESC_POS SEREMU_INTERFACE_DESC_POS+SEREMU_INTERFACE_DESC_SIZE
  546. #ifdef JOYSTICK_INTERFACE
  547. #define JOYSTICK_INTERFACE_DESC_SIZE 9+9+7
  548. #define JOYSTICK_HID_DESC_OFFSET JOYSTICK_INTERFACE_DESC_POS+9
  549. #else
  550. #define JOYSTICK_INTERFACE_DESC_SIZE 0
  551. #endif
  552. #define MTP_INTERFACE_DESC_POS JOYSTICK_INTERFACE_DESC_POS+JOYSTICK_INTERFACE_DESC_SIZE
  553. #ifdef MTP_INTERFACE
  554. #define MTP_INTERFACE_DESC_SIZE 9+7+7+7
  555. #else
  556. #define MTP_INTERFACE_DESC_SIZE 0
  557. #endif
  558. #define KEYMEDIA_INTERFACE_DESC_POS MTP_INTERFACE_DESC_POS+MTP_INTERFACE_DESC_SIZE
  559. #ifdef KEYMEDIA_INTERFACE
  560. #define KEYMEDIA_INTERFACE_DESC_SIZE 9+9+7
  561. #define KEYMEDIA_HID_DESC_OFFSET KEYMEDIA_INTERFACE_DESC_POS+9
  562. #else
  563. #define KEYMEDIA_INTERFACE_DESC_SIZE 0
  564. #endif
  565. #define AUDIO_INTERFACE_DESC_POS KEYMEDIA_INTERFACE_DESC_POS+KEYMEDIA_INTERFACE_DESC_SIZE
  566. #ifdef AUDIO_INTERFACE
  567. #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
  568. #else
  569. #define AUDIO_INTERFACE_DESC_SIZE 0
  570. #endif
  571. #define MULTITOUCH_INTERFACE_DESC_POS AUDIO_INTERFACE_DESC_POS+AUDIO_INTERFACE_DESC_SIZE
  572. #ifdef MULTITOUCH_INTERFACE
  573. #define MULTITOUCH_INTERFACE_DESC_SIZE 9+9+7
  574. #define MULTITOUCH_HID_DESC_OFFSET MULTITOUCH_INTERFACE_DESC_POS+9
  575. #else
  576. #define MULTITOUCH_INTERFACE_DESC_SIZE 0
  577. #endif
  578. #define CONFIG_DESC_SIZE MULTITOUCH_INTERFACE_DESC_POS+MULTITOUCH_INTERFACE_DESC_SIZE
  579. // **************************************************************
  580. // USB Configuration
  581. // **************************************************************
  582. // USB Configuration Descriptor. This huge descriptor tells all
  583. // of the devices capbilities.
  584. PROGMEM const uint8_t usb_config_descriptor_480[CONFIG_DESC_SIZE] = {
  585. // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
  586. 9, // bLength;
  587. 2, // bDescriptorType;
  588. LSB(CONFIG_DESC_SIZE), // wTotalLength
  589. MSB(CONFIG_DESC_SIZE),
  590. NUM_INTERFACE, // bNumInterfaces
  591. 1, // bConfigurationValue
  592. 0, // iConfiguration
  593. 0xC0, // bmAttributes
  594. 50, // bMaxPower
  595. #ifdef CDC_IAD_DESCRIPTOR
  596. // interface association descriptor, USB ECN, Table 9-Z
  597. 8, // bLength
  598. 11, // bDescriptorType
  599. CDC_STATUS_INTERFACE, // bFirstInterface
  600. 2, // bInterfaceCount
  601. 0x02, // bFunctionClass
  602. 0x02, // bFunctionSubClass
  603. 0x01, // bFunctionProtocol
  604. 0, // iFunction
  605. #endif
  606. #ifdef CDC_DATA_INTERFACE
  607. // configuration for 480 Mbit/sec speed
  608. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  609. 9, // bLength
  610. 4, // bDescriptorType
  611. CDC_STATUS_INTERFACE, // bInterfaceNumber
  612. 0, // bAlternateSetting
  613. 1, // bNumEndpoints
  614. 0x02, // bInterfaceClass
  615. 0x02, // bInterfaceSubClass
  616. 0x01, // bInterfaceProtocol
  617. 0, // iInterface
  618. // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26
  619. 5, // bFunctionLength
  620. 0x24, // bDescriptorType
  621. 0x00, // bDescriptorSubtype
  622. 0x10, 0x01, // bcdCDC
  623. // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27
  624. 5, // bFunctionLength
  625. 0x24, // bDescriptorType
  626. 0x01, // bDescriptorSubtype
  627. 0x01, // bmCapabilities
  628. 1, // bDataInterface
  629. // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28
  630. 4, // bFunctionLength
  631. 0x24, // bDescriptorType
  632. 0x02, // bDescriptorSubtype
  633. 0x06, // bmCapabilities
  634. // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33
  635. 5, // bFunctionLength
  636. 0x24, // bDescriptorType
  637. 0x06, // bDescriptorSubtype
  638. CDC_STATUS_INTERFACE, // bMasterInterface
  639. CDC_DATA_INTERFACE, // bSlaveInterface0
  640. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  641. 7, // bLength
  642. 5, // bDescriptorType
  643. CDC_ACM_ENDPOINT | 0x80, // bEndpointAddress
  644. 0x03, // bmAttributes (0x03=intr)
  645. LSB(CDC_ACM_SIZE),MSB(CDC_ACM_SIZE), // wMaxPacketSize
  646. 5, // bInterval
  647. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  648. 9, // bLength
  649. 4, // bDescriptorType
  650. CDC_DATA_INTERFACE, // bInterfaceNumber
  651. 0, // bAlternateSetting
  652. 2, // bNumEndpoints
  653. 0x0A, // bInterfaceClass
  654. 0x00, // bInterfaceSubClass
  655. 0x00, // bInterfaceProtocol
  656. 0, // iInterface
  657. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  658. 7, // bLength
  659. 5, // bDescriptorType
  660. CDC_RX_ENDPOINT, // bEndpointAddress
  661. 0x02, // bmAttributes (0x02=bulk)
  662. LSB(CDC_RX_SIZE_480),MSB(CDC_RX_SIZE_480),// wMaxPacketSize
  663. 0, // bInterval
  664. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  665. 7, // bLength
  666. 5, // bDescriptorType
  667. CDC_TX_ENDPOINT | 0x80, // bEndpointAddress
  668. 0x02, // bmAttributes (0x02=bulk)
  669. LSB(CDC_TX_SIZE_480),MSB(CDC_TX_SIZE_480),// wMaxPacketSize
  670. 0, // bInterval
  671. #endif // CDC_DATA_INTERFACE
  672. #ifdef CDC2_DATA_INTERFACE
  673. // configuration for 480 Mbit/sec speed
  674. // interface association descriptor, USB ECN, Table 9-Z
  675. 8, // bLength
  676. 11, // bDescriptorType
  677. CDC2_STATUS_INTERFACE, // bFirstInterface
  678. 2, // bInterfaceCount
  679. 0x02, // bFunctionClass
  680. 0x02, // bFunctionSubClass
  681. 0x01, // bFunctionProtocol
  682. 0, // iFunction
  683. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  684. 9, // bLength
  685. 4, // bDescriptorType
  686. CDC2_STATUS_INTERFACE, // bInterfaceNumber
  687. 0, // bAlternateSetting
  688. 1, // bNumEndpoints
  689. 0x02, // bInterfaceClass
  690. 0x02, // bInterfaceSubClass
  691. 0x01, // bInterfaceProtocol
  692. 0, // iInterface
  693. // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26
  694. 5, // bFunctionLength
  695. 0x24, // bDescriptorType
  696. 0x00, // bDescriptorSubtype
  697. 0x10, 0x01, // bcdCDC
  698. // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27
  699. 5, // bFunctionLength
  700. 0x24, // bDescriptorType
  701. 0x01, // bDescriptorSubtype
  702. 0x01, // bmCapabilities
  703. 1, // bDataInterface
  704. // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28
  705. 4, // bFunctionLength
  706. 0x24, // bDescriptorType
  707. 0x02, // bDescriptorSubtype
  708. 0x06, // bmCapabilities
  709. // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33
  710. 5, // bFunctionLength
  711. 0x24, // bDescriptorType
  712. 0x06, // bDescriptorSubtype
  713. CDC2_STATUS_INTERFACE, // bMasterInterface
  714. CDC2_DATA_INTERFACE, // bSlaveInterface0
  715. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  716. 7, // bLength
  717. 5, // bDescriptorType
  718. CDC2_ACM_ENDPOINT | 0x80, // bEndpointAddress
  719. 0x03, // bmAttributes (0x03=intr)
  720. CDC_ACM_SIZE, 0, // wMaxPacketSize
  721. 5, // bInterval
  722. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  723. 9, // bLength
  724. 4, // bDescriptorType
  725. CDC2_DATA_INTERFACE, // bInterfaceNumber
  726. 0, // bAlternateSetting
  727. 2, // bNumEndpoints
  728. 0x0A, // bInterfaceClass
  729. 0x00, // bInterfaceSubClass
  730. 0x00, // bInterfaceProtocol
  731. 0, // iInterface
  732. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  733. 7, // bLength
  734. 5, // bDescriptorType
  735. CDC2_RX_ENDPOINT, // bEndpointAddress
  736. 0x02, // bmAttributes (0x02=bulk)
  737. LSB(CDC_RX_SIZE_480),MSB(CDC_RX_SIZE_480),// wMaxPacketSize
  738. 0, // bInterval
  739. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  740. 7, // bLength
  741. 5, // bDescriptorType
  742. CDC2_TX_ENDPOINT | 0x80, // bEndpointAddress
  743. 0x02, // bmAttributes (0x02=bulk)
  744. LSB(CDC_TX_SIZE_480),MSB(CDC_TX_SIZE_480),// wMaxPacketSize
  745. 0, // bInterval
  746. #endif // CDC2_DATA_INTERFACE
  747. #ifdef CDC3_DATA_INTERFACE
  748. // configuration for 480 Mbit/sec speed
  749. // interface association descriptor, USB ECN, Table 9-Z
  750. 8, // bLength
  751. 11, // bDescriptorType
  752. CDC3_STATUS_INTERFACE, // bFirstInterface
  753. 2, // bInterfaceCount
  754. 0x02, // bFunctionClass
  755. 0x02, // bFunctionSubClass
  756. 0x01, // bFunctionProtocol
  757. 0, // iFunction
  758. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  759. 9, // bLength
  760. 4, // bDescriptorType
  761. CDC3_STATUS_INTERFACE, // bInterfaceNumber
  762. 0, // bAlternateSetting
  763. 1, // bNumEndpoints
  764. 0x02, // bInterfaceClass
  765. 0x02, // bInterfaceSubClass
  766. 0x01, // bInterfaceProtocol
  767. 0, // iInterface
  768. // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26
  769. 5, // bFunctionLength
  770. 0x24, // bDescriptorType
  771. 0x00, // bDescriptorSubtype
  772. 0x10, 0x01, // bcdCDC
  773. // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27
  774. 5, // bFunctionLength
  775. 0x24, // bDescriptorType
  776. 0x01, // bDescriptorSubtype
  777. 0x01, // bmCapabilities
  778. 1, // bDataInterface
  779. // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28
  780. 4, // bFunctionLength
  781. 0x24, // bDescriptorType
  782. 0x02, // bDescriptorSubtype
  783. 0x06, // bmCapabilities
  784. // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33
  785. 5, // bFunctionLength
  786. 0x24, // bDescriptorType
  787. 0x06, // bDescriptorSubtype
  788. CDC3_STATUS_INTERFACE, // bMasterInterface
  789. CDC3_DATA_INTERFACE, // bSlaveInterface0
  790. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  791. 7, // bLength
  792. 5, // bDescriptorType
  793. CDC3_ACM_ENDPOINT | 0x80, // bEndpointAddress
  794. 0x03, // bmAttributes (0x03=intr)
  795. CDC_ACM_SIZE, 0, // wMaxPacketSize
  796. 5, // bInterval
  797. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  798. 9, // bLength
  799. 4, // bDescriptorType
  800. CDC3_DATA_INTERFACE, // bInterfaceNumber
  801. 0, // bAlternateSetting
  802. 2, // bNumEndpoints
  803. 0x0A, // bInterfaceClass
  804. 0x00, // bInterfaceSubClass
  805. 0x00, // bInterfaceProtocol
  806. 0, // iInterface
  807. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  808. 7, // bLength
  809. 5, // bDescriptorType
  810. CDC3_RX_ENDPOINT, // bEndpointAddress
  811. 0x02, // bmAttributes (0x02=bulk)
  812. LSB(CDC_RX_SIZE_480),MSB(CDC_RX_SIZE_480),// wMaxPacketSize
  813. 0, // bInterval
  814. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  815. 7, // bLength
  816. 5, // bDescriptorType
  817. CDC3_TX_ENDPOINT | 0x80, // bEndpointAddress
  818. 0x02, // bmAttributes (0x02=bulk)
  819. LSB(CDC_TX_SIZE_480),MSB(CDC_TX_SIZE_480),// wMaxPacketSize
  820. 0, // bInterval
  821. #endif // CDC3_DATA_INTERFACE
  822. #ifdef MIDI_INTERFACE
  823. // configuration for 480 Mbit/sec speed
  824. // Standard MS Interface Descriptor,
  825. 9, // bLength
  826. 4, // bDescriptorType
  827. MIDI_INTERFACE, // bInterfaceNumber
  828. 0, // bAlternateSetting
  829. 2, // bNumEndpoints
  830. 0x01, // bInterfaceClass (0x01 = Audio)
  831. 0x03, // bInterfaceSubClass (0x03 = MIDI)
  832. 0x00, // bInterfaceProtocol (unused for MIDI)
  833. 0, // iInterface
  834. // MIDI MS Interface Header, USB MIDI 6.1.2.1, page 21, Table 6-2
  835. 7, // bLength
  836. 0x24, // bDescriptorType = CS_INTERFACE
  837. 0x01, // bDescriptorSubtype = MS_HEADER
  838. 0x00, 0x01, // bcdMSC = revision 01.00
  839. LSB(7+(6+6+9+9)*MIDI_NUM_CABLES), // wTotalLength
  840. MSB(7+(6+6+9+9)*MIDI_NUM_CABLES),
  841. // MIDI IN Jack Descriptor, B.4.3, Table B-7 (embedded), page 40
  842. 6, // bLength
  843. 0x24, // bDescriptorType = CS_INTERFACE
  844. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  845. 0x01, // bJackType = EMBEDDED
  846. 1, // bJackID, ID = 1
  847. 0, // iJack
  848. // MIDI IN Jack Descriptor, B.4.3, Table B-8 (external), page 40
  849. 6, // bLength
  850. 0x24, // bDescriptorType = CS_INTERFACE
  851. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  852. 0x02, // bJackType = EXTERNAL
  853. 2, // bJackID, ID = 2
  854. 0, // iJack
  855. // MIDI OUT Jack Descriptor, B.4.4, Table B-9, page 41
  856. 9,
  857. 0x24, // bDescriptorType = CS_INTERFACE
  858. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  859. 0x01, // bJackType = EMBEDDED
  860. 3, // bJackID, ID = 3
  861. 1, // bNrInputPins = 1 pin
  862. 2, // BaSourceID(1) = 2
  863. 1, // BaSourcePin(1) = first pin
  864. 0, // iJack
  865. // MIDI OUT Jack Descriptor, B.4.4, Table B-10, page 41
  866. 9,
  867. 0x24, // bDescriptorType = CS_INTERFACE
  868. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  869. 0x02, // bJackType = EXTERNAL
  870. 4, // bJackID, ID = 4
  871. 1, // bNrInputPins = 1 pin
  872. 1, // BaSourceID(1) = 1
  873. 1, // BaSourcePin(1) = first pin
  874. 0, // iJack
  875. #if MIDI_NUM_CABLES >= 2
  876. #define MIDI_INTERFACE_JACK_PAIR(a, b, c, d) \
  877. 6, 0x24, 0x02, 0x01, (a), 0, \
  878. 6, 0x24, 0x02, 0x02, (b), 0, \
  879. 9, 0x24, 0x03, 0x01, (c), 1, (b), 1, 0, \
  880. 9, 0x24, 0x03, 0x02, (d), 1, (a), 1, 0,
  881. MIDI_INTERFACE_JACK_PAIR(5, 6, 7, 8)
  882. #endif
  883. #if MIDI_NUM_CABLES >= 3
  884. MIDI_INTERFACE_JACK_PAIR(9, 10, 11, 12)
  885. #endif
  886. #if MIDI_NUM_CABLES >= 4
  887. MIDI_INTERFACE_JACK_PAIR(13, 14, 15, 16)
  888. #endif
  889. #if MIDI_NUM_CABLES >= 5
  890. MIDI_INTERFACE_JACK_PAIR(17, 18, 19, 20)
  891. #endif
  892. #if MIDI_NUM_CABLES >= 6
  893. MIDI_INTERFACE_JACK_PAIR(21, 22, 23, 24)
  894. #endif
  895. #if MIDI_NUM_CABLES >= 7
  896. MIDI_INTERFACE_JACK_PAIR(25, 26, 27, 28)
  897. #endif
  898. #if MIDI_NUM_CABLES >= 8
  899. MIDI_INTERFACE_JACK_PAIR(29, 30, 31, 32)
  900. #endif
  901. #if MIDI_NUM_CABLES >= 9
  902. MIDI_INTERFACE_JACK_PAIR(33, 34, 35, 36)
  903. #endif
  904. #if MIDI_NUM_CABLES >= 10
  905. MIDI_INTERFACE_JACK_PAIR(37, 38, 39, 40)
  906. #endif
  907. #if MIDI_NUM_CABLES >= 11
  908. MIDI_INTERFACE_JACK_PAIR(41, 42, 43, 44)
  909. #endif
  910. #if MIDI_NUM_CABLES >= 12
  911. MIDI_INTERFACE_JACK_PAIR(45, 46, 47, 48)
  912. #endif
  913. #if MIDI_NUM_CABLES >= 13
  914. MIDI_INTERFACE_JACK_PAIR(49, 50, 51, 52)
  915. #endif
  916. #if MIDI_NUM_CABLES >= 14
  917. MIDI_INTERFACE_JACK_PAIR(53, 54, 55, 56)
  918. #endif
  919. #if MIDI_NUM_CABLES >= 15
  920. MIDI_INTERFACE_JACK_PAIR(57, 58, 59, 60)
  921. #endif
  922. #if MIDI_NUM_CABLES >= 16
  923. MIDI_INTERFACE_JACK_PAIR(61, 62, 63, 64)
  924. #endif
  925. // Standard Bulk OUT Endpoint Descriptor, B.5.1, Table B-11, pae 42
  926. 9, // bLength
  927. 5, // bDescriptorType = ENDPOINT
  928. MIDI_RX_ENDPOINT, // bEndpointAddress
  929. 0x02, // bmAttributes (0x02=bulk)
  930. LSB(MIDI_RX_SIZE_480),MSB(MIDI_RX_SIZE_480),// wMaxPacketSize
  931. 0, // bInterval
  932. 0, // bRefresh
  933. 0, // bSynchAddress
  934. // Class-specific MS Bulk OUT Endpoint Descriptor, B.5.2, Table B-12, page 42
  935. 4+MIDI_NUM_CABLES, // bLength
  936. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  937. 0x01, // bJackType = MS_GENERAL
  938. MIDI_NUM_CABLES, // bNumEmbMIDIJack = number of jacks
  939. 1, // BaAssocJackID(1) = jack ID #1
  940. #if MIDI_NUM_CABLES >= 2
  941. 5,
  942. #endif
  943. #if MIDI_NUM_CABLES >= 3
  944. 9,
  945. #endif
  946. #if MIDI_NUM_CABLES >= 4
  947. 13,
  948. #endif
  949. #if MIDI_NUM_CABLES >= 5
  950. 17,
  951. #endif
  952. #if MIDI_NUM_CABLES >= 6
  953. 21,
  954. #endif
  955. #if MIDI_NUM_CABLES >= 7
  956. 25,
  957. #endif
  958. #if MIDI_NUM_CABLES >= 8
  959. 29,
  960. #endif
  961. #if MIDI_NUM_CABLES >= 9
  962. 33,
  963. #endif
  964. #if MIDI_NUM_CABLES >= 10
  965. 37,
  966. #endif
  967. #if MIDI_NUM_CABLES >= 11
  968. 41,
  969. #endif
  970. #if MIDI_NUM_CABLES >= 12
  971. 45,
  972. #endif
  973. #if MIDI_NUM_CABLES >= 13
  974. 49,
  975. #endif
  976. #if MIDI_NUM_CABLES >= 14
  977. 53,
  978. #endif
  979. #if MIDI_NUM_CABLES >= 15
  980. 57,
  981. #endif
  982. #if MIDI_NUM_CABLES >= 16
  983. 61,
  984. #endif
  985. // Standard Bulk IN Endpoint Descriptor, B.5.1, Table B-11, pae 42
  986. 9, // bLength
  987. 5, // bDescriptorType = ENDPOINT
  988. MIDI_TX_ENDPOINT | 0x80, // bEndpointAddress
  989. 0x02, // bmAttributes (0x02=bulk)
  990. LSB(MIDI_TX_SIZE_480),MSB(MIDI_TX_SIZE_480),// wMaxPacketSize
  991. 0, // bInterval
  992. 0, // bRefresh
  993. 0, // bSynchAddress
  994. // Class-specific MS Bulk IN Endpoint Descriptor, B.5.2, Table B-12, page 42
  995. 4+MIDI_NUM_CABLES, // bLength
  996. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  997. 0x01, // bJackType = MS_GENERAL
  998. MIDI_NUM_CABLES, // bNumEmbMIDIJack = number of jacks
  999. 3, // BaAssocJackID(1) = jack ID #3
  1000. #if MIDI_NUM_CABLES >= 2
  1001. 7,
  1002. #endif
  1003. #if MIDI_NUM_CABLES >= 3
  1004. 11,
  1005. #endif
  1006. #if MIDI_NUM_CABLES >= 4
  1007. 15,
  1008. #endif
  1009. #if MIDI_NUM_CABLES >= 5
  1010. 19,
  1011. #endif
  1012. #if MIDI_NUM_CABLES >= 6
  1013. 23,
  1014. #endif
  1015. #if MIDI_NUM_CABLES >= 7
  1016. 27,
  1017. #endif
  1018. #if MIDI_NUM_CABLES >= 8
  1019. 31,
  1020. #endif
  1021. #if MIDI_NUM_CABLES >= 9
  1022. 35,
  1023. #endif
  1024. #if MIDI_NUM_CABLES >= 10
  1025. 39,
  1026. #endif
  1027. #if MIDI_NUM_CABLES >= 11
  1028. 43,
  1029. #endif
  1030. #if MIDI_NUM_CABLES >= 12
  1031. 47,
  1032. #endif
  1033. #if MIDI_NUM_CABLES >= 13
  1034. 51,
  1035. #endif
  1036. #if MIDI_NUM_CABLES >= 14
  1037. 55,
  1038. #endif
  1039. #if MIDI_NUM_CABLES >= 15
  1040. 59,
  1041. #endif
  1042. #if MIDI_NUM_CABLES >= 16
  1043. 63,
  1044. #endif
  1045. #endif // MIDI_INTERFACE
  1046. #ifdef KEYBOARD_INTERFACE
  1047. // configuration for 480 Mbit/sec speed
  1048. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1049. 9, // bLength
  1050. 4, // bDescriptorType
  1051. KEYBOARD_INTERFACE, // bInterfaceNumber
  1052. 0, // bAlternateSetting
  1053. 1, // bNumEndpoints
  1054. 0x03, // bInterfaceClass (0x03 = HID)
  1055. 0x01, // bInterfaceSubClass (0x01 = Boot)
  1056. 0x01, // bInterfaceProtocol (0x01 = Keyboard)
  1057. 0, // iInterface
  1058. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1059. 9, // bLength
  1060. 0x21, // bDescriptorType
  1061. 0x11, 0x01, // bcdHID
  1062. 0, // bCountryCode
  1063. 1, // bNumDescriptors
  1064. 0x22, // bDescriptorType
  1065. LSB(sizeof(keyboard_report_desc)), // wDescriptorLength
  1066. MSB(sizeof(keyboard_report_desc)),
  1067. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1068. 7, // bLength
  1069. 5, // bDescriptorType
  1070. KEYBOARD_ENDPOINT | 0x80, // bEndpointAddress
  1071. 0x03, // bmAttributes (0x03=intr)
  1072. KEYBOARD_SIZE, 0, // wMaxPacketSize
  1073. KEYBOARD_INTERVAL, // bInterval
  1074. #endif // KEYBOARD_INTERFACE
  1075. #ifdef MOUSE_INTERFACE
  1076. // configuration for 480 Mbit/sec speed
  1077. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1078. 9, // bLength
  1079. 4, // bDescriptorType
  1080. MOUSE_INTERFACE, // bInterfaceNumber
  1081. 0, // bAlternateSetting
  1082. 1, // bNumEndpoints
  1083. 0x03, // bInterfaceClass (0x03 = HID)
  1084. 0x00, // bInterfaceSubClass (0x01 = Boot)
  1085. 0x00, // bInterfaceProtocol (0x02 = Mouse)
  1086. 0, // iInterface
  1087. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1088. 9, // bLength
  1089. 0x21, // bDescriptorType
  1090. 0x11, 0x01, // bcdHID
  1091. 0, // bCountryCode
  1092. 1, // bNumDescriptors
  1093. 0x22, // bDescriptorType
  1094. LSB(sizeof(mouse_report_desc)), // wDescriptorLength
  1095. MSB(sizeof(mouse_report_desc)),
  1096. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1097. 7, // bLength
  1098. 5, // bDescriptorType
  1099. MOUSE_ENDPOINT | 0x80, // bEndpointAddress
  1100. 0x03, // bmAttributes (0x03=intr)
  1101. MOUSE_SIZE, 0, // wMaxPacketSize
  1102. MOUSE_INTERVAL, // bInterval
  1103. #endif // MOUSE_INTERFACE
  1104. #ifdef RAWHID_INTERFACE
  1105. // configuration for 480 Mbit/sec speed
  1106. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1107. 9, // bLength
  1108. 4, // bDescriptorType
  1109. RAWHID_INTERFACE, // bInterfaceNumber
  1110. 0, // bAlternateSetting
  1111. 2, // bNumEndpoints
  1112. 0x03, // bInterfaceClass (0x03 = HID)
  1113. 0x00, // bInterfaceSubClass
  1114. 0x00, // bInterfaceProtocol
  1115. 0, // iInterface
  1116. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1117. 9, // bLength
  1118. 0x21, // bDescriptorType
  1119. 0x11, 0x01, // bcdHID
  1120. 0, // bCountryCode
  1121. 1, // bNumDescriptors
  1122. 0x22, // bDescriptorType
  1123. LSB(sizeof(rawhid_report_desc)), // wDescriptorLength
  1124. MSB(sizeof(rawhid_report_desc)),
  1125. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1126. 7, // bLength
  1127. 5, // bDescriptorType
  1128. RAWHID_TX_ENDPOINT | 0x80, // bEndpointAddress
  1129. 0x03, // bmAttributes (0x03=intr)
  1130. RAWHID_TX_SIZE, 0, // wMaxPacketSize
  1131. RAWHID_TX_INTERVAL, // bInterval
  1132. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1133. 7, // bLength
  1134. 5, // bDescriptorType
  1135. RAWHID_RX_ENDPOINT, // bEndpointAddress
  1136. 0x03, // bmAttributes (0x03=intr)
  1137. RAWHID_RX_SIZE, 0, // wMaxPacketSize
  1138. RAWHID_RX_INTERVAL, // bInterval
  1139. #endif // RAWHID_INTERFACE
  1140. #ifdef FLIGHTSIM_INTERFACE
  1141. // configuration for 480 Mbit/sec speed
  1142. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1143. 9, // bLength
  1144. 4, // bDescriptorType
  1145. FLIGHTSIM_INTERFACE, // bInterfaceNumber
  1146. 0, // bAlternateSetting
  1147. 2, // bNumEndpoints
  1148. 0x03, // bInterfaceClass (0x03 = HID)
  1149. 0x00, // bInterfaceSubClass
  1150. 0x00, // bInterfaceProtocol
  1151. 0, // iInterface
  1152. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1153. 9, // bLength
  1154. 0x21, // bDescriptorType
  1155. 0x11, 0x01, // bcdHID
  1156. 0, // bCountryCode
  1157. 1, // bNumDescriptors
  1158. 0x22, // bDescriptorType
  1159. LSB(sizeof(flightsim_report_desc)), // wDescriptorLength
  1160. MSB(sizeof(flightsim_report_desc)),
  1161. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1162. 7, // bLength
  1163. 5, // bDescriptorType
  1164. FLIGHTSIM_TX_ENDPOINT | 0x80, // bEndpointAddress
  1165. 0x03, // bmAttributes (0x03=intr)
  1166. FLIGHTSIM_TX_SIZE, 0, // wMaxPacketSize
  1167. FLIGHTSIM_TX_INTERVAL, // bInterval
  1168. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1169. 7, // bLength
  1170. 5, // bDescriptorType
  1171. FLIGHTSIM_RX_ENDPOINT, // bEndpointAddress
  1172. 0x03, // bmAttributes (0x03=intr)
  1173. FLIGHTSIM_RX_SIZE, 0, // wMaxPacketSize
  1174. FLIGHTSIM_RX_INTERVAL, // bInterval
  1175. #endif // FLIGHTSIM_INTERFACE
  1176. #ifdef SEREMU_INTERFACE
  1177. // configuration for 480 Mbit/sec speed
  1178. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1179. 9, // bLength
  1180. 4, // bDescriptorType
  1181. SEREMU_INTERFACE, // bInterfaceNumber
  1182. 0, // bAlternateSetting
  1183. 2, // bNumEndpoints
  1184. 0x03, // bInterfaceClass (0x03 = HID)
  1185. 0x00, // bInterfaceSubClass
  1186. 0x00, // bInterfaceProtocol
  1187. 0, // iInterface
  1188. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1189. 9, // bLength
  1190. 0x21, // bDescriptorType
  1191. 0x11, 0x01, // bcdHID
  1192. 0, // bCountryCode
  1193. 1, // bNumDescriptors
  1194. 0x22, // bDescriptorType
  1195. LSB(sizeof(seremu_report_desc)), // wDescriptorLength
  1196. MSB(sizeof(seremu_report_desc)),
  1197. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1198. 7, // bLength
  1199. 5, // bDescriptorType
  1200. SEREMU_TX_ENDPOINT | 0x80, // bEndpointAddress
  1201. 0x03, // bmAttributes (0x03=intr)
  1202. SEREMU_TX_SIZE, 0, // wMaxPacketSize
  1203. SEREMU_TX_INTERVAL, // bInterval
  1204. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1205. 7, // bLength
  1206. 5, // bDescriptorType
  1207. SEREMU_RX_ENDPOINT, // bEndpointAddress
  1208. 0x03, // bmAttributes (0x03=intr)
  1209. SEREMU_RX_SIZE, 0, // wMaxPacketSize
  1210. SEREMU_RX_INTERVAL, // bInterval
  1211. #endif // SEREMU_INTERFACE
  1212. #ifdef JOYSTICK_INTERFACE
  1213. // configuration for 480 Mbit/sec speed
  1214. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1215. 9, // bLength
  1216. 4, // bDescriptorType
  1217. JOYSTICK_INTERFACE, // bInterfaceNumber
  1218. 0, // bAlternateSetting
  1219. 1, // bNumEndpoints
  1220. 0x03, // bInterfaceClass (0x03 = HID)
  1221. 0x00, // bInterfaceSubClass
  1222. 0x00, // bInterfaceProtocol
  1223. 0, // iInterface
  1224. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1225. 9, // bLength
  1226. 0x21, // bDescriptorType
  1227. 0x11, 0x01, // bcdHID
  1228. 0, // bCountryCode
  1229. 1, // bNumDescriptors
  1230. 0x22, // bDescriptorType
  1231. LSB(sizeof(joystick_report_desc)), // wDescriptorLength
  1232. MSB(sizeof(joystick_report_desc)),
  1233. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1234. 7, // bLength
  1235. 5, // bDescriptorType
  1236. JOYSTICK_ENDPOINT | 0x80, // bEndpointAddress
  1237. 0x03, // bmAttributes (0x03=intr)
  1238. JOYSTICK_SIZE, 0, // wMaxPacketSize
  1239. JOYSTICK_INTERVAL, // bInterval
  1240. #endif // JOYSTICK_INTERFACE
  1241. #ifdef MTP_INTERFACE
  1242. // configuration for 480 Mbit/sec speed
  1243. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1244. 9, // bLength
  1245. 4, // bDescriptorType
  1246. MTP_INTERFACE, // bInterfaceNumber
  1247. 0, // bAlternateSetting
  1248. 3, // bNumEndpoints
  1249. 0x06, // bInterfaceClass (0x06 = still image)
  1250. 0x01, // bInterfaceSubClass
  1251. 0x01, // bInterfaceProtocol
  1252. 0, // iInterface
  1253. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1254. 7, // bLength
  1255. 5, // bDescriptorType
  1256. MTP_TX_ENDPOINT | 0x80, // bEndpointAddress
  1257. 0x02, // bmAttributes (0x02=bulk)
  1258. LSB(MTP_TX_SIZE_480),MSB(MTP_TX_SIZE_480), // wMaxPacketSize
  1259. 0, // bInterval
  1260. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1261. 7, // bLength
  1262. 5, // bDescriptorType
  1263. MTP_RX_ENDPOINT, // bEndpointAddress
  1264. 0x02, // bmAttributes (0x02=bulk)
  1265. LSB(MTP_RX_SIZE_480),MSB(MTP_RX_SIZE_480), // wMaxPacketSize
  1266. 0, // bInterval
  1267. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1268. 7, // bLength
  1269. 5, // bDescriptorType
  1270. MTP_EVENT_ENDPOINT | 0x80, // bEndpointAddress
  1271. 0x03, // bmAttributes (0x03=intr)
  1272. MTP_EVENT_SIZE, 0, // wMaxPacketSize
  1273. MTP_EVENT_INTERVAL_480, // bInterval
  1274. #endif // MTP_INTERFACE
  1275. #ifdef KEYMEDIA_INTERFACE
  1276. // configuration for 480 Mbit/sec speed
  1277. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1278. 9, // bLength
  1279. 4, // bDescriptorType
  1280. KEYMEDIA_INTERFACE, // bInterfaceNumber
  1281. 0, // bAlternateSetting
  1282. 1, // bNumEndpoints
  1283. 0x03, // bInterfaceClass (0x03 = HID)
  1284. 0x00, // bInterfaceSubClass
  1285. 0x00, // bInterfaceProtocol
  1286. 0, // iInterface
  1287. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1288. 9, // bLength
  1289. 0x21, // bDescriptorType
  1290. 0x11, 0x01, // bcdHID
  1291. 0, // bCountryCode
  1292. 1, // bNumDescriptors
  1293. 0x22, // bDescriptorType
  1294. LSB(sizeof(keymedia_report_desc)), // wDescriptorLength
  1295. MSB(sizeof(keymedia_report_desc)),
  1296. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1297. 7, // bLength
  1298. 5, // bDescriptorType
  1299. KEYMEDIA_ENDPOINT | 0x80, // bEndpointAddress
  1300. 0x03, // bmAttributes (0x03=intr)
  1301. KEYMEDIA_SIZE, 0, // wMaxPacketSize
  1302. KEYMEDIA_INTERVAL, // bInterval
  1303. #endif // KEYMEDIA_INTERFACE
  1304. #ifdef AUDIO_INTERFACE
  1305. // configuration for 480 Mbit/sec speed
  1306. // interface association descriptor, USB ECN, Table 9-Z
  1307. 8, // bLength
  1308. 11, // bDescriptorType
  1309. AUDIO_INTERFACE, // bFirstInterface
  1310. 3, // bInterfaceCount
  1311. 0x01, // bFunctionClass
  1312. 0x01, // bFunctionSubClass
  1313. 0x00, // bFunctionProtocol
  1314. 0, // iFunction
  1315. // Standard AudioControl (AC) Interface Descriptor
  1316. // USB DCD for Audio Devices 1.0, Table 4-1, page 36
  1317. 9, // bLength
  1318. 4, // bDescriptorType, 4 = INTERFACE
  1319. AUDIO_INTERFACE, // bInterfaceNumber
  1320. 0, // bAlternateSetting
  1321. 0, // bNumEndpoints
  1322. 1, // bInterfaceClass, 1 = AUDIO
  1323. 1, // bInterfaceSubclass, 1 = AUDIO_CONTROL
  1324. 0, // bInterfaceProtocol
  1325. 0, // iInterface
  1326. // Class-specific AC Interface Header Descriptor
  1327. // USB DCD for Audio Devices 1.0, Table 4-2, page 37-38
  1328. 10, // bLength
  1329. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1330. 0x01, // bDescriptorSubtype, 1 = HEADER
  1331. 0x00, 0x01, // bcdADC (version 1.0)
  1332. LSB(62), MSB(62), // wTotalLength
  1333. 2, // bInCollection
  1334. AUDIO_INTERFACE+1, // baInterfaceNr(1) - Transmit to PC
  1335. AUDIO_INTERFACE+2, // baInterfaceNr(2) - Receive from PC
  1336. // Input Terminal Descriptor
  1337. // USB DCD for Audio Devices 1.0, Table 4-3, page 39
  1338. 12, // bLength
  1339. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1340. 0x02, // bDescriptorSubType, 2 = INPUT_TERMINAL
  1341. 1, // bTerminalID
  1342. //0x01, 0x02, // wTerminalType, 0x0201 = MICROPHONE
  1343. //0x03, 0x06, // wTerminalType, 0x0603 = Line Connector
  1344. 0x02, 0x06, // wTerminalType, 0x0602 = Digital Audio
  1345. 0, // bAssocTerminal, 0 = unidirectional
  1346. 2, // bNrChannels
  1347. 0x03, 0x00, // wChannelConfig, 0x0003 = Left & Right Front
  1348. 0, // iChannelNames
  1349. 0, // iTerminal
  1350. // Output Terminal Descriptor
  1351. // USB DCD for Audio Devices 1.0, Table 4-4, page 40
  1352. 9, // bLength
  1353. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1354. 3, // bDescriptorSubtype, 3 = OUTPUT_TERMINAL
  1355. 2, // bTerminalID
  1356. 0x01, 0x01, // wTerminalType, 0x0101 = USB_STREAMING
  1357. 0, // bAssocTerminal, 0 = unidirectional
  1358. 1, // bCSourceID, connected to input terminal, ID=1
  1359. 0, // iTerminal
  1360. // Input Terminal Descriptor
  1361. // USB DCD for Audio Devices 1.0, Table 4-3, page 39
  1362. 12, // bLength
  1363. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1364. 2, // bDescriptorSubType, 2 = INPUT_TERMINAL
  1365. 3, // bTerminalID
  1366. 0x01, 0x01, // wTerminalType, 0x0101 = USB_STREAMING
  1367. 0, // bAssocTerminal, 0 = unidirectional
  1368. 2, // bNrChannels
  1369. 0x03, 0x00, // wChannelConfig, 0x0003 = Left & Right Front
  1370. 0, // iChannelNames
  1371. 0, // iTerminal
  1372. // Volume feature descriptor
  1373. 10, // bLength
  1374. 0x24, // bDescriptorType = CS_INTERFACE
  1375. 0x06, // bDescriptorSubType = FEATURE_UNIT
  1376. 0x31, // bUnitID
  1377. 0x03, // bSourceID (Input Terminal)
  1378. 0x01, // bControlSize (each channel is 1 byte, 3 channels)
  1379. 0x01, // bmaControls(0) Master: Mute
  1380. 0x02, // bmaControls(1) Left: Volume
  1381. 0x02, // bmaControls(2) Right: Volume
  1382. 0x00, // iFeature
  1383. // Output Terminal Descriptor
  1384. // USB DCD for Audio Devices 1.0, Table 4-4, page 40
  1385. 9, // bLength
  1386. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1387. 3, // bDescriptorSubtype, 3 = OUTPUT_TERMINAL
  1388. 4, // bTerminalID
  1389. //0x02, 0x03, // wTerminalType, 0x0302 = Headphones
  1390. 0x02, 0x06, // wTerminalType, 0x0602 = Digital Audio
  1391. 0, // bAssocTerminal, 0 = unidirectional
  1392. 0x31, // bCSourceID, connected to feature, ID=31
  1393. 0, // iTerminal
  1394. // Standard AS Interface Descriptor
  1395. // USB DCD for Audio Devices 1.0, Section 4.5.1, Table 4-18, page 59
  1396. // Alternate 0: default setting, disabled zero bandwidth
  1397. 9, // bLenght
  1398. 4, // bDescriptorType = INTERFACE
  1399. AUDIO_INTERFACE+1, // bInterfaceNumber
  1400. 0, // bAlternateSetting
  1401. 0, // bNumEndpoints
  1402. 1, // bInterfaceClass, 1 = AUDIO
  1403. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  1404. 0, // bInterfaceProtocol
  1405. 0, // iInterface
  1406. // Alternate 1: streaming data
  1407. 9, // bLenght
  1408. 4, // bDescriptorType = INTERFACE
  1409. AUDIO_INTERFACE+1, // bInterfaceNumber
  1410. 1, // bAlternateSetting
  1411. 1, // bNumEndpoints
  1412. 1, // bInterfaceClass, 1 = AUDIO
  1413. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  1414. 0, // bInterfaceProtocol
  1415. 0, // iInterface
  1416. // Class-Specific AS Interface Descriptor
  1417. // USB DCD for Audio Devices 1.0, Section 4.5.2, Table 4-19, page 60
  1418. 7, // bLength
  1419. 0x24, // bDescriptorType = CS_INTERFACE
  1420. 1, // bDescriptorSubtype, 1 = AS_GENERAL
  1421. 2, // bTerminalLink: Terminal ID = 2
  1422. 3, // bDelay (approx 3ms delay, audio lib updates)
  1423. 0x01, 0x00, // wFormatTag, 0x0001 = PCM
  1424. // Type I Format Descriptor
  1425. // USB DCD for Audio Data Formats 1.0, Section 2.2.5, Table 2-1, page 10
  1426. 11, // bLength
  1427. 0x24, // bDescriptorType = CS_INTERFACE
  1428. 2, // bDescriptorSubtype = FORMAT_TYPE
  1429. 1, // bFormatType = FORMAT_TYPE_I
  1430. 2, // bNrChannels = 2
  1431. 2, // bSubFrameSize = 2 byte
  1432. 16, // bBitResolution = 16 bits
  1433. 1, // bSamFreqType = 1 frequency
  1434. LSB(44100), MSB(44100), 0, // tSamFreq
  1435. // Standard AS Isochronous Audio Data Endpoint Descriptor
  1436. // USB DCD for Audio Devices 1.0, Section 4.6.1.1, Table 4-20, page 61-62
  1437. 9, // bLength
  1438. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  1439. AUDIO_TX_ENDPOINT | 0x80, // bEndpointAddress
  1440. 0x09, // bmAttributes = isochronous, adaptive
  1441. LSB(AUDIO_TX_SIZE), MSB(AUDIO_TX_SIZE), // wMaxPacketSize
  1442. 4, // bInterval, 4 = every 8 micro-frames
  1443. 0, // bRefresh
  1444. 0, // bSynchAddress
  1445. // Class-Specific AS Isochronous Audio Data Endpoint Descriptor
  1446. // USB DCD for Audio Devices 1.0, Section 4.6.1.2, Table 4-21, page 62-63
  1447. 7, // bLength
  1448. 0x25, // bDescriptorType, 0x25 = CS_ENDPOINT
  1449. 1, // bDescriptorSubtype, 1 = EP_GENERAL
  1450. 0x00, // bmAttributes
  1451. 0, // bLockDelayUnits, 1 = ms
  1452. 0x00, 0x00, // wLockDelay
  1453. // Standard AS Interface Descriptor
  1454. // USB DCD for Audio Devices 1.0, Section 4.5.1, Table 4-18, page 59
  1455. // Alternate 0: default setting, disabled zero bandwidth
  1456. 9, // bLenght
  1457. 4, // bDescriptorType = INTERFACE
  1458. AUDIO_INTERFACE+2, // bInterfaceNumber
  1459. 0, // bAlternateSetting
  1460. 0, // bNumEndpoints
  1461. 1, // bInterfaceClass, 1 = AUDIO
  1462. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  1463. 0, // bInterfaceProtocol
  1464. 0, // iInterface
  1465. // Alternate 1: streaming data
  1466. 9, // bLenght
  1467. 4, // bDescriptorType = INTERFACE
  1468. AUDIO_INTERFACE+2, // bInterfaceNumber
  1469. 1, // bAlternateSetting
  1470. 2, // bNumEndpoints
  1471. 1, // bInterfaceClass, 1 = AUDIO
  1472. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  1473. 0, // bInterfaceProtocol
  1474. 0, // iInterface
  1475. // Class-Specific AS Interface Descriptor
  1476. // USB DCD for Audio Devices 1.0, Section 4.5.2, Table 4-19, page 60
  1477. 7, // bLength
  1478. 0x24, // bDescriptorType = CS_INTERFACE
  1479. 1, // bDescriptorSubtype, 1 = AS_GENERAL
  1480. 3, // bTerminalLink: Terminal ID = 3
  1481. 3, // bDelay (approx 3ms delay, audio lib updates)
  1482. 0x01, 0x00, // wFormatTag, 0x0001 = PCM
  1483. // Type I Format Descriptor
  1484. // USB DCD for Audio Data Formats 1.0, Section 2.2.5, Table 2-1, page 10
  1485. 11, // bLength
  1486. 0x24, // bDescriptorType = CS_INTERFACE
  1487. 2, // bDescriptorSubtype = FORMAT_TYPE
  1488. 1, // bFormatType = FORMAT_TYPE_I
  1489. 2, // bNrChannels = 2
  1490. 2, // bSubFrameSize = 2 byte
  1491. 16, // bBitResolution = 16 bits
  1492. 1, // bSamFreqType = 1 frequency
  1493. LSB(44100), MSB(44100), 0, // tSamFreq
  1494. // Standard AS Isochronous Audio Data Endpoint Descriptor
  1495. // USB DCD for Audio Devices 1.0, Section 4.6.1.1, Table 4-20, page 61-62
  1496. 9, // bLength
  1497. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  1498. AUDIO_RX_ENDPOINT, // bEndpointAddress
  1499. 0x05, // bmAttributes = isochronous, asynchronous
  1500. LSB(AUDIO_RX_SIZE), MSB(AUDIO_RX_SIZE), // wMaxPacketSize
  1501. 4, // bInterval, 4 = every 8 micro-frames
  1502. 0, // bRefresh
  1503. AUDIO_SYNC_ENDPOINT | 0x80, // bSynchAddress
  1504. // Class-Specific AS Isochronous Audio Data Endpoint Descriptor
  1505. // USB DCD for Audio Devices 1.0, Section 4.6.1.2, Table 4-21, page 62-63
  1506. 7, // bLength
  1507. 0x25, // bDescriptorType, 0x25 = CS_ENDPOINT
  1508. 1, // bDescriptorSubtype, 1 = EP_GENERAL
  1509. 0x00, // bmAttributes
  1510. 0, // bLockDelayUnits, 1 = ms
  1511. 0x00, 0x00, // wLockDelay
  1512. // Standard AS Isochronous Audio Synch Endpoint Descriptor
  1513. // USB DCD for Audio Devices 1.0, Section 4.6.2.1, Table 4-22, page 63-64
  1514. 9, // bLength
  1515. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  1516. AUDIO_SYNC_ENDPOINT | 0x80, // bEndpointAddress
  1517. 0x11, // bmAttributes = isochronous, feedback
  1518. 4, 0, // wMaxPacketSize, 4 bytes
  1519. 4, // bInterval, 4 = 4 = every 8 micro-frames
  1520. 7, // bRefresh,
  1521. 0, // bSynchAddress
  1522. #endif
  1523. #ifdef MULTITOUCH_INTERFACE
  1524. // configuration for 480 Mbit/sec speed
  1525. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1526. 9, // bLength
  1527. 4, // bDescriptorType
  1528. MULTITOUCH_INTERFACE, // bInterfaceNumber
  1529. 0, // bAlternateSetting
  1530. 1, // bNumEndpoints
  1531. 0x03, // bInterfaceClass (0x03 = HID)
  1532. 0x00, // bInterfaceSubClass
  1533. 0x00, // bInterfaceProtocol
  1534. 0, // iInterface
  1535. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1536. 9, // bLength
  1537. 0x21, // bDescriptorType
  1538. 0x11, 0x01, // bcdHID
  1539. 0, // bCountryCode
  1540. 1, // bNumDescriptors
  1541. 0x22, // bDescriptorType
  1542. LSB(sizeof(multitouch_report_desc)), // wDescriptorLength
  1543. MSB(sizeof(multitouch_report_desc)),
  1544. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1545. 7, // bLength
  1546. 5, // bDescriptorType
  1547. MULTITOUCH_ENDPOINT | 0x80, // bEndpointAddress
  1548. 0x03, // bmAttributes (0x03=intr)
  1549. MULTITOUCH_SIZE, 0, // wMaxPacketSize
  1550. 4, // bInterval, 4 = 1ms
  1551. #endif // KEYMEDIA_INTERFACE
  1552. };
  1553. PROGMEM const uint8_t usb_config_descriptor_12[CONFIG_DESC_SIZE] = {
  1554. // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
  1555. 9, // bLength;
  1556. 2, // bDescriptorType;
  1557. LSB(CONFIG_DESC_SIZE), // wTotalLength
  1558. MSB(CONFIG_DESC_SIZE),
  1559. NUM_INTERFACE, // bNumInterfaces
  1560. 1, // bConfigurationValue
  1561. 0, // iConfiguration
  1562. 0xC0, // bmAttributes
  1563. 50, // bMaxPower
  1564. #ifdef CDC_IAD_DESCRIPTOR
  1565. // interface association descriptor, USB ECN, Table 9-Z
  1566. 8, // bLength
  1567. 11, // bDescriptorType
  1568. CDC_STATUS_INTERFACE, // bFirstInterface
  1569. 2, // bInterfaceCount
  1570. 0x02, // bFunctionClass
  1571. 0x02, // bFunctionSubClass
  1572. 0x01, // bFunctionProtocol
  1573. 0, // iFunction
  1574. #endif
  1575. #ifdef CDC_DATA_INTERFACE
  1576. // configuration for 12 Mbit/sec speed
  1577. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1578. 9, // bLength
  1579. 4, // bDescriptorType
  1580. CDC_STATUS_INTERFACE, // bInterfaceNumber
  1581. 0, // bAlternateSetting
  1582. 1, // bNumEndpoints
  1583. 0x02, // bInterfaceClass
  1584. 0x02, // bInterfaceSubClass
  1585. 0x01, // bInterfaceProtocol
  1586. 0, // iInterface
  1587. // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26
  1588. 5, // bFunctionLength
  1589. 0x24, // bDescriptorType
  1590. 0x00, // bDescriptorSubtype
  1591. 0x10, 0x01, // bcdCDC
  1592. // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27
  1593. 5, // bFunctionLength
  1594. 0x24, // bDescriptorType
  1595. 0x01, // bDescriptorSubtype
  1596. 0x01, // bmCapabilities
  1597. 1, // bDataInterface
  1598. // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28
  1599. 4, // bFunctionLength
  1600. 0x24, // bDescriptorType
  1601. 0x02, // bDescriptorSubtype
  1602. 0x06, // bmCapabilities
  1603. // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33
  1604. 5, // bFunctionLength
  1605. 0x24, // bDescriptorType
  1606. 0x06, // bDescriptorSubtype
  1607. CDC_STATUS_INTERFACE, // bMasterInterface
  1608. CDC_DATA_INTERFACE, // bSlaveInterface0
  1609. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1610. 7, // bLength
  1611. 5, // bDescriptorType
  1612. CDC_ACM_ENDPOINT | 0x80, // bEndpointAddress
  1613. 0x03, // bmAttributes (0x03=intr)
  1614. CDC_ACM_SIZE, 0, // wMaxPacketSize
  1615. 16, // bInterval
  1616. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1617. 9, // bLength
  1618. 4, // bDescriptorType
  1619. CDC_DATA_INTERFACE, // bInterfaceNumber
  1620. 0, // bAlternateSetting
  1621. 2, // bNumEndpoints
  1622. 0x0A, // bInterfaceClass
  1623. 0x00, // bInterfaceSubClass
  1624. 0x00, // bInterfaceProtocol
  1625. 0, // iInterface
  1626. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1627. 7, // bLength
  1628. 5, // bDescriptorType
  1629. CDC_RX_ENDPOINT, // bEndpointAddress
  1630. 0x02, // bmAttributes (0x02=bulk)
  1631. LSB(CDC_RX_SIZE_12),MSB(CDC_RX_SIZE_12),// wMaxPacketSize
  1632. 0, // bInterval
  1633. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1634. 7, // bLength
  1635. 5, // bDescriptorType
  1636. CDC_TX_ENDPOINT | 0x80, // bEndpointAddress
  1637. 0x02, // bmAttributes (0x02=bulk)
  1638. LSB(CDC_TX_SIZE_12),MSB(CDC_TX_SIZE_12),// wMaxPacketSize
  1639. 0, // bInterval
  1640. #endif // CDC_DATA_INTERFACE
  1641. #ifdef CDC2_DATA_INTERFACE
  1642. // configuration for 12 Mbit/sec speed
  1643. // interface association descriptor, USB ECN, Table 9-Z
  1644. 8, // bLength
  1645. 11, // bDescriptorType
  1646. CDC2_STATUS_INTERFACE, // bFirstInterface
  1647. 2, // bInterfaceCount
  1648. 0x02, // bFunctionClass
  1649. 0x02, // bFunctionSubClass
  1650. 0x01, // bFunctionProtocol
  1651. 0, // iFunction
  1652. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1653. 9, // bLength
  1654. 4, // bDescriptorType
  1655. CDC2_STATUS_INTERFACE, // bInterfaceNumber
  1656. 0, // bAlternateSetting
  1657. 1, // bNumEndpoints
  1658. 0x02, // bInterfaceClass
  1659. 0x02, // bInterfaceSubClass
  1660. 0x01, // bInterfaceProtocol
  1661. 0, // iInterface
  1662. // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26
  1663. 5, // bFunctionLength
  1664. 0x24, // bDescriptorType
  1665. 0x00, // bDescriptorSubtype
  1666. 0x10, 0x01, // bcdCDC
  1667. // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27
  1668. 5, // bFunctionLength
  1669. 0x24, // bDescriptorType
  1670. 0x01, // bDescriptorSubtype
  1671. 0x01, // bmCapabilities
  1672. 1, // bDataInterface
  1673. // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28
  1674. 4, // bFunctionLength
  1675. 0x24, // bDescriptorType
  1676. 0x02, // bDescriptorSubtype
  1677. 0x06, // bmCapabilities
  1678. // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33
  1679. 5, // bFunctionLength
  1680. 0x24, // bDescriptorType
  1681. 0x06, // bDescriptorSubtype
  1682. CDC2_STATUS_INTERFACE, // bMasterInterface
  1683. CDC2_DATA_INTERFACE, // bSlaveInterface0
  1684. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1685. 7, // bLength
  1686. 5, // bDescriptorType
  1687. CDC2_ACM_ENDPOINT | 0x80, // bEndpointAddress
  1688. 0x03, // bmAttributes (0x03=intr)
  1689. CDC_ACM_SIZE, 0, // wMaxPacketSize
  1690. 64, // bInterval
  1691. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1692. 9, // bLength
  1693. 4, // bDescriptorType
  1694. CDC2_DATA_INTERFACE, // bInterfaceNumber
  1695. 0, // bAlternateSetting
  1696. 2, // bNumEndpoints
  1697. 0x0A, // bInterfaceClass
  1698. 0x00, // bInterfaceSubClass
  1699. 0x00, // bInterfaceProtocol
  1700. 0, // iInterface
  1701. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1702. 7, // bLength
  1703. 5, // bDescriptorType
  1704. CDC2_RX_ENDPOINT, // bEndpointAddress
  1705. 0x02, // bmAttributes (0x02=bulk)
  1706. CDC_RX_SIZE_12, 0, // wMaxPacketSize
  1707. 0, // bInterval
  1708. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1709. 7, // bLength
  1710. 5, // bDescriptorType
  1711. CDC2_TX_ENDPOINT | 0x80, // bEndpointAddress
  1712. 0x02, // bmAttributes (0x02=bulk)
  1713. CDC_TX_SIZE_12, 0, // wMaxPacketSize
  1714. 0, // bInterval
  1715. #endif // CDC2_DATA_INTERFACE
  1716. #ifdef CDC3_DATA_INTERFACE
  1717. // configuration for 12 Mbit/sec speed
  1718. // interface association descriptor, USB ECN, Table 9-Z
  1719. 8, // bLength
  1720. 11, // bDescriptorType
  1721. CDC3_STATUS_INTERFACE, // bFirstInterface
  1722. 2, // bInterfaceCount
  1723. 0x02, // bFunctionClass
  1724. 0x02, // bFunctionSubClass
  1725. 0x01, // bFunctionProtocol
  1726. 0, // iFunction
  1727. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1728. 9, // bLength
  1729. 4, // bDescriptorType
  1730. CDC3_STATUS_INTERFACE, // bInterfaceNumber
  1731. 0, // bAlternateSetting
  1732. 1, // bNumEndpoints
  1733. 0x02, // bInterfaceClass
  1734. 0x02, // bInterfaceSubClass
  1735. 0x01, // bInterfaceProtocol
  1736. 0, // iInterface
  1737. // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26
  1738. 5, // bFunctionLength
  1739. 0x24, // bDescriptorType
  1740. 0x00, // bDescriptorSubtype
  1741. 0x10, 0x01, // bcdCDC
  1742. // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27
  1743. 5, // bFunctionLength
  1744. 0x24, // bDescriptorType
  1745. 0x01, // bDescriptorSubtype
  1746. 0x01, // bmCapabilities
  1747. 1, // bDataInterface
  1748. // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28
  1749. 4, // bFunctionLength
  1750. 0x24, // bDescriptorType
  1751. 0x02, // bDescriptorSubtype
  1752. 0x06, // bmCapabilities
  1753. // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33
  1754. 5, // bFunctionLength
  1755. 0x24, // bDescriptorType
  1756. 0x06, // bDescriptorSubtype
  1757. CDC3_STATUS_INTERFACE, // bMasterInterface
  1758. CDC3_DATA_INTERFACE, // bSlaveInterface0
  1759. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1760. 7, // bLength
  1761. 5, // bDescriptorType
  1762. CDC3_ACM_ENDPOINT | 0x80, // bEndpointAddress
  1763. 0x03, // bmAttributes (0x03=intr)
  1764. CDC_ACM_SIZE, 0, // wMaxPacketSize
  1765. 64, // bInterval
  1766. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1767. 9, // bLength
  1768. 4, // bDescriptorType
  1769. CDC3_DATA_INTERFACE, // bInterfaceNumber
  1770. 0, // bAlternateSetting
  1771. 2, // bNumEndpoints
  1772. 0x0A, // bInterfaceClass
  1773. 0x00, // bInterfaceSubClass
  1774. 0x00, // bInterfaceProtocol
  1775. 0, // iInterface
  1776. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1777. 7, // bLength
  1778. 5, // bDescriptorType
  1779. CDC3_RX_ENDPOINT, // bEndpointAddress
  1780. 0x02, // bmAttributes (0x02=bulk)
  1781. CDC_RX_SIZE_12, 0, // wMaxPacketSize
  1782. 0, // bInterval
  1783. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1784. 7, // bLength
  1785. 5, // bDescriptorType
  1786. CDC3_TX_ENDPOINT | 0x80, // bEndpointAddress
  1787. 0x02, // bmAttributes (0x02=bulk)
  1788. CDC_TX_SIZE_12, 0, // wMaxPacketSize
  1789. 0, // bInterval
  1790. #endif // CDC3_DATA_INTERFACE
  1791. #ifdef MIDI_INTERFACE
  1792. // configuration for 12 Mbit/sec speed
  1793. // Standard MS Interface Descriptor,
  1794. 9, // bLength
  1795. 4, // bDescriptorType
  1796. MIDI_INTERFACE, // bInterfaceNumber
  1797. 0, // bAlternateSetting
  1798. 2, // bNumEndpoints
  1799. 0x01, // bInterfaceClass (0x01 = Audio)
  1800. 0x03, // bInterfaceSubClass (0x03 = MIDI)
  1801. 0x00, // bInterfaceProtocol (unused for MIDI)
  1802. 0, // iInterface
  1803. // MIDI MS Interface Header, USB MIDI 6.1.2.1, page 21, Table 6-2
  1804. 7, // bLength
  1805. 0x24, // bDescriptorType = CS_INTERFACE
  1806. 0x01, // bDescriptorSubtype = MS_HEADER
  1807. 0x00, 0x01, // bcdMSC = revision 01.00
  1808. LSB(7+(6+6+9+9)*MIDI_NUM_CABLES), // wTotalLength
  1809. MSB(7+(6+6+9+9)*MIDI_NUM_CABLES),
  1810. // MIDI IN Jack Descriptor, B.4.3, Table B-7 (embedded), page 40
  1811. 6, // bLength
  1812. 0x24, // bDescriptorType = CS_INTERFACE
  1813. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  1814. 0x01, // bJackType = EMBEDDED
  1815. 1, // bJackID, ID = 1
  1816. 0, // iJack
  1817. // MIDI IN Jack Descriptor, B.4.3, Table B-8 (external), page 40
  1818. 6, // bLength
  1819. 0x24, // bDescriptorType = CS_INTERFACE
  1820. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  1821. 0x02, // bJackType = EXTERNAL
  1822. 2, // bJackID, ID = 2
  1823. 0, // iJack
  1824. // MIDI OUT Jack Descriptor, B.4.4, Table B-9, page 41
  1825. 9,
  1826. 0x24, // bDescriptorType = CS_INTERFACE
  1827. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  1828. 0x01, // bJackType = EMBEDDED
  1829. 3, // bJackID, ID = 3
  1830. 1, // bNrInputPins = 1 pin
  1831. 2, // BaSourceID(1) = 2
  1832. 1, // BaSourcePin(1) = first pin
  1833. 0, // iJack
  1834. // MIDI OUT Jack Descriptor, B.4.4, Table B-10, page 41
  1835. 9,
  1836. 0x24, // bDescriptorType = CS_INTERFACE
  1837. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  1838. 0x02, // bJackType = EXTERNAL
  1839. 4, // bJackID, ID = 4
  1840. 1, // bNrInputPins = 1 pin
  1841. 1, // BaSourceID(1) = 1
  1842. 1, // BaSourcePin(1) = first pin
  1843. 0, // iJack
  1844. #if MIDI_NUM_CABLES >= 2
  1845. #define MIDI_INTERFACE_JACK_PAIR(a, b, c, d) \
  1846. 6, 0x24, 0x02, 0x01, (a), 0, \
  1847. 6, 0x24, 0x02, 0x02, (b), 0, \
  1848. 9, 0x24, 0x03, 0x01, (c), 1, (b), 1, 0, \
  1849. 9, 0x24, 0x03, 0x02, (d), 1, (a), 1, 0,
  1850. MIDI_INTERFACE_JACK_PAIR(5, 6, 7, 8)
  1851. #endif
  1852. #if MIDI_NUM_CABLES >= 3
  1853. MIDI_INTERFACE_JACK_PAIR(9, 10, 11, 12)
  1854. #endif
  1855. #if MIDI_NUM_CABLES >= 4
  1856. MIDI_INTERFACE_JACK_PAIR(13, 14, 15, 16)
  1857. #endif
  1858. #if MIDI_NUM_CABLES >= 5
  1859. MIDI_INTERFACE_JACK_PAIR(17, 18, 19, 20)
  1860. #endif
  1861. #if MIDI_NUM_CABLES >= 6
  1862. MIDI_INTERFACE_JACK_PAIR(21, 22, 23, 24)
  1863. #endif
  1864. #if MIDI_NUM_CABLES >= 7
  1865. MIDI_INTERFACE_JACK_PAIR(25, 26, 27, 28)
  1866. #endif
  1867. #if MIDI_NUM_CABLES >= 8
  1868. MIDI_INTERFACE_JACK_PAIR(29, 30, 31, 32)
  1869. #endif
  1870. #if MIDI_NUM_CABLES >= 9
  1871. MIDI_INTERFACE_JACK_PAIR(33, 34, 35, 36)
  1872. #endif
  1873. #if MIDI_NUM_CABLES >= 10
  1874. MIDI_INTERFACE_JACK_PAIR(37, 38, 39, 40)
  1875. #endif
  1876. #if MIDI_NUM_CABLES >= 11
  1877. MIDI_INTERFACE_JACK_PAIR(41, 42, 43, 44)
  1878. #endif
  1879. #if MIDI_NUM_CABLES >= 12
  1880. MIDI_INTERFACE_JACK_PAIR(45, 46, 47, 48)
  1881. #endif
  1882. #if MIDI_NUM_CABLES >= 13
  1883. MIDI_INTERFACE_JACK_PAIR(49, 50, 51, 52)
  1884. #endif
  1885. #if MIDI_NUM_CABLES >= 14
  1886. MIDI_INTERFACE_JACK_PAIR(53, 54, 55, 56)
  1887. #endif
  1888. #if MIDI_NUM_CABLES >= 15
  1889. MIDI_INTERFACE_JACK_PAIR(57, 58, 59, 60)
  1890. #endif
  1891. #if MIDI_NUM_CABLES >= 16
  1892. MIDI_INTERFACE_JACK_PAIR(61, 62, 63, 64)
  1893. #endif
  1894. // Standard Bulk OUT Endpoint Descriptor, B.5.1, Table B-11, pae 42
  1895. 9, // bLength
  1896. 5, // bDescriptorType = ENDPOINT
  1897. MIDI_RX_ENDPOINT, // bEndpointAddress
  1898. 0x02, // bmAttributes (0x02=bulk)
  1899. LSB(MIDI_RX_SIZE_12),MSB(MIDI_RX_SIZE_12),// wMaxPacketSize
  1900. 0, // bInterval
  1901. 0, // bRefresh
  1902. 0, // bSynchAddress
  1903. // Class-specific MS Bulk OUT Endpoint Descriptor, B.5.2, Table B-12, page 42
  1904. 4+MIDI_NUM_CABLES, // bLength
  1905. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  1906. 0x01, // bJackType = MS_GENERAL
  1907. MIDI_NUM_CABLES, // bNumEmbMIDIJack = number of jacks
  1908. 1, // BaAssocJackID(1) = jack ID #1
  1909. #if MIDI_NUM_CABLES >= 2
  1910. 5,
  1911. #endif
  1912. #if MIDI_NUM_CABLES >= 3
  1913. 9,
  1914. #endif
  1915. #if MIDI_NUM_CABLES >= 4
  1916. 13,
  1917. #endif
  1918. #if MIDI_NUM_CABLES >= 5
  1919. 17,
  1920. #endif
  1921. #if MIDI_NUM_CABLES >= 6
  1922. 21,
  1923. #endif
  1924. #if MIDI_NUM_CABLES >= 7
  1925. 25,
  1926. #endif
  1927. #if MIDI_NUM_CABLES >= 8
  1928. 29,
  1929. #endif
  1930. #if MIDI_NUM_CABLES >= 9
  1931. 33,
  1932. #endif
  1933. #if MIDI_NUM_CABLES >= 10
  1934. 37,
  1935. #endif
  1936. #if MIDI_NUM_CABLES >= 11
  1937. 41,
  1938. #endif
  1939. #if MIDI_NUM_CABLES >= 12
  1940. 45,
  1941. #endif
  1942. #if MIDI_NUM_CABLES >= 13
  1943. 49,
  1944. #endif
  1945. #if MIDI_NUM_CABLES >= 14
  1946. 53,
  1947. #endif
  1948. #if MIDI_NUM_CABLES >= 15
  1949. 57,
  1950. #endif
  1951. #if MIDI_NUM_CABLES >= 16
  1952. 61,
  1953. #endif
  1954. // Standard Bulk IN Endpoint Descriptor, B.5.1, Table B-11, pae 42
  1955. 9, // bLength
  1956. 5, // bDescriptorType = ENDPOINT
  1957. MIDI_TX_ENDPOINT | 0x80, // bEndpointAddress
  1958. 0x02, // bmAttributes (0x02=bulk)
  1959. LSB(MIDI_TX_SIZE_12),MSB(MIDI_TX_SIZE_12),// wMaxPacketSize
  1960. 0, // bInterval
  1961. 0, // bRefresh
  1962. 0, // bSynchAddress
  1963. // Class-specific MS Bulk IN Endpoint Descriptor, B.5.2, Table B-12, page 42
  1964. 4+MIDI_NUM_CABLES, // bLength
  1965. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  1966. 0x01, // bJackType = MS_GENERAL
  1967. MIDI_NUM_CABLES, // bNumEmbMIDIJack = number of jacks
  1968. 3, // BaAssocJackID(1) = jack ID #3
  1969. #if MIDI_NUM_CABLES >= 2
  1970. 7,
  1971. #endif
  1972. #if MIDI_NUM_CABLES >= 3
  1973. 11,
  1974. #endif
  1975. #if MIDI_NUM_CABLES >= 4
  1976. 15,
  1977. #endif
  1978. #if MIDI_NUM_CABLES >= 5
  1979. 19,
  1980. #endif
  1981. #if MIDI_NUM_CABLES >= 6
  1982. 23,
  1983. #endif
  1984. #if MIDI_NUM_CABLES >= 7
  1985. 27,
  1986. #endif
  1987. #if MIDI_NUM_CABLES >= 8
  1988. 31,
  1989. #endif
  1990. #if MIDI_NUM_CABLES >= 9
  1991. 35,
  1992. #endif
  1993. #if MIDI_NUM_CABLES >= 10
  1994. 39,
  1995. #endif
  1996. #if MIDI_NUM_CABLES >= 11
  1997. 43,
  1998. #endif
  1999. #if MIDI_NUM_CABLES >= 12
  2000. 47,
  2001. #endif
  2002. #if MIDI_NUM_CABLES >= 13
  2003. 51,
  2004. #endif
  2005. #if MIDI_NUM_CABLES >= 14
  2006. 55,
  2007. #endif
  2008. #if MIDI_NUM_CABLES >= 15
  2009. 59,
  2010. #endif
  2011. #if MIDI_NUM_CABLES >= 16
  2012. 63,
  2013. #endif
  2014. #endif // MIDI_INTERFACE
  2015. #ifdef KEYBOARD_INTERFACE
  2016. // configuration for 12 Mbit/sec speed
  2017. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  2018. 9, // bLength
  2019. 4, // bDescriptorType
  2020. KEYBOARD_INTERFACE, // bInterfaceNumber
  2021. 0, // bAlternateSetting
  2022. 1, // bNumEndpoints
  2023. 0x03, // bInterfaceClass (0x03 = HID)
  2024. 0x01, // bInterfaceSubClass (0x01 = Boot)
  2025. 0x01, // bInterfaceProtocol (0x01 = Keyboard)
  2026. 0, // iInterface
  2027. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  2028. 9, // bLength
  2029. 0x21, // bDescriptorType
  2030. 0x11, 0x01, // bcdHID
  2031. 0, // bCountryCode
  2032. 1, // bNumDescriptors
  2033. 0x22, // bDescriptorType
  2034. LSB(sizeof(keyboard_report_desc)), // wDescriptorLength
  2035. MSB(sizeof(keyboard_report_desc)),
  2036. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  2037. 7, // bLength
  2038. 5, // bDescriptorType
  2039. KEYBOARD_ENDPOINT | 0x80, // bEndpointAddress
  2040. 0x03, // bmAttributes (0x03=intr)
  2041. KEYBOARD_SIZE, 0, // wMaxPacketSize
  2042. KEYBOARD_INTERVAL, // bInterval
  2043. #endif // KEYBOARD_INTERFACE
  2044. #ifdef MOUSE_INTERFACE
  2045. // configuration for 12 Mbit/sec speed
  2046. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  2047. 9, // bLength
  2048. 4, // bDescriptorType
  2049. MOUSE_INTERFACE, // bInterfaceNumber
  2050. 0, // bAlternateSetting
  2051. 1, // bNumEndpoints
  2052. 0x03, // bInterfaceClass (0x03 = HID)
  2053. 0x00, // bInterfaceSubClass (0x01 = Boot)
  2054. 0x00, // bInterfaceProtocol (0x02 = Mouse)
  2055. 0, // iInterface
  2056. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  2057. 9, // bLength
  2058. 0x21, // bDescriptorType
  2059. 0x11, 0x01, // bcdHID
  2060. 0, // bCountryCode
  2061. 1, // bNumDescriptors
  2062. 0x22, // bDescriptorType
  2063. LSB(sizeof(mouse_report_desc)), // wDescriptorLength
  2064. MSB(sizeof(mouse_report_desc)),
  2065. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  2066. 7, // bLength
  2067. 5, // bDescriptorType
  2068. MOUSE_ENDPOINT | 0x80, // bEndpointAddress
  2069. 0x03, // bmAttributes (0x03=intr)
  2070. MOUSE_SIZE, 0, // wMaxPacketSize
  2071. MOUSE_INTERVAL, // bInterval
  2072. #endif // MOUSE_INTERFACE
  2073. #ifdef RAWHID_INTERFACE
  2074. // configuration for 12 Mbit/sec speed
  2075. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  2076. 9, // bLength
  2077. 4, // bDescriptorType
  2078. RAWHID_INTERFACE, // bInterfaceNumber
  2079. 0, // bAlternateSetting
  2080. 2, // bNumEndpoints
  2081. 0x03, // bInterfaceClass (0x03 = HID)
  2082. 0x00, // bInterfaceSubClass
  2083. 0x00, // bInterfaceProtocol
  2084. 0, // iInterface
  2085. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  2086. 9, // bLength
  2087. 0x21, // bDescriptorType
  2088. 0x11, 0x01, // bcdHID
  2089. 0, // bCountryCode
  2090. 1, // bNumDescriptors
  2091. 0x22, // bDescriptorType
  2092. LSB(sizeof(rawhid_report_desc)), // wDescriptorLength
  2093. MSB(sizeof(rawhid_report_desc)),
  2094. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  2095. 7, // bLength
  2096. 5, // bDescriptorType
  2097. RAWHID_TX_ENDPOINT | 0x80, // bEndpointAddress
  2098. 0x03, // bmAttributes (0x03=intr)
  2099. RAWHID_TX_SIZE, 0, // wMaxPacketSize
  2100. RAWHID_TX_INTERVAL, // bInterval
  2101. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  2102. 7, // bLength
  2103. 5, // bDescriptorType
  2104. RAWHID_RX_ENDPOINT, // bEndpointAddress
  2105. 0x03, // bmAttributes (0x03=intr)
  2106. RAWHID_RX_SIZE, 0, // wMaxPacketSize
  2107. RAWHID_RX_INTERVAL, // bInterval
  2108. #endif // RAWHID_INTERFACE
  2109. #ifdef FLIGHTSIM_INTERFACE
  2110. // configuration for 12 Mbit/sec speed
  2111. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  2112. 9, // bLength
  2113. 4, // bDescriptorType
  2114. FLIGHTSIM_INTERFACE, // bInterfaceNumber
  2115. 0, // bAlternateSetting
  2116. 2, // bNumEndpoints
  2117. 0x03, // bInterfaceClass (0x03 = HID)
  2118. 0x00, // bInterfaceSubClass
  2119. 0x00, // bInterfaceProtocol
  2120. 0, // iInterface
  2121. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  2122. 9, // bLength
  2123. 0x21, // bDescriptorType
  2124. 0x11, 0x01, // bcdHID
  2125. 0, // bCountryCode
  2126. 1, // bNumDescriptors
  2127. 0x22, // bDescriptorType
  2128. LSB(sizeof(flightsim_report_desc)), // wDescriptorLength
  2129. MSB(sizeof(flightsim_report_desc)),
  2130. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  2131. 7, // bLength
  2132. 5, // bDescriptorType
  2133. FLIGHTSIM_TX_ENDPOINT | 0x80, // bEndpointAddress
  2134. 0x03, // bmAttributes (0x03=intr)
  2135. FLIGHTSIM_TX_SIZE, 0, // wMaxPacketSize
  2136. FLIGHTSIM_TX_INTERVAL, // bInterval
  2137. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  2138. 7, // bLength
  2139. 5, // bDescriptorType
  2140. FLIGHTSIM_RX_ENDPOINT, // bEndpointAddress
  2141. 0x03, // bmAttributes (0x03=intr)
  2142. FLIGHTSIM_RX_SIZE, 0, // wMaxPacketSize
  2143. FLIGHTSIM_RX_INTERVAL, // bInterval
  2144. #endif // FLIGHTSIM_INTERFACE
  2145. #ifdef SEREMU_INTERFACE
  2146. // configuration for 12 Mbit/sec speed
  2147. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  2148. 9, // bLength
  2149. 4, // bDescriptorType
  2150. SEREMU_INTERFACE, // bInterfaceNumber
  2151. 0, // bAlternateSetting
  2152. 2, // bNumEndpoints
  2153. 0x03, // bInterfaceClass (0x03 = HID)
  2154. 0x00, // bInterfaceSubClass
  2155. 0x00, // bInterfaceProtocol
  2156. 0, // iInterface
  2157. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  2158. 9, // bLength
  2159. 0x21, // bDescriptorType
  2160. 0x11, 0x01, // bcdHID
  2161. 0, // bCountryCode
  2162. 1, // bNumDescriptors
  2163. 0x22, // bDescriptorType
  2164. LSB(sizeof(seremu_report_desc)), // wDescriptorLength
  2165. MSB(sizeof(seremu_report_desc)),
  2166. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  2167. 7, // bLength
  2168. 5, // bDescriptorType
  2169. SEREMU_TX_ENDPOINT | 0x80, // bEndpointAddress
  2170. 0x03, // bmAttributes (0x03=intr)
  2171. SEREMU_TX_SIZE, 0, // wMaxPacketSize
  2172. SEREMU_TX_INTERVAL, // bInterval
  2173. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  2174. 7, // bLength
  2175. 5, // bDescriptorType
  2176. SEREMU_RX_ENDPOINT, // bEndpointAddress
  2177. 0x03, // bmAttributes (0x03=intr)
  2178. SEREMU_RX_SIZE, 0, // wMaxPacketSize
  2179. SEREMU_RX_INTERVAL, // bInterval
  2180. #endif // SEREMU_INTERFACE
  2181. #ifdef JOYSTICK_INTERFACE
  2182. // configuration for 12 Mbit/sec speed
  2183. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  2184. 9, // bLength
  2185. 4, // bDescriptorType
  2186. JOYSTICK_INTERFACE, // bInterfaceNumber
  2187. 0, // bAlternateSetting
  2188. 1, // bNumEndpoints
  2189. 0x03, // bInterfaceClass (0x03 = HID)
  2190. 0x00, // bInterfaceSubClass
  2191. 0x00, // bInterfaceProtocol
  2192. 0, // iInterface
  2193. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  2194. 9, // bLength
  2195. 0x21, // bDescriptorType
  2196. 0x11, 0x01, // bcdHID
  2197. 0, // bCountryCode
  2198. 1, // bNumDescriptors
  2199. 0x22, // bDescriptorType
  2200. LSB(sizeof(joystick_report_desc)), // wDescriptorLength
  2201. MSB(sizeof(joystick_report_desc)),
  2202. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  2203. 7, // bLength
  2204. 5, // bDescriptorType
  2205. JOYSTICK_ENDPOINT | 0x80, // bEndpointAddress
  2206. 0x03, // bmAttributes (0x03=intr)
  2207. JOYSTICK_SIZE, 0, // wMaxPacketSize
  2208. JOYSTICK_INTERVAL, // bInterval
  2209. #endif // JOYSTICK_INTERFACE
  2210. #ifdef MTP_INTERFACE
  2211. // configuration for 12 Mbit/sec speed
  2212. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  2213. 9, // bLength
  2214. 4, // bDescriptorType
  2215. MTP_INTERFACE, // bInterfaceNumber
  2216. 0, // bAlternateSetting
  2217. 3, // bNumEndpoints
  2218. 0x06, // bInterfaceClass (0x06 = still image)
  2219. 0x01, // bInterfaceSubClass
  2220. 0x01, // bInterfaceProtocol
  2221. 0, // iInterface
  2222. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  2223. 7, // bLength
  2224. 5, // bDescriptorType
  2225. MTP_TX_ENDPOINT | 0x80, // bEndpointAddress
  2226. 0x02, // bmAttributes (0x02=bulk)
  2227. LSB(MTP_TX_SIZE_12),MSB(MTP_TX_SIZE_12),// wMaxPacketSize
  2228. 0, // bInterval
  2229. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  2230. 7, // bLength
  2231. 5, // bDescriptorType
  2232. MTP_RX_ENDPOINT, // bEndpointAddress
  2233. 0x02, // bmAttributes (0x02=bulk)
  2234. LSB(MTP_RX_SIZE_12),MSB(MTP_RX_SIZE_12),// wMaxPacketSize
  2235. 0, // bInterval
  2236. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  2237. 7, // bLength
  2238. 5, // bDescriptorType
  2239. MTP_EVENT_ENDPOINT | 0x80, // bEndpointAddress
  2240. 0x03, // bmAttributes (0x03=intr)
  2241. MTP_EVENT_SIZE, 0, // wMaxPacketSize
  2242. MTP_EVENT_INTERVAL_12, // bInterval
  2243. #endif // MTP_INTERFACE
  2244. #ifdef KEYMEDIA_INTERFACE
  2245. // configuration for 12 Mbit/sec speed
  2246. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  2247. 9, // bLength
  2248. 4, // bDescriptorType
  2249. KEYMEDIA_INTERFACE, // bInterfaceNumber
  2250. 0, // bAlternateSetting
  2251. 1, // bNumEndpoints
  2252. 0x03, // bInterfaceClass (0x03 = HID)
  2253. 0x00, // bInterfaceSubClass
  2254. 0x00, // bInterfaceProtocol
  2255. 0, // iInterface
  2256. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  2257. 9, // bLength
  2258. 0x21, // bDescriptorType
  2259. 0x11, 0x01, // bcdHID
  2260. 0, // bCountryCode
  2261. 1, // bNumDescriptors
  2262. 0x22, // bDescriptorType
  2263. LSB(sizeof(keymedia_report_desc)), // wDescriptorLength
  2264. MSB(sizeof(keymedia_report_desc)),
  2265. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  2266. 7, // bLength
  2267. 5, // bDescriptorType
  2268. KEYMEDIA_ENDPOINT | 0x80, // bEndpointAddress
  2269. 0x03, // bmAttributes (0x03=intr)
  2270. KEYMEDIA_SIZE, 0, // wMaxPacketSize
  2271. KEYMEDIA_INTERVAL, // bInterval
  2272. #endif // KEYMEDIA_INTERFACE
  2273. #ifdef AUDIO_INTERFACE
  2274. // configuration for 12 Mbit/sec speed
  2275. // interface association descriptor, USB ECN, Table 9-Z
  2276. 8, // bLength
  2277. 11, // bDescriptorType
  2278. AUDIO_INTERFACE, // bFirstInterface
  2279. 3, // bInterfaceCount
  2280. 0x01, // bFunctionClass
  2281. 0x01, // bFunctionSubClass
  2282. 0x00, // bFunctionProtocol
  2283. 0, // iFunction
  2284. // Standard AudioControl (AC) Interface Descriptor
  2285. // USB DCD for Audio Devices 1.0, Table 4-1, page 36
  2286. 9, // bLength
  2287. 4, // bDescriptorType, 4 = INTERFACE
  2288. AUDIO_INTERFACE, // bInterfaceNumber
  2289. 0, // bAlternateSetting
  2290. 0, // bNumEndpoints
  2291. 1, // bInterfaceClass, 1 = AUDIO
  2292. 1, // bInterfaceSubclass, 1 = AUDIO_CONTROL
  2293. 0, // bInterfaceProtocol
  2294. 0, // iInterface
  2295. // Class-specific AC Interface Header Descriptor
  2296. // USB DCD for Audio Devices 1.0, Table 4-2, page 37-38
  2297. 10, // bLength
  2298. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  2299. 0x01, // bDescriptorSubtype, 1 = HEADER
  2300. 0x00, 0x01, // bcdADC (version 1.0)
  2301. LSB(62), MSB(62), // wTotalLength
  2302. 2, // bInCollection
  2303. AUDIO_INTERFACE+1, // baInterfaceNr(1) - Transmit to PC
  2304. AUDIO_INTERFACE+2, // baInterfaceNr(2) - Receive from PC
  2305. // Input Terminal Descriptor
  2306. // USB DCD for Audio Devices 1.0, Table 4-3, page 39
  2307. 12, // bLength
  2308. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  2309. 0x02, // bDescriptorSubType, 2 = INPUT_TERMINAL
  2310. 1, // bTerminalID
  2311. //0x01, 0x02, // wTerminalType, 0x0201 = MICROPHONE
  2312. //0x03, 0x06, // wTerminalType, 0x0603 = Line Connector
  2313. 0x02, 0x06, // wTerminalType, 0x0602 = Digital Audio
  2314. 0, // bAssocTerminal, 0 = unidirectional
  2315. 2, // bNrChannels
  2316. 0x03, 0x00, // wChannelConfig, 0x0003 = Left & Right Front
  2317. 0, // iChannelNames
  2318. 0, // iTerminal
  2319. // Output Terminal Descriptor
  2320. // USB DCD for Audio Devices 1.0, Table 4-4, page 40
  2321. 9, // bLength
  2322. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  2323. 3, // bDescriptorSubtype, 3 = OUTPUT_TERMINAL
  2324. 2, // bTerminalID
  2325. 0x01, 0x01, // wTerminalType, 0x0101 = USB_STREAMING
  2326. 0, // bAssocTerminal, 0 = unidirectional
  2327. 1, // bCSourceID, connected to input terminal, ID=1
  2328. 0, // iTerminal
  2329. // Input Terminal Descriptor
  2330. // USB DCD for Audio Devices 1.0, Table 4-3, page 39
  2331. 12, // bLength
  2332. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  2333. 2, // bDescriptorSubType, 2 = INPUT_TERMINAL
  2334. 3, // bTerminalID
  2335. 0x01, 0x01, // wTerminalType, 0x0101 = USB_STREAMING
  2336. 0, // bAssocTerminal, 0 = unidirectional
  2337. 2, // bNrChannels
  2338. 0x03, 0x00, // wChannelConfig, 0x0003 = Left & Right Front
  2339. 0, // iChannelNames
  2340. 0, // iTerminal
  2341. // Volume feature descriptor
  2342. 10, // bLength
  2343. 0x24, // bDescriptorType = CS_INTERFACE
  2344. 0x06, // bDescriptorSubType = FEATURE_UNIT
  2345. 0x31, // bUnitID
  2346. 0x03, // bSourceID (Input Terminal)
  2347. 0x01, // bControlSize (each channel is 1 byte, 3 channels)
  2348. 0x01, // bmaControls(0) Master: Mute
  2349. 0x02, // bmaControls(1) Left: Volume
  2350. 0x02, // bmaControls(2) Right: Volume
  2351. 0x00, // iFeature
  2352. // Output Terminal Descriptor
  2353. // USB DCD for Audio Devices 1.0, Table 4-4, page 40
  2354. 9, // bLength
  2355. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  2356. 3, // bDescriptorSubtype, 3 = OUTPUT_TERMINAL
  2357. 4, // bTerminalID
  2358. //0x02, 0x03, // wTerminalType, 0x0302 = Headphones
  2359. 0x02, 0x06, // wTerminalType, 0x0602 = Digital Audio
  2360. 0, // bAssocTerminal, 0 = unidirectional
  2361. 0x31, // bCSourceID, connected to feature, ID=31
  2362. 0, // iTerminal
  2363. // Standard AS Interface Descriptor
  2364. // USB DCD for Audio Devices 1.0, Section 4.5.1, Table 4-18, page 59
  2365. // Alternate 0: default setting, disabled zero bandwidth
  2366. 9, // bLenght
  2367. 4, // bDescriptorType = INTERFACE
  2368. AUDIO_INTERFACE+1, // bInterfaceNumber
  2369. 0, // bAlternateSetting
  2370. 0, // bNumEndpoints
  2371. 1, // bInterfaceClass, 1 = AUDIO
  2372. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  2373. 0, // bInterfaceProtocol
  2374. 0, // iInterface
  2375. // Alternate 1: streaming data
  2376. 9, // bLenght
  2377. 4, // bDescriptorType = INTERFACE
  2378. AUDIO_INTERFACE+1, // bInterfaceNumber
  2379. 1, // bAlternateSetting
  2380. 1, // bNumEndpoints
  2381. 1, // bInterfaceClass, 1 = AUDIO
  2382. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  2383. 0, // bInterfaceProtocol
  2384. 0, // iInterface
  2385. // Class-Specific AS Interface Descriptor
  2386. // USB DCD for Audio Devices 1.0, Section 4.5.2, Table 4-19, page 60
  2387. 7, // bLength
  2388. 0x24, // bDescriptorType = CS_INTERFACE
  2389. 1, // bDescriptorSubtype, 1 = AS_GENERAL
  2390. 2, // bTerminalLink: Terminal ID = 2
  2391. 3, // bDelay (approx 3ms delay, audio lib updates)
  2392. 0x01, 0x00, // wFormatTag, 0x0001 = PCM
  2393. // Type I Format Descriptor
  2394. // USB DCD for Audio Data Formats 1.0, Section 2.2.5, Table 2-1, page 10
  2395. 11, // bLength
  2396. 0x24, // bDescriptorType = CS_INTERFACE
  2397. 2, // bDescriptorSubtype = FORMAT_TYPE
  2398. 1, // bFormatType = FORMAT_TYPE_I
  2399. 2, // bNrChannels = 2
  2400. 2, // bSubFrameSize = 2 byte
  2401. 16, // bBitResolution = 16 bits
  2402. 1, // bSamFreqType = 1 frequency
  2403. LSB(44100), MSB(44100), 0, // tSamFreq
  2404. // Standard AS Isochronous Audio Data Endpoint Descriptor
  2405. // USB DCD for Audio Devices 1.0, Section 4.6.1.1, Table 4-20, page 61-62
  2406. 9, // bLength
  2407. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  2408. AUDIO_TX_ENDPOINT | 0x80, // bEndpointAddress
  2409. 0x09, // bmAttributes = isochronous, adaptive
  2410. LSB(AUDIO_TX_SIZE), MSB(AUDIO_TX_SIZE), // wMaxPacketSize
  2411. 1, // bInterval, 1 = every frame
  2412. 0, // bRefresh
  2413. 0, // bSynchAddress
  2414. // Class-Specific AS Isochronous Audio Data Endpoint Descriptor
  2415. // USB DCD for Audio Devices 1.0, Section 4.6.1.2, Table 4-21, page 62-63
  2416. 7, // bLength
  2417. 0x25, // bDescriptorType, 0x25 = CS_ENDPOINT
  2418. 1, // bDescriptorSubtype, 1 = EP_GENERAL
  2419. 0x00, // bmAttributes
  2420. 0, // bLockDelayUnits, 1 = ms
  2421. 0x00, 0x00, // wLockDelay
  2422. // Standard AS Interface Descriptor
  2423. // USB DCD for Audio Devices 1.0, Section 4.5.1, Table 4-18, page 59
  2424. // Alternate 0: default setting, disabled zero bandwidth
  2425. 9, // bLenght
  2426. 4, // bDescriptorType = INTERFACE
  2427. AUDIO_INTERFACE+2, // bInterfaceNumber
  2428. 0, // bAlternateSetting
  2429. 0, // bNumEndpoints
  2430. 1, // bInterfaceClass, 1 = AUDIO
  2431. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  2432. 0, // bInterfaceProtocol
  2433. 0, // iInterface
  2434. // Alternate 1: streaming data
  2435. 9, // bLenght
  2436. 4, // bDescriptorType = INTERFACE
  2437. AUDIO_INTERFACE+2, // bInterfaceNumber
  2438. 1, // bAlternateSetting
  2439. 2, // bNumEndpoints
  2440. 1, // bInterfaceClass, 1 = AUDIO
  2441. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  2442. 0, // bInterfaceProtocol
  2443. 0, // iInterface
  2444. // Class-Specific AS Interface Descriptor
  2445. // USB DCD for Audio Devices 1.0, Section 4.5.2, Table 4-19, page 60
  2446. 7, // bLength
  2447. 0x24, // bDescriptorType = CS_INTERFACE
  2448. 1, // bDescriptorSubtype, 1 = AS_GENERAL
  2449. 3, // bTerminalLink: Terminal ID = 3
  2450. 3, // bDelay (approx 3ms delay, audio lib updates)
  2451. 0x01, 0x00, // wFormatTag, 0x0001 = PCM
  2452. // Type I Format Descriptor
  2453. // USB DCD for Audio Data Formats 1.0, Section 2.2.5, Table 2-1, page 10
  2454. 11, // bLength
  2455. 0x24, // bDescriptorType = CS_INTERFACE
  2456. 2, // bDescriptorSubtype = FORMAT_TYPE
  2457. 1, // bFormatType = FORMAT_TYPE_I
  2458. 2, // bNrChannels = 2
  2459. 2, // bSubFrameSize = 2 byte
  2460. 16, // bBitResolution = 16 bits
  2461. 1, // bSamFreqType = 1 frequency
  2462. LSB(44100), MSB(44100), 0, // tSamFreq
  2463. // Standard AS Isochronous Audio Data Endpoint Descriptor
  2464. // USB DCD for Audio Devices 1.0, Section 4.6.1.1, Table 4-20, page 61-62
  2465. 9, // bLength
  2466. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  2467. AUDIO_RX_ENDPOINT, // bEndpointAddress
  2468. 0x05, // bmAttributes = isochronous, asynchronous
  2469. LSB(AUDIO_RX_SIZE), MSB(AUDIO_RX_SIZE), // wMaxPacketSize
  2470. 1, // bInterval, 1 = every frame
  2471. 0, // bRefresh
  2472. AUDIO_SYNC_ENDPOINT | 0x80, // bSynchAddress
  2473. // Class-Specific AS Isochronous Audio Data Endpoint Descriptor
  2474. // USB DCD for Audio Devices 1.0, Section 4.6.1.2, Table 4-21, page 62-63
  2475. 7, // bLength
  2476. 0x25, // bDescriptorType, 0x25 = CS_ENDPOINT
  2477. 1, // bDescriptorSubtype, 1 = EP_GENERAL
  2478. 0x00, // bmAttributes
  2479. 0, // bLockDelayUnits, 1 = ms
  2480. 0x00, 0x00, // wLockDelay
  2481. // Standard AS Isochronous Audio Synch Endpoint Descriptor
  2482. // USB DCD for Audio Devices 1.0, Section 4.6.2.1, Table 4-22, page 63-64
  2483. 9, // bLength
  2484. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  2485. AUDIO_SYNC_ENDPOINT | 0x80, // bEndpointAddress
  2486. 0x11, // bmAttributes = isochronous, feedback
  2487. 3, 0, // wMaxPacketSize, 3 bytes
  2488. 1, // bInterval, 1 = every frame
  2489. 5, // bRefresh, 5 = 32ms
  2490. 0, // bSynchAddress
  2491. #endif
  2492. #ifdef MULTITOUCH_INTERFACE
  2493. // configuration for 12 Mbit/sec speed
  2494. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  2495. 9, // bLength
  2496. 4, // bDescriptorType
  2497. MULTITOUCH_INTERFACE, // bInterfaceNumber
  2498. 0, // bAlternateSetting
  2499. 1, // bNumEndpoints
  2500. 0x03, // bInterfaceClass (0x03 = HID)
  2501. 0x00, // bInterfaceSubClass
  2502. 0x00, // bInterfaceProtocol
  2503. 0, // iInterface
  2504. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  2505. 9, // bLength
  2506. 0x21, // bDescriptorType
  2507. 0x11, 0x01, // bcdHID
  2508. 0, // bCountryCode
  2509. 1, // bNumDescriptors
  2510. 0x22, // bDescriptorType
  2511. LSB(sizeof(multitouch_report_desc)), // wDescriptorLength
  2512. MSB(sizeof(multitouch_report_desc)),
  2513. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  2514. 7, // bLength
  2515. 5, // bDescriptorType
  2516. MULTITOUCH_ENDPOINT | 0x80, // bEndpointAddress
  2517. 0x03, // bmAttributes (0x03=intr)
  2518. MULTITOUCH_SIZE, 0, // wMaxPacketSize
  2519. 1, // bInterval
  2520. #endif // KEYMEDIA_INTERFACE
  2521. };
  2522. __attribute__ ((section(".dmabuffers"), aligned(32)))
  2523. uint8_t usb_descriptor_buffer[CONFIG_DESC_SIZE];
  2524. // **************************************************************
  2525. // String Descriptors
  2526. // **************************************************************
  2527. // The descriptors above can provide human readable strings,
  2528. // referenced by index numbers. These descriptors are the
  2529. // actual string data
  2530. /* defined in usb_names.h
  2531. struct usb_string_descriptor_struct {
  2532. uint8_t bLength;
  2533. uint8_t bDescriptorType;
  2534. uint16_t wString[];
  2535. };
  2536. */
  2537. extern struct usb_string_descriptor_struct usb_string_manufacturer_name
  2538. __attribute__ ((weak, alias("usb_string_manufacturer_name_default")));
  2539. extern struct usb_string_descriptor_struct usb_string_product_name
  2540. __attribute__ ((weak, alias("usb_string_product_name_default")));
  2541. extern struct usb_string_descriptor_struct usb_string_serial_number
  2542. __attribute__ ((weak, alias("usb_string_serial_number_default")));
  2543. PROGMEM const struct usb_string_descriptor_struct string0 = {
  2544. 4,
  2545. 3,
  2546. {0x0409}
  2547. };
  2548. PROGMEM const struct usb_string_descriptor_struct usb_string_manufacturer_name_default = {
  2549. 2 + MANUFACTURER_NAME_LEN * 2,
  2550. 3,
  2551. MANUFACTURER_NAME
  2552. };
  2553. PROGMEM const struct usb_string_descriptor_struct usb_string_product_name_default = {
  2554. 2 + PRODUCT_NAME_LEN * 2,
  2555. 3,
  2556. PRODUCT_NAME
  2557. };
  2558. struct usb_string_descriptor_struct usb_string_serial_number_default = {
  2559. 12,
  2560. 3,
  2561. {0,0,0,0,0,0,0,0,0,0}
  2562. };
  2563. #ifdef MTP_INTERFACE
  2564. PROGMEM const struct usb_string_descriptor_struct usb_string_mtp = {
  2565. 2 + 3 * 2,
  2566. 3,
  2567. {'M','T','P'}
  2568. };
  2569. #endif
  2570. void usb_init_serialnumber(void)
  2571. {
  2572. char buf[11];
  2573. uint32_t i, num;
  2574. num = HW_OCOTP_MAC0 & 0xFFFFFF;
  2575. // add extra zero to work around OS-X CDC-ACM driver bug
  2576. if (num < 10000000) num = num * 10;
  2577. ultoa(num, buf, 10);
  2578. for (i=0; i<10; i++) {
  2579. char c = buf[i];
  2580. if (!c) break;
  2581. usb_string_serial_number_default.wString[i] = c;
  2582. }
  2583. usb_string_serial_number_default.bLength = i * 2 + 2;
  2584. }
  2585. // **************************************************************
  2586. // Descriptors List
  2587. // **************************************************************
  2588. // This table provides access to all the descriptor data above.
  2589. const usb_descriptor_list_t usb_descriptor_list[] = {
  2590. //wValue, wIndex, address, length
  2591. {0x0100, 0x0000, device_descriptor, sizeof(device_descriptor)},
  2592. {0x0600, 0x0000, qualifier_descriptor, sizeof(qualifier_descriptor)},
  2593. {0x0200, 0x0000, usb_config_descriptor_480, CONFIG_DESC_SIZE},
  2594. {0x0700, 0x0000, usb_config_descriptor_12, CONFIG_DESC_SIZE},
  2595. #ifdef SEREMU_INTERFACE
  2596. {0x2200, SEREMU_INTERFACE, seremu_report_desc, sizeof(seremu_report_desc)},
  2597. {0x2100, SEREMU_INTERFACE, usb_config_descriptor_480+SEREMU_HID_DESC_OFFSET, 9},
  2598. #endif
  2599. #ifdef KEYBOARD_INTERFACE
  2600. {0x2200, KEYBOARD_INTERFACE, keyboard_report_desc, sizeof(keyboard_report_desc)},
  2601. {0x2100, KEYBOARD_INTERFACE, usb_config_descriptor_480+KEYBOARD_HID_DESC_OFFSET, 9},
  2602. #endif
  2603. #ifdef MOUSE_INTERFACE
  2604. {0x2200, MOUSE_INTERFACE, mouse_report_desc, sizeof(mouse_report_desc)},
  2605. {0x2100, MOUSE_INTERFACE, usb_config_descriptor_480+MOUSE_HID_DESC_OFFSET, 9},
  2606. #endif
  2607. #ifdef JOYSTICK_INTERFACE
  2608. {0x2200, JOYSTICK_INTERFACE, joystick_report_desc, sizeof(joystick_report_desc)},
  2609. {0x2100, JOYSTICK_INTERFACE, usb_config_descriptor_480+JOYSTICK_HID_DESC_OFFSET, 9},
  2610. #endif
  2611. #ifdef RAWHID_INTERFACE
  2612. {0x2200, RAWHID_INTERFACE, rawhid_report_desc, sizeof(rawhid_report_desc)},
  2613. {0x2100, RAWHID_INTERFACE, usb_config_descriptor_480+RAWHID_HID_DESC_OFFSET, 9},
  2614. #endif
  2615. #ifdef FLIGHTSIM_INTERFACE
  2616. {0x2200, FLIGHTSIM_INTERFACE, flightsim_report_desc, sizeof(flightsim_report_desc)},
  2617. {0x2100, FLIGHTSIM_INTERFACE, usb_config_descriptor_480+FLIGHTSIM_HID_DESC_OFFSET, 9},
  2618. #endif
  2619. #ifdef KEYMEDIA_INTERFACE
  2620. {0x2200, KEYMEDIA_INTERFACE, keymedia_report_desc, sizeof(keymedia_report_desc)},
  2621. {0x2100, KEYMEDIA_INTERFACE, usb_config_descriptor_480+KEYMEDIA_HID_DESC_OFFSET, 9},
  2622. #endif
  2623. #ifdef MULTITOUCH_INTERFACE
  2624. {0x2200, MULTITOUCH_INTERFACE, multitouch_report_desc, sizeof(multitouch_report_desc)},
  2625. {0x2100, MULTITOUCH_INTERFACE, usb_config_descriptor_480+MULTITOUCH_HID_DESC_OFFSET, 9},
  2626. #endif
  2627. #ifdef MTP_INTERFACE
  2628. {0x0304, 0x0409, (const uint8_t *)&usb_string_mtp, 0},
  2629. #endif
  2630. {0x0300, 0x0000, (const uint8_t *)&string0, 0},
  2631. {0x0301, 0x0409, (const uint8_t *)&usb_string_manufacturer_name, 0},
  2632. {0x0302, 0x0409, (const uint8_t *)&usb_string_product_name, 0},
  2633. {0x0303, 0x0409, (const uint8_t *)&usb_string_serial_number, 0},
  2634. {0, 0, NULL, 0}
  2635. };
  2636. #endif // NUM_ENDPOINTS
  2637. //#endif // F_CPU >= 20 MHz