您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401
  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. 0x01, 0x01, // 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, 0x02, // bcdDevice
  82. 1, // iManufacturer
  83. 2, // iProduct
  84. 3, // iSerialNumber
  85. 1 // bNumConfigurations
  86. };
  87. // These descriptors must NOT be "const", because the USB DMA
  88. // has trouble accessing flash memory with enough bandwidth
  89. // while the processor is executing from flash.
  90. // **************************************************************
  91. // HID Report Descriptors
  92. // **************************************************************
  93. // Each HID interface needs a special report descriptor that tells
  94. // the meaning and format of the data.
  95. #ifdef KEYBOARD_INTERFACE
  96. // Keyboard Protocol 1, HID 1.11 spec, Appendix B, page 59-60
  97. static uint8_t keyboard_report_desc[] = {
  98. 0x05, 0x01, // Usage Page (Generic Desktop),
  99. 0x09, 0x06, // Usage (Keyboard),
  100. 0xA1, 0x01, // Collection (Application),
  101. 0x75, 0x01, // Report Size (1),
  102. 0x95, 0x08, // Report Count (8),
  103. 0x05, 0x07, // Usage Page (Key Codes),
  104. 0x19, 0xE0, // Usage Minimum (224),
  105. 0x29, 0xE7, // Usage Maximum (231),
  106. 0x15, 0x00, // Logical Minimum (0),
  107. 0x25, 0x01, // Logical Maximum (1),
  108. 0x81, 0x02, // Input (Data, Variable, Absolute), ;Modifier keys
  109. 0x95, 0x01, // Report Count (1),
  110. 0x75, 0x08, // Report Size (8),
  111. 0x81, 0x03, // Input (Constant), ;Reserved byte
  112. 0x95, 0x05, // Report Count (5),
  113. 0x75, 0x01, // Report Size (1),
  114. 0x05, 0x08, // Usage Page (LEDs),
  115. 0x19, 0x01, // Usage Minimum (1),
  116. 0x29, 0x05, // Usage Maximum (5),
  117. 0x91, 0x02, // Output (Data, Variable, Absolute), ;LED report
  118. 0x95, 0x01, // Report Count (1),
  119. 0x75, 0x03, // Report Size (3),
  120. 0x91, 0x03, // Output (Constant), ;LED report padding
  121. 0x95, 0x06, // Report Count (6),
  122. 0x75, 0x08, // Report Size (8),
  123. 0x15, 0x00, // Logical Minimum (0),
  124. 0x25, 0x7F, // Logical Maximum(104),
  125. 0x05, 0x07, // Usage Page (Key Codes),
  126. 0x19, 0x00, // Usage Minimum (0),
  127. 0x29, 0x7F, // Usage Maximum (104),
  128. 0x81, 0x00, // Input (Data, Array), ;Normal keys
  129. 0xC0 // End Collection
  130. };
  131. #endif
  132. #ifdef KEYMEDIA_INTERFACE
  133. static uint8_t keymedia_report_desc[] = {
  134. 0x05, 0x0C, // Usage Page (Consumer)
  135. 0x09, 0x01, // Usage (Consumer Controls)
  136. 0xA1, 0x01, // Collection (Application)
  137. 0x75, 0x0A, // Report Size (10)
  138. 0x95, 0x04, // Report Count (4)
  139. 0x19, 0x00, // Usage Minimum (0)
  140. 0x2A, 0x9C, 0x02, // Usage Maximum (0x29C)
  141. 0x15, 0x00, // Logical Minimum (0)
  142. 0x26, 0x9C, 0x02, // Logical Maximum (0x29C)
  143. 0x81, 0x00, // Input (Data, Array)
  144. 0x05, 0x01, // Usage Page (Generic Desktop)
  145. 0x75, 0x08, // Report Size (8)
  146. 0x95, 0x03, // Report Count (3)
  147. 0x19, 0x00, // Usage Minimum (0)
  148. 0x29, 0xB7, // Usage Maximum (0xB7)
  149. 0x15, 0x00, // Logical Minimum (0)
  150. 0x26, 0xB7, 0x00, // Logical Maximum (0xB7)
  151. 0x81, 0x00, // Input (Data, Array)
  152. 0xC0 // End Collection
  153. };
  154. #endif
  155. #ifdef MOUSE_INTERFACE
  156. // Mouse Protocol 1, HID 1.11 spec, Appendix B, page 59-60, with wheel extension
  157. static uint8_t mouse_report_desc[] = {
  158. 0x05, 0x01, // Usage Page (Generic Desktop)
  159. 0x09, 0x02, // Usage (Mouse)
  160. 0xA1, 0x01, // Collection (Application)
  161. 0x85, 0x01, // REPORT_ID (1)
  162. 0x05, 0x09, // Usage Page (Button)
  163. 0x19, 0x01, // Usage Minimum (Button #1)
  164. 0x29, 0x08, // Usage Maximum (Button #8)
  165. 0x15, 0x00, // Logical Minimum (0)
  166. 0x25, 0x01, // Logical Maximum (1)
  167. 0x95, 0x08, // Report Count (8)
  168. 0x75, 0x01, // Report Size (1)
  169. 0x81, 0x02, // Input (Data, Variable, Absolute)
  170. 0x05, 0x01, // Usage Page (Generic Desktop)
  171. 0x09, 0x30, // Usage (X)
  172. 0x09, 0x31, // Usage (Y)
  173. 0x09, 0x38, // Usage (Wheel)
  174. 0x15, 0x81, // Logical Minimum (-127)
  175. 0x25, 0x7F, // Logical Maximum (127)
  176. 0x75, 0x08, // Report Size (8),
  177. 0x95, 0x03, // Report Count (3),
  178. 0x81, 0x06, // Input (Data, Variable, Relative)
  179. 0x05, 0x0C, // Usage Page (Consumer)
  180. 0x0A, 0x38, 0x02, // Usage (AC Pan)
  181. 0x15, 0x81, // Logical Minimum (-127)
  182. 0x25, 0x7F, // Logical Maximum (127)
  183. 0x75, 0x08, // Report Size (8),
  184. 0x95, 0x01, // Report Count (1),
  185. 0x81, 0x06, // Input (Data, Variable, Relative)
  186. 0xC0, // End Collection
  187. 0x05, 0x01, // Usage Page (Generic Desktop)
  188. 0x09, 0x02, // Usage (Mouse)
  189. 0xA1, 0x01, // Collection (Application)
  190. 0x85, 0x02, // REPORT_ID (2)
  191. 0x05, 0x01, // Usage Page (Generic Desktop)
  192. 0x09, 0x30, // Usage (X)
  193. 0x09, 0x31, // Usage (Y)
  194. 0x15, 0x00, // Logical Minimum (0)
  195. 0x26, 0xFF, 0x7F, // Logical Maximum (32767)
  196. 0x75, 0x10, // Report Size (16),
  197. 0x95, 0x02, // Report Count (2),
  198. 0x81, 0x02, // Input (Data, Variable, Absolute)
  199. 0xC0 // End Collection
  200. };
  201. #endif
  202. #ifdef JOYSTICK_INTERFACE
  203. static uint8_t joystick_report_desc[] = {
  204. 0x05, 0x01, // Usage Page (Generic Desktop)
  205. 0x09, 0x04, // Usage (Joystick)
  206. 0xA1, 0x01, // Collection (Application)
  207. 0x15, 0x00, // Logical Minimum (0)
  208. 0x25, 0x01, // Logical Maximum (1)
  209. 0x75, 0x01, // Report Size (1)
  210. 0x95, 0x20, // Report Count (32)
  211. 0x05, 0x09, // Usage Page (Button)
  212. 0x19, 0x01, // Usage Minimum (Button #1)
  213. 0x29, 0x20, // Usage Maximum (Button #32)
  214. 0x81, 0x02, // Input (variable,absolute)
  215. 0x15, 0x00, // Logical Minimum (0)
  216. 0x25, 0x07, // Logical Maximum (7)
  217. 0x35, 0x00, // Physical Minimum (0)
  218. 0x46, 0x3B, 0x01, // Physical Maximum (315)
  219. 0x75, 0x04, // Report Size (4)
  220. 0x95, 0x01, // Report Count (1)
  221. 0x65, 0x14, // Unit (20)
  222. 0x05, 0x01, // Usage Page (Generic Desktop)
  223. 0x09, 0x39, // Usage (Hat switch)
  224. 0x81, 0x42, // Input (variable,absolute,null_state)
  225. 0x05, 0x01, // Usage Page (Generic Desktop)
  226. 0x09, 0x01, // Usage (Pointer)
  227. 0xA1, 0x00, // Collection ()
  228. 0x15, 0x00, // Logical Minimum (0)
  229. 0x26, 0xFF, 0x03, // Logical Maximum (1023)
  230. 0x75, 0x0A, // Report Size (10)
  231. 0x95, 0x04, // Report Count (4)
  232. 0x09, 0x30, // Usage (X)
  233. 0x09, 0x31, // Usage (Y)
  234. 0x09, 0x32, // Usage (Z)
  235. 0x09, 0x35, // Usage (Rz)
  236. 0x81, 0x02, // Input (variable,absolute)
  237. 0xC0, // End Collection
  238. 0x15, 0x00, // Logical Minimum (0)
  239. 0x26, 0xFF, 0x03, // Logical Maximum (1023)
  240. 0x75, 0x0A, // Report Size (10)
  241. 0x95, 0x02, // Report Count (2)
  242. 0x09, 0x36, // Usage (Slider)
  243. 0x09, 0x36, // Usage (Slider)
  244. 0x81, 0x02, // Input (variable,absolute)
  245. 0xC0 // End Collection
  246. };
  247. #endif
  248. #ifdef MULTITOUCH_INTERFACE
  249. // https://forum.pjrc.com/threads/32331-USB-HID-Touchscreen-support-needed
  250. // https://msdn.microsoft.com/en-us/library/windows/hardware/jj151563%28v=vs.85%29.aspx
  251. // https://msdn.microsoft.com/en-us/library/windows/hardware/jj151565%28v=vs.85%29.aspx
  252. // https://msdn.microsoft.com/en-us/library/windows/hardware/ff553734%28v=vs.85%29.aspx
  253. // https://msdn.microsoft.com/en-us/library/windows/hardware/jj151564%28v=vs.85%29.aspx
  254. // download.microsoft.com/download/a/d/f/adf1347d-08dc-41a4-9084-623b1194d4b2/digitizerdrvs_touch.docx
  255. static uint8_t multitouch_report_desc[] = {
  256. 0x05, 0x0D, // Usage Page (Digitizer)
  257. 0x09, 0x04, // Usage (Touch Screen)
  258. 0xa1, 0x01, // Collection (Application)
  259. 0x09, 0x22, // Usage (Finger)
  260. 0xA1, 0x02, // Collection (Logical)
  261. 0x09, 0x42, // Usage (Tip Switch)
  262. 0x15, 0x00, // Logical Minimum (0)
  263. 0x25, 0x01, // Logical Maximum (1)
  264. 0x75, 0x01, // Report Size (1)
  265. 0x95, 0x01, // Report Count (1)
  266. 0x81, 0x02, // Input (variable,absolute)
  267. 0x09, 0x30, // Usage (Pressure)
  268. 0x25, 0x7F, // Logical Maximum (127)
  269. 0x75, 0x07, // Report Size (7)
  270. 0x95, 0x01, // Report Count (1)
  271. 0x81, 0x02, // Input (variable,absolute)
  272. 0x09, 0x51, // Usage (Contact Identifier)
  273. 0x26, 0xFF, 0x00, // Logical Maximum (255)
  274. 0x75, 0x08, // Report Size (8)
  275. 0x95, 0x01, // Report Count (1)
  276. 0x81, 0x02, // Input (variable,absolute)
  277. 0x05, 0x01, // Usage Page (Generic Desktop)
  278. 0x09, 0x30, // Usage (X)
  279. 0x09, 0x31, // Usage (Y)
  280. 0x26, 0xFF, 0x7F, // Logical Maximum (32767)
  281. 0x65, 0x00, // Unit (None) <-- probably needs real units?
  282. 0x75, 0x10, // Report Size (16)
  283. 0x95, 0x02, // Report Count (2)
  284. 0x81, 0x02, // Input (variable,absolute)
  285. 0xC0, // End Collection
  286. 0x05, 0x0D, // Usage Page (Digitizer)
  287. 0x27, 0xFF, 0xFF, 0, 0, // Logical Maximum (65535)
  288. 0x75, 0x10, // Report Size (16)
  289. 0x95, 0x01, // Report Count (1)
  290. 0x09, 0x56, // Usage (Scan Time)
  291. 0x81, 0x02, // Input (variable,absolute)
  292. 0x09, 0x54, // Usage (Contact Count)
  293. 0x25, MULTITOUCH_FINGERS, // Logical Maximum (10)
  294. 0x75, 0x08, // Report Size (8)
  295. 0x95, 0x01, // Report Count (1)
  296. 0x81, 0x02, // Input (variable,absolute)
  297. 0x05, 0x0D, // Usage Page (Digitizers)
  298. 0x09, 0x55, // Usage (Contact Count Maximum)
  299. 0x25, MULTITOUCH_FINGERS, // Logical Maximum (10)
  300. 0x75, 0x08, // Report Size (8)
  301. 0x95, 0x01, // Report Count (1)
  302. 0xB1, 0x02, // Feature (variable,absolute)
  303. 0xC0 // End Collection
  304. };
  305. #endif
  306. #ifdef SEREMU_INTERFACE
  307. static uint8_t seremu_report_desc[] = {
  308. 0x06, 0xC9, 0xFF, // Usage Page 0xFFC9 (vendor defined)
  309. 0x09, 0x04, // Usage 0x04
  310. 0xA1, 0x5C, // Collection 0x5C
  311. 0x75, 0x08, // report size = 8 bits (global)
  312. 0x15, 0x00, // logical minimum = 0 (global)
  313. 0x26, 0xFF, 0x00, // logical maximum = 255 (global)
  314. 0x95, SEREMU_TX_SIZE, // report count (global)
  315. 0x09, 0x75, // usage (local)
  316. 0x81, 0x02, // Input
  317. 0x95, SEREMU_RX_SIZE, // report count (global)
  318. 0x09, 0x76, // usage (local)
  319. 0x91, 0x02, // Output
  320. 0x95, 0x04, // report count (global)
  321. 0x09, 0x76, // usage (local)
  322. 0xB1, 0x02, // Feature
  323. 0xC0 // end collection
  324. };
  325. #endif
  326. #ifdef RAWHID_INTERFACE
  327. static uint8_t rawhid_report_desc[] = {
  328. 0x06, LSB(RAWHID_USAGE_PAGE), MSB(RAWHID_USAGE_PAGE),
  329. 0x0A, LSB(RAWHID_USAGE), MSB(RAWHID_USAGE),
  330. 0xA1, 0x01, // Collection 0x01
  331. 0x75, 0x08, // report size = 8 bits
  332. 0x15, 0x00, // logical minimum = 0
  333. 0x26, 0xFF, 0x00, // logical maximum = 255
  334. 0x95, RAWHID_TX_SIZE, // report count
  335. 0x09, 0x01, // usage
  336. 0x81, 0x02, // Input (array)
  337. 0x95, RAWHID_RX_SIZE, // report count
  338. 0x09, 0x02, // usage
  339. 0x91, 0x02, // Output (array)
  340. 0xC0 // end collection
  341. };
  342. #endif
  343. #ifdef FLIGHTSIM_INTERFACE
  344. static uint8_t flightsim_report_desc[] = {
  345. 0x06, 0x1C, 0xFF, // Usage page = 0xFF1C
  346. 0x0A, 0x39, 0xA7, // Usage = 0xA739
  347. 0xA1, 0x01, // Collection 0x01
  348. 0x75, 0x08, // report size = 8 bits
  349. 0x15, 0x00, // logical minimum = 0
  350. 0x26, 0xFF, 0x00, // logical maximum = 255
  351. 0x95, FLIGHTSIM_TX_SIZE, // report count
  352. 0x09, 0x01, // usage
  353. 0x81, 0x02, // Input (array)
  354. 0x95, FLIGHTSIM_RX_SIZE, // report count
  355. 0x09, 0x02, // usage
  356. 0x91, 0x02, // Output (array)
  357. 0xC0 // end collection
  358. };
  359. #endif
  360. // **************************************************************
  361. // USB Descriptor Sizes
  362. // **************************************************************
  363. // pre-compute the size and position of everything in the config descriptor
  364. //
  365. #define CONFIG_HEADER_DESCRIPTOR_SIZE 9
  366. #define CDC_IAD_DESCRIPTOR_POS CONFIG_HEADER_DESCRIPTOR_SIZE
  367. #ifdef CDC_IAD_DESCRIPTOR
  368. #define CDC_IAD_DESCRIPTOR_SIZE 8
  369. #else
  370. #define CDC_IAD_DESCRIPTOR_SIZE 0
  371. #endif
  372. #define CDC_DATA_INTERFACE_DESC_POS CDC_IAD_DESCRIPTOR_POS+CDC_IAD_DESCRIPTOR_SIZE
  373. #ifdef CDC_DATA_INTERFACE
  374. #define CDC_DATA_INTERFACE_DESC_SIZE 9+5+5+4+5+7+9+7+7
  375. #else
  376. #define CDC_DATA_INTERFACE_DESC_SIZE 0
  377. #endif
  378. #define MIDI_INTERFACE_DESC_POS CDC_DATA_INTERFACE_DESC_POS+CDC_DATA_INTERFACE_DESC_SIZE
  379. #ifdef MIDI_INTERFACE
  380. #define MIDI_INTERFACE_DESC_SIZE 9+7+6+6+9+9+9+5+9+5
  381. #else
  382. #define MIDI_INTERFACE_DESC_SIZE 0
  383. #endif
  384. #define KEYBOARD_INTERFACE_DESC_POS MIDI_INTERFACE_DESC_POS+MIDI_INTERFACE_DESC_SIZE
  385. #ifdef KEYBOARD_INTERFACE
  386. #define KEYBOARD_INTERFACE_DESC_SIZE 9+9+7
  387. #define KEYBOARD_HID_DESC_OFFSET KEYBOARD_INTERFACE_DESC_POS+9
  388. #else
  389. #define KEYBOARD_INTERFACE_DESC_SIZE 0
  390. #endif
  391. #define MOUSE_INTERFACE_DESC_POS KEYBOARD_INTERFACE_DESC_POS+KEYBOARD_INTERFACE_DESC_SIZE
  392. #ifdef MOUSE_INTERFACE
  393. #define MOUSE_INTERFACE_DESC_SIZE 9+9+7
  394. #define MOUSE_HID_DESC_OFFSET MOUSE_INTERFACE_DESC_POS+9
  395. #else
  396. #define MOUSE_INTERFACE_DESC_SIZE 0
  397. #endif
  398. #define RAWHID_INTERFACE_DESC_POS MOUSE_INTERFACE_DESC_POS+MOUSE_INTERFACE_DESC_SIZE
  399. #ifdef RAWHID_INTERFACE
  400. #define RAWHID_INTERFACE_DESC_SIZE 9+9+7+7
  401. #define RAWHID_HID_DESC_OFFSET RAWHID_INTERFACE_DESC_POS+9
  402. #else
  403. #define RAWHID_INTERFACE_DESC_SIZE 0
  404. #endif
  405. #define FLIGHTSIM_INTERFACE_DESC_POS RAWHID_INTERFACE_DESC_POS+RAWHID_INTERFACE_DESC_SIZE
  406. #ifdef FLIGHTSIM_INTERFACE
  407. #define FLIGHTSIM_INTERFACE_DESC_SIZE 9+9+7+7
  408. #define FLIGHTSIM_HID_DESC_OFFSET FLIGHTSIM_INTERFACE_DESC_POS+9
  409. #else
  410. #define FLIGHTSIM_INTERFACE_DESC_SIZE 0
  411. #endif
  412. #define SEREMU_INTERFACE_DESC_POS FLIGHTSIM_INTERFACE_DESC_POS+FLIGHTSIM_INTERFACE_DESC_SIZE
  413. #ifdef SEREMU_INTERFACE
  414. #define SEREMU_INTERFACE_DESC_SIZE 9+9+7+7
  415. #define SEREMU_HID_DESC_OFFSET SEREMU_INTERFACE_DESC_POS+9
  416. #else
  417. #define SEREMU_INTERFACE_DESC_SIZE 0
  418. #endif
  419. #define JOYSTICK_INTERFACE_DESC_POS SEREMU_INTERFACE_DESC_POS+SEREMU_INTERFACE_DESC_SIZE
  420. #ifdef JOYSTICK_INTERFACE
  421. #define JOYSTICK_INTERFACE_DESC_SIZE 9+9+7
  422. #define JOYSTICK_HID_DESC_OFFSET JOYSTICK_INTERFACE_DESC_POS+9
  423. #else
  424. #define JOYSTICK_INTERFACE_DESC_SIZE 0
  425. #endif
  426. #define MTP_INTERFACE_DESC_POS JOYSTICK_INTERFACE_DESC_POS+JOYSTICK_INTERFACE_DESC_SIZE
  427. #ifdef MTP_INTERFACE
  428. #define MTP_INTERFACE_DESC_SIZE 9+7+7+7
  429. #else
  430. #define MTP_INTERFACE_DESC_SIZE 0
  431. #endif
  432. #define KEYMEDIA_INTERFACE_DESC_POS MTP_INTERFACE_DESC_POS+MTP_INTERFACE_DESC_SIZE
  433. #ifdef KEYMEDIA_INTERFACE
  434. #define KEYMEDIA_INTERFACE_DESC_SIZE 9+9+7
  435. #define KEYMEDIA_HID_DESC_OFFSET KEYMEDIA_INTERFACE_DESC_POS+9
  436. #else
  437. #define KEYMEDIA_INTERFACE_DESC_SIZE 0
  438. #endif
  439. #define AUDIO_INTERFACE_DESC_POS KEYMEDIA_INTERFACE_DESC_POS+KEYMEDIA_INTERFACE_DESC_SIZE
  440. #ifdef AUDIO_INTERFACE
  441. #define AUDIO_INTERFACE_DESC_SIZE 9+10+12+9+12+10+9 + 9+9+7+11+9+7 + 9+9+7+11+9+7+9
  442. #else
  443. #define AUDIO_INTERFACE_DESC_SIZE 0
  444. #endif
  445. #define MULTITOUCH_INTERFACE_DESC_POS AUDIO_INTERFACE_DESC_POS+AUDIO_INTERFACE_DESC_SIZE
  446. #ifdef MULTITOUCH_INTERFACE
  447. #define MULTITOUCH_INTERFACE_DESC_SIZE 9+9+7
  448. #define MULTITOUCH_HID_DESC_OFFSET MULTITOUCH_INTERFACE_DESC_POS+9
  449. #else
  450. #define MULTITOUCH_INTERFACE_DESC_SIZE 0
  451. #endif
  452. #define CONFIG_DESC_SIZE MULTITOUCH_INTERFACE_DESC_POS+MULTITOUCH_INTERFACE_DESC_SIZE
  453. // **************************************************************
  454. // USB Configuration
  455. // **************************************************************
  456. // USB Configuration Descriptor. This huge descriptor tells all
  457. // of the devices capbilities.
  458. static uint8_t config_descriptor[CONFIG_DESC_SIZE] = {
  459. // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
  460. 9, // bLength;
  461. 2, // bDescriptorType;
  462. LSB(CONFIG_DESC_SIZE), // wTotalLength
  463. MSB(CONFIG_DESC_SIZE),
  464. NUM_INTERFACE, // bNumInterfaces
  465. 1, // bConfigurationValue
  466. 0, // iConfiguration
  467. 0xC0, // bmAttributes
  468. 50, // bMaxPower
  469. #ifdef CDC_IAD_DESCRIPTOR
  470. // interface association descriptor, USB ECN, Table 9-Z
  471. 8, // bLength
  472. 11, // bDescriptorType
  473. CDC_STATUS_INTERFACE, // bFirstInterface
  474. 2, // bInterfaceCount
  475. 0x02, // bFunctionClass
  476. 0x02, // bFunctionSubClass
  477. 0x01, // bFunctionProtocol
  478. 4, // iFunction
  479. #endif
  480. #ifdef CDC_DATA_INTERFACE
  481. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  482. 9, // bLength
  483. 4, // bDescriptorType
  484. CDC_STATUS_INTERFACE, // bInterfaceNumber
  485. 0, // bAlternateSetting
  486. 1, // bNumEndpoints
  487. 0x02, // bInterfaceClass
  488. 0x02, // bInterfaceSubClass
  489. 0x01, // bInterfaceProtocol
  490. 0, // iInterface
  491. // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26
  492. 5, // bFunctionLength
  493. 0x24, // bDescriptorType
  494. 0x00, // bDescriptorSubtype
  495. 0x10, 0x01, // bcdCDC
  496. // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27
  497. 5, // bFunctionLength
  498. 0x24, // bDescriptorType
  499. 0x01, // bDescriptorSubtype
  500. 0x01, // bmCapabilities
  501. 1, // bDataInterface
  502. // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28
  503. 4, // bFunctionLength
  504. 0x24, // bDescriptorType
  505. 0x02, // bDescriptorSubtype
  506. 0x06, // bmCapabilities
  507. // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33
  508. 5, // bFunctionLength
  509. 0x24, // bDescriptorType
  510. 0x06, // bDescriptorSubtype
  511. CDC_STATUS_INTERFACE, // bMasterInterface
  512. CDC_DATA_INTERFACE, // bSlaveInterface0
  513. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  514. 7, // bLength
  515. 5, // bDescriptorType
  516. CDC_ACM_ENDPOINT | 0x80, // bEndpointAddress
  517. 0x03, // bmAttributes (0x03=intr)
  518. CDC_ACM_SIZE, 0, // wMaxPacketSize
  519. 64, // bInterval
  520. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  521. 9, // bLength
  522. 4, // bDescriptorType
  523. CDC_DATA_INTERFACE, // bInterfaceNumber
  524. 0, // bAlternateSetting
  525. 2, // bNumEndpoints
  526. 0x0A, // bInterfaceClass
  527. 0x00, // bInterfaceSubClass
  528. 0x00, // bInterfaceProtocol
  529. 0, // iInterface
  530. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  531. 7, // bLength
  532. 5, // bDescriptorType
  533. CDC_RX_ENDPOINT, // bEndpointAddress
  534. 0x02, // bmAttributes (0x02=bulk)
  535. CDC_RX_SIZE, 0, // wMaxPacketSize
  536. 0, // bInterval
  537. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  538. 7, // bLength
  539. 5, // bDescriptorType
  540. CDC_TX_ENDPOINT | 0x80, // bEndpointAddress
  541. 0x02, // bmAttributes (0x02=bulk)
  542. CDC_TX_SIZE, 0, // wMaxPacketSize
  543. 0, // bInterval
  544. #endif // CDC_DATA_INTERFACE
  545. #ifdef MIDI_INTERFACE
  546. // Standard MS Interface Descriptor,
  547. 9, // bLength
  548. 4, // bDescriptorType
  549. MIDI_INTERFACE, // bInterfaceNumber
  550. 0, // bAlternateSetting
  551. 2, // bNumEndpoints
  552. 0x01, // bInterfaceClass (0x01 = Audio)
  553. 0x03, // bInterfaceSubClass (0x03 = MIDI)
  554. 0x00, // bInterfaceProtocol (unused for MIDI)
  555. 0, // iInterface
  556. // MIDI MS Interface Header, USB MIDI 6.1.2.1, page 21, Table 6-2
  557. 7, // bLength
  558. 0x24, // bDescriptorType = CS_INTERFACE
  559. 0x01, // bDescriptorSubtype = MS_HEADER
  560. 0x00, 0x01, // bcdMSC = revision 01.00
  561. 0x41, 0x00, // wTotalLength
  562. // MIDI IN Jack Descriptor, B.4.3, Table B-7 (embedded), page 40
  563. 6, // bLength
  564. 0x24, // bDescriptorType = CS_INTERFACE
  565. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  566. 0x01, // bJackType = EMBEDDED
  567. 1, // bJackID, ID = 1
  568. 0, // iJack
  569. // MIDI IN Jack Descriptor, B.4.3, Table B-8 (external), page 40
  570. 6, // bLength
  571. 0x24, // bDescriptorType = CS_INTERFACE
  572. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  573. 0x02, // bJackType = EXTERNAL
  574. 2, // bJackID, ID = 2
  575. 0, // iJack
  576. // MIDI OUT Jack Descriptor, B.4.4, Table B-9, page 41
  577. 9,
  578. 0x24, // bDescriptorType = CS_INTERFACE
  579. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  580. 0x01, // bJackType = EMBEDDED
  581. 3, // bJackID, ID = 3
  582. 1, // bNrInputPins = 1 pin
  583. 2, // BaSourceID(1) = 2
  584. 1, // BaSourcePin(1) = first pin
  585. 0, // iJack
  586. // MIDI OUT Jack Descriptor, B.4.4, Table B-10, page 41
  587. 9,
  588. 0x24, // bDescriptorType = CS_INTERFACE
  589. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  590. 0x02, // bJackType = EXTERNAL
  591. 4, // bJackID, ID = 4
  592. 1, // bNrInputPins = 1 pin
  593. 1, // BaSourceID(1) = 1
  594. 1, // BaSourcePin(1) = first pin
  595. 0, // iJack
  596. // Standard Bulk OUT Endpoint Descriptor, B.5.1, Table B-11, pae 42
  597. 9, // bLength
  598. 5, // bDescriptorType = ENDPOINT
  599. MIDI_RX_ENDPOINT, // bEndpointAddress
  600. 0x02, // bmAttributes (0x02=bulk)
  601. MIDI_RX_SIZE, 0, // wMaxPacketSize
  602. 0, // bInterval
  603. 0, // bRefresh
  604. 0, // bSynchAddress
  605. // Class-specific MS Bulk OUT Endpoint Descriptor, B.5.2, Table B-12, page 42
  606. 5, // bLength
  607. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  608. 0x01, // bJackType = MS_GENERAL
  609. 1, // bNumEmbMIDIJack = 1 jack
  610. 1, // BaAssocJackID(1) = jack ID #1
  611. // Standard Bulk IN Endpoint Descriptor, B.5.1, Table B-11, pae 42
  612. 9, // bLength
  613. 5, // bDescriptorType = ENDPOINT
  614. MIDI_TX_ENDPOINT | 0x80, // bEndpointAddress
  615. 0x02, // bmAttributes (0x02=bulk)
  616. MIDI_TX_SIZE, 0, // wMaxPacketSize
  617. 0, // bInterval
  618. 0, // bRefresh
  619. 0, // bSynchAddress
  620. // Class-specific MS Bulk IN Endpoint Descriptor, B.5.2, Table B-12, page 42
  621. 5, // bLength
  622. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  623. 0x01, // bJackType = MS_GENERAL
  624. 1, // bNumEmbMIDIJack = 1 jack
  625. 3, // BaAssocJackID(1) = jack ID #3
  626. #endif // MIDI_INTERFACE
  627. #ifdef KEYBOARD_INTERFACE
  628. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  629. 9, // bLength
  630. 4, // bDescriptorType
  631. KEYBOARD_INTERFACE, // bInterfaceNumber
  632. 0, // bAlternateSetting
  633. 1, // bNumEndpoints
  634. 0x03, // bInterfaceClass (0x03 = HID)
  635. 0x01, // bInterfaceSubClass (0x01 = Boot)
  636. 0x01, // bInterfaceProtocol (0x01 = Keyboard)
  637. 0, // iInterface
  638. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  639. 9, // bLength
  640. 0x21, // bDescriptorType
  641. 0x11, 0x01, // bcdHID
  642. 0, // bCountryCode
  643. 1, // bNumDescriptors
  644. 0x22, // bDescriptorType
  645. LSB(sizeof(keyboard_report_desc)), // wDescriptorLength
  646. MSB(sizeof(keyboard_report_desc)),
  647. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  648. 7, // bLength
  649. 5, // bDescriptorType
  650. KEYBOARD_ENDPOINT | 0x80, // bEndpointAddress
  651. 0x03, // bmAttributes (0x03=intr)
  652. KEYBOARD_SIZE, 0, // wMaxPacketSize
  653. KEYBOARD_INTERVAL, // bInterval
  654. #endif // KEYBOARD_INTERFACE
  655. #ifdef MOUSE_INTERFACE
  656. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  657. 9, // bLength
  658. 4, // bDescriptorType
  659. MOUSE_INTERFACE, // bInterfaceNumber
  660. 0, // bAlternateSetting
  661. 1, // bNumEndpoints
  662. 0x03, // bInterfaceClass (0x03 = HID)
  663. 0x00, // bInterfaceSubClass (0x01 = Boot)
  664. 0x00, // bInterfaceProtocol (0x02 = Mouse)
  665. 0, // iInterface
  666. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  667. 9, // bLength
  668. 0x21, // bDescriptorType
  669. 0x11, 0x01, // bcdHID
  670. 0, // bCountryCode
  671. 1, // bNumDescriptors
  672. 0x22, // bDescriptorType
  673. LSB(sizeof(mouse_report_desc)), // wDescriptorLength
  674. MSB(sizeof(mouse_report_desc)),
  675. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  676. 7, // bLength
  677. 5, // bDescriptorType
  678. MOUSE_ENDPOINT | 0x80, // bEndpointAddress
  679. 0x03, // bmAttributes (0x03=intr)
  680. MOUSE_SIZE, 0, // wMaxPacketSize
  681. MOUSE_INTERVAL, // bInterval
  682. #endif // MOUSE_INTERFACE
  683. #ifdef RAWHID_INTERFACE
  684. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  685. 9, // bLength
  686. 4, // bDescriptorType
  687. RAWHID_INTERFACE, // bInterfaceNumber
  688. 0, // bAlternateSetting
  689. 2, // bNumEndpoints
  690. 0x03, // bInterfaceClass (0x03 = HID)
  691. 0x00, // bInterfaceSubClass
  692. 0x00, // bInterfaceProtocol
  693. 0, // iInterface
  694. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  695. 9, // bLength
  696. 0x21, // bDescriptorType
  697. 0x11, 0x01, // bcdHID
  698. 0, // bCountryCode
  699. 1, // bNumDescriptors
  700. 0x22, // bDescriptorType
  701. LSB(sizeof(rawhid_report_desc)), // wDescriptorLength
  702. MSB(sizeof(rawhid_report_desc)),
  703. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  704. 7, // bLength
  705. 5, // bDescriptorType
  706. RAWHID_TX_ENDPOINT | 0x80, // bEndpointAddress
  707. 0x03, // bmAttributes (0x03=intr)
  708. RAWHID_TX_SIZE, 0, // wMaxPacketSize
  709. RAWHID_TX_INTERVAL, // bInterval
  710. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  711. 7, // bLength
  712. 5, // bDescriptorType
  713. RAWHID_RX_ENDPOINT, // bEndpointAddress
  714. 0x03, // bmAttributes (0x03=intr)
  715. RAWHID_RX_SIZE, 0, // wMaxPacketSize
  716. RAWHID_RX_INTERVAL, // bInterval
  717. #endif // RAWHID_INTERFACE
  718. #ifdef FLIGHTSIM_INTERFACE
  719. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  720. 9, // bLength
  721. 4, // bDescriptorType
  722. FLIGHTSIM_INTERFACE, // bInterfaceNumber
  723. 0, // bAlternateSetting
  724. 2, // bNumEndpoints
  725. 0x03, // bInterfaceClass (0x03 = HID)
  726. 0x00, // bInterfaceSubClass
  727. 0x00, // bInterfaceProtocol
  728. 0, // iInterface
  729. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  730. 9, // bLength
  731. 0x21, // bDescriptorType
  732. 0x11, 0x01, // bcdHID
  733. 0, // bCountryCode
  734. 1, // bNumDescriptors
  735. 0x22, // bDescriptorType
  736. LSB(sizeof(flightsim_report_desc)), // wDescriptorLength
  737. MSB(sizeof(flightsim_report_desc)),
  738. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  739. 7, // bLength
  740. 5, // bDescriptorType
  741. FLIGHTSIM_TX_ENDPOINT | 0x80, // bEndpointAddress
  742. 0x03, // bmAttributes (0x03=intr)
  743. FLIGHTSIM_TX_SIZE, 0, // wMaxPacketSize
  744. FLIGHTSIM_TX_INTERVAL, // bInterval
  745. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  746. 7, // bLength
  747. 5, // bDescriptorType
  748. FLIGHTSIM_RX_ENDPOINT, // bEndpointAddress
  749. 0x03, // bmAttributes (0x03=intr)
  750. FLIGHTSIM_RX_SIZE, 0, // wMaxPacketSize
  751. FLIGHTSIM_RX_INTERVAL, // bInterval
  752. #endif // FLIGHTSIM_INTERFACE
  753. #ifdef SEREMU_INTERFACE
  754. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  755. 9, // bLength
  756. 4, // bDescriptorType
  757. SEREMU_INTERFACE, // bInterfaceNumber
  758. 0, // bAlternateSetting
  759. 2, // bNumEndpoints
  760. 0x03, // bInterfaceClass (0x03 = HID)
  761. 0x00, // bInterfaceSubClass
  762. 0x00, // bInterfaceProtocol
  763. 0, // iInterface
  764. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  765. 9, // bLength
  766. 0x21, // bDescriptorType
  767. 0x11, 0x01, // bcdHID
  768. 0, // bCountryCode
  769. 1, // bNumDescriptors
  770. 0x22, // bDescriptorType
  771. LSB(sizeof(seremu_report_desc)), // wDescriptorLength
  772. MSB(sizeof(seremu_report_desc)),
  773. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  774. 7, // bLength
  775. 5, // bDescriptorType
  776. SEREMU_TX_ENDPOINT | 0x80, // bEndpointAddress
  777. 0x03, // bmAttributes (0x03=intr)
  778. SEREMU_TX_SIZE, 0, // wMaxPacketSize
  779. SEREMU_TX_INTERVAL, // bInterval
  780. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  781. 7, // bLength
  782. 5, // bDescriptorType
  783. SEREMU_RX_ENDPOINT, // bEndpointAddress
  784. 0x03, // bmAttributes (0x03=intr)
  785. SEREMU_RX_SIZE, 0, // wMaxPacketSize
  786. SEREMU_RX_INTERVAL, // bInterval
  787. #endif // SEREMU_INTERFACE
  788. #ifdef JOYSTICK_INTERFACE
  789. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  790. 9, // bLength
  791. 4, // bDescriptorType
  792. JOYSTICK_INTERFACE, // bInterfaceNumber
  793. 0, // bAlternateSetting
  794. 1, // bNumEndpoints
  795. 0x03, // bInterfaceClass (0x03 = HID)
  796. 0x00, // bInterfaceSubClass
  797. 0x00, // bInterfaceProtocol
  798. 0, // iInterface
  799. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  800. 9, // bLength
  801. 0x21, // bDescriptorType
  802. 0x11, 0x01, // bcdHID
  803. 0, // bCountryCode
  804. 1, // bNumDescriptors
  805. 0x22, // bDescriptorType
  806. LSB(sizeof(joystick_report_desc)), // wDescriptorLength
  807. MSB(sizeof(joystick_report_desc)),
  808. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  809. 7, // bLength
  810. 5, // bDescriptorType
  811. JOYSTICK_ENDPOINT | 0x80, // bEndpointAddress
  812. 0x03, // bmAttributes (0x03=intr)
  813. JOYSTICK_SIZE, 0, // wMaxPacketSize
  814. JOYSTICK_INTERVAL, // bInterval
  815. #endif // JOYSTICK_INTERFACE
  816. #ifdef MTP_INTERFACE
  817. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  818. 9, // bLength
  819. 4, // bDescriptorType
  820. MTP_INTERFACE, // bInterfaceNumber
  821. 0, // bAlternateSetting
  822. 3, // bNumEndpoints
  823. 0x06, // bInterfaceClass (0x06 = still image)
  824. 0x01, // bInterfaceSubClass
  825. 0x01, // bInterfaceProtocol
  826. 0, // iInterface
  827. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  828. 7, // bLength
  829. 5, // bDescriptorType
  830. MTP_TX_ENDPOINT | 0x80, // bEndpointAddress
  831. 0x02, // bmAttributes (0x02=bulk)
  832. MTP_TX_SIZE, 0, // wMaxPacketSize
  833. 0, // bInterval
  834. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  835. 7, // bLength
  836. 5, // bDescriptorType
  837. MTP_RX_ENDPOINT, // bEndpointAddress
  838. 0x02, // bmAttributes (0x02=bulk)
  839. MTP_RX_SIZE, 0, // wMaxPacketSize
  840. 0, // bInterval
  841. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  842. 7, // bLength
  843. 5, // bDescriptorType
  844. MTP_EVENT_ENDPOINT | 0x80, // bEndpointAddress
  845. 0x03, // bmAttributes (0x03=intr)
  846. MTP_EVENT_SIZE, 0, // wMaxPacketSize
  847. MTP_EVENT_INTERVAL, // bInterval
  848. #endif // MTP_INTERFACE
  849. #ifdef KEYMEDIA_INTERFACE
  850. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  851. 9, // bLength
  852. 4, // bDescriptorType
  853. KEYMEDIA_INTERFACE, // bInterfaceNumber
  854. 0, // bAlternateSetting
  855. 1, // bNumEndpoints
  856. 0x03, // bInterfaceClass (0x03 = HID)
  857. 0x00, // bInterfaceSubClass
  858. 0x00, // bInterfaceProtocol
  859. 0, // iInterface
  860. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  861. 9, // bLength
  862. 0x21, // bDescriptorType
  863. 0x11, 0x01, // bcdHID
  864. 0, // bCountryCode
  865. 1, // bNumDescriptors
  866. 0x22, // bDescriptorType
  867. LSB(sizeof(keymedia_report_desc)), // wDescriptorLength
  868. MSB(sizeof(keymedia_report_desc)),
  869. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  870. 7, // bLength
  871. 5, // bDescriptorType
  872. KEYMEDIA_ENDPOINT | 0x80, // bEndpointAddress
  873. 0x03, // bmAttributes (0x03=intr)
  874. KEYMEDIA_SIZE, 0, // wMaxPacketSize
  875. KEYMEDIA_INTERVAL, // bInterval
  876. #endif // KEYMEDIA_INTERFACE
  877. #ifdef AUDIO_INTERFACE
  878. // Standard AudioControl (AC) Interface Descriptor
  879. // USB DCD for Audio Devices 1.0, Table 4-1, page 36
  880. 9, // bLength
  881. 4, // bDescriptorType, 4 = INTERFACE
  882. AUDIO_INTERFACE, // bInterfaceNumber
  883. 0, // bAlternateSetting
  884. 0, // bNumEndpoints
  885. 1, // bInterfaceClass, 1 = AUDIO
  886. 1, // bInterfaceSubclass, 1 = AUDIO_CONTROL
  887. 0, // bInterfaceProtocol
  888. 0, // iInterface
  889. // Class-specific AC Interface Header Descriptor
  890. // USB DCD for Audio Devices 1.0, Table 4-2, page 37-38
  891. 10, // bLength
  892. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  893. 0x01, // bDescriptorSubtype, 1 = HEADER
  894. 0x00, 0x01, // bcdADC (version 1.0)
  895. LSB(62), MSB(62), // wTotalLength
  896. 2, // bInCollection
  897. AUDIO_INTERFACE+1, // baInterfaceNr(1) - Transmit to PC
  898. AUDIO_INTERFACE+2, // baInterfaceNr(2) - Receive from PC
  899. // Input Terminal Descriptor
  900. // USB DCD for Audio Devices 1.0, Table 4-3, page 39
  901. 12, // bLength
  902. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  903. 0x02, // bDescriptorSubType, 2 = INPUT_TERMINAL
  904. 1, // bTerminalID
  905. //0x01, 0x02, // wTerminalType, 0x0201 = MICROPHONE
  906. //0x03, 0x06, // wTerminalType, 0x0603 = Line Connector
  907. 0x02, 0x06, // wTerminalType, 0x0602 = Digital Audio
  908. 0, // bAssocTerminal, 0 = unidirectional
  909. 2, // bNrChannels
  910. 0x03, 0x00, // wChannelConfig, 0x0003 = Left & Right Front
  911. 0, // iChannelNames
  912. 0, // iTerminal
  913. // Output Terminal Descriptor
  914. // USB DCD for Audio Devices 1.0, Table 4-4, page 40
  915. 9, // bLength
  916. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  917. 3, // bDescriptorSubtype, 3 = OUTPUT_TERMINAL
  918. 2, // bTerminalID
  919. 0x01, 0x01, // wTerminalType, 0x0101 = USB_STREAMING
  920. 0, // bAssocTerminal, 0 = unidirectional
  921. 1, // bCSourceID, connected to input terminal, ID=1
  922. 0, // iTerminal
  923. // Input Terminal Descriptor
  924. // USB DCD for Audio Devices 1.0, Table 4-3, page 39
  925. 12, // bLength
  926. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  927. 2, // bDescriptorSubType, 2 = INPUT_TERMINAL
  928. 3, // bTerminalID
  929. 0x01, 0x01, // wTerminalType, 0x0101 = USB_STREAMING
  930. 0, // bAssocTerminal, 0 = unidirectional
  931. 2, // bNrChannels
  932. 0x03, 0x00, // wChannelConfig, 0x0003 = Left & Right Front
  933. 0, // iChannelNames
  934. 0, // iTerminal
  935. // Volume feature descriptor
  936. 10, // bLength
  937. 0x24, // bDescriptorType = CS_INTERFACE
  938. 0x06, // bDescriptorSubType = FEATURE_UNIT
  939. 0x31, // bUnitID
  940. 0x03, // bSourceID (Input Terminal)
  941. 0x01, // bControlSize (each channel is 1 byte, 3 channels)
  942. 0x01, // bmaControls(0) Master: Mute
  943. 0x02, // bmaControls(1) Left: Volume
  944. 0x02, // bmaControls(2) Right: Volume
  945. 0x00, // iFeature
  946. // Output Terminal Descriptor
  947. // USB DCD for Audio Devices 1.0, Table 4-4, page 40
  948. 9, // bLength
  949. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  950. 3, // bDescriptorSubtype, 3 = OUTPUT_TERMINAL
  951. 4, // bTerminalID
  952. //0x02, 0x03, // wTerminalType, 0x0302 = Headphones
  953. 0x02, 0x06, // wTerminalType, 0x0602 = Digital Audio
  954. 0, // bAssocTerminal, 0 = unidirectional
  955. 0x31, // bCSourceID, connected to feature, ID=31
  956. 0, // iTerminal
  957. // Standard AS Interface Descriptor
  958. // USB DCD for Audio Devices 1.0, Section 4.5.1, Table 4-18, page 59
  959. // Alternate 0: default setting, disabled zero bandwidth
  960. 9, // bLenght
  961. 4, // bDescriptorType = INTERFACE
  962. AUDIO_INTERFACE+1, // bInterfaceNumber
  963. 0, // bAlternateSetting
  964. 0, // bNumEndpoints
  965. 1, // bInterfaceClass, 1 = AUDIO
  966. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  967. 0, // bInterfaceProtocol
  968. 0, // iInterface
  969. // Alternate 1: streaming data
  970. 9, // bLenght
  971. 4, // bDescriptorType = INTERFACE
  972. AUDIO_INTERFACE+1, // bInterfaceNumber
  973. 1, // bAlternateSetting
  974. 1, // bNumEndpoints
  975. 1, // bInterfaceClass, 1 = AUDIO
  976. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  977. 0, // bInterfaceProtocol
  978. 0, // iInterface
  979. // Class-Specific AS Interface Descriptor
  980. // USB DCD for Audio Devices 1.0, Section 4.5.2, Table 4-19, page 60
  981. 7, // bLength
  982. 0x24, // bDescriptorType = CS_INTERFACE
  983. 1, // bDescriptorSubtype, 1 = AS_GENERAL
  984. 2, // bTerminalLink: Terminal ID = 2
  985. 3, // bDelay (approx 3ms delay, audio lib updates)
  986. 0x01, 0x00, // wFormatTag, 0x0001 = PCM
  987. // Type I Format Descriptor
  988. // USB DCD for Audio Data Formats 1.0, Section 2.2.5, Table 2-1, page 10
  989. 11, // bLength
  990. 0x24, // bDescriptorType = CS_INTERFACE
  991. 2, // bDescriptorSubtype = FORMAT_TYPE
  992. 1, // bFormatType = FORMAT_TYPE_I
  993. 2, // bNrChannels = 2
  994. 2, // bSubFrameSize = 2 byte
  995. 16, // bBitResolution = 16 bits
  996. 1, // bSamFreqType = 1 frequency
  997. LSB(44100), MSB(44100), 0, // tSamFreq
  998. // Standard AS Isochronous Audio Data Endpoint Descriptor
  999. // USB DCD for Audio Devices 1.0, Section 4.6.1.1, Table 4-20, page 61-62
  1000. 9, // bLength
  1001. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  1002. AUDIO_TX_ENDPOINT | 0x80, // bEndpointAddress
  1003. 0x05, // bmAttributes = isochronous, asynchronous
  1004. LSB(AUDIO_TX_SIZE), MSB(AUDIO_TX_SIZE), // wMaxPacketSize
  1005. 1, // bInterval, 1 = every frame
  1006. 0, // bRefresh
  1007. 0, // bSynchAddress
  1008. // Class-Specific AS Isochronous Audio Data Endpoint Descriptor
  1009. // USB DCD for Audio Devices 1.0, Section 4.6.1.2, Table 4-21, page 62-63
  1010. 7, // bLength
  1011. 0x25, // bDescriptorType, 0x25 = CS_ENDPOINT
  1012. 1, // bDescriptorSubtype, 1 = EP_GENERAL
  1013. 0x00, // bmAttributes
  1014. 0, // bLockDelayUnits, 1 = ms
  1015. 0x00, 0x00, // wLockDelay
  1016. // Standard AS Interface Descriptor
  1017. // USB DCD for Audio Devices 1.0, Section 4.5.1, Table 4-18, page 59
  1018. // Alternate 0: default setting, disabled zero bandwidth
  1019. 9, // bLenght
  1020. 4, // bDescriptorType = INTERFACE
  1021. AUDIO_INTERFACE+2, // bInterfaceNumber
  1022. 0, // bAlternateSetting
  1023. 0, // bNumEndpoints
  1024. 1, // bInterfaceClass, 1 = AUDIO
  1025. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  1026. 0, // bInterfaceProtocol
  1027. 0, // iInterface
  1028. // Alternate 1: streaming data
  1029. 9, // bLenght
  1030. 4, // bDescriptorType = INTERFACE
  1031. AUDIO_INTERFACE+2, // bInterfaceNumber
  1032. 1, // bAlternateSetting
  1033. 2, // bNumEndpoints
  1034. 1, // bInterfaceClass, 1 = AUDIO
  1035. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  1036. 0, // bInterfaceProtocol
  1037. 0, // iInterface
  1038. // Class-Specific AS Interface Descriptor
  1039. // USB DCD for Audio Devices 1.0, Section 4.5.2, Table 4-19, page 60
  1040. 7, // bLength
  1041. 0x24, // bDescriptorType = CS_INTERFACE
  1042. 1, // bDescriptorSubtype, 1 = AS_GENERAL
  1043. 3, // bTerminalLink: Terminal ID = 3
  1044. 3, // bDelay (approx 3ms delay, audio lib updates)
  1045. 0x01, 0x00, // wFormatTag, 0x0001 = PCM
  1046. // Type I Format Descriptor
  1047. // USB DCD for Audio Data Formats 1.0, Section 2.2.5, Table 2-1, page 10
  1048. 11, // bLength
  1049. 0x24, // bDescriptorType = CS_INTERFACE
  1050. 2, // bDescriptorSubtype = FORMAT_TYPE
  1051. 1, // bFormatType = FORMAT_TYPE_I
  1052. 2, // bNrChannels = 2
  1053. 2, // bSubFrameSize = 2 byte
  1054. 16, // bBitResolution = 16 bits
  1055. 1, // bSamFreqType = 1 frequency
  1056. LSB(44100), MSB(44100), 0, // tSamFreq
  1057. // Standard AS Isochronous Audio Data Endpoint Descriptor
  1058. // USB DCD for Audio Devices 1.0, Section 4.6.1.1, Table 4-20, page 61-62
  1059. 9, // bLength
  1060. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  1061. AUDIO_RX_ENDPOINT, // bEndpointAddress
  1062. 0x05, // bmAttributes = isochronous, asynchronous
  1063. LSB(AUDIO_RX_SIZE), MSB(AUDIO_RX_SIZE), // wMaxPacketSize
  1064. 1, // bInterval, 1 = every frame
  1065. 0, // bRefresh
  1066. AUDIO_SYNC_ENDPOINT | 0x80, // bSynchAddress
  1067. // Class-Specific AS Isochronous Audio Data Endpoint Descriptor
  1068. // USB DCD for Audio Devices 1.0, Section 4.6.1.2, Table 4-21, page 62-63
  1069. 7, // bLength
  1070. 0x25, // bDescriptorType, 0x25 = CS_ENDPOINT
  1071. 1, // bDescriptorSubtype, 1 = EP_GENERAL
  1072. 0x00, // bmAttributes
  1073. 0, // bLockDelayUnits, 1 = ms
  1074. 0x00, 0x00, // wLockDelay
  1075. // Standard AS Isochronous Audio Synch Endpoint Descriptor
  1076. // USB DCD for Audio Devices 1.0, Section 4.6.2.1, Table 4-22, page 63-64
  1077. 9, // bLength
  1078. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  1079. AUDIO_SYNC_ENDPOINT | 0x80, // bEndpointAddress
  1080. 0x11, // bmAttributes = isochronous, feedback
  1081. 3, 0, // wMaxPacketSize, 3 bytes
  1082. 1, // bInterval, 1 = every frame
  1083. 5, // bRefresh, 5 = 32ms
  1084. 0, // bSynchAddress
  1085. #endif
  1086. #ifdef MULTITOUCH_INTERFACE
  1087. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1088. 9, // bLength
  1089. 4, // bDescriptorType
  1090. MULTITOUCH_INTERFACE, // bInterfaceNumber
  1091. 0, // bAlternateSetting
  1092. 1, // bNumEndpoints
  1093. 0x03, // bInterfaceClass (0x03 = HID)
  1094. 0x00, // bInterfaceSubClass
  1095. 0x00, // bInterfaceProtocol
  1096. 0, // iInterface
  1097. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1098. 9, // bLength
  1099. 0x21, // bDescriptorType
  1100. 0x11, 0x01, // bcdHID
  1101. 0, // bCountryCode
  1102. 1, // bNumDescriptors
  1103. 0x22, // bDescriptorType
  1104. LSB(sizeof(multitouch_report_desc)), // wDescriptorLength
  1105. MSB(sizeof(multitouch_report_desc)),
  1106. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1107. 7, // bLength
  1108. 5, // bDescriptorType
  1109. MULTITOUCH_ENDPOINT | 0x80, // bEndpointAddress
  1110. 0x03, // bmAttributes (0x03=intr)
  1111. MULTITOUCH_SIZE, 0, // wMaxPacketSize
  1112. 1, // bInterval
  1113. #endif // KEYMEDIA_INTERFACE
  1114. };
  1115. // **************************************************************
  1116. // String Descriptors
  1117. // **************************************************************
  1118. // The descriptors above can provide human readable strings,
  1119. // referenced by index numbers. These descriptors are the
  1120. // actual string data
  1121. /* defined in usb_names.h
  1122. struct usb_string_descriptor_struct {
  1123. uint8_t bLength;
  1124. uint8_t bDescriptorType;
  1125. uint16_t wString[];
  1126. };
  1127. */
  1128. extern struct usb_string_descriptor_struct usb_string_manufacturer_name
  1129. __attribute__ ((weak, alias("usb_string_manufacturer_name_default")));
  1130. extern struct usb_string_descriptor_struct usb_string_product_name
  1131. __attribute__ ((weak, alias("usb_string_product_name_default")));
  1132. extern struct usb_string_descriptor_struct usb_string_serial_number
  1133. __attribute__ ((weak, alias("usb_string_serial_number_default")));
  1134. struct usb_string_descriptor_struct string0 = {
  1135. 4,
  1136. 3,
  1137. {0x0409}
  1138. };
  1139. struct usb_string_descriptor_struct usb_string_manufacturer_name_default = {
  1140. 2 + MANUFACTURER_NAME_LEN * 2,
  1141. 3,
  1142. MANUFACTURER_NAME
  1143. };
  1144. struct usb_string_descriptor_struct usb_string_product_name_default = {
  1145. 2 + PRODUCT_NAME_LEN * 2,
  1146. 3,
  1147. PRODUCT_NAME
  1148. };
  1149. struct usb_string_descriptor_struct usb_string_serial_number_default = {
  1150. 12,
  1151. 3,
  1152. {0,0,0,0,0,0,0,0,0,0}
  1153. };
  1154. void usb_init_serialnumber(void)
  1155. {
  1156. char buf[11];
  1157. uint32_t i, num;
  1158. __disable_irq();
  1159. #if defined(HAS_KINETIS_FLASH_FTFA) || defined(HAS_KINETIS_FLASH_FTFL)
  1160. FTFL_FSTAT = FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL;
  1161. FTFL_FCCOB0 = 0x41;
  1162. FTFL_FCCOB1 = 15;
  1163. FTFL_FSTAT = FTFL_FSTAT_CCIF;
  1164. while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF)) ; // wait
  1165. num = *(uint32_t *)&FTFL_FCCOB7;
  1166. #elif defined(HAS_KINETIS_FLASH_FTFE)
  1167. // TODO: does not work in HSRUN mode
  1168. FTFL_FSTAT = FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL;
  1169. *(uint32_t *)&FTFL_FCCOB3 = 0x41070000;
  1170. FTFL_FSTAT = FTFL_FSTAT_CCIF;
  1171. while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF)) ; // wait
  1172. num = *(uint32_t *)&FTFL_FCCOBB;
  1173. #endif
  1174. __enable_irq();
  1175. // add extra zero to work around OS-X CDC-ACM driver bug
  1176. if (num < 10000000) num = num * 10;
  1177. ultoa(num, buf, 10);
  1178. for (i=0; i<10; i++) {
  1179. char c = buf[i];
  1180. if (!c) break;
  1181. usb_string_serial_number_default.wString[i] = c;
  1182. }
  1183. usb_string_serial_number_default.bLength = i * 2 + 2;
  1184. }
  1185. // **************************************************************
  1186. // Descriptors List
  1187. // **************************************************************
  1188. // This table provides access to all the descriptor data above.
  1189. const usb_descriptor_list_t usb_descriptor_list[] = {
  1190. //wValue, wIndex, address, length
  1191. {0x0100, 0x0000, device_descriptor, sizeof(device_descriptor)},
  1192. {0x0200, 0x0000, config_descriptor, sizeof(config_descriptor)},
  1193. #ifdef SEREMU_INTERFACE
  1194. {0x2200, SEREMU_INTERFACE, seremu_report_desc, sizeof(seremu_report_desc)},
  1195. {0x2100, SEREMU_INTERFACE, config_descriptor+SEREMU_HID_DESC_OFFSET, 9},
  1196. #endif
  1197. #ifdef KEYBOARD_INTERFACE
  1198. {0x2200, KEYBOARD_INTERFACE, keyboard_report_desc, sizeof(keyboard_report_desc)},
  1199. {0x2100, KEYBOARD_INTERFACE, config_descriptor+KEYBOARD_HID_DESC_OFFSET, 9},
  1200. #endif
  1201. #ifdef MOUSE_INTERFACE
  1202. {0x2200, MOUSE_INTERFACE, mouse_report_desc, sizeof(mouse_report_desc)},
  1203. {0x2100, MOUSE_INTERFACE, config_descriptor+MOUSE_HID_DESC_OFFSET, 9},
  1204. #endif
  1205. #ifdef JOYSTICK_INTERFACE
  1206. {0x2200, JOYSTICK_INTERFACE, joystick_report_desc, sizeof(joystick_report_desc)},
  1207. {0x2100, JOYSTICK_INTERFACE, config_descriptor+JOYSTICK_HID_DESC_OFFSET, 9},
  1208. #endif
  1209. #ifdef RAWHID_INTERFACE
  1210. {0x2200, RAWHID_INTERFACE, rawhid_report_desc, sizeof(rawhid_report_desc)},
  1211. {0x2100, RAWHID_INTERFACE, config_descriptor+RAWHID_HID_DESC_OFFSET, 9},
  1212. #endif
  1213. #ifdef FLIGHTSIM_INTERFACE
  1214. {0x2200, FLIGHTSIM_INTERFACE, flightsim_report_desc, sizeof(flightsim_report_desc)},
  1215. {0x2100, FLIGHTSIM_INTERFACE, config_descriptor+FLIGHTSIM_HID_DESC_OFFSET, 9},
  1216. #endif
  1217. #ifdef KEYMEDIA_INTERFACE
  1218. {0x2200, KEYMEDIA_INTERFACE, keymedia_report_desc, sizeof(keymedia_report_desc)},
  1219. {0x2100, KEYMEDIA_INTERFACE, config_descriptor+KEYMEDIA_HID_DESC_OFFSET, 9},
  1220. #endif
  1221. #ifdef MULTITOUCH_INTERFACE
  1222. {0x2200, MULTITOUCH_INTERFACE, multitouch_report_desc, sizeof(multitouch_report_desc)},
  1223. {0x2100, MULTITOUCH_INTERFACE, config_descriptor+MULTITOUCH_HID_DESC_OFFSET, 9},
  1224. #endif
  1225. {0x0300, 0x0000, (const uint8_t *)&string0, 0},
  1226. {0x0301, 0x0409, (const uint8_t *)&usb_string_manufacturer_name, 0},
  1227. {0x0302, 0x0409, (const uint8_t *)&usb_string_product_name, 0},
  1228. {0x0303, 0x0409, (const uint8_t *)&usb_string_serial_number, 0},
  1229. {0, 0, NULL, 0}
  1230. };
  1231. // **************************************************************
  1232. // Endpoint Configuration
  1233. // **************************************************************
  1234. #if 0
  1235. // 0x00 = not used
  1236. // 0x19 = Recieve only
  1237. // 0x15 = Transmit only
  1238. // 0x1D = Transmit & Recieve
  1239. //
  1240. const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS] =
  1241. {
  1242. 0x00, 0x15, 0x19, 0x15, 0x00, 0x00, 0x00, 0x00,
  1243. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1244. };
  1245. #endif
  1246. const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS] =
  1247. {
  1248. #if (defined(ENDPOINT1_CONFIG) && NUM_ENDPOINTS >= 1)
  1249. ENDPOINT1_CONFIG,
  1250. #elif (NUM_ENDPOINTS >= 1)
  1251. ENDPOINT_UNUSED,
  1252. #endif
  1253. #if (defined(ENDPOINT2_CONFIG) && NUM_ENDPOINTS >= 2)
  1254. ENDPOINT2_CONFIG,
  1255. #elif (NUM_ENDPOINTS >= 2)
  1256. ENDPOINT_UNUSED,
  1257. #endif
  1258. #if (defined(ENDPOINT3_CONFIG) && NUM_ENDPOINTS >= 3)
  1259. ENDPOINT3_CONFIG,
  1260. #elif (NUM_ENDPOINTS >= 3)
  1261. ENDPOINT_UNUSED,
  1262. #endif
  1263. #if (defined(ENDPOINT4_CONFIG) && NUM_ENDPOINTS >= 4)
  1264. ENDPOINT4_CONFIG,
  1265. #elif (NUM_ENDPOINTS >= 4)
  1266. ENDPOINT_UNUSED,
  1267. #endif
  1268. #if (defined(ENDPOINT5_CONFIG) && NUM_ENDPOINTS >= 5)
  1269. ENDPOINT5_CONFIG,
  1270. #elif (NUM_ENDPOINTS >= 5)
  1271. ENDPOINT_UNUSED,
  1272. #endif
  1273. #if (defined(ENDPOINT6_CONFIG) && NUM_ENDPOINTS >= 6)
  1274. ENDPOINT6_CONFIG,
  1275. #elif (NUM_ENDPOINTS >= 6)
  1276. ENDPOINT_UNUSED,
  1277. #endif
  1278. #if (defined(ENDPOINT7_CONFIG) && NUM_ENDPOINTS >= 7)
  1279. ENDPOINT7_CONFIG,
  1280. #elif (NUM_ENDPOINTS >= 7)
  1281. ENDPOINT_UNUSED,
  1282. #endif
  1283. #if (defined(ENDPOINT8_CONFIG) && NUM_ENDPOINTS >= 8)
  1284. ENDPOINT8_CONFIG,
  1285. #elif (NUM_ENDPOINTS >= 8)
  1286. ENDPOINT_UNUSED,
  1287. #endif
  1288. #if (defined(ENDPOINT9_CONFIG) && NUM_ENDPOINTS >= 9)
  1289. ENDPOINT9_CONFIG,
  1290. #elif (NUM_ENDPOINTS >= 9)
  1291. ENDPOINT_UNUSED,
  1292. #endif
  1293. #if (defined(ENDPOINT10_CONFIG) && NUM_ENDPOINTS >= 10)
  1294. ENDPOINT10_CONFIG,
  1295. #elif (NUM_ENDPOINTS >= 10)
  1296. ENDPOINT_UNUSED,
  1297. #endif
  1298. #if (defined(ENDPOINT11_CONFIG) && NUM_ENDPOINTS >= 11)
  1299. ENDPOINT11_CONFIG,
  1300. #elif (NUM_ENDPOINTS >= 11)
  1301. ENDPOINT_UNUSED,
  1302. #endif
  1303. #if (defined(ENDPOINT12_CONFIG) && NUM_ENDPOINTS >= 12)
  1304. ENDPOINT12_CONFIG,
  1305. #elif (NUM_ENDPOINTS >= 12)
  1306. ENDPOINT_UNUSED,
  1307. #endif
  1308. #if (defined(ENDPOINT13_CONFIG) && NUM_ENDPOINTS >= 13)
  1309. ENDPOINT13_CONFIG,
  1310. #elif (NUM_ENDPOINTS >= 13)
  1311. ENDPOINT_UNUSED,
  1312. #endif
  1313. #if (defined(ENDPOINT14_CONFIG) && NUM_ENDPOINTS >= 14)
  1314. ENDPOINT14_CONFIG,
  1315. #elif (NUM_ENDPOINTS >= 14)
  1316. ENDPOINT_UNUSED,
  1317. #endif
  1318. #if (defined(ENDPOINT15_CONFIG) && NUM_ENDPOINTS >= 15)
  1319. ENDPOINT15_CONFIG,
  1320. #elif (NUM_ENDPOINTS >= 15)
  1321. ENDPOINT_UNUSED,
  1322. #endif
  1323. };
  1324. #endif // NUM_ENDPOINTS
  1325. #endif // F_CPU >= 20 MHz