Teensy 4.1 core updated for C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1479 lines
71KB

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