選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

usb_desc.c 47KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974
  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 CONFIG_DESC_SIZE JOYSTICK_INTERFACE_DESC_POS+JOYSTICK_INTERFACE_DESC_SIZE
  350. // **************************************************************
  351. // USB Configuration
  352. // **************************************************************
  353. // USB Configuration Descriptor. This huge descriptor tells all
  354. // of the devices capbilities.
  355. static uint8_t config_descriptor[CONFIG_DESC_SIZE] = {
  356. // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
  357. 9, // bLength;
  358. 2, // bDescriptorType;
  359. LSB(CONFIG_DESC_SIZE), // wTotalLength
  360. MSB(CONFIG_DESC_SIZE),
  361. NUM_INTERFACE, // bNumInterfaces
  362. 1, // bConfigurationValue
  363. 0, // iConfiguration
  364. 0xC0, // bmAttributes
  365. 50, // bMaxPower
  366. #ifdef CDC_IAD_DESCRIPTOR
  367. // interface association descriptor, USB ECN, Table 9-Z
  368. 8, // bLength
  369. 11, // bDescriptorType
  370. CDC_STATUS_INTERFACE, // bFirstInterface
  371. 2, // bInterfaceCount
  372. 0x02, // bFunctionClass
  373. 0x02, // bFunctionSubClass
  374. 0x01, // bFunctionProtocol
  375. 4, // iFunction
  376. #endif
  377. #ifdef CDC_DATA_INTERFACE
  378. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  379. 9, // bLength
  380. 4, // bDescriptorType
  381. CDC_STATUS_INTERFACE, // bInterfaceNumber
  382. 0, // bAlternateSetting
  383. 1, // bNumEndpoints
  384. 0x02, // bInterfaceClass
  385. 0x02, // bInterfaceSubClass
  386. 0x01, // bInterfaceProtocol
  387. 0, // iInterface
  388. // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26
  389. 5, // bFunctionLength
  390. 0x24, // bDescriptorType
  391. 0x00, // bDescriptorSubtype
  392. 0x10, 0x01, // bcdCDC
  393. // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27
  394. 5, // bFunctionLength
  395. 0x24, // bDescriptorType
  396. 0x01, // bDescriptorSubtype
  397. 0x01, // bmCapabilities
  398. 1, // bDataInterface
  399. // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28
  400. 4, // bFunctionLength
  401. 0x24, // bDescriptorType
  402. 0x02, // bDescriptorSubtype
  403. 0x06, // bmCapabilities
  404. // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33
  405. 5, // bFunctionLength
  406. 0x24, // bDescriptorType
  407. 0x06, // bDescriptorSubtype
  408. CDC_STATUS_INTERFACE, // bMasterInterface
  409. CDC_DATA_INTERFACE, // bSlaveInterface0
  410. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  411. 7, // bLength
  412. 5, // bDescriptorType
  413. CDC_ACM_ENDPOINT | 0x80, // bEndpointAddress
  414. 0x03, // bmAttributes (0x03=intr)
  415. CDC_ACM_SIZE, 0, // wMaxPacketSize
  416. 64, // bInterval
  417. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  418. 9, // bLength
  419. 4, // bDescriptorType
  420. CDC_DATA_INTERFACE, // bInterfaceNumber
  421. 0, // bAlternateSetting
  422. 2, // bNumEndpoints
  423. 0x0A, // bInterfaceClass
  424. 0x00, // bInterfaceSubClass
  425. 0x00, // bInterfaceProtocol
  426. 0, // iInterface
  427. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  428. 7, // bLength
  429. 5, // bDescriptorType
  430. CDC_RX_ENDPOINT, // bEndpointAddress
  431. 0x02, // bmAttributes (0x02=bulk)
  432. CDC_RX_SIZE, 0, // wMaxPacketSize
  433. 0, // bInterval
  434. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  435. 7, // bLength
  436. 5, // bDescriptorType
  437. CDC_TX_ENDPOINT | 0x80, // bEndpointAddress
  438. 0x02, // bmAttributes (0x02=bulk)
  439. CDC_TX_SIZE, 0, // wMaxPacketSize
  440. 0, // bInterval
  441. #endif // CDC_DATA_INTERFACE
  442. #ifdef MIDI_INTERFACE
  443. // Standard MS Interface Descriptor,
  444. 9, // bLength
  445. 4, // bDescriptorType
  446. MIDI_INTERFACE, // bInterfaceNumber
  447. 0, // bAlternateSetting
  448. 2, // bNumEndpoints
  449. 0x01, // bInterfaceClass (0x01 = Audio)
  450. 0x03, // bInterfaceSubClass (0x03 = MIDI)
  451. 0x00, // bInterfaceProtocol (unused for MIDI)
  452. 0, // iInterface
  453. // MIDI MS Interface Header, USB MIDI 6.1.2.1, page 21, Table 6-2
  454. 7, // bLength
  455. 0x24, // bDescriptorType = CS_INTERFACE
  456. 0x01, // bDescriptorSubtype = MS_HEADER
  457. 0x00, 0x01, // bcdMSC = revision 01.00
  458. 0x41, 0x00, // wTotalLength
  459. // MIDI IN Jack Descriptor, B.4.3, Table B-7 (embedded), page 40
  460. 6, // bLength
  461. 0x24, // bDescriptorType = CS_INTERFACE
  462. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  463. 0x01, // bJackType = EMBEDDED
  464. 1, // bJackID, ID = 1
  465. 0, // iJack
  466. // MIDI IN Jack Descriptor, B.4.3, Table B-8 (external), page 40
  467. 6, // bLength
  468. 0x24, // bDescriptorType = CS_INTERFACE
  469. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  470. 0x02, // bJackType = EXTERNAL
  471. 2, // bJackID, ID = 2
  472. 0, // iJack
  473. // MIDI OUT Jack Descriptor, B.4.4, Table B-9, page 41
  474. 9,
  475. 0x24, // bDescriptorType = CS_INTERFACE
  476. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  477. 0x01, // bJackType = EMBEDDED
  478. 3, // bJackID, ID = 3
  479. 1, // bNrInputPins = 1 pin
  480. 2, // BaSourceID(1) = 2
  481. 1, // BaSourcePin(1) = first pin
  482. 0, // iJack
  483. // MIDI OUT Jack Descriptor, B.4.4, Table B-10, page 41
  484. 9,
  485. 0x24, // bDescriptorType = CS_INTERFACE
  486. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  487. 0x02, // bJackType = EXTERNAL
  488. 4, // bJackID, ID = 4
  489. 1, // bNrInputPins = 1 pin
  490. 1, // BaSourceID(1) = 1
  491. 1, // BaSourcePin(1) = first pin
  492. 0, // iJack
  493. // Standard Bulk OUT Endpoint Descriptor, B.5.1, Table B-11, pae 42
  494. 9, // bLength
  495. 5, // bDescriptorType = ENDPOINT
  496. MIDI_RX_ENDPOINT, // bEndpointAddress
  497. 0x02, // bmAttributes (0x02=bulk)
  498. MIDI_RX_SIZE, 0, // wMaxPacketSize
  499. 0, // bInterval
  500. 0, // bRefresh
  501. 0, // bSynchAddress
  502. // Class-specific MS Bulk OUT Endpoint Descriptor, B.5.2, Table B-12, page 42
  503. 5, // bLength
  504. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  505. 0x01, // bJackType = MS_GENERAL
  506. 1, // bNumEmbMIDIJack = 1 jack
  507. 1, // BaAssocJackID(1) = jack ID #1
  508. // Standard Bulk IN Endpoint Descriptor, B.5.1, Table B-11, pae 42
  509. 9, // bLength
  510. 5, // bDescriptorType = ENDPOINT
  511. MIDI_TX_ENDPOINT | 0x80, // bEndpointAddress
  512. 0x02, // bmAttributes (0x02=bulk)
  513. MIDI_TX_SIZE, 0, // wMaxPacketSize
  514. 0, // bInterval
  515. 0, // bRefresh
  516. 0, // bSynchAddress
  517. // Class-specific MS Bulk IN Endpoint Descriptor, B.5.2, Table B-12, page 42
  518. 5, // bLength
  519. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  520. 0x01, // bJackType = MS_GENERAL
  521. 1, // bNumEmbMIDIJack = 1 jack
  522. 3, // BaAssocJackID(1) = jack ID #3
  523. #endif // MIDI_INTERFACE
  524. #ifdef KEYBOARD_INTERFACE
  525. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  526. 9, // bLength
  527. 4, // bDescriptorType
  528. KEYBOARD_INTERFACE, // bInterfaceNumber
  529. 0, // bAlternateSetting
  530. 1, // bNumEndpoints
  531. 0x03, // bInterfaceClass (0x03 = HID)
  532. 0x01, // bInterfaceSubClass (0x01 = Boot)
  533. 0x01, // bInterfaceProtocol (0x01 = Keyboard)
  534. 0, // iInterface
  535. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  536. 9, // bLength
  537. 0x21, // bDescriptorType
  538. 0x11, 0x01, // bcdHID
  539. 0, // bCountryCode
  540. 1, // bNumDescriptors
  541. 0x22, // bDescriptorType
  542. LSB(sizeof(keyboard_report_desc)), // wDescriptorLength
  543. MSB(sizeof(keyboard_report_desc)),
  544. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  545. 7, // bLength
  546. 5, // bDescriptorType
  547. KEYBOARD_ENDPOINT | 0x80, // bEndpointAddress
  548. 0x03, // bmAttributes (0x03=intr)
  549. KEYBOARD_SIZE, 0, // wMaxPacketSize
  550. KEYBOARD_INTERVAL, // bInterval
  551. #endif // KEYBOARD_INTERFACE
  552. #ifdef MOUSE_INTERFACE
  553. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  554. 9, // bLength
  555. 4, // bDescriptorType
  556. MOUSE_INTERFACE, // bInterfaceNumber
  557. 0, // bAlternateSetting
  558. 1, // bNumEndpoints
  559. 0x03, // bInterfaceClass (0x03 = HID)
  560. 0x00, // bInterfaceSubClass (0x01 = Boot)
  561. 0x00, // bInterfaceProtocol (0x02 = Mouse)
  562. 0, // iInterface
  563. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  564. 9, // bLength
  565. 0x21, // bDescriptorType
  566. 0x11, 0x01, // bcdHID
  567. 0, // bCountryCode
  568. 1, // bNumDescriptors
  569. 0x22, // bDescriptorType
  570. LSB(sizeof(mouse_report_desc)), // wDescriptorLength
  571. MSB(sizeof(mouse_report_desc)),
  572. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  573. 7, // bLength
  574. 5, // bDescriptorType
  575. MOUSE_ENDPOINT | 0x80, // bEndpointAddress
  576. 0x03, // bmAttributes (0x03=intr)
  577. MOUSE_SIZE, 0, // wMaxPacketSize
  578. MOUSE_INTERVAL, // bInterval
  579. #endif // MOUSE_INTERFACE
  580. #ifdef RAWHID_INTERFACE
  581. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  582. 9, // bLength
  583. 4, // bDescriptorType
  584. RAWHID_INTERFACE, // bInterfaceNumber
  585. 0, // bAlternateSetting
  586. 2, // bNumEndpoints
  587. 0x03, // bInterfaceClass (0x03 = HID)
  588. 0x00, // bInterfaceSubClass
  589. 0x00, // bInterfaceProtocol
  590. 0, // iInterface
  591. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  592. 9, // bLength
  593. 0x21, // bDescriptorType
  594. 0x11, 0x01, // bcdHID
  595. 0, // bCountryCode
  596. 1, // bNumDescriptors
  597. 0x22, // bDescriptorType
  598. LSB(sizeof(rawhid_report_desc)), // wDescriptorLength
  599. MSB(sizeof(rawhid_report_desc)),
  600. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  601. 7, // bLength
  602. 5, // bDescriptorType
  603. RAWHID_TX_ENDPOINT | 0x80, // bEndpointAddress
  604. 0x03, // bmAttributes (0x03=intr)
  605. RAWHID_TX_SIZE, 0, // wMaxPacketSize
  606. RAWHID_TX_INTERVAL, // bInterval
  607. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  608. 7, // bLength
  609. 5, // bDescriptorType
  610. RAWHID_RX_ENDPOINT, // bEndpointAddress
  611. 0x03, // bmAttributes (0x03=intr)
  612. RAWHID_RX_SIZE, 0, // wMaxPacketSize
  613. RAWHID_RX_INTERVAL, // bInterval
  614. #endif // RAWHID_INTERFACE
  615. #ifdef FLIGHTSIM_INTERFACE
  616. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  617. 9, // bLength
  618. 4, // bDescriptorType
  619. FLIGHTSIM_INTERFACE, // bInterfaceNumber
  620. 0, // bAlternateSetting
  621. 2, // bNumEndpoints
  622. 0x03, // bInterfaceClass (0x03 = HID)
  623. 0x00, // bInterfaceSubClass
  624. 0x00, // bInterfaceProtocol
  625. 0, // iInterface
  626. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  627. 9, // bLength
  628. 0x21, // bDescriptorType
  629. 0x11, 0x01, // bcdHID
  630. 0, // bCountryCode
  631. 1, // bNumDescriptors
  632. 0x22, // bDescriptorType
  633. LSB(sizeof(flightsim_report_desc)), // wDescriptorLength
  634. MSB(sizeof(flightsim_report_desc)),
  635. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  636. 7, // bLength
  637. 5, // bDescriptorType
  638. FLIGHTSIM_TX_ENDPOINT | 0x80, // bEndpointAddress
  639. 0x03, // bmAttributes (0x03=intr)
  640. FLIGHTSIM_TX_SIZE, 0, // wMaxPacketSize
  641. FLIGHTSIM_TX_INTERVAL, // bInterval
  642. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  643. 7, // bLength
  644. 5, // bDescriptorType
  645. FLIGHTSIM_RX_ENDPOINT, // bEndpointAddress
  646. 0x03, // bmAttributes (0x03=intr)
  647. FLIGHTSIM_RX_SIZE, 0, // wMaxPacketSize
  648. FLIGHTSIM_RX_INTERVAL, // bInterval
  649. #endif // FLIGHTSIM_INTERFACE
  650. #ifdef SEREMU_INTERFACE
  651. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  652. 9, // bLength
  653. 4, // bDescriptorType
  654. SEREMU_INTERFACE, // bInterfaceNumber
  655. 0, // bAlternateSetting
  656. 2, // bNumEndpoints
  657. 0x03, // bInterfaceClass (0x03 = HID)
  658. 0x00, // bInterfaceSubClass
  659. 0x00, // bInterfaceProtocol
  660. 0, // iInterface
  661. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  662. 9, // bLength
  663. 0x21, // bDescriptorType
  664. 0x11, 0x01, // bcdHID
  665. 0, // bCountryCode
  666. 1, // bNumDescriptors
  667. 0x22, // bDescriptorType
  668. LSB(sizeof(seremu_report_desc)), // wDescriptorLength
  669. MSB(sizeof(seremu_report_desc)),
  670. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  671. 7, // bLength
  672. 5, // bDescriptorType
  673. SEREMU_TX_ENDPOINT | 0x80, // bEndpointAddress
  674. 0x03, // bmAttributes (0x03=intr)
  675. SEREMU_TX_SIZE, 0, // wMaxPacketSize
  676. SEREMU_TX_INTERVAL, // bInterval
  677. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  678. 7, // bLength
  679. 5, // bDescriptorType
  680. SEREMU_RX_ENDPOINT, // bEndpointAddress
  681. 0x03, // bmAttributes (0x03=intr)
  682. SEREMU_RX_SIZE, 0, // wMaxPacketSize
  683. SEREMU_RX_INTERVAL, // bInterval
  684. #endif // SEREMU_INTERFACE
  685. #ifdef JOYSTICK_INTERFACE
  686. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  687. 9, // bLength
  688. 4, // bDescriptorType
  689. JOYSTICK_INTERFACE, // bInterfaceNumber
  690. 0, // bAlternateSetting
  691. 1, // bNumEndpoints
  692. 0x03, // bInterfaceClass (0x03 = HID)
  693. 0x00, // bInterfaceSubClass
  694. 0x00, // bInterfaceProtocol
  695. 0, // iInterface
  696. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  697. 9, // bLength
  698. 0x21, // bDescriptorType
  699. 0x11, 0x01, // bcdHID
  700. 0, // bCountryCode
  701. 1, // bNumDescriptors
  702. 0x22, // bDescriptorType
  703. LSB(sizeof(joystick_report_desc)), // wDescriptorLength
  704. MSB(sizeof(joystick_report_desc)),
  705. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  706. 7, // bLength
  707. 5, // bDescriptorType
  708. JOYSTICK_ENDPOINT | 0x80, // bEndpointAddress
  709. 0x03, // bmAttributes (0x03=intr)
  710. JOYSTICK_SIZE, 0, // wMaxPacketSize
  711. JOYSTICK_INTERVAL, // bInterval
  712. #endif // JOYSTICK_INTERFACE
  713. };
  714. // **************************************************************
  715. // String Descriptors
  716. // **************************************************************
  717. // The descriptors above can provide human readable strings,
  718. // referenced by index numbers. These descriptors are the
  719. // actual string data
  720. /* defined in usb_names.h
  721. struct usb_string_descriptor_struct {
  722. uint8_t bLength;
  723. uint8_t bDescriptorType;
  724. uint16_t wString[];
  725. };
  726. */
  727. extern struct usb_string_descriptor_struct usb_string_manufacturer_name
  728. __attribute__ ((weak, alias("usb_string_manufacturer_name_default")));
  729. extern struct usb_string_descriptor_struct usb_string_product_name
  730. __attribute__ ((weak, alias("usb_string_product_name_default")));
  731. extern struct usb_string_descriptor_struct usb_string_serial_number
  732. __attribute__ ((weak, alias("usb_string_serial_number_default")));
  733. struct usb_string_descriptor_struct string0 = {
  734. 4,
  735. 3,
  736. {0x0409}
  737. };
  738. struct usb_string_descriptor_struct usb_string_manufacturer_name_default = {
  739. 2 + MANUFACTURER_NAME_LEN * 2,
  740. 3,
  741. MANUFACTURER_NAME
  742. };
  743. struct usb_string_descriptor_struct usb_string_product_name_default = {
  744. 2 + PRODUCT_NAME_LEN * 2,
  745. 3,
  746. PRODUCT_NAME
  747. };
  748. struct usb_string_descriptor_struct usb_string_serial_number_default = {
  749. 12,
  750. 3,
  751. {0,0,0,0,0,0,0,0,0,0}
  752. };
  753. void usb_init_serialnumber(void)
  754. {
  755. char buf[11];
  756. uint32_t i, num;
  757. __disable_irq();
  758. FTFL_FSTAT = FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL;
  759. FTFL_FCCOB0 = 0x41;
  760. FTFL_FCCOB1 = 15;
  761. FTFL_FSTAT = FTFL_FSTAT_CCIF;
  762. while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF)) ; // wait
  763. num = *(uint32_t *)&FTFL_FCCOB7;
  764. __enable_irq();
  765. // add extra zero to work around OS-X CDC-ACM driver bug
  766. if (num < 10000000) num = num * 10;
  767. ultoa(num, buf, 10);
  768. for (i=0; i<10; i++) {
  769. char c = buf[i];
  770. if (!c) break;
  771. usb_string_serial_number_default.wString[i] = c;
  772. }
  773. usb_string_serial_number_default.bLength = i * 2 + 2;
  774. }
  775. // **************************************************************
  776. // Descriptors List
  777. // **************************************************************
  778. // This table provides access to all the descriptor data above.
  779. const usb_descriptor_list_t usb_descriptor_list[] = {
  780. //wValue, wIndex, address, length
  781. {0x0100, 0x0000, device_descriptor, sizeof(device_descriptor)},
  782. {0x0200, 0x0000, config_descriptor, sizeof(config_descriptor)},
  783. #ifdef SEREMU_INTERFACE
  784. {0x2200, SEREMU_INTERFACE, seremu_report_desc, sizeof(seremu_report_desc)},
  785. {0x2100, SEREMU_INTERFACE, config_descriptor+SEREMU_HID_DESC_OFFSET, 9},
  786. #endif
  787. #ifdef KEYBOARD_INTERFACE
  788. {0x2200, KEYBOARD_INTERFACE, keyboard_report_desc, sizeof(keyboard_report_desc)},
  789. {0x2100, KEYBOARD_INTERFACE, config_descriptor+KEYBOARD_HID_DESC_OFFSET, 9},
  790. #endif
  791. #ifdef MOUSE_INTERFACE
  792. {0x2200, MOUSE_INTERFACE, mouse_report_desc, sizeof(mouse_report_desc)},
  793. {0x2100, MOUSE_INTERFACE, config_descriptor+MOUSE_HID_DESC_OFFSET, 9},
  794. #endif
  795. #ifdef JOYSTICK_INTERFACE
  796. {0x2200, JOYSTICK_INTERFACE, joystick_report_desc, sizeof(joystick_report_desc)},
  797. {0x2100, JOYSTICK_INTERFACE, config_descriptor+JOYSTICK_HID_DESC_OFFSET, 9},
  798. #endif
  799. #ifdef RAWHID_INTERFACE
  800. {0x2200, RAWHID_INTERFACE, rawhid_report_desc, sizeof(rawhid_report_desc)},
  801. {0x2100, RAWHID_INTERFACE, config_descriptor+RAWHID_HID_DESC_OFFSET, 9},
  802. #endif
  803. #ifdef FLIGHTSIM_INTERFACE
  804. {0x2200, FLIGHTSIM_INTERFACE, flightsim_report_desc, sizeof(flightsim_report_desc)},
  805. {0x2100, FLIGHTSIM_INTERFACE, config_descriptor+FLIGHTSIM_HID_DESC_OFFSET, 9},
  806. #endif
  807. {0x0300, 0x0000, (const uint8_t *)&string0, 0},
  808. {0x0301, 0x0409, (const uint8_t *)&usb_string_manufacturer_name, 0},
  809. {0x0302, 0x0409, (const uint8_t *)&usb_string_product_name, 0},
  810. {0x0303, 0x0409, (const uint8_t *)&usb_string_serial_number, 0},
  811. {0, 0, NULL, 0}
  812. };
  813. // **************************************************************
  814. // Endpoint Configuration
  815. // **************************************************************
  816. #if 0
  817. // 0x00 = not used
  818. // 0x19 = Recieve only
  819. // 0x15 = Transmit only
  820. // 0x1D = Transmit & Recieve
  821. //
  822. const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS] =
  823. {
  824. 0x00, 0x15, 0x19, 0x15, 0x00, 0x00, 0x00, 0x00,
  825. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  826. };
  827. #endif
  828. const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS] =
  829. {
  830. #if (defined(ENDPOINT1_CONFIG) && NUM_ENDPOINTS >= 1)
  831. ENDPOINT1_CONFIG,
  832. #elif (NUM_ENDPOINTS >= 1)
  833. ENDPOINT_UNUSED,
  834. #endif
  835. #if (defined(ENDPOINT2_CONFIG) && NUM_ENDPOINTS >= 2)
  836. ENDPOINT2_CONFIG,
  837. #elif (NUM_ENDPOINTS >= 2)
  838. ENDPOINT_UNUSED,
  839. #endif
  840. #if (defined(ENDPOINT3_CONFIG) && NUM_ENDPOINTS >= 3)
  841. ENDPOINT3_CONFIG,
  842. #elif (NUM_ENDPOINTS >= 3)
  843. ENDPOINT_UNUSED,
  844. #endif
  845. #if (defined(ENDPOINT4_CONFIG) && NUM_ENDPOINTS >= 4)
  846. ENDPOINT4_CONFIG,
  847. #elif (NUM_ENDPOINTS >= 4)
  848. ENDPOINT_UNUSED,
  849. #endif
  850. #if (defined(ENDPOINT5_CONFIG) && NUM_ENDPOINTS >= 5)
  851. ENDPOINT5_CONFIG,
  852. #elif (NUM_ENDPOINTS >= 5)
  853. ENDPOINT_UNUSED,
  854. #endif
  855. #if (defined(ENDPOINT6_CONFIG) && NUM_ENDPOINTS >= 6)
  856. ENDPOINT6_CONFIG,
  857. #elif (NUM_ENDPOINTS >= 6)
  858. ENDPOINT_UNUSED,
  859. #endif
  860. #if (defined(ENDPOINT7_CONFIG) && NUM_ENDPOINTS >= 7)
  861. ENDPOINT7_CONFIG,
  862. #elif (NUM_ENDPOINTS >= 7)
  863. ENDPOINT_UNUSED,
  864. #endif
  865. #if (defined(ENDPOINT8_CONFIG) && NUM_ENDPOINTS >= 8)
  866. ENDPOINT8_CONFIG,
  867. #elif (NUM_ENDPOINTS >= 8)
  868. ENDPOINT_UNUSED,
  869. #endif
  870. #if (defined(ENDPOINT9_CONFIG) && NUM_ENDPOINTS >= 9)
  871. ENDPOINT9_CONFIG,
  872. #elif (NUM_ENDPOINTS >= 9)
  873. ENDPOINT_UNUSED,
  874. #endif
  875. #if (defined(ENDPOINT10_CONFIG) && NUM_ENDPOINTS >= 10)
  876. ENDPOINT10_CONFIG,
  877. #elif (NUM_ENDPOINTS >= 10)
  878. ENDPOINT_UNUSED,
  879. #endif
  880. #if (defined(ENDPOINT11_CONFIG) && NUM_ENDPOINTS >= 11)
  881. ENDPOINT11_CONFIG,
  882. #elif (NUM_ENDPOINTS >= 11)
  883. ENDPOINT_UNUSED,
  884. #endif
  885. #if (defined(ENDPOINT12_CONFIG) && NUM_ENDPOINTS >= 12)
  886. ENDPOINT12_CONFIG,
  887. #elif (NUM_ENDPOINTS >= 12)
  888. ENDPOINT_UNUSED,
  889. #endif
  890. #if (defined(ENDPOINT13_CONFIG) && NUM_ENDPOINTS >= 13)
  891. ENDPOINT13_CONFIG,
  892. #elif (NUM_ENDPOINTS >= 13)
  893. ENDPOINT_UNUSED,
  894. #endif
  895. #if (defined(ENDPOINT14_CONFIG) && NUM_ENDPOINTS >= 14)
  896. ENDPOINT14_CONFIG,
  897. #elif (NUM_ENDPOINTS >= 14)
  898. ENDPOINT_UNUSED,
  899. #endif
  900. #if (defined(ENDPOINT15_CONFIG) && NUM_ENDPOINTS >= 15)
  901. ENDPOINT15_CONFIG,
  902. #elif (NUM_ENDPOINTS >= 15)
  903. ENDPOINT_UNUSED,
  904. #endif
  905. };
  906. #endif // NUM_ENDPOINTS
  907. #endif // F_CPU >= 20 MHz