Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

1412 lines
68KB

  1. /* Teensyduino Core Library
  2. * http://www.pjrc.com/teensy/
  3. * Copyright (c) 2013 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 "kinetis.h"
  36. #include "avr_functions.h"
  37. // USB Descriptors are binary data which the USB host reads to
  38. // automatically detect a USB device's capabilities. The format
  39. // and meaning of every field is documented in numerous USB
  40. // standards. When working with USB descriptors, despite the
  41. // complexity of the standards and poor writing quality in many
  42. // of those documents, remember descriptors are nothing more
  43. // than constant binary data that tells the USB host what the
  44. // device can do. Computers will load drivers based on this data.
  45. // Those drivers then communicate on the endpoints specified by
  46. // the descriptors.
  47. // To configure a new combination of interfaces or make minor
  48. // changes to existing configuration (eg, change the name or ID
  49. // numbers), usually you would edit "usb_desc.h". This file
  50. // is meant to be configured by the header, so generally it is
  51. // only edited to add completely new USB interfaces or features.
  52. // **************************************************************
  53. // USB Device
  54. // **************************************************************
  55. #define LSB(n) ((n) & 255)
  56. #define MSB(n) (((n) >> 8) & 255)
  57. // USB Device Descriptor. The USB host reads this first, to learn
  58. // what type of device is connected.
  59. static uint8_t device_descriptor[] = {
  60. 18, // bLength
  61. 1, // bDescriptorType
  62. 0x01, 0x01, // bcdUSB
  63. #ifdef DEVICE_CLASS
  64. DEVICE_CLASS, // bDeviceClass
  65. #else
  66. 0,
  67. #endif
  68. #ifdef DEVICE_SUBCLASS
  69. DEVICE_SUBCLASS, // bDeviceSubClass
  70. #else
  71. 0,
  72. #endif
  73. #ifdef DEVICE_PROTOCOL
  74. DEVICE_PROTOCOL, // bDeviceProtocol
  75. #else
  76. 0,
  77. #endif
  78. EP0_SIZE, // bMaxPacketSize0
  79. LSB(VENDOR_ID), MSB(VENDOR_ID), // idVendor
  80. LSB(PRODUCT_ID), MSB(PRODUCT_ID), // idProduct
  81. 0x00, 0x02, // bcdDevice
  82. 1, // iManufacturer
  83. 2, // iProduct
  84. 3, // iSerialNumber
  85. 1 // bNumConfigurations
  86. };
  87. // These descriptors must NOT be "const", because the USB DMA
  88. // has trouble accessing flash memory with enough bandwidth
  89. // while the processor is executing from flash.
  90. // **************************************************************
  91. // HID Report Descriptors
  92. // **************************************************************
  93. // Each HID interface needs a special report descriptor that tells
  94. // the meaning and format of the data.
  95. #ifdef KEYBOARD_INTERFACE
  96. // Keyboard Protocol 1, HID 1.11 spec, Appendix B, page 59-60
  97. static uint8_t keyboard_report_desc[] = {
  98. 0x05, 0x01, // Usage Page (Generic Desktop),
  99. 0x09, 0x06, // Usage (Keyboard),
  100. 0xA1, 0x01, // Collection (Application),
  101. 0x75, 0x01, // Report Size (1),
  102. 0x95, 0x08, // Report Count (8),
  103. 0x05, 0x07, // Usage Page (Key Codes),
  104. 0x19, 0xE0, // Usage Minimum (224),
  105. 0x29, 0xE7, // Usage Maximum (231),
  106. 0x15, 0x00, // Logical Minimum (0),
  107. 0x25, 0x01, // Logical Maximum (1),
  108. 0x81, 0x02, // Input (Data, Variable, Absolute), ;Modifier keys
  109. 0x95, 0x01, // Report Count (1),
  110. 0x75, 0x08, // Report Size (8),
  111. 0x81, 0x03, // Input (Constant), ;Reserved byte
  112. 0x95, 0x05, // Report Count (5),
  113. 0x75, 0x01, // Report Size (1),
  114. 0x05, 0x08, // Usage Page (LEDs),
  115. 0x19, 0x01, // Usage Minimum (1),
  116. 0x29, 0x05, // Usage Maximum (5),
  117. 0x91, 0x02, // Output (Data, Variable, Absolute), ;LED report
  118. 0x95, 0x01, // Report Count (1),
  119. 0x75, 0x03, // Report Size (3),
  120. 0x91, 0x03, // Output (Constant), ;LED report padding
  121. 0x95, 0x06, // Report Count (6),
  122. 0x75, 0x08, // Report Size (8),
  123. 0x15, 0x00, // Logical Minimum (0),
  124. 0x25, 0x7F, // Logical Maximum(104),
  125. 0x05, 0x07, // Usage Page (Key Codes),
  126. 0x19, 0x00, // Usage Minimum (0),
  127. 0x29, 0x7F, // Usage Maximum (104),
  128. 0x81, 0x00, // Input (Data, Array), ;Normal keys
  129. 0xC0 // End Collection
  130. };
  131. #endif
  132. #ifdef KEYMEDIA_INTERFACE
  133. static uint8_t keymedia_report_desc[] = {
  134. 0x05, 0x0C, // Usage Page (Consumer)
  135. 0x09, 0x01, // Usage (Consumer Controls)
  136. 0xA1, 0x01, // Collection (Application)
  137. 0x75, 0x0A, // Report Size (10)
  138. 0x95, 0x04, // Report Count (4)
  139. 0x19, 0x00, // Usage Minimum (0)
  140. 0x2A, 0x9C, 0x02, // Usage Maximum (0x29C)
  141. 0x15, 0x00, // Logical Minimum (0)
  142. 0x26, 0x9C, 0x02, // Logical Maximum (0x29C)
  143. 0x81, 0x00, // Input (Data, Array)
  144. 0x05, 0x01, // Usage Page (Generic Desktop)
  145. 0x75, 0x08, // Report Size (8)
  146. 0x95, 0x03, // Report Count (3)
  147. 0x19, 0x00, // Usage Minimum (0)
  148. 0x29, 0xB7, // Usage Maximum (0xB7)
  149. 0x15, 0x00, // Logical Minimum (0)
  150. 0x26, 0xB7, 0x00, // Logical Maximum (0xB7)
  151. 0x81, 0x00, // Input (Data, Array)
  152. 0xC0 // End Collection
  153. };
  154. #endif
  155. #ifdef MOUSE_INTERFACE
  156. // Mouse Protocol 1, HID 1.11 spec, Appendix B, page 59-60, with wheel extension
  157. static uint8_t mouse_report_desc[] = {
  158. 0x05, 0x01, // Usage Page (Generic Desktop)
  159. 0x09, 0x02, // Usage (Mouse)
  160. 0xA1, 0x01, // Collection (Application)
  161. 0x85, 0x01, // REPORT_ID (1)
  162. 0x05, 0x09, // Usage Page (Button)
  163. 0x19, 0x01, // Usage Minimum (Button #1)
  164. 0x29, 0x08, // Usage Maximum (Button #8)
  165. 0x15, 0x00, // Logical Minimum (0)
  166. 0x25, 0x01, // Logical Maximum (1)
  167. 0x95, 0x08, // Report Count (8)
  168. 0x75, 0x01, // Report Size (1)
  169. 0x81, 0x02, // Input (Data, Variable, Absolute)
  170. 0x05, 0x01, // Usage Page (Generic Desktop)
  171. 0x09, 0x30, // Usage (X)
  172. 0x09, 0x31, // Usage (Y)
  173. 0x09, 0x38, // Usage (Wheel)
  174. 0x15, 0x81, // Logical Minimum (-127)
  175. 0x25, 0x7F, // Logical Maximum (127)
  176. 0x75, 0x08, // Report Size (8),
  177. 0x95, 0x03, // Report Count (3),
  178. 0x81, 0x06, // Input (Data, Variable, Relative)
  179. 0x05, 0x0C, // Usage Page (Consumer)
  180. 0x0A, 0x38, 0x02, // Usage (AC Pan)
  181. 0x15, 0x81, // Logical Minimum (-127)
  182. 0x25, 0x7F, // Logical Maximum (127)
  183. 0x75, 0x08, // Report Size (8),
  184. 0x95, 0x01, // Report Count (1),
  185. 0x81, 0x06, // Input (Data, Variable, Relative)
  186. 0xC0, // End Collection
  187. 0x05, 0x01, // Usage Page (Generic Desktop)
  188. 0x09, 0x02, // Usage (Mouse)
  189. 0xA1, 0x01, // Collection (Application)
  190. 0x85, 0x02, // REPORT_ID (2)
  191. 0x05, 0x01, // Usage Page (Generic Desktop)
  192. 0x09, 0x30, // Usage (X)
  193. 0x09, 0x31, // Usage (Y)
  194. 0x15, 0x00, // Logical Minimum (0)
  195. 0x26, 0xFF, 0x7F, // Logical Maximum (32767)
  196. 0x75, 0x10, // Report Size (16),
  197. 0x95, 0x02, // Report Count (2),
  198. 0x81, 0x02, // Input (Data, Variable, Absolute)
  199. 0xC0 // End Collection
  200. };
  201. #endif
  202. #ifdef JOYSTICK_INTERFACE
  203. static uint8_t joystick_report_desc[] = {
  204. 0x05, 0x01, // Usage Page (Generic Desktop)
  205. 0x09, 0x04, // Usage (Joystick)
  206. 0xA1, 0x01, // Collection (Application)
  207. 0x15, 0x00, // Logical Minimum (0)
  208. 0x25, 0x01, // Logical Maximum (1)
  209. 0x75, 0x01, // Report Size (1)
  210. 0x95, 0x20, // Report Count (32)
  211. 0x05, 0x09, // Usage Page (Button)
  212. 0x19, 0x01, // Usage Minimum (Button #1)
  213. 0x29, 0x20, // Usage Maximum (Button #32)
  214. 0x81, 0x02, // Input (variable,absolute)
  215. 0x15, 0x00, // Logical Minimum (0)
  216. 0x25, 0x07, // Logical Maximum (7)
  217. 0x35, 0x00, // Physical Minimum (0)
  218. 0x46, 0x3B, 0x01, // Physical Maximum (315)
  219. 0x75, 0x04, // Report Size (4)
  220. 0x95, 0x01, // Report Count (1)
  221. 0x65, 0x14, // Unit (20)
  222. 0x05, 0x01, // Usage Page (Generic Desktop)
  223. 0x09, 0x39, // Usage (Hat switch)
  224. 0x81, 0x42, // Input (variable,absolute,null_state)
  225. 0x05, 0x01, // Usage Page (Generic Desktop)
  226. 0x09, 0x01, // Usage (Pointer)
  227. 0xA1, 0x00, // Collection ()
  228. 0x15, 0x00, // Logical Minimum (0)
  229. 0x26, 0xFF, 0x03, // Logical Maximum (1023)
  230. 0x75, 0x0A, // Report Size (10)
  231. 0x95, 0x04, // Report Count (4)
  232. 0x09, 0x30, // Usage (X)
  233. 0x09, 0x31, // Usage (Y)
  234. 0x09, 0x32, // Usage (Z)
  235. 0x09, 0x35, // Usage (Rz)
  236. 0x81, 0x02, // Input (variable,absolute)
  237. 0xC0, // End Collection
  238. 0x15, 0x00, // Logical Minimum (0)
  239. 0x26, 0xFF, 0x03, // Logical Maximum (1023)
  240. 0x75, 0x0A, // Report Size (10)
  241. 0x95, 0x02, // Report Count (2)
  242. 0x09, 0x36, // Usage (Slider)
  243. 0x09, 0x36, // Usage (Slider)
  244. 0x81, 0x02, // Input (variable,absolute)
  245. 0xC0 // End Collection
  246. };
  247. #endif
  248. #ifdef MULTITOUCH_INTERFACE
  249. // https://forum.pjrc.com/threads/32331-USB-HID-Touchscreen-support-needed
  250. // https://msdn.microsoft.com/en-us/library/windows/hardware/jj151563%28v=vs.85%29.aspx
  251. // https://msdn.microsoft.com/en-us/library/windows/hardware/jj151565%28v=vs.85%29.aspx
  252. // https://msdn.microsoft.com/en-us/library/windows/hardware/ff553734%28v=vs.85%29.aspx
  253. // https://msdn.microsoft.com/en-us/library/windows/hardware/jj151564%28v=vs.85%29.aspx
  254. // download.microsoft.com/download/a/d/f/adf1347d-08dc-41a4-9084-623b1194d4b2/digitizerdrvs_touch.docx
  255. static uint8_t multitouch_report_desc[] = {
  256. 0x05, 0x0D, // Usage Page (Digitizer)
  257. 0x09, 0x04, // Usage (Touch Screen)
  258. 0xa1, 0x01, // Collection (Application)
  259. 0x09, 0x22, // Usage (Finger)
  260. 0xA1, 0x02, // Collection (Logical)
  261. 0x09, 0x42, // Usage (Tip Switch)
  262. 0x15, 0x00, // Logical Minimum (0)
  263. 0x25, 0x01, // Logical Maximum (1)
  264. 0x75, 0x01, // Report Size (1)
  265. 0x95, 0x01, // Report Count (1)
  266. 0x81, 0x02, // Input (variable,absolute)
  267. 0x09, 0x30, // Usage (Pressure)
  268. 0x25, 0x7F, // Logical Maximum (127)
  269. 0x75, 0x07, // Report Size (7)
  270. 0x95, 0x01, // Report Count (1)
  271. 0x81, 0x02, // Input (variable,absolute)
  272. 0x09, 0x51, // Usage (Contact Identifier)
  273. 0x26, 0xFF, 0x00, // Logical Maximum (255)
  274. 0x75, 0x08, // Report Size (8)
  275. 0x95, 0x01, // Report Count (1)
  276. 0x81, 0x02, // Input (variable,absolute)
  277. 0x05, 0x01, // Usage Page (Generic Desktop)
  278. 0x09, 0x30, // Usage (X)
  279. 0x09, 0x31, // Usage (Y)
  280. 0x26, 0xFF, 0x7F, // Logical Maximum (32767)
  281. 0x65, 0x00, // Unit (None) <-- probably needs real units?
  282. 0x75, 0x10, // Report Size (16)
  283. 0x95, 0x02, // Report Count (2)
  284. 0x81, 0x02, // Input (variable,absolute)
  285. 0xC0, // End Collection
  286. 0x05, 0x0D, // Usage Page (Digitizer)
  287. 0x27, 0xFF, 0xFF, 0, 0, // Logical Maximum (65535)
  288. 0x75, 0x10, // Report Size (16)
  289. 0x95, 0x01, // Report Count (1)
  290. 0x09, 0x56, // Usage (Scan Time)
  291. 0x81, 0x02, // Input (variable,absolute)
  292. 0x09, 0x54, // Usage (Contact Count)
  293. 0x25, MULTITOUCH_FINGERS, // Logical Maximum (10)
  294. 0x75, 0x08, // Report Size (8)
  295. 0x95, 0x01, // Report Count (1)
  296. 0x81, 0x02, // Input (variable,absolute)
  297. 0x05, 0x0D, // Usage Page (Digitizers)
  298. 0x09, 0x55, // Usage (Contact Count Maximum)
  299. 0x25, MULTITOUCH_FINGERS, // Logical Maximum (10)
  300. 0x75, 0x08, // Report Size (8)
  301. 0x95, 0x01, // Report Count (1)
  302. 0xB1, 0x02, // Feature (variable,absolute)
  303. 0xC0 // End Collection
  304. };
  305. #endif
  306. #ifdef SEREMU_INTERFACE
  307. static uint8_t seremu_report_desc[] = {
  308. 0x06, 0xC9, 0xFF, // Usage Page 0xFFC9 (vendor defined)
  309. 0x09, 0x04, // Usage 0x04
  310. 0xA1, 0x5C, // Collection 0x5C
  311. 0x75, 0x08, // report size = 8 bits (global)
  312. 0x15, 0x00, // logical minimum = 0 (global)
  313. 0x26, 0xFF, 0x00, // logical maximum = 255 (global)
  314. 0x95, SEREMU_TX_SIZE, // report count (global)
  315. 0x09, 0x75, // usage (local)
  316. 0x81, 0x02, // Input
  317. 0x95, SEREMU_RX_SIZE, // report count (global)
  318. 0x09, 0x76, // usage (local)
  319. 0x91, 0x02, // Output
  320. 0x95, 0x04, // report count (global)
  321. 0x09, 0x76, // usage (local)
  322. 0xB1, 0x02, // Feature
  323. 0xC0 // end collection
  324. };
  325. #endif
  326. #ifdef RAWHID_INTERFACE
  327. static uint8_t rawhid_report_desc[] = {
  328. 0x06, LSB(RAWHID_USAGE_PAGE), MSB(RAWHID_USAGE_PAGE),
  329. 0x0A, LSB(RAWHID_USAGE), MSB(RAWHID_USAGE),
  330. 0xA1, 0x01, // Collection 0x01
  331. 0x75, 0x08, // report size = 8 bits
  332. 0x15, 0x00, // logical minimum = 0
  333. 0x26, 0xFF, 0x00, // logical maximum = 255
  334. 0x95, RAWHID_TX_SIZE, // report count
  335. 0x09, 0x01, // usage
  336. 0x81, 0x02, // Input (array)
  337. 0x95, RAWHID_RX_SIZE, // report count
  338. 0x09, 0x02, // usage
  339. 0x91, 0x02, // Output (array)
  340. 0xC0 // end collection
  341. };
  342. #endif
  343. #ifdef FLIGHTSIM_INTERFACE
  344. static uint8_t flightsim_report_desc[] = {
  345. 0x06, 0x1C, 0xFF, // Usage page = 0xFF1C
  346. 0x0A, 0x39, 0xA7, // Usage = 0xA739
  347. 0xA1, 0x01, // Collection 0x01
  348. 0x75, 0x08, // report size = 8 bits
  349. 0x15, 0x00, // logical minimum = 0
  350. 0x26, 0xFF, 0x00, // logical maximum = 255
  351. 0x95, FLIGHTSIM_TX_SIZE, // report count
  352. 0x09, 0x01, // usage
  353. 0x81, 0x02, // Input (array)
  354. 0x95, FLIGHTSIM_RX_SIZE, // report count
  355. 0x09, 0x02, // usage
  356. 0x91, 0x02, // Output (array)
  357. 0xC0 // end collection
  358. };
  359. #endif
  360. // **************************************************************
  361. // USB Descriptor Sizes
  362. // **************************************************************
  363. // pre-compute the size and position of everything in the config descriptor
  364. //
  365. #define CONFIG_HEADER_DESCRIPTOR_SIZE 9
  366. #define CDC_IAD_DESCRIPTOR_POS CONFIG_HEADER_DESCRIPTOR_SIZE
  367. #ifdef CDC_IAD_DESCRIPTOR
  368. #define CDC_IAD_DESCRIPTOR_SIZE 8
  369. #else
  370. #define CDC_IAD_DESCRIPTOR_SIZE 0
  371. #endif
  372. #define CDC_DATA_INTERFACE_DESC_POS CDC_IAD_DESCRIPTOR_POS+CDC_IAD_DESCRIPTOR_SIZE
  373. #ifdef CDC_DATA_INTERFACE
  374. #define CDC_DATA_INTERFACE_DESC_SIZE 9+5+5+4+5+7+9+7+7
  375. #else
  376. #define CDC_DATA_INTERFACE_DESC_SIZE 0
  377. #endif
  378. #define MIDI_INTERFACE_DESC_POS CDC_DATA_INTERFACE_DESC_POS+CDC_DATA_INTERFACE_DESC_SIZE
  379. #ifdef MIDI_INTERFACE
  380. #define MIDI_INTERFACE_DESC_SIZE 9+7+6+6+9+9+9+5+9+5
  381. #else
  382. #define MIDI_INTERFACE_DESC_SIZE 0
  383. #endif
  384. #define KEYBOARD_INTERFACE_DESC_POS MIDI_INTERFACE_DESC_POS+MIDI_INTERFACE_DESC_SIZE
  385. #ifdef KEYBOARD_INTERFACE
  386. #define KEYBOARD_INTERFACE_DESC_SIZE 9+9+7
  387. #define KEYBOARD_HID_DESC_OFFSET KEYBOARD_INTERFACE_DESC_POS+9
  388. #else
  389. #define KEYBOARD_INTERFACE_DESC_SIZE 0
  390. #endif
  391. #define MOUSE_INTERFACE_DESC_POS KEYBOARD_INTERFACE_DESC_POS+KEYBOARD_INTERFACE_DESC_SIZE
  392. #ifdef MOUSE_INTERFACE
  393. #define MOUSE_INTERFACE_DESC_SIZE 9+9+7
  394. #define MOUSE_HID_DESC_OFFSET MOUSE_INTERFACE_DESC_POS+9
  395. #else
  396. #define MOUSE_INTERFACE_DESC_SIZE 0
  397. #endif
  398. #define RAWHID_INTERFACE_DESC_POS MOUSE_INTERFACE_DESC_POS+MOUSE_INTERFACE_DESC_SIZE
  399. #ifdef RAWHID_INTERFACE
  400. #define RAWHID_INTERFACE_DESC_SIZE 9+9+7+7
  401. #define RAWHID_HID_DESC_OFFSET RAWHID_INTERFACE_DESC_POS+9
  402. #else
  403. #define RAWHID_INTERFACE_DESC_SIZE 0
  404. #endif
  405. #define FLIGHTSIM_INTERFACE_DESC_POS RAWHID_INTERFACE_DESC_POS+RAWHID_INTERFACE_DESC_SIZE
  406. #ifdef FLIGHTSIM_INTERFACE
  407. #define FLIGHTSIM_INTERFACE_DESC_SIZE 9+9+7+7
  408. #define FLIGHTSIM_HID_DESC_OFFSET FLIGHTSIM_INTERFACE_DESC_POS+9
  409. #else
  410. #define FLIGHTSIM_INTERFACE_DESC_SIZE 0
  411. #endif
  412. #define SEREMU_INTERFACE_DESC_POS FLIGHTSIM_INTERFACE_DESC_POS+FLIGHTSIM_INTERFACE_DESC_SIZE
  413. #ifdef SEREMU_INTERFACE
  414. #define SEREMU_INTERFACE_DESC_SIZE 9+9+7+7
  415. #define SEREMU_HID_DESC_OFFSET SEREMU_INTERFACE_DESC_POS+9
  416. #else
  417. #define SEREMU_INTERFACE_DESC_SIZE 0
  418. #endif
  419. #define JOYSTICK_INTERFACE_DESC_POS SEREMU_INTERFACE_DESC_POS+SEREMU_INTERFACE_DESC_SIZE
  420. #ifdef JOYSTICK_INTERFACE
  421. #define JOYSTICK_INTERFACE_DESC_SIZE 9+9+7
  422. #define JOYSTICK_HID_DESC_OFFSET JOYSTICK_INTERFACE_DESC_POS+9
  423. #else
  424. #define JOYSTICK_INTERFACE_DESC_SIZE 0
  425. #endif
  426. #define MTP_INTERFACE_DESC_POS JOYSTICK_INTERFACE_DESC_POS+JOYSTICK_INTERFACE_DESC_SIZE
  427. #ifdef MTP_INTERFACE
  428. #define MTP_INTERFACE_DESC_SIZE 9+7+7+7
  429. #else
  430. #define MTP_INTERFACE_DESC_SIZE 0
  431. #endif
  432. #define KEYMEDIA_INTERFACE_DESC_POS MTP_INTERFACE_DESC_POS+MTP_INTERFACE_DESC_SIZE
  433. #ifdef KEYMEDIA_INTERFACE
  434. #define KEYMEDIA_INTERFACE_DESC_SIZE 9+9+7
  435. #define KEYMEDIA_HID_DESC_OFFSET KEYMEDIA_INTERFACE_DESC_POS+9
  436. #else
  437. #define KEYMEDIA_INTERFACE_DESC_SIZE 0
  438. #endif
  439. #define AUDIO_INTERFACE_DESC_POS KEYMEDIA_INTERFACE_DESC_POS+KEYMEDIA_INTERFACE_DESC_SIZE
  440. #ifdef AUDIO_INTERFACE
  441. #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
  442. #else
  443. #define AUDIO_INTERFACE_DESC_SIZE 0
  444. #endif
  445. #define MULTITOUCH_INTERFACE_DESC_POS AUDIO_INTERFACE_DESC_POS+AUDIO_INTERFACE_DESC_SIZE
  446. #ifdef MULTITOUCH_INTERFACE
  447. #define MULTITOUCH_INTERFACE_DESC_SIZE 9+9+7
  448. #define MULTITOUCH_HID_DESC_OFFSET MULTITOUCH_INTERFACE_DESC_POS+9
  449. #else
  450. #define MULTITOUCH_INTERFACE_DESC_SIZE 0
  451. #endif
  452. #define CONFIG_DESC_SIZE MULTITOUCH_INTERFACE_DESC_POS+MULTITOUCH_INTERFACE_DESC_SIZE
  453. // **************************************************************
  454. // USB Configuration
  455. // **************************************************************
  456. // USB Configuration Descriptor. This huge descriptor tells all
  457. // of the devices capbilities.
  458. static uint8_t config_descriptor[CONFIG_DESC_SIZE] = {
  459. // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
  460. 9, // bLength;
  461. 2, // bDescriptorType;
  462. LSB(CONFIG_DESC_SIZE), // wTotalLength
  463. MSB(CONFIG_DESC_SIZE),
  464. NUM_INTERFACE, // bNumInterfaces
  465. 1, // bConfigurationValue
  466. 0, // iConfiguration
  467. 0xC0, // bmAttributes
  468. 50, // bMaxPower
  469. #ifdef CDC_IAD_DESCRIPTOR
  470. // interface association descriptor, USB ECN, Table 9-Z
  471. 8, // bLength
  472. 11, // bDescriptorType
  473. CDC_STATUS_INTERFACE, // bFirstInterface
  474. 2, // bInterfaceCount
  475. 0x02, // bFunctionClass
  476. 0x02, // bFunctionSubClass
  477. 0x01, // bFunctionProtocol
  478. 4, // iFunction
  479. #endif
  480. #ifdef CDC_DATA_INTERFACE
  481. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  482. 9, // bLength
  483. 4, // bDescriptorType
  484. CDC_STATUS_INTERFACE, // bInterfaceNumber
  485. 0, // bAlternateSetting
  486. 1, // bNumEndpoints
  487. 0x02, // bInterfaceClass
  488. 0x02, // bInterfaceSubClass
  489. 0x01, // bInterfaceProtocol
  490. 0, // iInterface
  491. // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26
  492. 5, // bFunctionLength
  493. 0x24, // bDescriptorType
  494. 0x00, // bDescriptorSubtype
  495. 0x10, 0x01, // bcdCDC
  496. // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27
  497. 5, // bFunctionLength
  498. 0x24, // bDescriptorType
  499. 0x01, // bDescriptorSubtype
  500. 0x01, // bmCapabilities
  501. 1, // bDataInterface
  502. // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28
  503. 4, // bFunctionLength
  504. 0x24, // bDescriptorType
  505. 0x02, // bDescriptorSubtype
  506. 0x06, // bmCapabilities
  507. // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33
  508. 5, // bFunctionLength
  509. 0x24, // bDescriptorType
  510. 0x06, // bDescriptorSubtype
  511. CDC_STATUS_INTERFACE, // bMasterInterface
  512. CDC_DATA_INTERFACE, // bSlaveInterface0
  513. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  514. 7, // bLength
  515. 5, // bDescriptorType
  516. CDC_ACM_ENDPOINT | 0x80, // bEndpointAddress
  517. 0x03, // bmAttributes (0x03=intr)
  518. CDC_ACM_SIZE, 0, // wMaxPacketSize
  519. 64, // bInterval
  520. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  521. 9, // bLength
  522. 4, // bDescriptorType
  523. CDC_DATA_INTERFACE, // bInterfaceNumber
  524. 0, // bAlternateSetting
  525. 2, // bNumEndpoints
  526. 0x0A, // bInterfaceClass
  527. 0x00, // bInterfaceSubClass
  528. 0x00, // bInterfaceProtocol
  529. 0, // iInterface
  530. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  531. 7, // bLength
  532. 5, // bDescriptorType
  533. CDC_RX_ENDPOINT, // bEndpointAddress
  534. 0x02, // bmAttributes (0x02=bulk)
  535. CDC_RX_SIZE, 0, // wMaxPacketSize
  536. 0, // bInterval
  537. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  538. 7, // bLength
  539. 5, // bDescriptorType
  540. CDC_TX_ENDPOINT | 0x80, // bEndpointAddress
  541. 0x02, // bmAttributes (0x02=bulk)
  542. CDC_TX_SIZE, 0, // wMaxPacketSize
  543. 0, // bInterval
  544. #endif // CDC_DATA_INTERFACE
  545. #ifdef MIDI_INTERFACE
  546. // Standard MS Interface Descriptor,
  547. 9, // bLength
  548. 4, // bDescriptorType
  549. MIDI_INTERFACE, // bInterfaceNumber
  550. 0, // bAlternateSetting
  551. 2, // bNumEndpoints
  552. 0x01, // bInterfaceClass (0x01 = Audio)
  553. 0x03, // bInterfaceSubClass (0x03 = MIDI)
  554. 0x00, // bInterfaceProtocol (unused for MIDI)
  555. 0, // iInterface
  556. // MIDI MS Interface Header, USB MIDI 6.1.2.1, page 21, Table 6-2
  557. 7, // bLength
  558. 0x24, // bDescriptorType = CS_INTERFACE
  559. 0x01, // bDescriptorSubtype = MS_HEADER
  560. 0x00, 0x01, // bcdMSC = revision 01.00
  561. 0x41, 0x00, // wTotalLength
  562. // MIDI IN Jack Descriptor, B.4.3, Table B-7 (embedded), page 40
  563. 6, // bLength
  564. 0x24, // bDescriptorType = CS_INTERFACE
  565. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  566. 0x01, // bJackType = EMBEDDED
  567. 1, // bJackID, ID = 1
  568. 0, // iJack
  569. // MIDI IN Jack Descriptor, B.4.3, Table B-8 (external), page 40
  570. 6, // bLength
  571. 0x24, // bDescriptorType = CS_INTERFACE
  572. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  573. 0x02, // bJackType = EXTERNAL
  574. 2, // bJackID, ID = 2
  575. 0, // iJack
  576. // MIDI OUT Jack Descriptor, B.4.4, Table B-9, page 41
  577. 9,
  578. 0x24, // bDescriptorType = CS_INTERFACE
  579. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  580. 0x01, // bJackType = EMBEDDED
  581. 3, // bJackID, ID = 3
  582. 1, // bNrInputPins = 1 pin
  583. 2, // BaSourceID(1) = 2
  584. 1, // BaSourcePin(1) = first pin
  585. 0, // iJack
  586. // MIDI OUT Jack Descriptor, B.4.4, Table B-10, page 41
  587. 9,
  588. 0x24, // bDescriptorType = CS_INTERFACE
  589. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  590. 0x02, // bJackType = EXTERNAL
  591. 4, // bJackID, ID = 4
  592. 1, // bNrInputPins = 1 pin
  593. 1, // BaSourceID(1) = 1
  594. 1, // BaSourcePin(1) = first pin
  595. 0, // iJack
  596. // Standard Bulk OUT Endpoint Descriptor, B.5.1, Table B-11, pae 42
  597. 9, // bLength
  598. 5, // bDescriptorType = ENDPOINT
  599. MIDI_RX_ENDPOINT, // bEndpointAddress
  600. 0x02, // bmAttributes (0x02=bulk)
  601. MIDI_RX_SIZE, 0, // wMaxPacketSize
  602. 0, // bInterval
  603. 0, // bRefresh
  604. 0, // bSynchAddress
  605. // Class-specific MS Bulk OUT Endpoint Descriptor, B.5.2, Table B-12, page 42
  606. 5, // bLength
  607. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  608. 0x01, // bJackType = MS_GENERAL
  609. 1, // bNumEmbMIDIJack = 1 jack
  610. 1, // BaAssocJackID(1) = jack ID #1
  611. // Standard Bulk IN Endpoint Descriptor, B.5.1, Table B-11, pae 42
  612. 9, // bLength
  613. 5, // bDescriptorType = ENDPOINT
  614. MIDI_TX_ENDPOINT | 0x80, // bEndpointAddress
  615. 0x02, // bmAttributes (0x02=bulk)
  616. MIDI_TX_SIZE, 0, // wMaxPacketSize
  617. 0, // bInterval
  618. 0, // bRefresh
  619. 0, // bSynchAddress
  620. // Class-specific MS Bulk IN Endpoint Descriptor, B.5.2, Table B-12, page 42
  621. 5, // bLength
  622. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  623. 0x01, // bJackType = MS_GENERAL
  624. 1, // bNumEmbMIDIJack = 1 jack
  625. 3, // BaAssocJackID(1) = jack ID #3
  626. #endif // MIDI_INTERFACE
  627. #ifdef KEYBOARD_INTERFACE
  628. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  629. 9, // bLength
  630. 4, // bDescriptorType
  631. KEYBOARD_INTERFACE, // bInterfaceNumber
  632. 0, // bAlternateSetting
  633. 1, // bNumEndpoints
  634. 0x03, // bInterfaceClass (0x03 = HID)
  635. 0x01, // bInterfaceSubClass (0x01 = Boot)
  636. 0x01, // bInterfaceProtocol (0x01 = Keyboard)
  637. 0, // iInterface
  638. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  639. 9, // bLength
  640. 0x21, // bDescriptorType
  641. 0x11, 0x01, // bcdHID
  642. 0, // bCountryCode
  643. 1, // bNumDescriptors
  644. 0x22, // bDescriptorType
  645. LSB(sizeof(keyboard_report_desc)), // wDescriptorLength
  646. MSB(sizeof(keyboard_report_desc)),
  647. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  648. 7, // bLength
  649. 5, // bDescriptorType
  650. KEYBOARD_ENDPOINT | 0x80, // bEndpointAddress
  651. 0x03, // bmAttributes (0x03=intr)
  652. KEYBOARD_SIZE, 0, // wMaxPacketSize
  653. KEYBOARD_INTERVAL, // bInterval
  654. #endif // KEYBOARD_INTERFACE
  655. #ifdef MOUSE_INTERFACE
  656. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  657. 9, // bLength
  658. 4, // bDescriptorType
  659. MOUSE_INTERFACE, // bInterfaceNumber
  660. 0, // bAlternateSetting
  661. 1, // bNumEndpoints
  662. 0x03, // bInterfaceClass (0x03 = HID)
  663. 0x00, // bInterfaceSubClass (0x01 = Boot)
  664. 0x00, // bInterfaceProtocol (0x02 = Mouse)
  665. 0, // iInterface
  666. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  667. 9, // bLength
  668. 0x21, // bDescriptorType
  669. 0x11, 0x01, // bcdHID
  670. 0, // bCountryCode
  671. 1, // bNumDescriptors
  672. 0x22, // bDescriptorType
  673. LSB(sizeof(mouse_report_desc)), // wDescriptorLength
  674. MSB(sizeof(mouse_report_desc)),
  675. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  676. 7, // bLength
  677. 5, // bDescriptorType
  678. MOUSE_ENDPOINT | 0x80, // bEndpointAddress
  679. 0x03, // bmAttributes (0x03=intr)
  680. MOUSE_SIZE, 0, // wMaxPacketSize
  681. MOUSE_INTERVAL, // bInterval
  682. #endif // MOUSE_INTERFACE
  683. #ifdef RAWHID_INTERFACE
  684. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  685. 9, // bLength
  686. 4, // bDescriptorType
  687. RAWHID_INTERFACE, // bInterfaceNumber
  688. 0, // bAlternateSetting
  689. 2, // bNumEndpoints
  690. 0x03, // bInterfaceClass (0x03 = HID)
  691. 0x00, // bInterfaceSubClass
  692. 0x00, // bInterfaceProtocol
  693. 0, // iInterface
  694. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  695. 9, // bLength
  696. 0x21, // bDescriptorType
  697. 0x11, 0x01, // bcdHID
  698. 0, // bCountryCode
  699. 1, // bNumDescriptors
  700. 0x22, // bDescriptorType
  701. LSB(sizeof(rawhid_report_desc)), // wDescriptorLength
  702. MSB(sizeof(rawhid_report_desc)),
  703. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  704. 7, // bLength
  705. 5, // bDescriptorType
  706. RAWHID_TX_ENDPOINT | 0x80, // bEndpointAddress
  707. 0x03, // bmAttributes (0x03=intr)
  708. RAWHID_TX_SIZE, 0, // wMaxPacketSize
  709. RAWHID_TX_INTERVAL, // bInterval
  710. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  711. 7, // bLength
  712. 5, // bDescriptorType
  713. RAWHID_RX_ENDPOINT, // bEndpointAddress
  714. 0x03, // bmAttributes (0x03=intr)
  715. RAWHID_RX_SIZE, 0, // wMaxPacketSize
  716. RAWHID_RX_INTERVAL, // bInterval
  717. #endif // RAWHID_INTERFACE
  718. #ifdef FLIGHTSIM_INTERFACE
  719. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  720. 9, // bLength
  721. 4, // bDescriptorType
  722. FLIGHTSIM_INTERFACE, // bInterfaceNumber
  723. 0, // bAlternateSetting
  724. 2, // bNumEndpoints
  725. 0x03, // bInterfaceClass (0x03 = HID)
  726. 0x00, // bInterfaceSubClass
  727. 0x00, // bInterfaceProtocol
  728. 0, // iInterface
  729. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  730. 9, // bLength
  731. 0x21, // bDescriptorType
  732. 0x11, 0x01, // bcdHID
  733. 0, // bCountryCode
  734. 1, // bNumDescriptors
  735. 0x22, // bDescriptorType
  736. LSB(sizeof(flightsim_report_desc)), // wDescriptorLength
  737. MSB(sizeof(flightsim_report_desc)),
  738. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  739. 7, // bLength
  740. 5, // bDescriptorType
  741. FLIGHTSIM_TX_ENDPOINT | 0x80, // bEndpointAddress
  742. 0x03, // bmAttributes (0x03=intr)
  743. FLIGHTSIM_TX_SIZE, 0, // wMaxPacketSize
  744. FLIGHTSIM_TX_INTERVAL, // bInterval
  745. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  746. 7, // bLength
  747. 5, // bDescriptorType
  748. FLIGHTSIM_RX_ENDPOINT, // bEndpointAddress
  749. 0x03, // bmAttributes (0x03=intr)
  750. FLIGHTSIM_RX_SIZE, 0, // wMaxPacketSize
  751. FLIGHTSIM_RX_INTERVAL, // bInterval
  752. #endif // FLIGHTSIM_INTERFACE
  753. #ifdef SEREMU_INTERFACE
  754. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  755. 9, // bLength
  756. 4, // bDescriptorType
  757. SEREMU_INTERFACE, // bInterfaceNumber
  758. 0, // bAlternateSetting
  759. 2, // bNumEndpoints
  760. 0x03, // bInterfaceClass (0x03 = HID)
  761. 0x00, // bInterfaceSubClass
  762. 0x00, // bInterfaceProtocol
  763. 0, // iInterface
  764. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  765. 9, // bLength
  766. 0x21, // bDescriptorType
  767. 0x11, 0x01, // bcdHID
  768. 0, // bCountryCode
  769. 1, // bNumDescriptors
  770. 0x22, // bDescriptorType
  771. LSB(sizeof(seremu_report_desc)), // wDescriptorLength
  772. MSB(sizeof(seremu_report_desc)),
  773. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  774. 7, // bLength
  775. 5, // bDescriptorType
  776. SEREMU_TX_ENDPOINT | 0x80, // bEndpointAddress
  777. 0x03, // bmAttributes (0x03=intr)
  778. SEREMU_TX_SIZE, 0, // wMaxPacketSize
  779. SEREMU_TX_INTERVAL, // bInterval
  780. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  781. 7, // bLength
  782. 5, // bDescriptorType
  783. SEREMU_RX_ENDPOINT, // bEndpointAddress
  784. 0x03, // bmAttributes (0x03=intr)
  785. SEREMU_RX_SIZE, 0, // wMaxPacketSize
  786. SEREMU_RX_INTERVAL, // bInterval
  787. #endif // SEREMU_INTERFACE
  788. #ifdef JOYSTICK_INTERFACE
  789. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  790. 9, // bLength
  791. 4, // bDescriptorType
  792. JOYSTICK_INTERFACE, // bInterfaceNumber
  793. 0, // bAlternateSetting
  794. 1, // bNumEndpoints
  795. 0x03, // bInterfaceClass (0x03 = HID)
  796. 0x00, // bInterfaceSubClass
  797. 0x00, // bInterfaceProtocol
  798. 0, // iInterface
  799. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  800. 9, // bLength
  801. 0x21, // bDescriptorType
  802. 0x11, 0x01, // bcdHID
  803. 0, // bCountryCode
  804. 1, // bNumDescriptors
  805. 0x22, // bDescriptorType
  806. LSB(sizeof(joystick_report_desc)), // wDescriptorLength
  807. MSB(sizeof(joystick_report_desc)),
  808. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  809. 7, // bLength
  810. 5, // bDescriptorType
  811. JOYSTICK_ENDPOINT | 0x80, // bEndpointAddress
  812. 0x03, // bmAttributes (0x03=intr)
  813. JOYSTICK_SIZE, 0, // wMaxPacketSize
  814. JOYSTICK_INTERVAL, // bInterval
  815. #endif // JOYSTICK_INTERFACE
  816. #ifdef MTP_INTERFACE
  817. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  818. 9, // bLength
  819. 4, // bDescriptorType
  820. MTP_INTERFACE, // bInterfaceNumber
  821. 0, // bAlternateSetting
  822. 3, // bNumEndpoints
  823. 0x06, // bInterfaceClass (0x06 = still image)
  824. 0x01, // bInterfaceSubClass
  825. 0x01, // bInterfaceProtocol
  826. 0, // iInterface
  827. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  828. 7, // bLength
  829. 5, // bDescriptorType
  830. MTP_TX_ENDPOINT | 0x80, // bEndpointAddress
  831. 0x02, // bmAttributes (0x02=bulk)
  832. MTP_TX_SIZE, 0, // wMaxPacketSize
  833. 0, // bInterval
  834. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  835. 7, // bLength
  836. 5, // bDescriptorType
  837. MTP_RX_ENDPOINT, // bEndpointAddress
  838. 0x02, // bmAttributes (0x02=bulk)
  839. MTP_RX_SIZE, 0, // wMaxPacketSize
  840. 0, // bInterval
  841. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  842. 7, // bLength
  843. 5, // bDescriptorType
  844. MTP_EVENT_ENDPOINT | 0x80, // bEndpointAddress
  845. 0x03, // bmAttributes (0x03=intr)
  846. MTP_EVENT_SIZE, 0, // wMaxPacketSize
  847. MTP_EVENT_INTERVAL, // bInterval
  848. #endif // MTP_INTERFACE
  849. #ifdef KEYMEDIA_INTERFACE
  850. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  851. 9, // bLength
  852. 4, // bDescriptorType
  853. KEYMEDIA_INTERFACE, // bInterfaceNumber
  854. 0, // bAlternateSetting
  855. 1, // bNumEndpoints
  856. 0x03, // bInterfaceClass (0x03 = HID)
  857. 0x00, // bInterfaceSubClass
  858. 0x00, // bInterfaceProtocol
  859. 0, // iInterface
  860. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  861. 9, // bLength
  862. 0x21, // bDescriptorType
  863. 0x11, 0x01, // bcdHID
  864. 0, // bCountryCode
  865. 1, // bNumDescriptors
  866. 0x22, // bDescriptorType
  867. LSB(sizeof(keymedia_report_desc)), // wDescriptorLength
  868. MSB(sizeof(keymedia_report_desc)),
  869. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  870. 7, // bLength
  871. 5, // bDescriptorType
  872. KEYMEDIA_ENDPOINT | 0x80, // bEndpointAddress
  873. 0x03, // bmAttributes (0x03=intr)
  874. KEYMEDIA_SIZE, 0, // wMaxPacketSize
  875. KEYMEDIA_INTERVAL, // bInterval
  876. #endif // KEYMEDIA_INTERFACE
  877. #ifdef AUDIO_INTERFACE
  878. // interface association descriptor, USB ECN, Table 9-Z
  879. 8, // bLength
  880. 11, // bDescriptorType
  881. AUDIO_INTERFACE, // bFirstInterface
  882. 3, // bInterfaceCount
  883. 0x01, // bFunctionClass
  884. 0x01, // bFunctionSubClass
  885. 0x00, // bFunctionProtocol
  886. 0, // iFunction
  887. // Standard AudioControl (AC) Interface Descriptor
  888. // USB DCD for Audio Devices 1.0, Table 4-1, page 36
  889. 9, // bLength
  890. 4, // bDescriptorType, 4 = INTERFACE
  891. AUDIO_INTERFACE, // bInterfaceNumber
  892. 0, // bAlternateSetting
  893. 0, // bNumEndpoints
  894. 1, // bInterfaceClass, 1 = AUDIO
  895. 1, // bInterfaceSubclass, 1 = AUDIO_CONTROL
  896. 0, // bInterfaceProtocol
  897. 0, // iInterface
  898. // Class-specific AC Interface Header Descriptor
  899. // USB DCD for Audio Devices 1.0, Table 4-2, page 37-38
  900. 10, // bLength
  901. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  902. 0x01, // bDescriptorSubtype, 1 = HEADER
  903. 0x00, 0x01, // bcdADC (version 1.0)
  904. LSB(62), MSB(62), // wTotalLength
  905. 2, // bInCollection
  906. AUDIO_INTERFACE+1, // baInterfaceNr(1) - Transmit to PC
  907. AUDIO_INTERFACE+2, // baInterfaceNr(2) - Receive from PC
  908. // Input Terminal Descriptor
  909. // USB DCD for Audio Devices 1.0, Table 4-3, page 39
  910. 12, // bLength
  911. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  912. 0x02, // bDescriptorSubType, 2 = INPUT_TERMINAL
  913. 1, // bTerminalID
  914. //0x01, 0x02, // wTerminalType, 0x0201 = MICROPHONE
  915. //0x03, 0x06, // wTerminalType, 0x0603 = Line Connector
  916. 0x02, 0x06, // wTerminalType, 0x0602 = Digital Audio
  917. 0, // bAssocTerminal, 0 = unidirectional
  918. 2, // bNrChannels
  919. 0x03, 0x00, // wChannelConfig, 0x0003 = Left & Right Front
  920. 0, // iChannelNames
  921. 0, // iTerminal
  922. // Output Terminal Descriptor
  923. // USB DCD for Audio Devices 1.0, Table 4-4, page 40
  924. 9, // bLength
  925. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  926. 3, // bDescriptorSubtype, 3 = OUTPUT_TERMINAL
  927. 2, // bTerminalID
  928. 0x01, 0x01, // wTerminalType, 0x0101 = USB_STREAMING
  929. 0, // bAssocTerminal, 0 = unidirectional
  930. 1, // bCSourceID, connected to input terminal, ID=1
  931. 0, // iTerminal
  932. // Input Terminal Descriptor
  933. // USB DCD for Audio Devices 1.0, Table 4-3, page 39
  934. 12, // bLength
  935. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  936. 2, // bDescriptorSubType, 2 = INPUT_TERMINAL
  937. 3, // bTerminalID
  938. 0x01, 0x01, // wTerminalType, 0x0101 = USB_STREAMING
  939. 0, // bAssocTerminal, 0 = unidirectional
  940. 2, // bNrChannels
  941. 0x03, 0x00, // wChannelConfig, 0x0003 = Left & Right Front
  942. 0, // iChannelNames
  943. 0, // iTerminal
  944. // Volume feature descriptor
  945. 10, // bLength
  946. 0x24, // bDescriptorType = CS_INTERFACE
  947. 0x06, // bDescriptorSubType = FEATURE_UNIT
  948. 0x31, // bUnitID
  949. 0x03, // bSourceID (Input Terminal)
  950. 0x01, // bControlSize (each channel is 1 byte, 3 channels)
  951. 0x01, // bmaControls(0) Master: Mute
  952. 0x02, // bmaControls(1) Left: Volume
  953. 0x02, // bmaControls(2) Right: Volume
  954. 0x00, // iFeature
  955. // Output Terminal Descriptor
  956. // USB DCD for Audio Devices 1.0, Table 4-4, page 40
  957. 9, // bLength
  958. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  959. 3, // bDescriptorSubtype, 3 = OUTPUT_TERMINAL
  960. 4, // bTerminalID
  961. //0x02, 0x03, // wTerminalType, 0x0302 = Headphones
  962. 0x02, 0x06, // wTerminalType, 0x0602 = Digital Audio
  963. 0, // bAssocTerminal, 0 = unidirectional
  964. 0x31, // bCSourceID, connected to feature, ID=31
  965. 0, // iTerminal
  966. // Standard AS Interface Descriptor
  967. // USB DCD for Audio Devices 1.0, Section 4.5.1, Table 4-18, page 59
  968. // Alternate 0: default setting, disabled zero bandwidth
  969. 9, // bLenght
  970. 4, // bDescriptorType = INTERFACE
  971. AUDIO_INTERFACE+1, // bInterfaceNumber
  972. 0, // bAlternateSetting
  973. 0, // bNumEndpoints
  974. 1, // bInterfaceClass, 1 = AUDIO
  975. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  976. 0, // bInterfaceProtocol
  977. 0, // iInterface
  978. // Alternate 1: streaming data
  979. 9, // bLenght
  980. 4, // bDescriptorType = INTERFACE
  981. AUDIO_INTERFACE+1, // bInterfaceNumber
  982. 1, // bAlternateSetting
  983. 1, // bNumEndpoints
  984. 1, // bInterfaceClass, 1 = AUDIO
  985. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  986. 0, // bInterfaceProtocol
  987. 0, // iInterface
  988. // Class-Specific AS Interface Descriptor
  989. // USB DCD for Audio Devices 1.0, Section 4.5.2, Table 4-19, page 60
  990. 7, // bLength
  991. 0x24, // bDescriptorType = CS_INTERFACE
  992. 1, // bDescriptorSubtype, 1 = AS_GENERAL
  993. 2, // bTerminalLink: Terminal ID = 2
  994. 3, // bDelay (approx 3ms delay, audio lib updates)
  995. 0x01, 0x00, // wFormatTag, 0x0001 = PCM
  996. // Type I Format Descriptor
  997. // USB DCD for Audio Data Formats 1.0, Section 2.2.5, Table 2-1, page 10
  998. 11, // bLength
  999. 0x24, // bDescriptorType = CS_INTERFACE
  1000. 2, // bDescriptorSubtype = FORMAT_TYPE
  1001. 1, // bFormatType = FORMAT_TYPE_I
  1002. 2, // bNrChannels = 2
  1003. 2, // bSubFrameSize = 2 byte
  1004. 16, // bBitResolution = 16 bits
  1005. 1, // bSamFreqType = 1 frequency
  1006. LSB(44100), MSB(44100), 0, // tSamFreq
  1007. // Standard AS Isochronous Audio Data Endpoint Descriptor
  1008. // USB DCD for Audio Devices 1.0, Section 4.6.1.1, Table 4-20, page 61-62
  1009. 9, // bLength
  1010. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  1011. AUDIO_TX_ENDPOINT | 0x80, // bEndpointAddress
  1012. 0x05, // bmAttributes = isochronous, asynchronous
  1013. LSB(AUDIO_TX_SIZE), MSB(AUDIO_TX_SIZE), // wMaxPacketSize
  1014. 1, // bInterval, 1 = every frame
  1015. 0, // bRefresh
  1016. 0, // bSynchAddress
  1017. // Class-Specific AS Isochronous Audio Data Endpoint Descriptor
  1018. // USB DCD for Audio Devices 1.0, Section 4.6.1.2, Table 4-21, page 62-63
  1019. 7, // bLength
  1020. 0x25, // bDescriptorType, 0x25 = CS_ENDPOINT
  1021. 1, // bDescriptorSubtype, 1 = EP_GENERAL
  1022. 0x00, // bmAttributes
  1023. 0, // bLockDelayUnits, 1 = ms
  1024. 0x00, 0x00, // wLockDelay
  1025. // Standard AS Interface Descriptor
  1026. // USB DCD for Audio Devices 1.0, Section 4.5.1, Table 4-18, page 59
  1027. // Alternate 0: default setting, disabled zero bandwidth
  1028. 9, // bLenght
  1029. 4, // bDescriptorType = INTERFACE
  1030. AUDIO_INTERFACE+2, // bInterfaceNumber
  1031. 0, // bAlternateSetting
  1032. 0, // bNumEndpoints
  1033. 1, // bInterfaceClass, 1 = AUDIO
  1034. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  1035. 0, // bInterfaceProtocol
  1036. 0, // iInterface
  1037. // Alternate 1: streaming data
  1038. 9, // bLenght
  1039. 4, // bDescriptorType = INTERFACE
  1040. AUDIO_INTERFACE+2, // bInterfaceNumber
  1041. 1, // bAlternateSetting
  1042. 2, // bNumEndpoints
  1043. 1, // bInterfaceClass, 1 = AUDIO
  1044. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  1045. 0, // bInterfaceProtocol
  1046. 0, // iInterface
  1047. // Class-Specific AS Interface Descriptor
  1048. // USB DCD for Audio Devices 1.0, Section 4.5.2, Table 4-19, page 60
  1049. 7, // bLength
  1050. 0x24, // bDescriptorType = CS_INTERFACE
  1051. 1, // bDescriptorSubtype, 1 = AS_GENERAL
  1052. 3, // bTerminalLink: Terminal ID = 3
  1053. 3, // bDelay (approx 3ms delay, audio lib updates)
  1054. 0x01, 0x00, // wFormatTag, 0x0001 = PCM
  1055. // Type I Format Descriptor
  1056. // USB DCD for Audio Data Formats 1.0, Section 2.2.5, Table 2-1, page 10
  1057. 11, // bLength
  1058. 0x24, // bDescriptorType = CS_INTERFACE
  1059. 2, // bDescriptorSubtype = FORMAT_TYPE
  1060. 1, // bFormatType = FORMAT_TYPE_I
  1061. 2, // bNrChannels = 2
  1062. 2, // bSubFrameSize = 2 byte
  1063. 16, // bBitResolution = 16 bits
  1064. 1, // bSamFreqType = 1 frequency
  1065. LSB(44100), MSB(44100), 0, // tSamFreq
  1066. // Standard AS Isochronous Audio Data Endpoint Descriptor
  1067. // USB DCD for Audio Devices 1.0, Section 4.6.1.1, Table 4-20, page 61-62
  1068. 9, // bLength
  1069. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  1070. AUDIO_RX_ENDPOINT, // bEndpointAddress
  1071. 0x05, // bmAttributes = isochronous, asynchronous
  1072. LSB(AUDIO_RX_SIZE), MSB(AUDIO_RX_SIZE), // wMaxPacketSize
  1073. 1, // bInterval, 1 = every frame
  1074. 0, // bRefresh
  1075. AUDIO_SYNC_ENDPOINT | 0x80, // bSynchAddress
  1076. // Class-Specific AS Isochronous Audio Data Endpoint Descriptor
  1077. // USB DCD for Audio Devices 1.0, Section 4.6.1.2, Table 4-21, page 62-63
  1078. 7, // bLength
  1079. 0x25, // bDescriptorType, 0x25 = CS_ENDPOINT
  1080. 1, // bDescriptorSubtype, 1 = EP_GENERAL
  1081. 0x00, // bmAttributes
  1082. 0, // bLockDelayUnits, 1 = ms
  1083. 0x00, 0x00, // wLockDelay
  1084. // Standard AS Isochronous Audio Synch Endpoint Descriptor
  1085. // USB DCD for Audio Devices 1.0, Section 4.6.2.1, Table 4-22, page 63-64
  1086. 9, // bLength
  1087. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  1088. AUDIO_SYNC_ENDPOINT | 0x80, // bEndpointAddress
  1089. 0x11, // bmAttributes = isochronous, feedback
  1090. 3, 0, // wMaxPacketSize, 3 bytes
  1091. 1, // bInterval, 1 = every frame
  1092. 5, // bRefresh, 5 = 32ms
  1093. 0, // bSynchAddress
  1094. #endif
  1095. #ifdef MULTITOUCH_INTERFACE
  1096. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1097. 9, // bLength
  1098. 4, // bDescriptorType
  1099. MULTITOUCH_INTERFACE, // bInterfaceNumber
  1100. 0, // bAlternateSetting
  1101. 1, // bNumEndpoints
  1102. 0x03, // bInterfaceClass (0x03 = HID)
  1103. 0x00, // bInterfaceSubClass
  1104. 0x00, // bInterfaceProtocol
  1105. 0, // iInterface
  1106. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1107. 9, // bLength
  1108. 0x21, // bDescriptorType
  1109. 0x11, 0x01, // bcdHID
  1110. 0, // bCountryCode
  1111. 1, // bNumDescriptors
  1112. 0x22, // bDescriptorType
  1113. LSB(sizeof(multitouch_report_desc)), // wDescriptorLength
  1114. MSB(sizeof(multitouch_report_desc)),
  1115. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1116. 7, // bLength
  1117. 5, // bDescriptorType
  1118. MULTITOUCH_ENDPOINT | 0x80, // bEndpointAddress
  1119. 0x03, // bmAttributes (0x03=intr)
  1120. MULTITOUCH_SIZE, 0, // wMaxPacketSize
  1121. 1, // bInterval
  1122. #endif // KEYMEDIA_INTERFACE
  1123. };
  1124. // **************************************************************
  1125. // String Descriptors
  1126. // **************************************************************
  1127. // The descriptors above can provide human readable strings,
  1128. // referenced by index numbers. These descriptors are the
  1129. // actual string data
  1130. /* defined in usb_names.h
  1131. struct usb_string_descriptor_struct {
  1132. uint8_t bLength;
  1133. uint8_t bDescriptorType;
  1134. uint16_t wString[];
  1135. };
  1136. */
  1137. extern struct usb_string_descriptor_struct usb_string_manufacturer_name
  1138. __attribute__ ((weak, alias("usb_string_manufacturer_name_default")));
  1139. extern struct usb_string_descriptor_struct usb_string_product_name
  1140. __attribute__ ((weak, alias("usb_string_product_name_default")));
  1141. extern struct usb_string_descriptor_struct usb_string_serial_number
  1142. __attribute__ ((weak, alias("usb_string_serial_number_default")));
  1143. struct usb_string_descriptor_struct string0 = {
  1144. 4,
  1145. 3,
  1146. {0x0409}
  1147. };
  1148. struct usb_string_descriptor_struct usb_string_manufacturer_name_default = {
  1149. 2 + MANUFACTURER_NAME_LEN * 2,
  1150. 3,
  1151. MANUFACTURER_NAME
  1152. };
  1153. struct usb_string_descriptor_struct usb_string_product_name_default = {
  1154. 2 + PRODUCT_NAME_LEN * 2,
  1155. 3,
  1156. PRODUCT_NAME
  1157. };
  1158. struct usb_string_descriptor_struct usb_string_serial_number_default = {
  1159. 12,
  1160. 3,
  1161. {0,0,0,0,0,0,0,0,0,0}
  1162. };
  1163. void usb_init_serialnumber(void)
  1164. {
  1165. char buf[11];
  1166. uint32_t i, num;
  1167. __disable_irq();
  1168. #if defined(HAS_KINETIS_FLASH_FTFA) || defined(HAS_KINETIS_FLASH_FTFL)
  1169. FTFL_FSTAT = FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL;
  1170. FTFL_FCCOB0 = 0x41;
  1171. FTFL_FCCOB1 = 15;
  1172. FTFL_FSTAT = FTFL_FSTAT_CCIF;
  1173. while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF)) ; // wait
  1174. num = *(uint32_t *)&FTFL_FCCOB7;
  1175. #elif defined(HAS_KINETIS_FLASH_FTFE)
  1176. kinetis_hsrun_disable();
  1177. FTFL_FSTAT = FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL;
  1178. *(uint32_t *)&FTFL_FCCOB3 = 0x41070000;
  1179. FTFL_FSTAT = FTFL_FSTAT_CCIF;
  1180. while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF)) ; // wait
  1181. num = *(uint32_t *)&FTFL_FCCOBB;
  1182. kinetis_hsrun_enable();
  1183. #endif
  1184. __enable_irq();
  1185. // add extra zero to work around OS-X CDC-ACM driver bug
  1186. if (num < 10000000) num = num * 10;
  1187. ultoa(num, buf, 10);
  1188. for (i=0; i<10; i++) {
  1189. char c = buf[i];
  1190. if (!c) break;
  1191. usb_string_serial_number_default.wString[i] = c;
  1192. }
  1193. usb_string_serial_number_default.bLength = i * 2 + 2;
  1194. }
  1195. // **************************************************************
  1196. // Descriptors List
  1197. // **************************************************************
  1198. // This table provides access to all the descriptor data above.
  1199. const usb_descriptor_list_t usb_descriptor_list[] = {
  1200. //wValue, wIndex, address, length
  1201. {0x0100, 0x0000, device_descriptor, sizeof(device_descriptor)},
  1202. {0x0200, 0x0000, config_descriptor, sizeof(config_descriptor)},
  1203. #ifdef SEREMU_INTERFACE
  1204. {0x2200, SEREMU_INTERFACE, seremu_report_desc, sizeof(seremu_report_desc)},
  1205. {0x2100, SEREMU_INTERFACE, config_descriptor+SEREMU_HID_DESC_OFFSET, 9},
  1206. #endif
  1207. #ifdef KEYBOARD_INTERFACE
  1208. {0x2200, KEYBOARD_INTERFACE, keyboard_report_desc, sizeof(keyboard_report_desc)},
  1209. {0x2100, KEYBOARD_INTERFACE, config_descriptor+KEYBOARD_HID_DESC_OFFSET, 9},
  1210. #endif
  1211. #ifdef MOUSE_INTERFACE
  1212. {0x2200, MOUSE_INTERFACE, mouse_report_desc, sizeof(mouse_report_desc)},
  1213. {0x2100, MOUSE_INTERFACE, config_descriptor+MOUSE_HID_DESC_OFFSET, 9},
  1214. #endif
  1215. #ifdef JOYSTICK_INTERFACE
  1216. {0x2200, JOYSTICK_INTERFACE, joystick_report_desc, sizeof(joystick_report_desc)},
  1217. {0x2100, JOYSTICK_INTERFACE, config_descriptor+JOYSTICK_HID_DESC_OFFSET, 9},
  1218. #endif
  1219. #ifdef RAWHID_INTERFACE
  1220. {0x2200, RAWHID_INTERFACE, rawhid_report_desc, sizeof(rawhid_report_desc)},
  1221. {0x2100, RAWHID_INTERFACE, config_descriptor+RAWHID_HID_DESC_OFFSET, 9},
  1222. #endif
  1223. #ifdef FLIGHTSIM_INTERFACE
  1224. {0x2200, FLIGHTSIM_INTERFACE, flightsim_report_desc, sizeof(flightsim_report_desc)},
  1225. {0x2100, FLIGHTSIM_INTERFACE, config_descriptor+FLIGHTSIM_HID_DESC_OFFSET, 9},
  1226. #endif
  1227. #ifdef KEYMEDIA_INTERFACE
  1228. {0x2200, KEYMEDIA_INTERFACE, keymedia_report_desc, sizeof(keymedia_report_desc)},
  1229. {0x2100, KEYMEDIA_INTERFACE, config_descriptor+KEYMEDIA_HID_DESC_OFFSET, 9},
  1230. #endif
  1231. #ifdef MULTITOUCH_INTERFACE
  1232. {0x2200, MULTITOUCH_INTERFACE, multitouch_report_desc, sizeof(multitouch_report_desc)},
  1233. {0x2100, MULTITOUCH_INTERFACE, config_descriptor+MULTITOUCH_HID_DESC_OFFSET, 9},
  1234. #endif
  1235. {0x0300, 0x0000, (const uint8_t *)&string0, 0},
  1236. {0x0301, 0x0409, (const uint8_t *)&usb_string_manufacturer_name, 0},
  1237. {0x0302, 0x0409, (const uint8_t *)&usb_string_product_name, 0},
  1238. {0x0303, 0x0409, (const uint8_t *)&usb_string_serial_number, 0},
  1239. {0, 0, NULL, 0}
  1240. };
  1241. // **************************************************************
  1242. // Endpoint Configuration
  1243. // **************************************************************
  1244. #if 0
  1245. // 0x00 = not used
  1246. // 0x19 = Recieve only
  1247. // 0x15 = Transmit only
  1248. // 0x1D = Transmit & Recieve
  1249. //
  1250. const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS] =
  1251. {
  1252. 0x00, 0x15, 0x19, 0x15, 0x00, 0x00, 0x00, 0x00,
  1253. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1254. };
  1255. #endif
  1256. const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS] =
  1257. {
  1258. #if (defined(ENDPOINT1_CONFIG) && NUM_ENDPOINTS >= 1)
  1259. ENDPOINT1_CONFIG,
  1260. #elif (NUM_ENDPOINTS >= 1)
  1261. ENDPOINT_UNUSED,
  1262. #endif
  1263. #if (defined(ENDPOINT2_CONFIG) && NUM_ENDPOINTS >= 2)
  1264. ENDPOINT2_CONFIG,
  1265. #elif (NUM_ENDPOINTS >= 2)
  1266. ENDPOINT_UNUSED,
  1267. #endif
  1268. #if (defined(ENDPOINT3_CONFIG) && NUM_ENDPOINTS >= 3)
  1269. ENDPOINT3_CONFIG,
  1270. #elif (NUM_ENDPOINTS >= 3)
  1271. ENDPOINT_UNUSED,
  1272. #endif
  1273. #if (defined(ENDPOINT4_CONFIG) && NUM_ENDPOINTS >= 4)
  1274. ENDPOINT4_CONFIG,
  1275. #elif (NUM_ENDPOINTS >= 4)
  1276. ENDPOINT_UNUSED,
  1277. #endif
  1278. #if (defined(ENDPOINT5_CONFIG) && NUM_ENDPOINTS >= 5)
  1279. ENDPOINT5_CONFIG,
  1280. #elif (NUM_ENDPOINTS >= 5)
  1281. ENDPOINT_UNUSED,
  1282. #endif
  1283. #if (defined(ENDPOINT6_CONFIG) && NUM_ENDPOINTS >= 6)
  1284. ENDPOINT6_CONFIG,
  1285. #elif (NUM_ENDPOINTS >= 6)
  1286. ENDPOINT_UNUSED,
  1287. #endif
  1288. #if (defined(ENDPOINT7_CONFIG) && NUM_ENDPOINTS >= 7)
  1289. ENDPOINT7_CONFIG,
  1290. #elif (NUM_ENDPOINTS >= 7)
  1291. ENDPOINT_UNUSED,
  1292. #endif
  1293. #if (defined(ENDPOINT8_CONFIG) && NUM_ENDPOINTS >= 8)
  1294. ENDPOINT8_CONFIG,
  1295. #elif (NUM_ENDPOINTS >= 8)
  1296. ENDPOINT_UNUSED,
  1297. #endif
  1298. #if (defined(ENDPOINT9_CONFIG) && NUM_ENDPOINTS >= 9)
  1299. ENDPOINT9_CONFIG,
  1300. #elif (NUM_ENDPOINTS >= 9)
  1301. ENDPOINT_UNUSED,
  1302. #endif
  1303. #if (defined(ENDPOINT10_CONFIG) && NUM_ENDPOINTS >= 10)
  1304. ENDPOINT10_CONFIG,
  1305. #elif (NUM_ENDPOINTS >= 10)
  1306. ENDPOINT_UNUSED,
  1307. #endif
  1308. #if (defined(ENDPOINT11_CONFIG) && NUM_ENDPOINTS >= 11)
  1309. ENDPOINT11_CONFIG,
  1310. #elif (NUM_ENDPOINTS >= 11)
  1311. ENDPOINT_UNUSED,
  1312. #endif
  1313. #if (defined(ENDPOINT12_CONFIG) && NUM_ENDPOINTS >= 12)
  1314. ENDPOINT12_CONFIG,
  1315. #elif (NUM_ENDPOINTS >= 12)
  1316. ENDPOINT_UNUSED,
  1317. #endif
  1318. #if (defined(ENDPOINT13_CONFIG) && NUM_ENDPOINTS >= 13)
  1319. ENDPOINT13_CONFIG,
  1320. #elif (NUM_ENDPOINTS >= 13)
  1321. ENDPOINT_UNUSED,
  1322. #endif
  1323. #if (defined(ENDPOINT14_CONFIG) && NUM_ENDPOINTS >= 14)
  1324. ENDPOINT14_CONFIG,
  1325. #elif (NUM_ENDPOINTS >= 14)
  1326. ENDPOINT_UNUSED,
  1327. #endif
  1328. #if (defined(ENDPOINT15_CONFIG) && NUM_ENDPOINTS >= 15)
  1329. ENDPOINT15_CONFIG,
  1330. #elif (NUM_ENDPOINTS >= 15)
  1331. ENDPOINT_UNUSED,
  1332. #endif
  1333. };
  1334. #endif // NUM_ENDPOINTS
  1335. #endif // F_CPU >= 20 MHz