Teensy 4.1 core updated for C++20
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

974 lines
47KB

  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. #include "usb_desc.h"
  32. #ifdef NUM_ENDPOINTS
  33. #include "usb_names.h"
  34. #include "kinetis.h"
  35. #include "avr_functions.h"
  36. // USB Descriptors are binary data which the USB host reads to
  37. // automatically detect a USB device's capabilities. The format
  38. // and meaning of every field is documented in numerous USB
  39. // standards. When working with USB descriptors, despite the
  40. // complexity of the standards and poor writing quality in many
  41. // of those documents, remember descriptors are nothing more
  42. // than constant binary data that tells the USB host what the
  43. // device can do. Computers will load drivers based on this data.
  44. // Those drivers then communicate on the endpoints specified by
  45. // the descriptors.
  46. // To configure a new combination of interfaces or make minor
  47. // changes to existing configuration (eg, change the name or ID
  48. // numbers), usually you would edit "usb_desc.h". This file
  49. // is meant to be configured by the header, so generally it is
  50. // only edited to add completely new USB interfaces or features.
  51. // **************************************************************
  52. // USB Device
  53. // **************************************************************
  54. #define LSB(n) ((n) & 255)
  55. #define MSB(n) (((n) >> 8) & 255)
  56. // USB Device Descriptor. The USB host reads this first, to learn
  57. // what type of device is connected.
  58. static uint8_t device_descriptor[] = {
  59. 18, // bLength
  60. 1, // bDescriptorType
  61. 0x00, 0x02, // bcdUSB
  62. #ifdef DEVICE_CLASS
  63. DEVICE_CLASS, // bDeviceClass
  64. #else
  65. 0,
  66. #endif
  67. #ifdef DEVICE_SUBCLASS
  68. DEVICE_SUBCLASS, // bDeviceSubClass
  69. #else
  70. 0,
  71. #endif
  72. #ifdef DEVICE_PROTOCOL
  73. DEVICE_PROTOCOL, // bDeviceProtocol
  74. #else
  75. 0,
  76. #endif
  77. EP0_SIZE, // bMaxPacketSize0
  78. LSB(VENDOR_ID), MSB(VENDOR_ID), // idVendor
  79. LSB(PRODUCT_ID), MSB(PRODUCT_ID), // idProduct
  80. 0x00, 0x01, // bcdDevice
  81. 1, // iManufacturer
  82. 2, // iProduct
  83. 3, // iSerialNumber
  84. 1 // bNumConfigurations
  85. };
  86. // These descriptors must NOT be "const", because the USB DMA
  87. // has trouble accessing flash memory with enough bandwidth
  88. // while the processor is executing from flash.
  89. // **************************************************************
  90. // HID Report Descriptors
  91. // **************************************************************
  92. // Each HID interface needs a special report descriptor that tells
  93. // the meaning and format of the data.
  94. #ifdef KEYBOARD_INTERFACE
  95. // Keyboard Protocol 1, HID 1.11 spec, Appendix B, page 59-60
  96. static uint8_t keyboard_report_desc[] = {
  97. 0x05, 0x01, // Usage Page (Generic Desktop),
  98. 0x09, 0x06, // Usage (Keyboard),
  99. 0xA1, 0x01, // Collection (Application),
  100. 0x75, 0x01, // Report Size (1),
  101. 0x95, 0x08, // Report Count (8),
  102. 0x05, 0x07, // Usage Page (Key Codes),
  103. 0x19, 0xE0, // Usage Minimum (224),
  104. 0x29, 0xE7, // Usage Maximum (231),
  105. 0x15, 0x00, // Logical Minimum (0),
  106. 0x25, 0x01, // Logical Maximum (1),
  107. 0x81, 0x02, // Input (Data, Variable, Absolute), ;Modifier byte
  108. 0x95, 0x08, // Report Count (8),
  109. 0x75, 0x01, // Report Size (1),
  110. 0x15, 0x00, // Logical Minimum (0),
  111. 0x25, 0x01, // Logical Maximum (1),
  112. 0x05, 0x0C, // Usage Page (Consumer),
  113. 0x09, 0xE9, // Usage (Volume Increment),
  114. 0x09, 0xEA, // Usage (Volume Decrement),
  115. 0x09, 0xE2, // Usage (Mute),
  116. 0x09, 0xCD, // Usage (Play/Pause),
  117. 0x09, 0xB5, // Usage (Scan Next Track),
  118. 0x09, 0xB6, // Usage (Scan Previous Track),
  119. 0x09, 0xB7, // Usage (Stop),
  120. 0x09, 0xB8, // Usage (Eject),
  121. 0x81, 0x02, // Input (Data, Variable, Absolute), ;Media keys
  122. 0x95, 0x05, // Report Count (5),
  123. 0x75, 0x01, // Report Size (1),
  124. 0x05, 0x08, // Usage Page (LEDs),
  125. 0x19, 0x01, // Usage Minimum (1),
  126. 0x29, 0x05, // Usage Maximum (5),
  127. 0x91, 0x02, // Output (Data, Variable, Absolute), ;LED report
  128. 0x95, 0x01, // Report Count (1),
  129. 0x75, 0x03, // Report Size (3),
  130. 0x91, 0x03, // Output (Constant), ;LED report padding
  131. 0x95, 0x06, // Report Count (6),
  132. 0x75, 0x08, // Report Size (8),
  133. 0x15, 0x00, // Logical Minimum (0),
  134. 0x25, 0x7F, // Logical Maximum(104),
  135. 0x05, 0x07, // Usage Page (Key Codes),
  136. 0x19, 0x00, // Usage Minimum (0),
  137. 0x29, 0x7F, // Usage Maximum (104),
  138. 0x81, 0x00, // Input (Data, Array), ;Normal keys
  139. 0xc0 // End Collection
  140. };
  141. #endif
  142. #ifdef MOUSE_INTERFACE
  143. // Mouse Protocol 1, HID 1.11 spec, Appendix B, page 59-60, with wheel extension
  144. static uint8_t mouse_report_desc[] = {
  145. 0x05, 0x01, // Usage Page (Generic Desktop)
  146. 0x09, 0x02, // Usage (Mouse)
  147. 0xA1, 0x01, // Collection (Application)
  148. 0x85, 0x01, // REPORT_ID (1)
  149. 0x05, 0x09, // Usage Page (Button)
  150. 0x19, 0x01, // Usage Minimum (Button #1)
  151. 0x29, 0x08, // Usage Maximum (Button #8)
  152. 0x15, 0x00, // Logical Minimum (0)
  153. 0x25, 0x01, // Logical Maximum (1)
  154. 0x95, 0x08, // Report Count (8)
  155. 0x75, 0x01, // Report Size (1)
  156. 0x81, 0x02, // Input (Data, Variable, Absolute)
  157. 0x05, 0x01, // Usage Page (Generic Desktop)
  158. 0x09, 0x30, // Usage (X)
  159. 0x09, 0x31, // Usage (Y)
  160. 0x09, 0x38, // Usage (Wheel)
  161. 0x15, 0x81, // Logical Minimum (-127)
  162. 0x25, 0x7F, // Logical Maximum (127)
  163. 0x75, 0x08, // Report Size (8),
  164. 0x95, 0x03, // Report Count (3),
  165. 0x81, 0x06, // Input (Data, Variable, Relative)
  166. 0xC0, // End Collection
  167. 0x05, 0x01, // Usage Page (Generic Desktop)
  168. 0x09, 0x02, // Usage (Mouse)
  169. 0xA1, 0x01, // Collection (Application)
  170. 0x85, 0x02, // REPORT_ID (2)
  171. 0x05, 0x01, // Usage Page (Generic Desktop)
  172. 0x09, 0x30, // Usage (X)
  173. 0x09, 0x31, // Usage (Y)
  174. 0x15, 0x00, // Logical Minimum (0)
  175. 0x26, 0xFF, 0x7F, // Logical Maximum (32767)
  176. 0x75, 0x10, // Report Size (16),
  177. 0x95, 0x02, // Report Count (2),
  178. 0x81, 0x02, // Input (Data, Variable, Absolute)
  179. 0xC0 // End Collection
  180. };
  181. #endif
  182. #ifdef JOYSTICK_INTERFACE
  183. static uint8_t joystick_report_desc[] = {
  184. 0x05, 0x01, // Usage Page (Generic Desktop)
  185. 0x09, 0x04, // Usage (Joystick)
  186. 0xA1, 0x01, // Collection (Application)
  187. 0x15, 0x00, // Logical Minimum (0)
  188. 0x25, 0x01, // Logical Maximum (1)
  189. 0x75, 0x01, // Report Size (1)
  190. 0x95, 0x20, // Report Count (32)
  191. 0x05, 0x09, // Usage Page (Button)
  192. 0x19, 0x01, // Usage Minimum (Button #1)
  193. 0x29, 0x20, // Usage Maximum (Button #32)
  194. 0x81, 0x02, // Input (variable,absolute)
  195. 0x15, 0x00, // Logical Minimum (0)
  196. 0x25, 0x07, // Logical Maximum (7)
  197. 0x35, 0x00, // Physical Minimum (0)
  198. 0x46, 0x3B, 0x01, // Physical Maximum (315)
  199. 0x75, 0x04, // Report Size (4)
  200. 0x95, 0x01, // Report Count (1)
  201. 0x65, 0x14, // Unit (20)
  202. 0x05, 0x01, // Usage Page (Generic Desktop)
  203. 0x09, 0x39, // Usage (Hat switch)
  204. 0x81, 0x42, // Input (variable,absolute,null_state)
  205. 0x05, 0x01, // Usage Page (Generic Desktop)
  206. 0x09, 0x01, // Usage (Pointer)
  207. 0xA1, 0x00, // Collection ()
  208. 0x15, 0x00, // Logical Minimum (0)
  209. 0x26, 0xFF, 0x03, // Logical Maximum (1023)
  210. 0x75, 0x0A, // Report Size (10)
  211. 0x95, 0x04, // Report Count (4)
  212. 0x09, 0x30, // Usage (X)
  213. 0x09, 0x31, // Usage (Y)
  214. 0x09, 0x32, // Usage (Z)
  215. 0x09, 0x35, // Usage (Rz)
  216. 0x81, 0x02, // Input (variable,absolute)
  217. 0xC0, // End Collection
  218. 0x15, 0x00, // Logical Minimum (0)
  219. 0x26, 0xFF, 0x03, // Logical Maximum (1023)
  220. 0x75, 0x0A, // Report Size (10)
  221. 0x95, 0x02, // Report Count (2)
  222. 0x09, 0x36, // Usage (Slider)
  223. 0x09, 0x36, // Usage (Slider)
  224. 0x81, 0x02, // Input (variable,absolute)
  225. 0xC0 // End Collection
  226. };
  227. #endif
  228. #ifdef SEREMU_INTERFACE
  229. static uint8_t seremu_report_desc[] = {
  230. 0x06, 0xC9, 0xFF, // Usage Page 0xFFC9 (vendor defined)
  231. 0x09, 0x04, // Usage 0x04
  232. 0xA1, 0x5C, // Collection 0x5C
  233. 0x75, 0x08, // report size = 8 bits (global)
  234. 0x15, 0x00, // logical minimum = 0 (global)
  235. 0x26, 0xFF, 0x00, // logical maximum = 255 (global)
  236. 0x95, SEREMU_TX_SIZE, // report count (global)
  237. 0x09, 0x75, // usage (local)
  238. 0x81, 0x02, // Input
  239. 0x95, SEREMU_RX_SIZE, // report count (global)
  240. 0x09, 0x76, // usage (local)
  241. 0x91, 0x02, // Output
  242. 0x95, 0x04, // report count (global)
  243. 0x09, 0x76, // usage (local)
  244. 0xB1, 0x02, // Feature
  245. 0xC0 // end collection
  246. };
  247. #endif
  248. #ifdef RAWHID_INTERFACE
  249. static uint8_t rawhid_report_desc[] = {
  250. 0x06, LSB(RAWHID_USAGE_PAGE), MSB(RAWHID_USAGE_PAGE),
  251. 0x0A, LSB(RAWHID_USAGE), MSB(RAWHID_USAGE),
  252. 0xA1, 0x01, // Collection 0x01
  253. 0x75, 0x08, // report size = 8 bits
  254. 0x15, 0x00, // logical minimum = 0
  255. 0x26, 0xFF, 0x00, // logical maximum = 255
  256. 0x95, RAWHID_TX_SIZE, // report count
  257. 0x09, 0x01, // usage
  258. 0x81, 0x02, // Input (array)
  259. 0x95, RAWHID_RX_SIZE, // report count
  260. 0x09, 0x02, // usage
  261. 0x91, 0x02, // Output (array)
  262. 0xC0 // end collection
  263. };
  264. #endif
  265. #ifdef FLIGHTSIM_INTERFACE
  266. static uint8_t flightsim_report_desc[] = {
  267. 0x06, 0x1C, 0xFF, // Usage page = 0xFF1C
  268. 0x0A, 0x39, 0xA7, // Usage = 0xA739
  269. 0xA1, 0x01, // Collection 0x01
  270. 0x75, 0x08, // report size = 8 bits
  271. 0x15, 0x00, // logical minimum = 0
  272. 0x26, 0xFF, 0x00, // logical maximum = 255
  273. 0x95, FLIGHTSIM_TX_SIZE, // report count
  274. 0x09, 0x01, // usage
  275. 0x81, 0x02, // Input (array)
  276. 0x95, FLIGHTSIM_RX_SIZE, // report count
  277. 0x09, 0x02, // usage
  278. 0x91, 0x02, // Output (array)
  279. 0xC0 // end collection
  280. };
  281. #endif
  282. // **************************************************************
  283. // USB Descriptor Sizes
  284. // **************************************************************
  285. // pre-compute the size and position of everything in the config descriptor
  286. //
  287. #define CONFIG_HEADER_DESCRIPTOR_SIZE 9
  288. #define CDC_IAD_DESCRIPTOR_POS CONFIG_HEADER_DESCRIPTOR_SIZE
  289. #ifdef CDC_IAD_DESCRIPTOR
  290. #define CDC_IAD_DESCRIPTOR_SIZE 8
  291. #else
  292. #define CDC_IAD_DESCRIPTOR_SIZE 0
  293. #endif
  294. #define CDC_DATA_INTERFACE_DESC_POS CDC_IAD_DESCRIPTOR_POS+CDC_IAD_DESCRIPTOR_SIZE
  295. #ifdef CDC_DATA_INTERFACE
  296. #define CDC_DATA_INTERFACE_DESC_SIZE 9+5+5+4+5+7+9+7+7
  297. #else
  298. #define CDC_DATA_INTERFACE_DESC_SIZE 0
  299. #endif
  300. #define MIDI_INTERFACE_DESC_POS CDC_DATA_INTERFACE_DESC_POS+CDC_DATA_INTERFACE_DESC_SIZE
  301. #ifdef MIDI_INTERFACE
  302. #define MIDI_INTERFACE_DESC_SIZE 9+7+6+6+9+9+9+5+9+5
  303. #else
  304. #define MIDI_INTERFACE_DESC_SIZE 0
  305. #endif
  306. #define KEYBOARD_INTERFACE_DESC_POS MIDI_INTERFACE_DESC_POS+MIDI_INTERFACE_DESC_SIZE
  307. #ifdef KEYBOARD_INTERFACE
  308. #define KEYBOARD_INTERFACE_DESC_SIZE 9+9+7
  309. #define KEYBOARD_HID_DESC_OFFSET KEYBOARD_INTERFACE_DESC_POS+9
  310. #else
  311. #define KEYBOARD_INTERFACE_DESC_SIZE 0
  312. #endif
  313. #define MOUSE_INTERFACE_DESC_POS KEYBOARD_INTERFACE_DESC_POS+KEYBOARD_INTERFACE_DESC_SIZE
  314. #ifdef MOUSE_INTERFACE
  315. #define MOUSE_INTERFACE_DESC_SIZE 9+9+7
  316. #define MOUSE_HID_DESC_OFFSET MOUSE_INTERFACE_DESC_POS+9
  317. #else
  318. #define MOUSE_INTERFACE_DESC_SIZE 0
  319. #endif
  320. #define RAWHID_INTERFACE_DESC_POS MOUSE_INTERFACE_DESC_POS+MOUSE_INTERFACE_DESC_SIZE
  321. #ifdef RAWHID_INTERFACE
  322. #define RAWHID_INTERFACE_DESC_SIZE 9+9+7+7
  323. #define RAWHID_HID_DESC_OFFSET RAWHID_INTERFACE_DESC_POS+9
  324. #else
  325. #define RAWHID_INTERFACE_DESC_SIZE 0
  326. #endif
  327. #define FLIGHTSIM_INTERFACE_DESC_POS RAWHID_INTERFACE_DESC_POS+RAWHID_INTERFACE_DESC_SIZE
  328. #ifdef FLIGHTSIM_INTERFACE
  329. #define FLIGHTSIM_INTERFACE_DESC_SIZE 9+9+7+7
  330. #define FLIGHTSIM_HID_DESC_OFFSET FLIGHTSIM_INTERFACE_DESC_POS+9
  331. #else
  332. #define FLIGHTSIM_INTERFACE_DESC_SIZE 0
  333. #endif
  334. #define SEREMU_INTERFACE_DESC_POS FLIGHTSIM_INTERFACE_DESC_POS+FLIGHTSIM_INTERFACE_DESC_SIZE
  335. #ifdef SEREMU_INTERFACE
  336. #define SEREMU_INTERFACE_DESC_SIZE 9+9+7+7
  337. #define SEREMU_HID_DESC_OFFSET SEREMU_INTERFACE_DESC_POS+9
  338. #else
  339. #define SEREMU_INTERFACE_DESC_SIZE 0
  340. #endif
  341. #define JOYSTICK_INTERFACE_DESC_POS SEREMU_INTERFACE_DESC_POS+SEREMU_INTERFACE_DESC_SIZE
  342. #ifdef JOYSTICK_INTERFACE
  343. #define JOYSTICK_INTERFACE_DESC_SIZE 9+9+7
  344. #define JOYSTICK_HID_DESC_OFFSET JOYSTICK_INTERFACE_DESC_POS+9
  345. #else
  346. #define JOYSTICK_INTERFACE_DESC_SIZE 0
  347. #endif
  348. #define CONFIG_DESC_SIZE JOYSTICK_INTERFACE_DESC_POS+JOYSTICK_INTERFACE_DESC_SIZE
  349. // **************************************************************
  350. // USB Configuration
  351. // **************************************************************
  352. // USB Configuration Descriptor. This huge descriptor tells all
  353. // of the devices capbilities.
  354. static uint8_t config_descriptor[CONFIG_DESC_SIZE] = {
  355. // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
  356. 9, // bLength;
  357. 2, // bDescriptorType;
  358. LSB(CONFIG_DESC_SIZE), // wTotalLength
  359. MSB(CONFIG_DESC_SIZE),
  360. NUM_INTERFACE, // bNumInterfaces
  361. 1, // bConfigurationValue
  362. 0, // iConfiguration
  363. 0xC0, // bmAttributes
  364. 50, // bMaxPower
  365. #ifdef CDC_IAD_DESCRIPTOR
  366. // interface association descriptor, USB ECN, Table 9-Z
  367. 8, // bLength
  368. 11, // bDescriptorType
  369. CDC_STATUS_INTERFACE, // bFirstInterface
  370. 2, // bInterfaceCount
  371. 0x02, // bFunctionClass
  372. 0x02, // bFunctionSubClass
  373. 0x01, // bFunctionProtocol
  374. 4, // iFunction
  375. #endif
  376. #ifdef CDC_DATA_INTERFACE
  377. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  378. 9, // bLength
  379. 4, // bDescriptorType
  380. CDC_STATUS_INTERFACE, // bInterfaceNumber
  381. 0, // bAlternateSetting
  382. 1, // bNumEndpoints
  383. 0x02, // bInterfaceClass
  384. 0x02, // bInterfaceSubClass
  385. 0x01, // bInterfaceProtocol
  386. 0, // iInterface
  387. // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26
  388. 5, // bFunctionLength
  389. 0x24, // bDescriptorType
  390. 0x00, // bDescriptorSubtype
  391. 0x10, 0x01, // bcdCDC
  392. // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27
  393. 5, // bFunctionLength
  394. 0x24, // bDescriptorType
  395. 0x01, // bDescriptorSubtype
  396. 0x01, // bmCapabilities
  397. 1, // bDataInterface
  398. // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28
  399. 4, // bFunctionLength
  400. 0x24, // bDescriptorType
  401. 0x02, // bDescriptorSubtype
  402. 0x06, // bmCapabilities
  403. // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33
  404. 5, // bFunctionLength
  405. 0x24, // bDescriptorType
  406. 0x06, // bDescriptorSubtype
  407. CDC_STATUS_INTERFACE, // bMasterInterface
  408. CDC_DATA_INTERFACE, // bSlaveInterface0
  409. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  410. 7, // bLength
  411. 5, // bDescriptorType
  412. CDC_ACM_ENDPOINT | 0x80, // bEndpointAddress
  413. 0x03, // bmAttributes (0x03=intr)
  414. CDC_ACM_SIZE, 0, // wMaxPacketSize
  415. 64, // bInterval
  416. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  417. 9, // bLength
  418. 4, // bDescriptorType
  419. CDC_DATA_INTERFACE, // bInterfaceNumber
  420. 0, // bAlternateSetting
  421. 2, // bNumEndpoints
  422. 0x0A, // bInterfaceClass
  423. 0x00, // bInterfaceSubClass
  424. 0x00, // bInterfaceProtocol
  425. 0, // iInterface
  426. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  427. 7, // bLength
  428. 5, // bDescriptorType
  429. CDC_RX_ENDPOINT, // bEndpointAddress
  430. 0x02, // bmAttributes (0x02=bulk)
  431. CDC_RX_SIZE, 0, // wMaxPacketSize
  432. 0, // bInterval
  433. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  434. 7, // bLength
  435. 5, // bDescriptorType
  436. CDC_TX_ENDPOINT | 0x80, // bEndpointAddress
  437. 0x02, // bmAttributes (0x02=bulk)
  438. CDC_TX_SIZE, 0, // wMaxPacketSize
  439. 0, // bInterval
  440. #endif // CDC_DATA_INTERFACE
  441. #ifdef MIDI_INTERFACE
  442. // Standard MS Interface Descriptor,
  443. 9, // bLength
  444. 4, // bDescriptorType
  445. MIDI_INTERFACE, // bInterfaceNumber
  446. 0, // bAlternateSetting
  447. 2, // bNumEndpoints
  448. 0x01, // bInterfaceClass (0x01 = Audio)
  449. 0x03, // bInterfaceSubClass (0x03 = MIDI)
  450. 0x00, // bInterfaceProtocol (unused for MIDI)
  451. 0, // iInterface
  452. // MIDI MS Interface Header, USB MIDI 6.1.2.1, page 21, Table 6-2
  453. 7, // bLength
  454. 0x24, // bDescriptorType = CS_INTERFACE
  455. 0x01, // bDescriptorSubtype = MS_HEADER
  456. 0x00, 0x01, // bcdMSC = revision 01.00
  457. 0x41, 0x00, // wTotalLength
  458. // MIDI IN Jack Descriptor, B.4.3, Table B-7 (embedded), page 40
  459. 6, // bLength
  460. 0x24, // bDescriptorType = CS_INTERFACE
  461. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  462. 0x01, // bJackType = EMBEDDED
  463. 1, // bJackID, ID = 1
  464. 0, // iJack
  465. // MIDI IN Jack Descriptor, B.4.3, Table B-8 (external), page 40
  466. 6, // bLength
  467. 0x24, // bDescriptorType = CS_INTERFACE
  468. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  469. 0x02, // bJackType = EXTERNAL
  470. 2, // bJackID, ID = 2
  471. 0, // iJack
  472. // MIDI OUT Jack Descriptor, B.4.4, Table B-9, page 41
  473. 9,
  474. 0x24, // bDescriptorType = CS_INTERFACE
  475. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  476. 0x01, // bJackType = EMBEDDED
  477. 3, // bJackID, ID = 3
  478. 1, // bNrInputPins = 1 pin
  479. 2, // BaSourceID(1) = 2
  480. 1, // BaSourcePin(1) = first pin
  481. 0, // iJack
  482. // MIDI OUT Jack Descriptor, B.4.4, Table B-10, page 41
  483. 9,
  484. 0x24, // bDescriptorType = CS_INTERFACE
  485. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  486. 0x02, // bJackType = EXTERNAL
  487. 4, // bJackID, ID = 4
  488. 1, // bNrInputPins = 1 pin
  489. 1, // BaSourceID(1) = 1
  490. 1, // BaSourcePin(1) = first pin
  491. 0, // iJack
  492. // Standard Bulk OUT Endpoint Descriptor, B.5.1, Table B-11, pae 42
  493. 9, // bLength
  494. 5, // bDescriptorType = ENDPOINT
  495. MIDI_RX_ENDPOINT, // bEndpointAddress
  496. 0x02, // bmAttributes (0x02=bulk)
  497. MIDI_RX_SIZE, 0, // wMaxPacketSize
  498. 0, // bInterval
  499. 0, // bRefresh
  500. 0, // bSynchAddress
  501. // Class-specific MS Bulk OUT Endpoint Descriptor, B.5.2, Table B-12, page 42
  502. 5, // bLength
  503. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  504. 0x01, // bJackType = MS_GENERAL
  505. 1, // bNumEmbMIDIJack = 1 jack
  506. 1, // BaAssocJackID(1) = jack ID #1
  507. // Standard Bulk IN Endpoint Descriptor, B.5.1, Table B-11, pae 42
  508. 9, // bLength
  509. 5, // bDescriptorType = ENDPOINT
  510. MIDI_TX_ENDPOINT | 0x80, // bEndpointAddress
  511. 0x02, // bmAttributes (0x02=bulk)
  512. MIDI_TX_SIZE, 0, // wMaxPacketSize
  513. 0, // bInterval
  514. 0, // bRefresh
  515. 0, // bSynchAddress
  516. // Class-specific MS Bulk IN Endpoint Descriptor, B.5.2, Table B-12, page 42
  517. 5, // bLength
  518. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  519. 0x01, // bJackType = MS_GENERAL
  520. 1, // bNumEmbMIDIJack = 1 jack
  521. 3, // BaAssocJackID(1) = jack ID #3
  522. #endif // MIDI_INTERFACE
  523. #ifdef KEYBOARD_INTERFACE
  524. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  525. 9, // bLength
  526. 4, // bDescriptorType
  527. KEYBOARD_INTERFACE, // bInterfaceNumber
  528. 0, // bAlternateSetting
  529. 1, // bNumEndpoints
  530. 0x03, // bInterfaceClass (0x03 = HID)
  531. 0x01, // bInterfaceSubClass (0x01 = Boot)
  532. 0x01, // bInterfaceProtocol (0x01 = Keyboard)
  533. 0, // iInterface
  534. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  535. 9, // bLength
  536. 0x21, // bDescriptorType
  537. 0x11, 0x01, // bcdHID
  538. 0, // bCountryCode
  539. 1, // bNumDescriptors
  540. 0x22, // bDescriptorType
  541. LSB(sizeof(keyboard_report_desc)), // wDescriptorLength
  542. MSB(sizeof(keyboard_report_desc)),
  543. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  544. 7, // bLength
  545. 5, // bDescriptorType
  546. KEYBOARD_ENDPOINT | 0x80, // bEndpointAddress
  547. 0x03, // bmAttributes (0x03=intr)
  548. KEYBOARD_SIZE, 0, // wMaxPacketSize
  549. KEYBOARD_INTERVAL, // bInterval
  550. #endif // KEYBOARD_INTERFACE
  551. #ifdef MOUSE_INTERFACE
  552. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  553. 9, // bLength
  554. 4, // bDescriptorType
  555. MOUSE_INTERFACE, // bInterfaceNumber
  556. 0, // bAlternateSetting
  557. 1, // bNumEndpoints
  558. 0x03, // bInterfaceClass (0x03 = HID)
  559. 0x00, // bInterfaceSubClass (0x01 = Boot)
  560. 0x00, // bInterfaceProtocol (0x02 = Mouse)
  561. 0, // iInterface
  562. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  563. 9, // bLength
  564. 0x21, // bDescriptorType
  565. 0x11, 0x01, // bcdHID
  566. 0, // bCountryCode
  567. 1, // bNumDescriptors
  568. 0x22, // bDescriptorType
  569. LSB(sizeof(mouse_report_desc)), // wDescriptorLength
  570. MSB(sizeof(mouse_report_desc)),
  571. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  572. 7, // bLength
  573. 5, // bDescriptorType
  574. MOUSE_ENDPOINT | 0x80, // bEndpointAddress
  575. 0x03, // bmAttributes (0x03=intr)
  576. MOUSE_SIZE, 0, // wMaxPacketSize
  577. MOUSE_INTERVAL, // bInterval
  578. #endif // MOUSE_INTERFACE
  579. #ifdef RAWHID_INTERFACE
  580. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  581. 9, // bLength
  582. 4, // bDescriptorType
  583. RAWHID_INTERFACE, // bInterfaceNumber
  584. 0, // bAlternateSetting
  585. 2, // bNumEndpoints
  586. 0x03, // bInterfaceClass (0x03 = HID)
  587. 0x00, // bInterfaceSubClass
  588. 0x00, // bInterfaceProtocol
  589. 0, // iInterface
  590. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  591. 9, // bLength
  592. 0x21, // bDescriptorType
  593. 0x11, 0x01, // bcdHID
  594. 0, // bCountryCode
  595. 1, // bNumDescriptors
  596. 0x22, // bDescriptorType
  597. LSB(sizeof(rawhid_report_desc)), // wDescriptorLength
  598. MSB(sizeof(rawhid_report_desc)),
  599. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  600. 7, // bLength
  601. 5, // bDescriptorType
  602. RAWHID_TX_ENDPOINT | 0x80, // bEndpointAddress
  603. 0x03, // bmAttributes (0x03=intr)
  604. RAWHID_TX_SIZE, 0, // wMaxPacketSize
  605. RAWHID_TX_INTERVAL, // bInterval
  606. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  607. 7, // bLength
  608. 5, // bDescriptorType
  609. RAWHID_RX_ENDPOINT, // bEndpointAddress
  610. 0x03, // bmAttributes (0x03=intr)
  611. RAWHID_RX_SIZE, 0, // wMaxPacketSize
  612. RAWHID_RX_INTERVAL, // bInterval
  613. #endif // RAWHID_INTERFACE
  614. #ifdef FLIGHTSIM_INTERFACE
  615. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  616. 9, // bLength
  617. 4, // bDescriptorType
  618. FLIGHTSIM_INTERFACE, // bInterfaceNumber
  619. 0, // bAlternateSetting
  620. 2, // bNumEndpoints
  621. 0x03, // bInterfaceClass (0x03 = HID)
  622. 0x00, // bInterfaceSubClass
  623. 0x00, // bInterfaceProtocol
  624. 0, // iInterface
  625. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  626. 9, // bLength
  627. 0x21, // bDescriptorType
  628. 0x11, 0x01, // bcdHID
  629. 0, // bCountryCode
  630. 1, // bNumDescriptors
  631. 0x22, // bDescriptorType
  632. LSB(sizeof(flightsim_report_desc)), // wDescriptorLength
  633. MSB(sizeof(flightsim_report_desc)),
  634. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  635. 7, // bLength
  636. 5, // bDescriptorType
  637. FLIGHTSIM_TX_ENDPOINT | 0x80, // bEndpointAddress
  638. 0x03, // bmAttributes (0x03=intr)
  639. FLIGHTSIM_TX_SIZE, 0, // wMaxPacketSize
  640. FLIGHTSIM_TX_INTERVAL, // bInterval
  641. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  642. 7, // bLength
  643. 5, // bDescriptorType
  644. FLIGHTSIM_RX_ENDPOINT, // bEndpointAddress
  645. 0x03, // bmAttributes (0x03=intr)
  646. FLIGHTSIM_RX_SIZE, 0, // wMaxPacketSize
  647. FLIGHTSIM_RX_INTERVAL, // bInterval
  648. #endif // FLIGHTSIM_INTERFACE
  649. #ifdef SEREMU_INTERFACE
  650. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  651. 9, // bLength
  652. 4, // bDescriptorType
  653. SEREMU_INTERFACE, // bInterfaceNumber
  654. 0, // bAlternateSetting
  655. 2, // bNumEndpoints
  656. 0x03, // bInterfaceClass (0x03 = HID)
  657. 0x00, // bInterfaceSubClass
  658. 0x00, // bInterfaceProtocol
  659. 0, // iInterface
  660. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  661. 9, // bLength
  662. 0x21, // bDescriptorType
  663. 0x11, 0x01, // bcdHID
  664. 0, // bCountryCode
  665. 1, // bNumDescriptors
  666. 0x22, // bDescriptorType
  667. LSB(sizeof(seremu_report_desc)), // wDescriptorLength
  668. MSB(sizeof(seremu_report_desc)),
  669. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  670. 7, // bLength
  671. 5, // bDescriptorType
  672. SEREMU_TX_ENDPOINT | 0x80, // bEndpointAddress
  673. 0x03, // bmAttributes (0x03=intr)
  674. SEREMU_TX_SIZE, 0, // wMaxPacketSize
  675. SEREMU_TX_INTERVAL, // bInterval
  676. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  677. 7, // bLength
  678. 5, // bDescriptorType
  679. SEREMU_RX_ENDPOINT, // bEndpointAddress
  680. 0x03, // bmAttributes (0x03=intr)
  681. SEREMU_RX_SIZE, 0, // wMaxPacketSize
  682. SEREMU_RX_INTERVAL, // bInterval
  683. #endif // SEREMU_INTERFACE
  684. #ifdef JOYSTICK_INTERFACE
  685. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  686. 9, // bLength
  687. 4, // bDescriptorType
  688. JOYSTICK_INTERFACE, // bInterfaceNumber
  689. 0, // bAlternateSetting
  690. 1, // bNumEndpoints
  691. 0x03, // bInterfaceClass (0x03 = HID)
  692. 0x00, // bInterfaceSubClass
  693. 0x00, // bInterfaceProtocol
  694. 0, // iInterface
  695. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  696. 9, // bLength
  697. 0x21, // bDescriptorType
  698. 0x11, 0x01, // bcdHID
  699. 0, // bCountryCode
  700. 1, // bNumDescriptors
  701. 0x22, // bDescriptorType
  702. LSB(sizeof(joystick_report_desc)), // wDescriptorLength
  703. MSB(sizeof(joystick_report_desc)),
  704. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  705. 7, // bLength
  706. 5, // bDescriptorType
  707. JOYSTICK_ENDPOINT | 0x80, // bEndpointAddress
  708. 0x03, // bmAttributes (0x03=intr)
  709. JOYSTICK_SIZE, 0, // wMaxPacketSize
  710. JOYSTICK_INTERVAL, // bInterval
  711. #endif // JOYSTICK_INTERFACE
  712. };
  713. // **************************************************************
  714. // String Descriptors
  715. // **************************************************************
  716. // The descriptors above can provide human readable strings,
  717. // referenced by index numbers. These descriptors are the
  718. // actual string data
  719. /* defined in usb_names.h
  720. struct usb_string_descriptor_struct {
  721. uint8_t bLength;
  722. uint8_t bDescriptorType;
  723. uint16_t wString[];
  724. };
  725. */
  726. extern struct usb_string_descriptor_struct usb_string_manufacturer_name
  727. __attribute__ ((weak, alias("usb_string_manufacturer_name_default")));
  728. extern struct usb_string_descriptor_struct usb_string_product_name
  729. __attribute__ ((weak, alias("usb_string_product_name_default")));
  730. extern struct usb_string_descriptor_struct usb_string_serial_number
  731. __attribute__ ((weak, alias("usb_string_serial_number_default")));
  732. struct usb_string_descriptor_struct string0 = {
  733. 4,
  734. 3,
  735. {0x0409}
  736. };
  737. struct usb_string_descriptor_struct usb_string_manufacturer_name_default = {
  738. 2 + MANUFACTURER_NAME_LEN * 2,
  739. 3,
  740. MANUFACTURER_NAME
  741. };
  742. struct usb_string_descriptor_struct usb_string_product_name_default = {
  743. 2 + PRODUCT_NAME_LEN * 2,
  744. 3,
  745. PRODUCT_NAME
  746. };
  747. struct usb_string_descriptor_struct usb_string_serial_number_default = {
  748. 12,
  749. 3,
  750. {0,0,0,0,0,0,0,0,0,0}
  751. };
  752. void usb_init_serialnumber(void)
  753. {
  754. char buf[11];
  755. uint32_t i, num;
  756. __disable_irq();
  757. FTFL_FSTAT = FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL;
  758. FTFL_FCCOB0 = 0x41;
  759. FTFL_FCCOB1 = 15;
  760. FTFL_FSTAT = FTFL_FSTAT_CCIF;
  761. while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF)) ; // wait
  762. num = *(uint32_t *)&FTFL_FCCOB7;
  763. __enable_irq();
  764. // add extra zero to work around OS-X CDC-ACM driver bug
  765. if (num < 10000000) num = num * 10;
  766. ultoa(num, buf, 10);
  767. for (i=0; i<10; i++) {
  768. char c = buf[i];
  769. if (!c) break;
  770. usb_string_serial_number_default.wString[i] = c;
  771. }
  772. usb_string_serial_number_default.bLength = i * 2 + 2;
  773. }
  774. // **************************************************************
  775. // Descriptors List
  776. // **************************************************************
  777. // This table provides access to all the descriptor data above.
  778. const usb_descriptor_list_t usb_descriptor_list[] = {
  779. //wValue, wIndex, address, length
  780. {0x0100, 0x0000, device_descriptor, sizeof(device_descriptor)},
  781. {0x0200, 0x0000, config_descriptor, sizeof(config_descriptor)},
  782. #ifdef SEREMU_INTERFACE
  783. {0x2200, SEREMU_INTERFACE, seremu_report_desc, sizeof(seremu_report_desc)},
  784. {0x2100, SEREMU_INTERFACE, config_descriptor+SEREMU_HID_DESC_OFFSET, 9},
  785. #endif
  786. #ifdef KEYBOARD_INTERFACE
  787. {0x2200, KEYBOARD_INTERFACE, keyboard_report_desc, sizeof(keyboard_report_desc)},
  788. {0x2100, KEYBOARD_INTERFACE, config_descriptor+KEYBOARD_HID_DESC_OFFSET, 9},
  789. #endif
  790. #ifdef MOUSE_INTERFACE
  791. {0x2200, MOUSE_INTERFACE, mouse_report_desc, sizeof(mouse_report_desc)},
  792. {0x2100, MOUSE_INTERFACE, config_descriptor+MOUSE_HID_DESC_OFFSET, 9},
  793. #endif
  794. #ifdef JOYSTICK_INTERFACE
  795. {0x2200, JOYSTICK_INTERFACE, joystick_report_desc, sizeof(joystick_report_desc)},
  796. {0x2100, JOYSTICK_INTERFACE, config_descriptor+JOYSTICK_HID_DESC_OFFSET, 9},
  797. #endif
  798. #ifdef RAWHID_INTERFACE
  799. {0x2200, RAWHID_INTERFACE, rawhid_report_desc, sizeof(rawhid_report_desc)},
  800. {0x2100, RAWHID_INTERFACE, config_descriptor+RAWHID_HID_DESC_OFFSET, 9},
  801. #endif
  802. #ifdef FLIGHTSIM_INTERFACE
  803. {0x2200, FLIGHTSIM_INTERFACE, flightsim_report_desc, sizeof(flightsim_report_desc)},
  804. {0x2100, FLIGHTSIM_INTERFACE, config_descriptor+FLIGHTSIM_HID_DESC_OFFSET, 9},
  805. #endif
  806. {0x0300, 0x0000, (const uint8_t *)&string0, 0},
  807. {0x0301, 0x0409, (const uint8_t *)&usb_string_manufacturer_name, 0},
  808. {0x0302, 0x0409, (const uint8_t *)&usb_string_product_name, 0},
  809. {0x0303, 0x0409, (const uint8_t *)&usb_string_serial_number, 0},
  810. {0, 0, NULL, 0}
  811. };
  812. // **************************************************************
  813. // Endpoint Configuration
  814. // **************************************************************
  815. #if 0
  816. // 0x00 = not used
  817. // 0x19 = Recieve only
  818. // 0x15 = Transmit only
  819. // 0x1D = Transmit & Recieve
  820. //
  821. const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS] =
  822. {
  823. 0x00, 0x15, 0x19, 0x15, 0x00, 0x00, 0x00, 0x00,
  824. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  825. };
  826. #endif
  827. const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS] =
  828. {
  829. #if (defined(ENDPOINT1_CONFIG) && NUM_ENDPOINTS >= 1)
  830. ENDPOINT1_CONFIG,
  831. #elif (NUM_ENDPOINTS >= 1)
  832. ENDPOINT_UNUSED,
  833. #endif
  834. #if (defined(ENDPOINT2_CONFIG) && NUM_ENDPOINTS >= 2)
  835. ENDPOINT2_CONFIG,
  836. #elif (NUM_ENDPOINTS >= 2)
  837. ENDPOINT_UNUSED,
  838. #endif
  839. #if (defined(ENDPOINT3_CONFIG) && NUM_ENDPOINTS >= 3)
  840. ENDPOINT3_CONFIG,
  841. #elif (NUM_ENDPOINTS >= 3)
  842. ENDPOINT_UNUSED,
  843. #endif
  844. #if (defined(ENDPOINT4_CONFIG) && NUM_ENDPOINTS >= 4)
  845. ENDPOINT4_CONFIG,
  846. #elif (NUM_ENDPOINTS >= 4)
  847. ENDPOINT_UNUSED,
  848. #endif
  849. #if (defined(ENDPOINT5_CONFIG) && NUM_ENDPOINTS >= 5)
  850. ENDPOINT5_CONFIG,
  851. #elif (NUM_ENDPOINTS >= 5)
  852. ENDPOINT_UNUSED,
  853. #endif
  854. #if (defined(ENDPOINT6_CONFIG) && NUM_ENDPOINTS >= 6)
  855. ENDPOINT6_CONFIG,
  856. #elif (NUM_ENDPOINTS >= 6)
  857. ENDPOINT_UNUSED,
  858. #endif
  859. #if (defined(ENDPOINT7_CONFIG) && NUM_ENDPOINTS >= 7)
  860. ENDPOINT7_CONFIG,
  861. #elif (NUM_ENDPOINTS >= 7)
  862. ENDPOINT_UNUSED,
  863. #endif
  864. #if (defined(ENDPOINT8_CONFIG) && NUM_ENDPOINTS >= 8)
  865. ENDPOINT8_CONFIG,
  866. #elif (NUM_ENDPOINTS >= 8)
  867. ENDPOINT_UNUSED,
  868. #endif
  869. #if (defined(ENDPOINT9_CONFIG) && NUM_ENDPOINTS >= 9)
  870. ENDPOINT9_CONFIG,
  871. #elif (NUM_ENDPOINTS >= 9)
  872. ENDPOINT_UNUSED,
  873. #endif
  874. #if (defined(ENDPOINT10_CONFIG) && NUM_ENDPOINTS >= 10)
  875. ENDPOINT10_CONFIG,
  876. #elif (NUM_ENDPOINTS >= 10)
  877. ENDPOINT_UNUSED,
  878. #endif
  879. #if (defined(ENDPOINT11_CONFIG) && NUM_ENDPOINTS >= 11)
  880. ENDPOINT11_CONFIG,
  881. #elif (NUM_ENDPOINTS >= 11)
  882. ENDPOINT_UNUSED,
  883. #endif
  884. #if (defined(ENDPOINT12_CONFIG) && NUM_ENDPOINTS >= 12)
  885. ENDPOINT12_CONFIG,
  886. #elif (NUM_ENDPOINTS >= 12)
  887. ENDPOINT_UNUSED,
  888. #endif
  889. #if (defined(ENDPOINT13_CONFIG) && NUM_ENDPOINTS >= 13)
  890. ENDPOINT13_CONFIG,
  891. #elif (NUM_ENDPOINTS >= 13)
  892. ENDPOINT_UNUSED,
  893. #endif
  894. #if (defined(ENDPOINT14_CONFIG) && NUM_ENDPOINTS >= 14)
  895. ENDPOINT14_CONFIG,
  896. #elif (NUM_ENDPOINTS >= 14)
  897. ENDPOINT_UNUSED,
  898. #endif
  899. #if (defined(ENDPOINT15_CONFIG) && NUM_ENDPOINTS >= 15)
  900. ENDPOINT15_CONFIG,
  901. #elif (NUM_ENDPOINTS >= 15)
  902. ENDPOINT_UNUSED,
  903. #endif
  904. };
  905. #endif // NUM_ENDPOINTS
  906. #endif // F_CPU >= 20 MHz