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

1015 lines
49KB

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