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

2408 lines
113KB

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