Kiibohd Controller
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

usb_desc.c 41KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031
  1. /* Teensyduino Core Library
  2. * http://www.pjrc.com/teensy/
  3. * Copyright (c) 2013 PJRC.COM, LLC.
  4. * Modified by Jacob Alexander (2013-2016)
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining
  7. * a copy of this software and associated documentation files (the
  8. * "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish,
  10. * distribute, sublicense, and/or sell copies of the Software, and to
  11. * permit persons to whom the Software is furnished to do so, subject to
  12. * the following conditions:
  13. *
  14. * 1. The above copyright notice and this permission notice shall be
  15. * included in all copies or substantial portions of the Software.
  16. *
  17. * 2. If the Software is incorporated into a build system that allows
  18. * selection among a list of target devices, then similar target
  19. * devices manufactured by PJRC.COM must be included in the list of
  20. * target devices and selectable in the same manner.
  21. *
  22. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  23. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  25. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  26. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  27. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  28. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  29. * SOFTWARE.
  30. */
  31. // ----- Includes -----
  32. // Local Includes
  33. #include "usb_desc.h"
  34. // Generated Includes
  35. #include <kll_defs.h>
  36. // ----- Macros -----
  37. #define LSB(n) ((n) & 255)
  38. #define MSB(n) (((n) >> 8) & 255)
  39. // ----- USB Device Descriptor -----
  40. // USB Device Descriptor. The USB host reads this first, to learn
  41. // what type of device is connected.
  42. static uint8_t device_descriptor[] = {
  43. 18, // bLength
  44. 1, // bDescriptorType
  45. 0x00, 0x02, // bcdUSB
  46. DEVICE_CLASS, // bDeviceClass
  47. DEVICE_SUBCLASS, // bDeviceSubClass
  48. DEVICE_PROTOCOL, // bDeviceProtocol
  49. EP0_SIZE, // bMaxPacketSize0
  50. LSB(VENDOR_ID), MSB(VENDOR_ID), // idVendor
  51. LSB(PRODUCT_ID), MSB(PRODUCT_ID), // idProduct
  52. LSB(BCD_VERSION), MSB(BCD_VERSION), // bcdDevice
  53. 1, // iManufacturer
  54. 2, // iProduct
  55. 3, // iSerialNumber
  56. 1 // bNumConfigurations
  57. };
  58. // USB Device Qualifier Descriptor
  59. static uint8_t device_qualifier_descriptor[] = {
  60. 0 // Indicate only single speed
  61. /* Device qualifier example (used for specifying multiple USB speeds)
  62. 10, // bLength
  63. 6, // bDescriptorType
  64. 0x00, 0x02, // bcdUSB
  65. DEVICE_CLASS, // bDeviceClass
  66. DEVICE_SUBCLASS, // bDeviceSubClass
  67. DEVICE_PROTOCOL, // bDeviceProtocol
  68. EP0_SIZE, // bMaxPacketSize0
  69. 0, // bNumOtherSpeedConfigurations
  70. 0 // bReserved
  71. */
  72. };
  73. // USB Debug Descriptor
  74. // XXX Not sure of exact use, lsusb requests it
  75. static uint8_t usb_debug_descriptor[] = {
  76. 0
  77. };
  78. // XXX
  79. // These descriptors must NOT be "const", because the USB DMA
  80. // has trouble accessing flash memory with enough bandwidth
  81. // while the processor is executing from flash.
  82. // XXX
  83. // ----- USB HID Report Descriptors -----
  84. // Each HID interface needs a special report descriptor that tells
  85. // the meaning and format of the data.
  86. // Keyboard Protocol 1, HID 1.11 spec, Appendix B, page 59-60
  87. #if enableKeyboard_define == 1
  88. static uint8_t keyboard_report_desc[] = {
  89. // Keyboard Collection
  90. 0x05, 0x01, // Usage Page (Generic Desktop),
  91. 0x09, 0x06, // Usage (Keyboard),
  92. 0xA1, 0x01, // Collection (Application) - Keyboard,
  93. // Modifier Byte
  94. 0x75, 0x01, // Report Size (1),
  95. 0x95, 0x08, // Report Count (8),
  96. 0x05, 0x07, // Usage Page (Key Codes),
  97. 0x19, 0xE0, // Usage Minimum (224),
  98. 0x29, 0xE7, // Usage Maximum (231),
  99. 0x15, 0x00, // Logical Minimum (0),
  100. 0x25, 0x01, // Logical Maximum (1),
  101. 0x81, 0x02, // Input (Data, Variable, Absolute),
  102. // Reserved Byte
  103. 0x75, 0x08, // Report Size (8),
  104. 0x95, 0x01, // Report Count (1),
  105. 0x81, 0x03, // Output (Constant),
  106. // LED Report
  107. 0x75, 0x01, // Report Size (1),
  108. 0x95, 0x05, // Report Count (5),
  109. 0x05, 0x08, // Usage Page (LEDs),
  110. 0x19, 0x01, // Usage Minimum (1),
  111. 0x29, 0x05, // Usage Maximum (5),
  112. 0x91, 0x02, // Output (Data, Variable, Absolute),
  113. // LED Report Padding
  114. 0x75, 0x03, // Report Size (3),
  115. 0x95, 0x01, // Report Count (1),
  116. 0x91, 0x03, // Output (Constant),
  117. // Normal Keys
  118. 0x75, 0x08, // Report Size (8),
  119. 0x95, 0x06, // Report Count (6),
  120. 0x15, 0x00, // Logical Minimum (0),
  121. 0x25, 0x7F, // Logical Maximum(104),
  122. 0x05, 0x07, // Usage Page (Key Codes),
  123. 0x19, 0x00, // Usage Minimum (0),
  124. 0x29, 0x7F, // Usage Maximum (104),
  125. 0x81, 0x00, // Input (Data, Array),
  126. 0xc0, // End Collection - Keyboard
  127. };
  128. // Keyboard Protocol 1, HID 1.11 spec, Appendix B, page 59-60
  129. static uint8_t nkro_keyboard_report_desc[] = {
  130. // Keyboard Collection
  131. 0x05, 0x01, // Usage Page (Generic Desktop),
  132. 0x09, 0x06, // Usage (Keyboard),
  133. 0xA1, 0x01, // Collection (Application) - Keyboard,
  134. // LED Report
  135. 0x85, 0x01, // Report ID (1),
  136. 0x75, 0x01, // Report Size (1),
  137. 0x95, 0x05, // Report Count (5),
  138. 0x05, 0x08, // Usage Page (LEDs),
  139. 0x19, 0x01, // Usage Minimum (1),
  140. 0x29, 0x05, // Usage Maximum (5),
  141. 0x91, 0x02, // Output (Data, Variable, Absolute),
  142. // LED Report Padding
  143. 0x75, 0x03, // Report Size (3),
  144. 0x95, 0x01, // Report Count (1),
  145. 0x91, 0x03, // Output (Constant),
  146. // Normal Keys - Using an NKRO Bitmap
  147. //
  148. // NOTES:
  149. // Supports all keys defined by the spec, except 1-3 which define error events
  150. // and 0 which is "no keys pressed"
  151. // See http://www.usb.org/developers/hidpage/Hut1_12v2.pdf Chapter 10
  152. // Or Macros/PartialMap/usb_hid.h
  153. //
  154. // 50 (ISO \ due to \ bug) and 156 (Clear due to Delete bug) must be excluded
  155. // due to a Linux bug with bitmaps (not useful anyways)
  156. // 165-175 are reserved/unused as well as 222-223 and 232-65535
  157. //
  158. // Compatibility Notes:
  159. // - Using a second endpoint for a boot mode device helps with compatibility
  160. // - DO NOT use Padding in the descriptor for bitfields
  161. // (Mac OSX silently fails... Windows/Linux work correctly)
  162. // - DO NOT use Report IDs, Windows 8.1 will not update keyboard correctly (modifiers disappear)
  163. // (all other OSs, including OSX work fine...)
  164. // (you can use them *iff* you only have 1 per collection)
  165. // - Mac OSX and Windows 8.1 are extremely picky about padding
  166. //
  167. // Packing of bitmaps are as follows:
  168. // 4-49 : 6 bytes (0x04-0x31) ( 46 bits + 2 padding bits for 6 bytes total)
  169. // 51-155 : 14 bytes (0x33-0x9B) (105 bits + 6 padding bits for 15 bytes total)
  170. // 157-164 : 1 byte (0x9D-0xA4) ( 8 bits)
  171. // 176-221 : 6 bytes (0xB0-0xDD) ( 46 bits + 2 padding bits for 6 bytes total)
  172. // 224-231 : 1 byte (0xE0-0xE7) ( 8 bits)
  173. // Modifier Byte
  174. 0x75, 0x01, // Report Size (1),
  175. 0x95, 0x08, // Report Count (8),
  176. 0x15, 0x00, // Logical Minimum (0),
  177. 0x25, 0x01, // Logical Maximum (1),
  178. 0x05, 0x07, // Usage Page (Key Codes),
  179. 0x19, 0xE0, // Usage Minimum (224),
  180. 0x29, 0xE7, // Usage Maximum (231),
  181. 0x81, 0x02, // Input (Data, Variable, Absolute),
  182. // 4-49 (6 bytes/46 bits) - MainKeys
  183. 0x75, 0x01, // Report Size (1),
  184. 0x95, 0x2E, // Report Count (46),
  185. 0x15, 0x00, // Logical Minimum (0),
  186. 0x25, 0x01, // Logical Maximum (1),
  187. 0x05, 0x07, // Usage Page (Key Codes),
  188. 0x19, 0x04, // Usage Minimum (4),
  189. 0x29, 0x31, // Usage Maximum (49),
  190. 0x81, 0x02, // Input (Data, Variable, Absolute, Bitfield),
  191. // Padding (2 bits)
  192. 0x75, 0x02, // Report Size (2),
  193. 0x95, 0x01, // Report Count (1),
  194. 0x81, 0x03, // Input (Constant),
  195. // 51-155 (14 bytes/105 bits) - SecondaryKeys
  196. 0x75, 0x01, // Report Size (1),
  197. 0x95, 0x69, // Report Count (105),
  198. 0x15, 0x00, // Logical Minimum (0),
  199. 0x25, 0x01, // Logical Maximum (1),
  200. 0x05, 0x07, // Usage Page (Key Codes),
  201. 0x19, 0x33, // Usage Minimum (51),
  202. 0x29, 0x9B, // Usage Maximum (155),
  203. 0x81, 0x02, // Input (Data, Variable, Absolute, Bitfield),
  204. // Padding (7 bits)
  205. 0x75, 0x07, // Report Size (7),
  206. 0x95, 0x01, // Report Count (1),
  207. 0x81, 0x03, // Input (Constant),
  208. // 157-164 (1 byte/8 bits) - TertiaryKeys
  209. 0x75, 0x01, // Report Size (1),
  210. 0x95, 0x08, // Report Count (8),
  211. 0x15, 0x00, // Logical Minimum (0),
  212. 0x25, 0x01, // Logical Maximum (1),
  213. 0x05, 0x07, // Usage Page (Key Codes),
  214. 0x19, 0x9D, // Usage Minimum (157),
  215. 0x29, 0xA4, // Usage Maximum (164),
  216. 0x81, 0x02, // Input (Data, Variable, Absolute, Bitfield),
  217. // 176-221 (6 bytes/46 bits) - QuartiaryKeys
  218. 0x75, 0x01, // Report Size (1),
  219. 0x95, 0x2E, // Report Count (46),
  220. 0x15, 0x00, // Logical Minimum (0),
  221. 0x25, 0x01, // Logical Maximum (1),
  222. 0x05, 0x07, // Usage Page (Key Codes),
  223. 0x19, 0xB0, // Usage Minimum (176),
  224. 0x29, 0xDD, // Usage Maximum (221),
  225. 0x81, 0x02, // Input (Data, Variable, Absolute, Bitfield),
  226. // Padding (2 bits)
  227. 0x75, 0x02, // Report Size (2),
  228. 0x95, 0x01, // Report Count (1),
  229. 0x81, 0x03, // Input (Constant),
  230. 0xc0, // End Collection - Keyboard
  231. };
  232. // System Control and Consumer Control
  233. static uint8_t sys_ctrl_report_desc[] = {
  234. // System Control Collection (8 bits)
  235. //
  236. // NOTES:
  237. // Not bothering with NKRO for this table. If there's need, I can implement it. -HaaTa
  238. // Using a 1KRO scheme
  239. 0x05, 0x01, // Usage Page (Generic Desktop),
  240. 0x09, 0x80, // Usage (System Control),
  241. 0xA1, 0x01, // Collection (Application),
  242. 0x85, 0x02, // Report ID (2),
  243. 0x75, 0x08, // Report Size (8),
  244. 0x95, 0x01, // Report Count (1),
  245. 0x16, 0x81, 0x00, // Logical Minimum (129),
  246. 0x26, 0xB7, 0x00, // Logical Maximum (183),
  247. 0x19, 0x81, // Usage Minimum (129),
  248. 0x29, 0xB7, // Usage Maximum (183),
  249. 0x81, 0x00, // Input (Data, Array),
  250. 0xc0, // End Collection - System Control
  251. // Consumer Control Collection - Media Keys (16 bits)
  252. //
  253. // NOTES:
  254. // Not bothering with NKRO for this table. If there's a need, I can implement it. -HaaTa
  255. // Using a 1KRO scheme
  256. 0x05, 0x0c, // Usage Page (Consumer),
  257. 0x09, 0x01, // Usage (Consumer Control),
  258. 0xA1, 0x01, // Collection (Application),
  259. 0x85, 0x03, // Report ID (3),
  260. 0x75, 0x10, // Report Size (16),
  261. 0x95, 0x01, // Report Count (1),
  262. 0x16, 0x01, 0x00, // Logical Minimum (1),
  263. 0x26, 0x9D, 0x02, // Logical Maximum (669),
  264. 0x05, 0x0C, // Usage Page (Consumer),
  265. 0x19, 0x01, // Usage Minimum (1),
  266. 0x2A, 0x9D, 0x02, // Usage Maximum (669),
  267. 0x81, 0x00, // Input (Data, Array),
  268. 0xc0, // End Collection - Consumer Control
  269. };
  270. #endif
  271. // Mouse Protocol 1, HID 1.11 spec, Appendix B, page 59-60, with wheel extension
  272. #if enableMouse_define == 1
  273. static uint8_t mouse_report_desc[] = {
  274. 0x05, 0x01, // Usage Page (Generic Desktop)
  275. 0x09, 0x02, // Usage (Mouse)
  276. 0xA1, 0x01, // Collection (Application)
  277. 0x09, 0x02, // Usage (Mouse)
  278. 0xA1, 0x02, // Collection (Logical)
  279. 0x09, 0x01, // Usage (Pointer)
  280. // Buttons (16 bits)
  281. 0xA1, 0x00, // Collection (Physical) - Buttons
  282. 0x05, 0x09, // Usage Page (Button)
  283. 0x19, 0x01, // Usage Minimum (Button 1)
  284. 0x29, 0x10, // Usage Maximum (Button 16)
  285. 0x15, 0x00, // Logical Minimum (0)
  286. 0x25, 0x01, // Logical Maximum (1)
  287. 0x75, 0x01, // Report Size (1)
  288. 0x95, 0x10, // Report Count (16)
  289. 0x81, 0x02, // Input (Data,Var,Abs)
  290. // Pointer (32 bits)
  291. 0x05, 0x01, // Usage PAGE (Generic Desktop)
  292. 0x09, 0x30, // Usage (X)
  293. 0x09, 0x31, // Usage (Y)
  294. 0x16, 0x01, 0x80, // Logical Minimum (-32 767)
  295. 0x26, 0xFF, 0x7F, // Logical Maximum (32 767)
  296. 0x75, 0x10, // Report Size (16)
  297. 0x95, 0x02, // Report Count (2)
  298. 0x81, 0x06, // Input (Data,Var,Rel)
  299. /*
  300. // Vertical Wheel
  301. // - Multiplier (2 bits)
  302. 0xa1, 0x02, // Collection (Logical)
  303. 0x09, 0x48, // Usage (Resolution Multiplier)
  304. 0x15, 0x00, // Logical Minimum (0)
  305. 0x25, 0x01, // Logical Maximum (1)
  306. 0x35, 0x01, // Physical Minimum (1)
  307. 0x45, 0x04, // Physical Maximum (4)
  308. 0x75, 0x02, // Report Size (2)
  309. 0x95, 0x01, // Report Count (1)
  310. 0xa4, // Push
  311. 0xb1, 0x02, // Feature (Data,Var,Abs)
  312. // - Device (8 bits)
  313. 0x09, 0x38, // Usage (Wheel)
  314. 0x15, 0x81, // Logical Minimum (-127)
  315. 0x25, 0x7f, // Logical Maximum (127)
  316. 0x35, 0x00, // Physical Minimum (0) - reset physical
  317. 0x45, 0x00, // Physical Maximum (0)
  318. 0x75, 0x08, // Report Size (8)
  319. 0x81, 0x06, // Input (Data,Var,Rel)
  320. 0xc0, // End Collection - Vertical Wheel
  321. // Horizontal Wheel
  322. // - Multiplier (2 bits)
  323. 0xa1, 0x02, // Collection (Logical)
  324. 0x09, 0x48, // Usage (Resolution Multiplier)
  325. 0xb4, // Pop
  326. 0xb1, 0x02, // Feature (Data,Var,Abs)
  327. // - Padding (4 bits)
  328. 0x35, 0x00, // Physical Minimum (0) - reset physical
  329. 0x45, 0x00, // Physical Maximum (0)
  330. 0x75, 0x04, // Report Size (4)
  331. 0xb1, 0x03, // Feature (Cnst,Var,Abs)
  332. // - Device (8 bits)
  333. 0x05, 0x0c, // Usage Page (Consumer Devices)
  334. 0x0a, 0x38, 0x02, // Usage (AC Pan)
  335. 0x15, 0x81, // Logical Minimum (-127)
  336. 0x25, 0x7f, // Logical Maximum (127)
  337. 0x75, 0x08, // Report Size (8)
  338. 0x81, 0x06, // Input (Data,Var,Rel)
  339. 0xc0, // End Collection - Horizontal Wheel
  340. */
  341. 0xc0, // End Collection - Buttons
  342. 0xc0, // End Collection - Mouse Logical
  343. 0xc0 // End Collection - Mouse Application
  344. };
  345. #endif
  346. // Joystick Protocol, HID 1.11 spec, Apendix D, page 64-65
  347. #if enableJoystick_define == 1
  348. static uint8_t joystick_report_desc[] = {
  349. 0x05, 0x01, // Usage Page (Generic Desktop)
  350. 0x09, 0x04, // Usage (Joystick)
  351. 0xA1, 0x01, // Collection (Application)
  352. 0x15, 0x00, // Logical Minimum (0)
  353. 0x25, 0x01, // Logical Maximum (1)
  354. 0x75, 0x01, // Report Size (1)
  355. 0x95, 0x20, // Report Count (32)
  356. 0x05, 0x09, // Usage Page (Button)
  357. 0x19, 0x01, // Usage Minimum (Button #1)
  358. 0x29, 0x20, // Usage Maximum (Button #32)
  359. 0x81, 0x02, // Input (variable,absolute)
  360. 0x15, 0x00, // Logical Minimum (0)
  361. 0x25, 0x07, // Logical Maximum (7)
  362. 0x35, 0x00, // Physical Minimum (0)
  363. 0x46, 0x3B, 0x01, // Physical Maximum (315)
  364. 0x75, 0x04, // Report Size (4)
  365. 0x95, 0x01, // Report Count (1)
  366. 0x65, 0x14, // Unit (20)
  367. 0x05, 0x01, // Usage Page (Generic Desktop)
  368. 0x09, 0x39, // Usage (Hat switch)
  369. 0x81, 0x42, // Input (variable,absolute,null_state)
  370. 0x05, 0x01, // Usage Page (Generic Desktop)
  371. 0x09, 0x01, // Usage (Pointer)
  372. 0xA1, 0x00, // Collection ()
  373. 0x15, 0x00, // Logical Minimum (0)
  374. 0x26, 0xFF, 0x03, // Logical Maximum (1023)
  375. 0x75, 0x0A, // Report Size (10)
  376. 0x95, 0x04, // Report Count (4)
  377. 0x09, 0x30, // Usage (X)
  378. 0x09, 0x31, // Usage (Y)
  379. 0x09, 0x32, // Usage (Z)
  380. 0x09, 0x35, // Usage (Rz)
  381. 0x81, 0x02, // Input (variable,absolute)
  382. 0xC0, // End Collection
  383. 0x15, 0x00, // Logical Minimum (0)
  384. 0x26, 0xFF, 0x03, // Logical Maximum (1023)
  385. 0x75, 0x0A, // Report Size (10)
  386. 0x95, 0x02, // Report Count (2)
  387. 0x09, 0x36, // Usage (Slider)
  388. 0x09, 0x36, // Usage (Slider)
  389. 0x81, 0x02, // Input (variable,absolute)
  390. 0xC0 // End Collection
  391. };
  392. #endif
  393. // ----- USB Configuration -----
  394. // Check for non-selected USB descriptors to update the total interface count
  395. // XXX This must be correct or some OSs/Init sequences will not initialize the keyboard/device
  396. #if enableKeyboard_define != 1
  397. #undef KEYBOARD_INTERFACES
  398. #define KEYBOARD_INTERFACES 0
  399. #endif
  400. #if enableMouse_define != 1
  401. #undef MOUSE_INTERFACES
  402. #define MOUSE_INTERFACES 0
  403. #endif
  404. #if enableJoystick_define != 1
  405. #undef JOYSTICK_INTERFACES
  406. #define JOYSTICK_INTERFACES 0
  407. #endif
  408. #if enableVirtualSerialPort_define != 1
  409. #undef CDC_INTERFACES
  410. #define CDC_INTERFACES 0
  411. #endif
  412. #if enableRawIO_define != 1
  413. #undef RAWIO_INTERFACES
  414. #define RAWIO_INTERFACES 0
  415. #endif
  416. // Determine number of interfaces
  417. #define NUM_INTERFACE (KEYBOARD_INTERFACES + CDC_INTERFACES + MOUSE_INTERFACES + JOYSTICK_INTERFACES + RAWIO_INTERFACES)
  418. // USB Configuration Descriptor. This huge descriptor tells all
  419. // of the devices capbilities.
  420. static uint8_t config_descriptor[] = {
  421. // --- Configuration ---
  422. // - 9 bytes -
  423. // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
  424. 9, // bLength;
  425. 2, // bDescriptorType;
  426. 0xFF, // wTotalLength - XXX Set in usb_init (simplifies defines)
  427. 0xFF,
  428. NUM_INTERFACE, // bNumInterfaces
  429. 1, // bConfigurationValue
  430. 0, // iConfiguration
  431. 0xA0, // bmAttributes
  432. 250, // bMaxPower - Entry Index 8
  433. //
  434. // --- Keyboard Endpoint Descriptors ---
  435. //
  436. #if enableKeyboard_define == 1
  437. #define KEYBOARD_DESC_TOTAL_OFFSET (KEYBOARD_DESC_SIZE + NKRO_KEYBOARD_DESC_SIZE + SYS_CTRL_DESC_SIZE)
  438. #define NKRO_KEYBOARD_DESC_BASE_OFFSET (KEYBOARD_DESC_BASE_OFFSET + KEYBOARD_DESC_SIZE)
  439. #define SYS_CTRL_DESC_BASE_OFFSET (KEYBOARD_DESC_BASE_OFFSET + KEYBOARD_DESC_SIZE + NKRO_KEYBOARD_DESC_SIZE)
  440. // --- Keyboard HID --- Boot Mode Keyboard Interface
  441. // - 9 bytes -
  442. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  443. 9, // bLength
  444. 4, // bDescriptorType
  445. KEYBOARD_INTERFACE, // bInterfaceNumber
  446. 0, // bAlternateSetting
  447. 1, // bNumEndpoints
  448. 0x03, // bInterfaceClass (0x03 = HID)
  449. 0x01, // bInterfaceSubClass (0x00 = Non-Boot, 0x01 = Boot)
  450. 0x01, // bInterfaceProtocol (0x01 = Keyboard)
  451. KEYBOARD_INTERFACE + 4, // iInterface
  452. // - 9 bytes -
  453. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  454. 9, // bLength
  455. 0x21, // bDescriptorType
  456. 0x11, 0x01, // bcdHID
  457. KeyboardLocale_define, // bCountryCode
  458. 1, // bNumDescriptors
  459. 0x22, // bDescriptorType
  460. LSB(sizeof(keyboard_report_desc)), // wDescriptorLength
  461. MSB(sizeof(keyboard_report_desc)),
  462. // - 7 bytes -
  463. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  464. 7, // bLength
  465. 5, // bDescriptorType
  466. KEYBOARD_ENDPOINT | 0x80, // bEndpointAddress
  467. 0x03, // bmAttributes (0x03=intr)
  468. KEYBOARD_SIZE, 0, // wMaxPacketSize
  469. KEYBOARD_INTERVAL, // bInterval
  470. // --- NKRO Keyboard HID --- OS Mode Keyboard Interface
  471. // - 9 bytes -
  472. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  473. 9, // bLength
  474. 4, // bDescriptorType
  475. NKRO_KEYBOARD_INTERFACE, // bInterfaceNumber
  476. 0, // bAlternateSetting
  477. 1, // bNumEndpoints
  478. 0x03, // bInterfaceClass (0x03 = HID)
  479. 0x00, // bInterfaceSubClass (0x00 = Non-Boot, 0x01 = Boot)
  480. 0x01, // bInterfaceProtocol (0x01 = Keyboard)
  481. NKRO_KEYBOARD_INTERFACE + 4, // iInterface
  482. // - 9 bytes -
  483. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  484. 9, // bLength
  485. 0x21, // bDescriptorType
  486. 0x11, 0x01, // bcdHID
  487. KeyboardLocale_define, // bCountryCode
  488. 1, // bNumDescriptors
  489. 0x22, // bDescriptorType
  490. LSB(sizeof(nkro_keyboard_report_desc)), // wDescriptorLength
  491. MSB(sizeof(nkro_keyboard_report_desc)),
  492. // - 7 bytes -
  493. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  494. 7, // bLength
  495. 5, // bDescriptorType
  496. NKRO_KEYBOARD_ENDPOINT | 0x80, // bEndpointAddress
  497. 0x03, // bmAttributes (0x03=intr)
  498. NKRO_KEYBOARD_SIZE, 0, // wMaxPacketSize
  499. NKRO_KEYBOARD_INTERVAL, // bInterval
  500. // --- System/Consumer Control ---
  501. // - 9 bytes -
  502. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  503. 9, // bLength
  504. 4, // bDescriptorType
  505. SYS_CTRL_INTERFACE, // bInterfaceNumber
  506. 0, // bAlternateSetting
  507. 1, // bNumEndpoints
  508. 0x03, // bInterfaceClass (0x03 = HID)
  509. 0x01, // bInterfaceSubClass (0x00 = Non-Boot, 0x01 = Boot)
  510. 0x00, // bInterfaceProtocol (0x00 = None)
  511. SYS_CTRL_INTERFACE + 4, // iInterface
  512. // - 9 bytes -
  513. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  514. 9, // bLength
  515. 0x21, // bDescriptorType
  516. 0x11, 0x01, // bcdHID
  517. KeyboardLocale_define, // bCountryCode
  518. 1, // bNumDescriptors
  519. 0x22, // bDescriptorType
  520. LSB(sizeof(sys_ctrl_report_desc)), // wDescriptorLength
  521. MSB(sizeof(sys_ctrl_report_desc)),
  522. // - 7 bytes -
  523. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  524. 7, // bLength
  525. 5, // bDescriptorType
  526. SYS_CTRL_ENDPOINT | 0x80, // bEndpointAddress
  527. 0x03, // bmAttributes (0x03=intr)
  528. SYS_CTRL_SIZE, 0, // wMaxPacketSize
  529. SYS_CTRL_INTERVAL, // bInterval
  530. #else
  531. #define KEYBOARD_DESC_TOTAL_OFFSET (0)
  532. #endif
  533. //
  534. // --- CDC / Serial Port Endpoint Descriptors ---
  535. //
  536. #if enableVirtualSerialPort_define == 1
  537. #define SERIAL_CDC_DESC_TOTAL_OFFSET (SERIAL_CDC_DESC_SIZE)
  538. // --- Serial CDC --- CDC IAD Descriptor
  539. // - 8 bytes -
  540. // interface association descriptor, USB ECN, Table 9-Z
  541. 8, // bLength
  542. 11, // bDescriptorType
  543. CDC_STATUS_INTERFACE, // bFirstInterface
  544. 2, // bInterfaceCount
  545. 0x02, // bFunctionClass
  546. 0x02, // bFunctionSubClass
  547. 0x01, // bFunctionProtocol
  548. 0, // iFunction (XXX No interface index, don't give string -HaaTa)
  549. // --- Serial CDC --- CDC Data Interface
  550. // - 9 bytes -
  551. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  552. 9, // bLength
  553. 4, // bDescriptorType
  554. CDC_STATUS_INTERFACE, // bInterfaceNumber
  555. 0, // bAlternateSetting
  556. 1, // bNumEndpoints
  557. 0x02, // bInterfaceClass
  558. 0x02, // bInterfaceSubClass
  559. 0x01, // bInterfaceProtocol
  560. CDC_STATUS_INTERFACE + 4, // iInterface
  561. // - 5 bytes -
  562. // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26
  563. 5, // bFunctionLength
  564. 0x24, // bDescriptorType
  565. 0x00, // bDescriptorSubtype
  566. 0x10, 0x01, // bcdCDC
  567. // - 5 bytes -
  568. // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27
  569. 5, // bFunctionLength
  570. 0x24, // bDescriptorType
  571. 0x01, // bDescriptorSubtype
  572. 0x01, // bmCapabilities
  573. CDC_DATA_INTERFACE, // bDataInterface
  574. // - 4 bytes -
  575. // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28
  576. 4, // bFunctionLength
  577. 0x24, // bDescriptorType
  578. 0x02, // bDescriptorSubtype
  579. 0x06, // bmCapabilities
  580. // - 5 bytes -
  581. // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33
  582. 5, // bFunctionLength
  583. 0x24, // bDescriptorType
  584. 0x06, // bDescriptorSubtype
  585. CDC_STATUS_INTERFACE, // bMasterInterface
  586. CDC_DATA_INTERFACE, // bSlaveInterface0
  587. // - 7 bytes -
  588. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  589. 7, // bLength
  590. 5, // bDescriptorType
  591. CDC_ACM_ENDPOINT | 0x80, // bEndpointAddress
  592. 0x03, // bmAttributes (0x03=intr)
  593. CDC_ACM_SIZE, 0, // wMaxPacketSize
  594. 64, // bInterval
  595. // - 9 bytes -
  596. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  597. 9, // bLength
  598. 4, // bDescriptorType
  599. CDC_DATA_INTERFACE, // bInterfaceNumber
  600. 0, // bAlternateSetting
  601. 2, // bNumEndpoints
  602. 0x0A, // bInterfaceClass
  603. 0x00, // bInterfaceSubClass
  604. 0x00, // bInterfaceProtocol
  605. CDC_DATA_INTERFACE + 4, // iInterface
  606. // - 7 bytes -
  607. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  608. 7, // bLength
  609. 5, // bDescriptorType
  610. CDC_RX_ENDPOINT, // bEndpointAddress
  611. 0x02, // bmAttributes (0x02=bulk)
  612. CDC_RX_SIZE, 0, // wMaxPacketSize
  613. 0, // bInterval
  614. // - 7 bytes -
  615. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  616. 7, // bLength
  617. 5, // bDescriptorType
  618. CDC_TX_ENDPOINT | 0x80, // bEndpointAddress
  619. 0x02, // bmAttributes (0x02=bulk)
  620. CDC_TX_SIZE, 0, // wMaxPacketSize
  621. 0, // bInterval
  622. #else
  623. #define SERIAL_CDC_DESC_TOTAL_OFFSET (0)
  624. #endif
  625. //
  626. // --- Raw IO Endpoint Descriptors ---
  627. //
  628. #if enableRawIO_define == 1
  629. #define RAWIO_DESC_TOTAL_OFFSET (RAWIO_DESC_SIZE)
  630. // --- Vendor Specific / RAW I/O ---
  631. // - 9 bytes -
  632. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  633. 9, // bLength
  634. 4, // bDescriptorType
  635. RAWIO_INTERFACE, // bInterfaceNumber
  636. 0, // bAlternateSetting
  637. 2, // bNumEndpoints
  638. 0xFF, // bInterfaceClass (0xFF)
  639. 0xFF, // bInterfaceSubClass
  640. 0xFF, // bInterfaceProtocol
  641. RAWIO_INTERFACE + 4, // iInterface
  642. // - 7 bytes -
  643. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  644. 7, // bLength
  645. 5, // bDescriptorType
  646. RAWIO_TX_ENDPOINT | 0x80, // bEndpointAddress
  647. 0x02, // bmAttributes (0x02=bulk)
  648. RAWIO_TX_SIZE, 0, // wMaxPacketSize
  649. RAWIO_TX_INTERVAL, // bInterval
  650. // - 7 bytes -
  651. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  652. 7, // bLength
  653. 5, // bDescriptorType
  654. RAWIO_RX_ENDPOINT, // bEndpointAddress
  655. 0x02, // bmAttributes (0x02=bulk)
  656. RAWIO_RX_SIZE, 0, // wMaxPacketSize
  657. RAWIO_RX_INTERVAL, // bInterval
  658. #else
  659. #define RAWIO_DESC_TOTAL_OFFSET (0)
  660. #endif
  661. //
  662. // --- Mouse Endpoint Descriptors ---
  663. //
  664. #if enableMouse_define == 1
  665. #define MOUSE_DESC_TOTAL_OFFSET (MOUSE_DESC_SIZE)
  666. // --- Mouse Interface ---
  667. // - 9 bytes -
  668. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  669. 9, // bLength
  670. 4, // bDescriptorType
  671. MOUSE_INTERFACE, // bInterfaceNumber
  672. 0, // bAlternateSetting
  673. 1, // bNumEndpoints
  674. 0x03, // bInterfaceClass (0x03 = HID)
  675. 0x00, // bInterfaceSubClass (0x01 = Boot)
  676. 0x02, // bInterfaceProtocol (0x02 = Mouse)
  677. MOUSE_INTERFACE + 4, // iInterface
  678. // - 9 bytes -
  679. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  680. 9, // bLength
  681. 0x21, // bDescriptorType
  682. 0x11, 0x01, // bcdHID
  683. 0, // bCountryCode
  684. 1, // bNumDescriptors
  685. 0x22, // bDescriptorType
  686. LSB(sizeof(mouse_report_desc)), // wDescriptorLength
  687. MSB(sizeof(mouse_report_desc)),
  688. // - 7 bytes -
  689. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  690. 7, // bLength
  691. 5, // bDescriptorType
  692. MOUSE_ENDPOINT | 0x80, // bEndpointAddress
  693. 0x03, // bmAttributes (0x03=intr)
  694. MOUSE_SIZE, 0, // wMaxPacketSize
  695. MOUSE_INTERVAL, // bInterval
  696. #else
  697. #define MOUSE_DESC_TOTAL_OFFSET (0)
  698. #endif
  699. //
  700. // --- Joystick Endpoint Descriptors ---
  701. //
  702. #if enableJoystick_define == 1
  703. #define JOYSTICK_DESC_TOTAL_OFFSET (JOYSTICK_DESC_SIZE)
  704. // --- Joystick Interface ---
  705. // - 9 bytes -
  706. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  707. 9, // bLength
  708. 4, // bDescriptorType
  709. JOYSTICK_INTERFACE, // bInterfaceNumber
  710. 0, // bAlternateSetting
  711. 1, // bNumEndpoints
  712. 0x03, // bInterfaceClass (0x03 = HID)
  713. 0x00, // bInterfaceSubClass
  714. 0x00, // bInterfaceProtocol
  715. JOYSTICK_INTERFACE + 4, // iInterface
  716. // - 9 bytes -
  717. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  718. 9, // bLength
  719. 0x21, // bDescriptorType
  720. 0x11, 0x01, // bcdHID
  721. 0, // bCountryCode
  722. 1, // bNumDescriptors
  723. 0x22, // bDescriptorType
  724. LSB(sizeof(joystick_report_desc)), // wDescriptorLength
  725. MSB(sizeof(joystick_report_desc)),
  726. // - 7 bytes -
  727. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  728. 7, // bLength
  729. 5, // bDescriptorType
  730. JOYSTICK_ENDPOINT | 0x80, // bEndpointAddress
  731. 0x03, // bmAttributes (0x03=intr)
  732. JOYSTICK_SIZE, 0, // wMaxPacketSize
  733. JOYSTICK_INTERVAL, // bInterval
  734. #else
  735. #define JOYSTICK_DESC_TOTAL_OFFSET (0)
  736. #endif
  737. };
  738. uint8_t *usb_bMaxPower = &config_descriptor[8];
  739. // ----- String Descriptors -----
  740. // The descriptors above can provide human readable strings,
  741. // referenced by index numbers. These descriptors are the
  742. // actual string data
  743. extern struct usb_string_descriptor_struct usb_string_manufacturer_name
  744. __attribute__ ((weak, alias("usb_string_manufacturer_name_default")));
  745. extern struct usb_string_descriptor_struct usb_string_product_name
  746. __attribute__ ((weak, alias("usb_string_product_name_default")));
  747. extern struct usb_string_descriptor_struct usb_string_serial_number
  748. __attribute__ ((weak, alias("usb_string_serial_number_default")));
  749. struct usb_string_descriptor_struct string0 = {
  750. 4,
  751. 3,
  752. {0x0409}
  753. };
  754. #define usb_string_descriptor(name, str) \
  755. struct usb_string_descriptor_struct name = { \
  756. sizeof(str), \
  757. 3, \
  758. {str} \
  759. }
  760. usb_string_descriptor( usb_string_manufacturer_name_default, STR_MANUFACTURER );
  761. usb_string_descriptor( usb_string_product_name_default, STR_PRODUCT );
  762. usb_string_descriptor( usb_string_serial_number_default, STR_SERIAL );
  763. #if enableKeyboard_define == 1
  764. usb_string_descriptor( usb_string_keyboard_name, KEYBOARD_NAME );
  765. usb_string_descriptor( usb_string_nkro_keyboard_name, NKRO_KEYBOARD_NAME );
  766. usb_string_descriptor( usb_string_sys_ctrl_name, SYS_CTRL_NAME );
  767. #endif
  768. #if enableVirtualSerialPort_define == 1
  769. usb_string_descriptor( usb_string_cdc_status_name, CDC_STATUS_NAME );
  770. usb_string_descriptor( usb_string_cdc_data_name, CDC_DATA_NAME );
  771. #endif
  772. #if enableRawIO_define == 1
  773. usb_string_descriptor( usb_string_rawio_name, RAWIO_NAME );
  774. #endif
  775. #if enableMouse_define == 1
  776. usb_string_descriptor( usb_string_mouse_name, MOUSE_NAME );
  777. #endif
  778. #if enableJoystick_define == 1
  779. usb_string_descriptor( usb_string_joystick_name, JOYSTICK_NAME );
  780. #endif
  781. // ----- Descriptors List -----
  782. #define iInterfaceString(num, var) \
  783. {0x0300 + 4 + num, 0x0409, (const uint8_t *)&var, 0 }
  784. // This table provides access to all the descriptor data above.
  785. const usb_descriptor_list_t usb_descriptor_list[] = {
  786. //wValue, wIndex, address, length
  787. {0x0100, 0x0000, device_descriptor, sizeof(device_descriptor)},
  788. {0x0200, 0x0000, config_descriptor, sizeof(config_descriptor)},
  789. {0x0600, 0x0000, device_qualifier_descriptor, sizeof(device_qualifier_descriptor)},
  790. {0x0A00, 0x0000, usb_debug_descriptor, sizeof(usb_debug_descriptor)},
  791. {0x0300, 0x0000, (const uint8_t *)&string0, 0},
  792. {0x0301, 0x0409, (const uint8_t *)&usb_string_manufacturer_name, 0},
  793. {0x0302, 0x0409, (const uint8_t *)&usb_string_product_name, 0},
  794. {0x0303, 0x0409, (const uint8_t *)&usb_string_serial_number, 0},
  795. #if enableKeyboard_define == 1
  796. {0x2200, KEYBOARD_INTERFACE, keyboard_report_desc, sizeof(keyboard_report_desc)},
  797. {0x2100, KEYBOARD_INTERFACE, config_descriptor + KEYBOARD_DESC_BASE_OFFSET, 9},
  798. {0x2200, NKRO_KEYBOARD_INTERFACE, nkro_keyboard_report_desc, sizeof(nkro_keyboard_report_desc)},
  799. {0x2100, NKRO_KEYBOARD_INTERFACE, config_descriptor + NKRO_KEYBOARD_DESC_BASE_OFFSET, 9},
  800. {0x2200, SYS_CTRL_INTERFACE, sys_ctrl_report_desc, sizeof(sys_ctrl_report_desc)},
  801. {0x2100, SYS_CTRL_INTERFACE, config_descriptor + SYS_CTRL_DESC_BASE_OFFSET, 9},
  802. iInterfaceString( KEYBOARD_INTERFACE, usb_string_keyboard_name ),
  803. iInterfaceString( NKRO_KEYBOARD_INTERFACE, usb_string_nkro_keyboard_name ),
  804. iInterfaceString( SYS_CTRL_INTERFACE, usb_string_sys_ctrl_name ),
  805. #endif
  806. #if enableVirtualSerialPort_define == 1
  807. iInterfaceString( CDC_STATUS_INTERFACE, usb_string_cdc_status_name ),
  808. iInterfaceString( CDC_DATA_INTERFACE, usb_string_cdc_data_name ),
  809. #endif
  810. #if enableRawIO_define == 1
  811. iInterfaceString( RAWIO_INTERFACE, usb_string_rawio_name ),
  812. #endif
  813. #if enableMouse_define == 1
  814. {0x2200, MOUSE_INTERFACE, mouse_report_desc, sizeof(mouse_report_desc)},
  815. {0x2100, MOUSE_INTERFACE, config_descriptor + MOUSE_DESC_BASE_OFFSET, 9},
  816. iInterfaceString( MOUSE_INTERFACE, usb_string_mouse_name ),
  817. #endif
  818. #if enableJoystick_define == 1
  819. {0x2200, JOYSTICK_INTERFACE, joystick_report_desc, sizeof(joystick_report_desc)},
  820. {0x2100, JOYSTICK_INTERFACE, config_descriptor + JOYSTICK_DESC_BASE_OFFSET, 9},
  821. iInterfaceString( JOYSTICK_INTERFACE, usb_string_joystick_name ),
  822. #endif
  823. {0, 0, NULL, 0}
  824. };
  825. // Simplifies defines for USB descriptors
  826. void usb_set_config_descriptor_size()
  827. {
  828. config_descriptor[2] = LSB( sizeof( config_descriptor ) );
  829. config_descriptor[3] = MSB( sizeof( config_descriptor ) );
  830. }
  831. // ----- Endpoint Configuration -----
  832. // See usb_desc.h for Endpoint configuration
  833. // 0x00 = not used
  834. // 0x19 = Recieve only
  835. // 0x15 = Transmit only
  836. // 0x1D = Transmit & Recieve
  837. //
  838. const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS] =
  839. {
  840. #if (defined(ENDPOINT1_CONFIG) && NUM_ENDPOINTS >= 1)
  841. ENDPOINT1_CONFIG,
  842. #elif (NUM_ENDPOINTS >= 1)
  843. ENDPOINT_UNUSED,
  844. #endif
  845. #if (defined(ENDPOINT2_CONFIG) && NUM_ENDPOINTS >= 2)
  846. ENDPOINT2_CONFIG,
  847. #elif (NUM_ENDPOINTS >= 2)
  848. ENDPOINT_UNUSED,
  849. #endif
  850. #if (defined(ENDPOINT3_CONFIG) && NUM_ENDPOINTS >= 3)
  851. ENDPOINT3_CONFIG,
  852. #elif (NUM_ENDPOINTS >= 3)
  853. ENDPOINT_UNUSED,
  854. #endif
  855. #if (defined(ENDPOINT4_CONFIG) && NUM_ENDPOINTS >= 4)
  856. ENDPOINT4_CONFIG,
  857. #elif (NUM_ENDPOINTS >= 4)
  858. ENDPOINT_UNUSED,
  859. #endif
  860. #if (defined(ENDPOINT5_CONFIG) && NUM_ENDPOINTS >= 5)
  861. ENDPOINT5_CONFIG,
  862. #elif (NUM_ENDPOINTS >= 5)
  863. ENDPOINT_UNUSED,
  864. #endif
  865. #if (defined(ENDPOINT6_CONFIG) && NUM_ENDPOINTS >= 6)
  866. ENDPOINT6_CONFIG,
  867. #elif (NUM_ENDPOINTS >= 6)
  868. ENDPOINT_UNUSED,
  869. #endif
  870. #if (defined(ENDPOINT7_CONFIG) && NUM_ENDPOINTS >= 7)
  871. ENDPOINT7_CONFIG,
  872. #elif (NUM_ENDPOINTS >= 7)
  873. ENDPOINT_UNUSED,
  874. #endif
  875. #if (defined(ENDPOINT8_CONFIG) && NUM_ENDPOINTS >= 8)
  876. ENDPOINT8_CONFIG,
  877. #elif (NUM_ENDPOINTS >= 8)
  878. ENDPOINT_UNUSED,
  879. #endif
  880. #if (defined(ENDPOINT9_CONFIG) && NUM_ENDPOINTS >= 9)
  881. ENDPOINT9_CONFIG,
  882. #elif (NUM_ENDPOINTS >= 9)
  883. ENDPOINT_UNUSED,
  884. #endif
  885. #if (defined(ENDPOINT10_CONFIG) && NUM_ENDPOINTS >= 10)
  886. ENDPOINT10_CONFIG,
  887. #elif (NUM_ENDPOINTS >= 10)
  888. ENDPOINT_UNUSED,
  889. #endif
  890. #if (defined(ENDPOINT11_CONFIG) && NUM_ENDPOINTS >= 11)
  891. ENDPOINT11_CONFIG,
  892. #elif (NUM_ENDPOINTS >= 11)
  893. ENDPOINT_UNUSED,
  894. #endif
  895. #if (defined(ENDPOINT12_CONFIG) && NUM_ENDPOINTS >= 12)
  896. ENDPOINT12_CONFIG,
  897. #elif (NUM_ENDPOINTS >= 12)
  898. ENDPOINT_UNUSED,
  899. #endif
  900. #if (defined(ENDPOINT13_CONFIG) && NUM_ENDPOINTS >= 13)
  901. ENDPOINT13_CONFIG,
  902. #elif (NUM_ENDPOINTS >= 13)
  903. ENDPOINT_UNUSED,
  904. #endif
  905. #if (defined(ENDPOINT14_CONFIG) && NUM_ENDPOINTS >= 14)
  906. ENDPOINT14_CONFIG,
  907. #elif (NUM_ENDPOINTS >= 14)
  908. ENDPOINT_UNUSED,
  909. #endif
  910. #if (defined(ENDPOINT15_CONFIG) && NUM_ENDPOINTS >= 15)
  911. ENDPOINT15_CONFIG,
  912. #elif (NUM_ENDPOINTS >= 15)
  913. ENDPOINT_UNUSED,
  914. #endif
  915. };