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.

2733 lines
134KB

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