Teensy 4.1 core updated for C++20
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1083 lines
52KB

  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. 0x00, 0x02, // 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, 0x01, // 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, 0x08, // Report Count (8),
  110. 0x75, 0x01, // Report Size (1),
  111. 0x15, 0x00, // Logical Minimum (0),
  112. 0x25, 0x01, // Logical Maximum (1),
  113. 0x05, 0x0C, // Usage Page (Consumer),
  114. 0x09, 0xE9, // Usage (Volume Increment),
  115. 0x09, 0xEA, // Usage (Volume Decrement),
  116. 0x09, 0xE2, // Usage (Mute),
  117. 0x09, 0xCD, // Usage (Play/Pause),
  118. 0x09, 0xB5, // Usage (Scan Next Track),
  119. 0x09, 0xB6, // Usage (Scan Previous Track),
  120. 0x09, 0xB7, // Usage (Stop),
  121. 0x09, 0xB8, // Usage (Eject),
  122. 0x81, 0x02, // Input (Data, Variable, Absolute), ;Media keys
  123. 0x95, 0x05, // Report Count (5),
  124. 0x75, 0x01, // Report Size (1),
  125. 0x05, 0x08, // Usage Page (LEDs),
  126. 0x19, 0x01, // Usage Minimum (1),
  127. 0x29, 0x05, // Usage Maximum (5),
  128. 0x91, 0x02, // Output (Data, Variable, Absolute), ;LED report
  129. 0x95, 0x01, // Report Count (1),
  130. 0x75, 0x03, // Report Size (3),
  131. 0x91, 0x03, // Output (Constant), ;LED report padding
  132. 0x95, 0x06, // Report Count (6),
  133. 0x75, 0x08, // Report Size (8),
  134. 0x15, 0x00, // Logical Minimum (0),
  135. 0x25, 0x7F, // Logical Maximum(104),
  136. 0x05, 0x07, // Usage Page (Key Codes),
  137. 0x19, 0x00, // Usage Minimum (0),
  138. 0x29, 0x7F, // Usage Maximum (104),
  139. 0x81, 0x00, // Input (Data, Array), ;Normal keys
  140. 0xC0 // End Collection
  141. };
  142. #endif
  143. #ifdef KEYMEDIA_INTERFACE
  144. static uint8_t keymedia_report_desc[] = {
  145. 0x05, 0x0C, // Usage Page (Consumer)
  146. 0x09, 0x01, // Usage (Consumer Controls)
  147. 0xA1, 0x01, // Collection (Application)
  148. 0x75, 0x0A, // Report Size (10)
  149. 0x95, 0x04, // Report Count (4)
  150. 0x19, 0x00, // Usage Minimum (0)
  151. 0x2A, 0x9C, 0x02, // Usage Maximum (0x29C)
  152. 0x15, 0x00, // Logical Minimum (0)
  153. 0x26, 0x9C, 0x02, // Logical Maximum (0x29C)
  154. 0x81, 0x00, // Input (Data, Array)
  155. 0xC0, // End Collection
  156. 0x05, 0x01, // Usage Page (Generic Desktop)
  157. 0x09, 0x80, // Usage (System Control)
  158. 0xA1, 0x01, // Collection (Application)
  159. 0x75, 0x08, // Report Size (8)
  160. 0x95, 0x03, // Report Count (3)
  161. 0x19, 0x00, // Usage Minimum (0)
  162. 0x29, 0xB7, // Usage Maximum (0xB7)
  163. 0x15, 0x00, // Logical Minimum (0)
  164. 0x26, 0xB7, 0x00, // Logical Maximum (0xB7)
  165. 0x81, 0x00, // Input (Data, Array)
  166. 0xC0 // End Collection
  167. };
  168. #endif
  169. #ifdef MOUSE_INTERFACE
  170. // Mouse Protocol 1, HID 1.11 spec, Appendix B, page 59-60, with wheel extension
  171. static uint8_t mouse_report_desc[] = {
  172. 0x05, 0x01, // Usage Page (Generic Desktop)
  173. 0x09, 0x02, // Usage (Mouse)
  174. 0xA1, 0x01, // Collection (Application)
  175. 0x85, 0x01, // REPORT_ID (1)
  176. 0x05, 0x09, // Usage Page (Button)
  177. 0x19, 0x01, // Usage Minimum (Button #1)
  178. 0x29, 0x08, // Usage Maximum (Button #8)
  179. 0x15, 0x00, // Logical Minimum (0)
  180. 0x25, 0x01, // Logical Maximum (1)
  181. 0x95, 0x08, // Report Count (8)
  182. 0x75, 0x01, // Report Size (1)
  183. 0x81, 0x02, // Input (Data, Variable, Absolute)
  184. 0x05, 0x01, // Usage Page (Generic Desktop)
  185. 0x09, 0x30, // Usage (X)
  186. 0x09, 0x31, // Usage (Y)
  187. 0x09, 0x38, // Usage (Wheel)
  188. 0x15, 0x81, // Logical Minimum (-127)
  189. 0x25, 0x7F, // Logical Maximum (127)
  190. 0x75, 0x08, // Report Size (8),
  191. 0x95, 0x03, // Report Count (3),
  192. 0x81, 0x06, // Input (Data, Variable, Relative)
  193. 0xC0, // End Collection
  194. 0x05, 0x01, // Usage Page (Generic Desktop)
  195. 0x09, 0x02, // Usage (Mouse)
  196. 0xA1, 0x01, // Collection (Application)
  197. 0x85, 0x02, // REPORT_ID (2)
  198. 0x05, 0x01, // Usage Page (Generic Desktop)
  199. 0x09, 0x30, // Usage (X)
  200. 0x09, 0x31, // Usage (Y)
  201. 0x15, 0x00, // Logical Minimum (0)
  202. 0x26, 0xFF, 0x7F, // Logical Maximum (32767)
  203. 0x75, 0x10, // Report Size (16),
  204. 0x95, 0x02, // Report Count (2),
  205. 0x81, 0x02, // Input (Data, Variable, Absolute)
  206. 0xC0 // End Collection
  207. };
  208. #endif
  209. #ifdef JOYSTICK_INTERFACE
  210. static uint8_t joystick_report_desc[] = {
  211. 0x05, 0x01, // Usage Page (Generic Desktop)
  212. 0x09, 0x04, // Usage (Joystick)
  213. 0xA1, 0x01, // Collection (Application)
  214. 0x15, 0x00, // Logical Minimum (0)
  215. 0x25, 0x01, // Logical Maximum (1)
  216. 0x75, 0x01, // Report Size (1)
  217. 0x95, 0x20, // Report Count (32)
  218. 0x05, 0x09, // Usage Page (Button)
  219. 0x19, 0x01, // Usage Minimum (Button #1)
  220. 0x29, 0x20, // Usage Maximum (Button #32)
  221. 0x81, 0x02, // Input (variable,absolute)
  222. 0x15, 0x00, // Logical Minimum (0)
  223. 0x25, 0x07, // Logical Maximum (7)
  224. 0x35, 0x00, // Physical Minimum (0)
  225. 0x46, 0x3B, 0x01, // Physical Maximum (315)
  226. 0x75, 0x04, // Report Size (4)
  227. 0x95, 0x01, // Report Count (1)
  228. 0x65, 0x14, // Unit (20)
  229. 0x05, 0x01, // Usage Page (Generic Desktop)
  230. 0x09, 0x39, // Usage (Hat switch)
  231. 0x81, 0x42, // Input (variable,absolute,null_state)
  232. 0x05, 0x01, // Usage Page (Generic Desktop)
  233. 0x09, 0x01, // Usage (Pointer)
  234. 0xA1, 0x00, // Collection ()
  235. 0x15, 0x00, // Logical Minimum (0)
  236. 0x26, 0xFF, 0x03, // Logical Maximum (1023)
  237. 0x75, 0x0A, // Report Size (10)
  238. 0x95, 0x04, // Report Count (4)
  239. 0x09, 0x30, // Usage (X)
  240. 0x09, 0x31, // Usage (Y)
  241. 0x09, 0x32, // Usage (Z)
  242. 0x09, 0x35, // Usage (Rz)
  243. 0x81, 0x02, // Input (variable,absolute)
  244. 0xC0, // End Collection
  245. 0x15, 0x00, // Logical Minimum (0)
  246. 0x26, 0xFF, 0x03, // Logical Maximum (1023)
  247. 0x75, 0x0A, // Report Size (10)
  248. 0x95, 0x02, // Report Count (2)
  249. 0x09, 0x36, // Usage (Slider)
  250. 0x09, 0x36, // Usage (Slider)
  251. 0x81, 0x02, // Input (variable,absolute)
  252. 0xC0 // End Collection
  253. };
  254. #endif
  255. #ifdef SEREMU_INTERFACE
  256. static uint8_t seremu_report_desc[] = {
  257. 0x06, 0xC9, 0xFF, // Usage Page 0xFFC9 (vendor defined)
  258. 0x09, 0x04, // Usage 0x04
  259. 0xA1, 0x5C, // Collection 0x5C
  260. 0x75, 0x08, // report size = 8 bits (global)
  261. 0x15, 0x00, // logical minimum = 0 (global)
  262. 0x26, 0xFF, 0x00, // logical maximum = 255 (global)
  263. 0x95, SEREMU_TX_SIZE, // report count (global)
  264. 0x09, 0x75, // usage (local)
  265. 0x81, 0x02, // Input
  266. 0x95, SEREMU_RX_SIZE, // report count (global)
  267. 0x09, 0x76, // usage (local)
  268. 0x91, 0x02, // Output
  269. 0x95, 0x04, // report count (global)
  270. 0x09, 0x76, // usage (local)
  271. 0xB1, 0x02, // Feature
  272. 0xC0 // end collection
  273. };
  274. #endif
  275. #ifdef RAWHID_INTERFACE
  276. static uint8_t rawhid_report_desc[] = {
  277. 0x06, LSB(RAWHID_USAGE_PAGE), MSB(RAWHID_USAGE_PAGE),
  278. 0x0A, LSB(RAWHID_USAGE), MSB(RAWHID_USAGE),
  279. 0xA1, 0x01, // Collection 0x01
  280. 0x75, 0x08, // report size = 8 bits
  281. 0x15, 0x00, // logical minimum = 0
  282. 0x26, 0xFF, 0x00, // logical maximum = 255
  283. 0x95, RAWHID_TX_SIZE, // report count
  284. 0x09, 0x01, // usage
  285. 0x81, 0x02, // Input (array)
  286. 0x95, RAWHID_RX_SIZE, // report count
  287. 0x09, 0x02, // usage
  288. 0x91, 0x02, // Output (array)
  289. 0xC0 // end collection
  290. };
  291. #endif
  292. #ifdef FLIGHTSIM_INTERFACE
  293. static uint8_t flightsim_report_desc[] = {
  294. 0x06, 0x1C, 0xFF, // Usage page = 0xFF1C
  295. 0x0A, 0x39, 0xA7, // Usage = 0xA739
  296. 0xA1, 0x01, // Collection 0x01
  297. 0x75, 0x08, // report size = 8 bits
  298. 0x15, 0x00, // logical minimum = 0
  299. 0x26, 0xFF, 0x00, // logical maximum = 255
  300. 0x95, FLIGHTSIM_TX_SIZE, // report count
  301. 0x09, 0x01, // usage
  302. 0x81, 0x02, // Input (array)
  303. 0x95, FLIGHTSIM_RX_SIZE, // report count
  304. 0x09, 0x02, // usage
  305. 0x91, 0x02, // Output (array)
  306. 0xC0 // end collection
  307. };
  308. #endif
  309. // **************************************************************
  310. // USB Descriptor Sizes
  311. // **************************************************************
  312. // pre-compute the size and position of everything in the config descriptor
  313. //
  314. #define CONFIG_HEADER_DESCRIPTOR_SIZE 9
  315. #define CDC_IAD_DESCRIPTOR_POS CONFIG_HEADER_DESCRIPTOR_SIZE
  316. #ifdef CDC_IAD_DESCRIPTOR
  317. #define CDC_IAD_DESCRIPTOR_SIZE 8
  318. #else
  319. #define CDC_IAD_DESCRIPTOR_SIZE 0
  320. #endif
  321. #define CDC_DATA_INTERFACE_DESC_POS CDC_IAD_DESCRIPTOR_POS+CDC_IAD_DESCRIPTOR_SIZE
  322. #ifdef CDC_DATA_INTERFACE
  323. #define CDC_DATA_INTERFACE_DESC_SIZE 9+5+5+4+5+7+9+7+7
  324. #else
  325. #define CDC_DATA_INTERFACE_DESC_SIZE 0
  326. #endif
  327. #define MIDI_INTERFACE_DESC_POS CDC_DATA_INTERFACE_DESC_POS+CDC_DATA_INTERFACE_DESC_SIZE
  328. #ifdef MIDI_INTERFACE
  329. #define MIDI_INTERFACE_DESC_SIZE 9+7+6+6+9+9+9+5+9+5
  330. #else
  331. #define MIDI_INTERFACE_DESC_SIZE 0
  332. #endif
  333. #define KEYBOARD_INTERFACE_DESC_POS MIDI_INTERFACE_DESC_POS+MIDI_INTERFACE_DESC_SIZE
  334. #ifdef KEYBOARD_INTERFACE
  335. #define KEYBOARD_INTERFACE_DESC_SIZE 9+9+7
  336. #define KEYBOARD_HID_DESC_OFFSET KEYBOARD_INTERFACE_DESC_POS+9
  337. #else
  338. #define KEYBOARD_INTERFACE_DESC_SIZE 0
  339. #endif
  340. #define MOUSE_INTERFACE_DESC_POS KEYBOARD_INTERFACE_DESC_POS+KEYBOARD_INTERFACE_DESC_SIZE
  341. #ifdef MOUSE_INTERFACE
  342. #define MOUSE_INTERFACE_DESC_SIZE 9+9+7
  343. #define MOUSE_HID_DESC_OFFSET MOUSE_INTERFACE_DESC_POS+9
  344. #else
  345. #define MOUSE_INTERFACE_DESC_SIZE 0
  346. #endif
  347. #define RAWHID_INTERFACE_DESC_POS MOUSE_INTERFACE_DESC_POS+MOUSE_INTERFACE_DESC_SIZE
  348. #ifdef RAWHID_INTERFACE
  349. #define RAWHID_INTERFACE_DESC_SIZE 9+9+7+7
  350. #define RAWHID_HID_DESC_OFFSET RAWHID_INTERFACE_DESC_POS+9
  351. #else
  352. #define RAWHID_INTERFACE_DESC_SIZE 0
  353. #endif
  354. #define FLIGHTSIM_INTERFACE_DESC_POS RAWHID_INTERFACE_DESC_POS+RAWHID_INTERFACE_DESC_SIZE
  355. #ifdef FLIGHTSIM_INTERFACE
  356. #define FLIGHTSIM_INTERFACE_DESC_SIZE 9+9+7+7
  357. #define FLIGHTSIM_HID_DESC_OFFSET FLIGHTSIM_INTERFACE_DESC_POS+9
  358. #else
  359. #define FLIGHTSIM_INTERFACE_DESC_SIZE 0
  360. #endif
  361. #define SEREMU_INTERFACE_DESC_POS FLIGHTSIM_INTERFACE_DESC_POS+FLIGHTSIM_INTERFACE_DESC_SIZE
  362. #ifdef SEREMU_INTERFACE
  363. #define SEREMU_INTERFACE_DESC_SIZE 9+9+7+7
  364. #define SEREMU_HID_DESC_OFFSET SEREMU_INTERFACE_DESC_POS+9
  365. #else
  366. #define SEREMU_INTERFACE_DESC_SIZE 0
  367. #endif
  368. #define JOYSTICK_INTERFACE_DESC_POS SEREMU_INTERFACE_DESC_POS+SEREMU_INTERFACE_DESC_SIZE
  369. #ifdef JOYSTICK_INTERFACE
  370. #define JOYSTICK_INTERFACE_DESC_SIZE 9+9+7
  371. #define JOYSTICK_HID_DESC_OFFSET JOYSTICK_INTERFACE_DESC_POS+9
  372. #else
  373. #define JOYSTICK_INTERFACE_DESC_SIZE 0
  374. #endif
  375. #define MTP_INTERFACE_DESC_POS JOYSTICK_INTERFACE_DESC_POS+JOYSTICK_INTERFACE_DESC_SIZE
  376. #ifdef MTP_INTERFACE
  377. #define MTP_INTERFACE_DESC_SIZE 9+7+7+7
  378. #else
  379. #define MTP_INTERFACE_DESC_SIZE 0
  380. #endif
  381. #define KEYMEDIA_INTERFACE_DESC_POS MTP_INTERFACE_DESC_POS+MTP_INTERFACE_DESC_SIZE
  382. #ifdef KEYMEDIA_INTERFACE
  383. #define KEYMEDIA_INTERFACE_DESC_SIZE 9+9+7
  384. #define KEYMEDIA_HID_DESC_OFFSET KEYMEDIA_INTERFACE_DESC_POS+9
  385. #else
  386. #define KEYMEDIA_INTERFACE_DESC_SIZE 0
  387. #endif
  388. #define CONFIG_DESC_SIZE KEYMEDIA_INTERFACE_DESC_POS+KEYMEDIA_INTERFACE_DESC_SIZE
  389. // **************************************************************
  390. // USB Configuration
  391. // **************************************************************
  392. // USB Configuration Descriptor. This huge descriptor tells all
  393. // of the devices capbilities.
  394. static uint8_t config_descriptor[CONFIG_DESC_SIZE] = {
  395. // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
  396. 9, // bLength;
  397. 2, // bDescriptorType;
  398. LSB(CONFIG_DESC_SIZE), // wTotalLength
  399. MSB(CONFIG_DESC_SIZE),
  400. NUM_INTERFACE, // bNumInterfaces
  401. 1, // bConfigurationValue
  402. 0, // iConfiguration
  403. 0xC0, // bmAttributes
  404. 50, // bMaxPower
  405. #ifdef CDC_IAD_DESCRIPTOR
  406. // interface association descriptor, USB ECN, Table 9-Z
  407. 8, // bLength
  408. 11, // bDescriptorType
  409. CDC_STATUS_INTERFACE, // bFirstInterface
  410. 2, // bInterfaceCount
  411. 0x02, // bFunctionClass
  412. 0x02, // bFunctionSubClass
  413. 0x01, // bFunctionProtocol
  414. 4, // iFunction
  415. #endif
  416. #ifdef CDC_DATA_INTERFACE
  417. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  418. 9, // bLength
  419. 4, // bDescriptorType
  420. CDC_STATUS_INTERFACE, // bInterfaceNumber
  421. 0, // bAlternateSetting
  422. 1, // bNumEndpoints
  423. 0x02, // bInterfaceClass
  424. 0x02, // bInterfaceSubClass
  425. 0x01, // bInterfaceProtocol
  426. 0, // iInterface
  427. // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26
  428. 5, // bFunctionLength
  429. 0x24, // bDescriptorType
  430. 0x00, // bDescriptorSubtype
  431. 0x10, 0x01, // bcdCDC
  432. // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27
  433. 5, // bFunctionLength
  434. 0x24, // bDescriptorType
  435. 0x01, // bDescriptorSubtype
  436. 0x01, // bmCapabilities
  437. 1, // bDataInterface
  438. // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28
  439. 4, // bFunctionLength
  440. 0x24, // bDescriptorType
  441. 0x02, // bDescriptorSubtype
  442. 0x06, // bmCapabilities
  443. // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33
  444. 5, // bFunctionLength
  445. 0x24, // bDescriptorType
  446. 0x06, // bDescriptorSubtype
  447. CDC_STATUS_INTERFACE, // bMasterInterface
  448. CDC_DATA_INTERFACE, // bSlaveInterface0
  449. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  450. 7, // bLength
  451. 5, // bDescriptorType
  452. CDC_ACM_ENDPOINT | 0x80, // bEndpointAddress
  453. 0x03, // bmAttributes (0x03=intr)
  454. CDC_ACM_SIZE, 0, // wMaxPacketSize
  455. 64, // bInterval
  456. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  457. 9, // bLength
  458. 4, // bDescriptorType
  459. CDC_DATA_INTERFACE, // bInterfaceNumber
  460. 0, // bAlternateSetting
  461. 2, // bNumEndpoints
  462. 0x0A, // bInterfaceClass
  463. 0x00, // bInterfaceSubClass
  464. 0x00, // bInterfaceProtocol
  465. 0, // iInterface
  466. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  467. 7, // bLength
  468. 5, // bDescriptorType
  469. CDC_RX_ENDPOINT, // bEndpointAddress
  470. 0x02, // bmAttributes (0x02=bulk)
  471. CDC_RX_SIZE, 0, // wMaxPacketSize
  472. 0, // bInterval
  473. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  474. 7, // bLength
  475. 5, // bDescriptorType
  476. CDC_TX_ENDPOINT | 0x80, // bEndpointAddress
  477. 0x02, // bmAttributes (0x02=bulk)
  478. CDC_TX_SIZE, 0, // wMaxPacketSize
  479. 0, // bInterval
  480. #endif // CDC_DATA_INTERFACE
  481. #ifdef MIDI_INTERFACE
  482. // Standard MS Interface Descriptor,
  483. 9, // bLength
  484. 4, // bDescriptorType
  485. MIDI_INTERFACE, // bInterfaceNumber
  486. 0, // bAlternateSetting
  487. 2, // bNumEndpoints
  488. 0x01, // bInterfaceClass (0x01 = Audio)
  489. 0x03, // bInterfaceSubClass (0x03 = MIDI)
  490. 0x00, // bInterfaceProtocol (unused for MIDI)
  491. 0, // iInterface
  492. // MIDI MS Interface Header, USB MIDI 6.1.2.1, page 21, Table 6-2
  493. 7, // bLength
  494. 0x24, // bDescriptorType = CS_INTERFACE
  495. 0x01, // bDescriptorSubtype = MS_HEADER
  496. 0x00, 0x01, // bcdMSC = revision 01.00
  497. 0x41, 0x00, // wTotalLength
  498. // MIDI IN Jack Descriptor, B.4.3, Table B-7 (embedded), page 40
  499. 6, // bLength
  500. 0x24, // bDescriptorType = CS_INTERFACE
  501. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  502. 0x01, // bJackType = EMBEDDED
  503. 1, // bJackID, ID = 1
  504. 0, // iJack
  505. // MIDI IN Jack Descriptor, B.4.3, Table B-8 (external), page 40
  506. 6, // bLength
  507. 0x24, // bDescriptorType = CS_INTERFACE
  508. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  509. 0x02, // bJackType = EXTERNAL
  510. 2, // bJackID, ID = 2
  511. 0, // iJack
  512. // MIDI OUT Jack Descriptor, B.4.4, Table B-9, page 41
  513. 9,
  514. 0x24, // bDescriptorType = CS_INTERFACE
  515. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  516. 0x01, // bJackType = EMBEDDED
  517. 3, // bJackID, ID = 3
  518. 1, // bNrInputPins = 1 pin
  519. 2, // BaSourceID(1) = 2
  520. 1, // BaSourcePin(1) = first pin
  521. 0, // iJack
  522. // MIDI OUT Jack Descriptor, B.4.4, Table B-10, page 41
  523. 9,
  524. 0x24, // bDescriptorType = CS_INTERFACE
  525. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  526. 0x02, // bJackType = EXTERNAL
  527. 4, // bJackID, ID = 4
  528. 1, // bNrInputPins = 1 pin
  529. 1, // BaSourceID(1) = 1
  530. 1, // BaSourcePin(1) = first pin
  531. 0, // iJack
  532. // Standard Bulk OUT Endpoint Descriptor, B.5.1, Table B-11, pae 42
  533. 9, // bLength
  534. 5, // bDescriptorType = ENDPOINT
  535. MIDI_RX_ENDPOINT, // bEndpointAddress
  536. 0x02, // bmAttributes (0x02=bulk)
  537. MIDI_RX_SIZE, 0, // wMaxPacketSize
  538. 0, // bInterval
  539. 0, // bRefresh
  540. 0, // bSynchAddress
  541. // Class-specific MS Bulk OUT Endpoint Descriptor, B.5.2, Table B-12, page 42
  542. 5, // bLength
  543. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  544. 0x01, // bJackType = MS_GENERAL
  545. 1, // bNumEmbMIDIJack = 1 jack
  546. 1, // BaAssocJackID(1) = jack ID #1
  547. // Standard Bulk IN Endpoint Descriptor, B.5.1, Table B-11, pae 42
  548. 9, // bLength
  549. 5, // bDescriptorType = ENDPOINT
  550. MIDI_TX_ENDPOINT | 0x80, // bEndpointAddress
  551. 0x02, // bmAttributes (0x02=bulk)
  552. MIDI_TX_SIZE, 0, // wMaxPacketSize
  553. 0, // bInterval
  554. 0, // bRefresh
  555. 0, // bSynchAddress
  556. // Class-specific MS Bulk IN Endpoint Descriptor, B.5.2, Table B-12, page 42
  557. 5, // bLength
  558. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  559. 0x01, // bJackType = MS_GENERAL
  560. 1, // bNumEmbMIDIJack = 1 jack
  561. 3, // BaAssocJackID(1) = jack ID #3
  562. #endif // MIDI_INTERFACE
  563. #ifdef KEYBOARD_INTERFACE
  564. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  565. 9, // bLength
  566. 4, // bDescriptorType
  567. KEYBOARD_INTERFACE, // bInterfaceNumber
  568. 0, // bAlternateSetting
  569. 1, // bNumEndpoints
  570. 0x03, // bInterfaceClass (0x03 = HID)
  571. 0x01, // bInterfaceSubClass (0x01 = Boot)
  572. 0x01, // bInterfaceProtocol (0x01 = Keyboard)
  573. 0, // iInterface
  574. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  575. 9, // bLength
  576. 0x21, // bDescriptorType
  577. 0x11, 0x01, // bcdHID
  578. 0, // bCountryCode
  579. 1, // bNumDescriptors
  580. 0x22, // bDescriptorType
  581. LSB(sizeof(keyboard_report_desc)), // wDescriptorLength
  582. MSB(sizeof(keyboard_report_desc)),
  583. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  584. 7, // bLength
  585. 5, // bDescriptorType
  586. KEYBOARD_ENDPOINT | 0x80, // bEndpointAddress
  587. 0x03, // bmAttributes (0x03=intr)
  588. KEYBOARD_SIZE, 0, // wMaxPacketSize
  589. KEYBOARD_INTERVAL, // bInterval
  590. #endif // KEYBOARD_INTERFACE
  591. #ifdef MOUSE_INTERFACE
  592. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  593. 9, // bLength
  594. 4, // bDescriptorType
  595. MOUSE_INTERFACE, // bInterfaceNumber
  596. 0, // bAlternateSetting
  597. 1, // bNumEndpoints
  598. 0x03, // bInterfaceClass (0x03 = HID)
  599. 0x00, // bInterfaceSubClass (0x01 = Boot)
  600. 0x00, // bInterfaceProtocol (0x02 = Mouse)
  601. 0, // iInterface
  602. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  603. 9, // bLength
  604. 0x21, // bDescriptorType
  605. 0x11, 0x01, // bcdHID
  606. 0, // bCountryCode
  607. 1, // bNumDescriptors
  608. 0x22, // bDescriptorType
  609. LSB(sizeof(mouse_report_desc)), // wDescriptorLength
  610. MSB(sizeof(mouse_report_desc)),
  611. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  612. 7, // bLength
  613. 5, // bDescriptorType
  614. MOUSE_ENDPOINT | 0x80, // bEndpointAddress
  615. 0x03, // bmAttributes (0x03=intr)
  616. MOUSE_SIZE, 0, // wMaxPacketSize
  617. MOUSE_INTERVAL, // bInterval
  618. #endif // MOUSE_INTERFACE
  619. #ifdef RAWHID_INTERFACE
  620. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  621. 9, // bLength
  622. 4, // bDescriptorType
  623. RAWHID_INTERFACE, // bInterfaceNumber
  624. 0, // bAlternateSetting
  625. 2, // bNumEndpoints
  626. 0x03, // bInterfaceClass (0x03 = HID)
  627. 0x00, // bInterfaceSubClass
  628. 0x00, // bInterfaceProtocol
  629. 0, // iInterface
  630. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  631. 9, // bLength
  632. 0x21, // bDescriptorType
  633. 0x11, 0x01, // bcdHID
  634. 0, // bCountryCode
  635. 1, // bNumDescriptors
  636. 0x22, // bDescriptorType
  637. LSB(sizeof(rawhid_report_desc)), // wDescriptorLength
  638. MSB(sizeof(rawhid_report_desc)),
  639. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  640. 7, // bLength
  641. 5, // bDescriptorType
  642. RAWHID_TX_ENDPOINT | 0x80, // bEndpointAddress
  643. 0x03, // bmAttributes (0x03=intr)
  644. RAWHID_TX_SIZE, 0, // wMaxPacketSize
  645. RAWHID_TX_INTERVAL, // bInterval
  646. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  647. 7, // bLength
  648. 5, // bDescriptorType
  649. RAWHID_RX_ENDPOINT, // bEndpointAddress
  650. 0x03, // bmAttributes (0x03=intr)
  651. RAWHID_RX_SIZE, 0, // wMaxPacketSize
  652. RAWHID_RX_INTERVAL, // bInterval
  653. #endif // RAWHID_INTERFACE
  654. #ifdef FLIGHTSIM_INTERFACE
  655. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  656. 9, // bLength
  657. 4, // bDescriptorType
  658. FLIGHTSIM_INTERFACE, // bInterfaceNumber
  659. 0, // bAlternateSetting
  660. 2, // bNumEndpoints
  661. 0x03, // bInterfaceClass (0x03 = HID)
  662. 0x00, // bInterfaceSubClass
  663. 0x00, // bInterfaceProtocol
  664. 0, // iInterface
  665. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  666. 9, // bLength
  667. 0x21, // bDescriptorType
  668. 0x11, 0x01, // bcdHID
  669. 0, // bCountryCode
  670. 1, // bNumDescriptors
  671. 0x22, // bDescriptorType
  672. LSB(sizeof(flightsim_report_desc)), // wDescriptorLength
  673. MSB(sizeof(flightsim_report_desc)),
  674. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  675. 7, // bLength
  676. 5, // bDescriptorType
  677. FLIGHTSIM_TX_ENDPOINT | 0x80, // bEndpointAddress
  678. 0x03, // bmAttributes (0x03=intr)
  679. FLIGHTSIM_TX_SIZE, 0, // wMaxPacketSize
  680. FLIGHTSIM_TX_INTERVAL, // bInterval
  681. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  682. 7, // bLength
  683. 5, // bDescriptorType
  684. FLIGHTSIM_RX_ENDPOINT, // bEndpointAddress
  685. 0x03, // bmAttributes (0x03=intr)
  686. FLIGHTSIM_RX_SIZE, 0, // wMaxPacketSize
  687. FLIGHTSIM_RX_INTERVAL, // bInterval
  688. #endif // FLIGHTSIM_INTERFACE
  689. #ifdef SEREMU_INTERFACE
  690. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  691. 9, // bLength
  692. 4, // bDescriptorType
  693. SEREMU_INTERFACE, // bInterfaceNumber
  694. 0, // bAlternateSetting
  695. 2, // bNumEndpoints
  696. 0x03, // bInterfaceClass (0x03 = HID)
  697. 0x00, // bInterfaceSubClass
  698. 0x00, // bInterfaceProtocol
  699. 0, // iInterface
  700. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  701. 9, // bLength
  702. 0x21, // bDescriptorType
  703. 0x11, 0x01, // bcdHID
  704. 0, // bCountryCode
  705. 1, // bNumDescriptors
  706. 0x22, // bDescriptorType
  707. LSB(sizeof(seremu_report_desc)), // wDescriptorLength
  708. MSB(sizeof(seremu_report_desc)),
  709. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  710. 7, // bLength
  711. 5, // bDescriptorType
  712. SEREMU_TX_ENDPOINT | 0x80, // bEndpointAddress
  713. 0x03, // bmAttributes (0x03=intr)
  714. SEREMU_TX_SIZE, 0, // wMaxPacketSize
  715. SEREMU_TX_INTERVAL, // bInterval
  716. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  717. 7, // bLength
  718. 5, // bDescriptorType
  719. SEREMU_RX_ENDPOINT, // bEndpointAddress
  720. 0x03, // bmAttributes (0x03=intr)
  721. SEREMU_RX_SIZE, 0, // wMaxPacketSize
  722. SEREMU_RX_INTERVAL, // bInterval
  723. #endif // SEREMU_INTERFACE
  724. #ifdef JOYSTICK_INTERFACE
  725. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  726. 9, // bLength
  727. 4, // bDescriptorType
  728. JOYSTICK_INTERFACE, // bInterfaceNumber
  729. 0, // bAlternateSetting
  730. 1, // bNumEndpoints
  731. 0x03, // bInterfaceClass (0x03 = HID)
  732. 0x00, // bInterfaceSubClass
  733. 0x00, // bInterfaceProtocol
  734. 0, // iInterface
  735. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  736. 9, // bLength
  737. 0x21, // bDescriptorType
  738. 0x11, 0x01, // bcdHID
  739. 0, // bCountryCode
  740. 1, // bNumDescriptors
  741. 0x22, // bDescriptorType
  742. LSB(sizeof(joystick_report_desc)), // wDescriptorLength
  743. MSB(sizeof(joystick_report_desc)),
  744. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  745. 7, // bLength
  746. 5, // bDescriptorType
  747. JOYSTICK_ENDPOINT | 0x80, // bEndpointAddress
  748. 0x03, // bmAttributes (0x03=intr)
  749. JOYSTICK_SIZE, 0, // wMaxPacketSize
  750. JOYSTICK_INTERVAL, // bInterval
  751. #endif // JOYSTICK_INTERFACE
  752. #ifdef MTP_INTERFACE
  753. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  754. 9, // bLength
  755. 4, // bDescriptorType
  756. MTP_INTERFACE, // bInterfaceNumber
  757. 0, // bAlternateSetting
  758. 3, // bNumEndpoints
  759. 0x06, // bInterfaceClass (0x06 = still image)
  760. 0x01, // bInterfaceSubClass
  761. 0x01, // bInterfaceProtocol
  762. 0, // iInterface
  763. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  764. 7, // bLength
  765. 5, // bDescriptorType
  766. MTP_TX_ENDPOINT | 0x80, // bEndpointAddress
  767. 0x02, // bmAttributes (0x02=bulk)
  768. MTP_TX_SIZE, 0, // wMaxPacketSize
  769. 0, // bInterval
  770. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  771. 7, // bLength
  772. 5, // bDescriptorType
  773. MTP_RX_ENDPOINT, // bEndpointAddress
  774. 0x02, // bmAttributes (0x02=bulk)
  775. MTP_RX_SIZE, 0, // wMaxPacketSize
  776. 0, // bInterval
  777. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  778. 7, // bLength
  779. 5, // bDescriptorType
  780. MTP_EVENT_ENDPOINT | 0x80, // bEndpointAddress
  781. 0x03, // bmAttributes (0x03=intr)
  782. MTP_EVENT_SIZE, 0, // wMaxPacketSize
  783. MTP_EVENT_INTERVAL, // bInterval
  784. #endif // MTP_INTERFACE
  785. #ifdef KEYMEDIA_INTERFACE
  786. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  787. 9, // bLength
  788. 4, // bDescriptorType
  789. KEYMEDIA_INTERFACE, // bInterfaceNumber
  790. 0, // bAlternateSetting
  791. 1, // 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(keymedia_report_desc)), // wDescriptorLength
  804. MSB(sizeof(keymedia_report_desc)),
  805. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  806. 7, // bLength
  807. 5, // bDescriptorType
  808. KEYMEDIA_ENDPOINT | 0x80, // bEndpointAddress
  809. 0x03, // bmAttributes (0x03=intr)
  810. KEYMEDIA_SIZE, 0, // wMaxPacketSize
  811. KEYMEDIA_INTERVAL, // bInterval
  812. #endif // KEYMEDIA_INTERFACE
  813. };
  814. // **************************************************************
  815. // String Descriptors
  816. // **************************************************************
  817. // The descriptors above can provide human readable strings,
  818. // referenced by index numbers. These descriptors are the
  819. // actual string data
  820. /* defined in usb_names.h
  821. struct usb_string_descriptor_struct {
  822. uint8_t bLength;
  823. uint8_t bDescriptorType;
  824. uint16_t wString[];
  825. };
  826. */
  827. extern struct usb_string_descriptor_struct usb_string_manufacturer_name
  828. __attribute__ ((weak, alias("usb_string_manufacturer_name_default")));
  829. extern struct usb_string_descriptor_struct usb_string_product_name
  830. __attribute__ ((weak, alias("usb_string_product_name_default")));
  831. extern struct usb_string_descriptor_struct usb_string_serial_number
  832. __attribute__ ((weak, alias("usb_string_serial_number_default")));
  833. struct usb_string_descriptor_struct string0 = {
  834. 4,
  835. 3,
  836. {0x0409}
  837. };
  838. struct usb_string_descriptor_struct usb_string_manufacturer_name_default = {
  839. 2 + MANUFACTURER_NAME_LEN * 2,
  840. 3,
  841. MANUFACTURER_NAME
  842. };
  843. struct usb_string_descriptor_struct usb_string_product_name_default = {
  844. 2 + PRODUCT_NAME_LEN * 2,
  845. 3,
  846. PRODUCT_NAME
  847. };
  848. struct usb_string_descriptor_struct usb_string_serial_number_default = {
  849. 12,
  850. 3,
  851. {0,0,0,0,0,0,0,0,0,0}
  852. };
  853. void usb_init_serialnumber(void)
  854. {
  855. char buf[11];
  856. uint32_t i, num;
  857. __disable_irq();
  858. FTFL_FSTAT = FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL;
  859. FTFL_FCCOB0 = 0x41;
  860. FTFL_FCCOB1 = 15;
  861. FTFL_FSTAT = FTFL_FSTAT_CCIF;
  862. while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF)) ; // wait
  863. num = *(uint32_t *)&FTFL_FCCOB7;
  864. __enable_irq();
  865. // add extra zero to work around OS-X CDC-ACM driver bug
  866. if (num < 10000000) num = num * 10;
  867. ultoa(num, buf, 10);
  868. for (i=0; i<10; i++) {
  869. char c = buf[i];
  870. if (!c) break;
  871. usb_string_serial_number_default.wString[i] = c;
  872. }
  873. usb_string_serial_number_default.bLength = i * 2 + 2;
  874. }
  875. // **************************************************************
  876. // Descriptors List
  877. // **************************************************************
  878. // This table provides access to all the descriptor data above.
  879. const usb_descriptor_list_t usb_descriptor_list[] = {
  880. //wValue, wIndex, address, length
  881. {0x0100, 0x0000, device_descriptor, sizeof(device_descriptor)},
  882. {0x0200, 0x0000, config_descriptor, sizeof(config_descriptor)},
  883. #ifdef SEREMU_INTERFACE
  884. {0x2200, SEREMU_INTERFACE, seremu_report_desc, sizeof(seremu_report_desc)},
  885. {0x2100, SEREMU_INTERFACE, config_descriptor+SEREMU_HID_DESC_OFFSET, 9},
  886. #endif
  887. #ifdef KEYBOARD_INTERFACE
  888. {0x2200, KEYBOARD_INTERFACE, keyboard_report_desc, sizeof(keyboard_report_desc)},
  889. {0x2100, KEYBOARD_INTERFACE, config_descriptor+KEYBOARD_HID_DESC_OFFSET, 9},
  890. #endif
  891. #ifdef MOUSE_INTERFACE
  892. {0x2200, MOUSE_INTERFACE, mouse_report_desc, sizeof(mouse_report_desc)},
  893. {0x2100, MOUSE_INTERFACE, config_descriptor+MOUSE_HID_DESC_OFFSET, 9},
  894. #endif
  895. #ifdef JOYSTICK_INTERFACE
  896. {0x2200, JOYSTICK_INTERFACE, joystick_report_desc, sizeof(joystick_report_desc)},
  897. {0x2100, JOYSTICK_INTERFACE, config_descriptor+JOYSTICK_HID_DESC_OFFSET, 9},
  898. #endif
  899. #ifdef RAWHID_INTERFACE
  900. {0x2200, RAWHID_INTERFACE, rawhid_report_desc, sizeof(rawhid_report_desc)},
  901. {0x2100, RAWHID_INTERFACE, config_descriptor+RAWHID_HID_DESC_OFFSET, 9},
  902. #endif
  903. #ifdef FLIGHTSIM_INTERFACE
  904. {0x2200, FLIGHTSIM_INTERFACE, flightsim_report_desc, sizeof(flightsim_report_desc)},
  905. {0x2100, FLIGHTSIM_INTERFACE, config_descriptor+FLIGHTSIM_HID_DESC_OFFSET, 9},
  906. #endif
  907. #ifdef KEYMEDIA_INTERFACE
  908. {0x2200, KEYMEDIA_INTERFACE, keymedia_report_desc, sizeof(keymedia_report_desc)},
  909. {0x2100, KEYMEDIA_INTERFACE, config_descriptor+KEYMEDIA_HID_DESC_OFFSET, 9},
  910. #endif
  911. {0x0300, 0x0000, (const uint8_t *)&string0, 0},
  912. {0x0301, 0x0409, (const uint8_t *)&usb_string_manufacturer_name, 0},
  913. {0x0302, 0x0409, (const uint8_t *)&usb_string_product_name, 0},
  914. {0x0303, 0x0409, (const uint8_t *)&usb_string_serial_number, 0},
  915. {0, 0, NULL, 0}
  916. };
  917. // **************************************************************
  918. // Endpoint Configuration
  919. // **************************************************************
  920. #if 0
  921. // 0x00 = not used
  922. // 0x19 = Recieve only
  923. // 0x15 = Transmit only
  924. // 0x1D = Transmit & Recieve
  925. //
  926. const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS] =
  927. {
  928. 0x00, 0x15, 0x19, 0x15, 0x00, 0x00, 0x00, 0x00,
  929. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  930. };
  931. #endif
  932. const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS] =
  933. {
  934. #if (defined(ENDPOINT1_CONFIG) && NUM_ENDPOINTS >= 1)
  935. ENDPOINT1_CONFIG,
  936. #elif (NUM_ENDPOINTS >= 1)
  937. ENDPOINT_UNUSED,
  938. #endif
  939. #if (defined(ENDPOINT2_CONFIG) && NUM_ENDPOINTS >= 2)
  940. ENDPOINT2_CONFIG,
  941. #elif (NUM_ENDPOINTS >= 2)
  942. ENDPOINT_UNUSED,
  943. #endif
  944. #if (defined(ENDPOINT3_CONFIG) && NUM_ENDPOINTS >= 3)
  945. ENDPOINT3_CONFIG,
  946. #elif (NUM_ENDPOINTS >= 3)
  947. ENDPOINT_UNUSED,
  948. #endif
  949. #if (defined(ENDPOINT4_CONFIG) && NUM_ENDPOINTS >= 4)
  950. ENDPOINT4_CONFIG,
  951. #elif (NUM_ENDPOINTS >= 4)
  952. ENDPOINT_UNUSED,
  953. #endif
  954. #if (defined(ENDPOINT5_CONFIG) && NUM_ENDPOINTS >= 5)
  955. ENDPOINT5_CONFIG,
  956. #elif (NUM_ENDPOINTS >= 5)
  957. ENDPOINT_UNUSED,
  958. #endif
  959. #if (defined(ENDPOINT6_CONFIG) && NUM_ENDPOINTS >= 6)
  960. ENDPOINT6_CONFIG,
  961. #elif (NUM_ENDPOINTS >= 6)
  962. ENDPOINT_UNUSED,
  963. #endif
  964. #if (defined(ENDPOINT7_CONFIG) && NUM_ENDPOINTS >= 7)
  965. ENDPOINT7_CONFIG,
  966. #elif (NUM_ENDPOINTS >= 7)
  967. ENDPOINT_UNUSED,
  968. #endif
  969. #if (defined(ENDPOINT8_CONFIG) && NUM_ENDPOINTS >= 8)
  970. ENDPOINT8_CONFIG,
  971. #elif (NUM_ENDPOINTS >= 8)
  972. ENDPOINT_UNUSED,
  973. #endif
  974. #if (defined(ENDPOINT9_CONFIG) && NUM_ENDPOINTS >= 9)
  975. ENDPOINT9_CONFIG,
  976. #elif (NUM_ENDPOINTS >= 9)
  977. ENDPOINT_UNUSED,
  978. #endif
  979. #if (defined(ENDPOINT10_CONFIG) && NUM_ENDPOINTS >= 10)
  980. ENDPOINT10_CONFIG,
  981. #elif (NUM_ENDPOINTS >= 10)
  982. ENDPOINT_UNUSED,
  983. #endif
  984. #if (defined(ENDPOINT11_CONFIG) && NUM_ENDPOINTS >= 11)
  985. ENDPOINT11_CONFIG,
  986. #elif (NUM_ENDPOINTS >= 11)
  987. ENDPOINT_UNUSED,
  988. #endif
  989. #if (defined(ENDPOINT12_CONFIG) && NUM_ENDPOINTS >= 12)
  990. ENDPOINT12_CONFIG,
  991. #elif (NUM_ENDPOINTS >= 12)
  992. ENDPOINT_UNUSED,
  993. #endif
  994. #if (defined(ENDPOINT13_CONFIG) && NUM_ENDPOINTS >= 13)
  995. ENDPOINT13_CONFIG,
  996. #elif (NUM_ENDPOINTS >= 13)
  997. ENDPOINT_UNUSED,
  998. #endif
  999. #if (defined(ENDPOINT14_CONFIG) && NUM_ENDPOINTS >= 14)
  1000. ENDPOINT14_CONFIG,
  1001. #elif (NUM_ENDPOINTS >= 14)
  1002. ENDPOINT_UNUSED,
  1003. #endif
  1004. #if (defined(ENDPOINT15_CONFIG) && NUM_ENDPOINTS >= 15)
  1005. ENDPOINT15_CONFIG,
  1006. #elif (NUM_ENDPOINTS >= 15)
  1007. ENDPOINT_UNUSED,
  1008. #endif
  1009. };
  1010. #endif // NUM_ENDPOINTS
  1011. #endif // F_CPU >= 20 MHz