Teensy 4.1 core updated for C++20
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.

2728 lines
133KB

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