Teensy 4.1 core updated for C++20
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

2743 rindas
134KB

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