Teensy 4.1 core updated for C++20
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.

пре 11 година
пре 11 година
пре 10 година
пре 11 година
пре 10 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 8 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 9 година
пре 8 година
пре 11 година
пре 10 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 10 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 10 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 9 година
пре 9 година
пре 8 година
пре 8 година
пре 8 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 11 година
пре 8 година
пре 11 година
пре 10 година
пре 11 година
пре 10 година
пре 11 година
пре 10 година
пре 11 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857
  1. /* Teensyduino Core Library
  2. * http://www.pjrc.com/teensy/
  3. * Copyright (c) 2017 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. 0x10, 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. #ifdef BCD_DEVICE
  82. LSB(BCD_DEVICE), MSB(BCD_DEVICE), // bcdDevice
  83. #else
  84. 0x00, 0x02,
  85. #endif
  86. 1, // iManufacturer
  87. 2, // iProduct
  88. 3, // iSerialNumber
  89. 1 // bNumConfigurations
  90. };
  91. // These descriptors must NOT be "const", because the USB DMA
  92. // has trouble accessing flash memory with enough bandwidth
  93. // while the processor is executing from flash.
  94. // **************************************************************
  95. // HID Report Descriptors
  96. // **************************************************************
  97. // Each HID interface needs a special report descriptor that tells
  98. // the meaning and format of the data.
  99. #ifdef KEYBOARD_INTERFACE
  100. // Keyboard Protocol 1, HID 1.11 spec, Appendix B, page 59-60
  101. static uint8_t keyboard_report_desc[] = {
  102. 0x05, 0x01, // Usage Page (Generic Desktop),
  103. 0x09, 0x06, // Usage (Keyboard),
  104. 0xA1, 0x01, // Collection (Application),
  105. 0x75, 0x01, // Report Size (1),
  106. 0x95, 0x08, // Report Count (8),
  107. 0x05, 0x07, // Usage Page (Key Codes),
  108. 0x19, 0xE0, // Usage Minimum (224),
  109. 0x29, 0xE7, // Usage Maximum (231),
  110. 0x15, 0x00, // Logical Minimum (0),
  111. 0x25, 0x01, // Logical Maximum (1),
  112. 0x81, 0x02, // Input (Data, Variable, Absolute), ;Modifier keys
  113. 0x95, 0x01, // Report Count (1),
  114. 0x75, 0x08, // Report Size (8),
  115. 0x81, 0x03, // Input (Constant), ;Reserved byte
  116. 0x95, 0x05, // Report Count (5),
  117. 0x75, 0x01, // Report Size (1),
  118. 0x05, 0x08, // Usage Page (LEDs),
  119. 0x19, 0x01, // Usage Minimum (1),
  120. 0x29, 0x05, // Usage Maximum (5),
  121. 0x91, 0x02, // Output (Data, Variable, Absolute), ;LED report
  122. 0x95, 0x01, // Report Count (1),
  123. 0x75, 0x03, // Report Size (3),
  124. 0x91, 0x03, // Output (Constant), ;LED report padding
  125. 0x95, 0x06, // Report Count (6),
  126. 0x75, 0x08, // Report Size (8),
  127. 0x15, 0x00, // Logical Minimum (0),
  128. 0x25, 0x7F, // Logical Maximum(104),
  129. 0x05, 0x07, // Usage Page (Key Codes),
  130. 0x19, 0x00, // Usage Minimum (0),
  131. 0x29, 0x7F, // Usage Maximum (104),
  132. 0x81, 0x00, // Input (Data, Array), ;Normal keys
  133. 0xC0 // End Collection
  134. };
  135. #endif
  136. #ifdef KEYMEDIA_INTERFACE
  137. static uint8_t keymedia_report_desc[] = {
  138. 0x05, 0x0C, // Usage Page (Consumer)
  139. 0x09, 0x01, // Usage (Consumer Controls)
  140. 0xA1, 0x01, // Collection (Application)
  141. 0x75, 0x0A, // Report Size (10)
  142. 0x95, 0x04, // Report Count (4)
  143. 0x19, 0x00, // Usage Minimum (0)
  144. 0x2A, 0x9C, 0x02, // Usage Maximum (0x29C)
  145. 0x15, 0x00, // Logical Minimum (0)
  146. 0x26, 0x9C, 0x02, // Logical Maximum (0x29C)
  147. 0x81, 0x00, // Input (Data, Array)
  148. 0x05, 0x01, // Usage Page (Generic Desktop)
  149. 0x75, 0x08, // Report Size (8)
  150. 0x95, 0x03, // Report Count (3)
  151. 0x19, 0x00, // Usage Minimum (0)
  152. 0x29, 0xB7, // Usage Maximum (0xB7)
  153. 0x15, 0x00, // Logical Minimum (0)
  154. 0x26, 0xB7, 0x00, // Logical Maximum (0xB7)
  155. 0x81, 0x00, // Input (Data, Array)
  156. 0xC0 // End Collection
  157. };
  158. #endif
  159. #ifdef MOUSE_INTERFACE
  160. // Mouse Protocol 1, HID 1.11 spec, Appendix B, page 59-60, with wheel extension
  161. static uint8_t mouse_report_desc[] = {
  162. 0x05, 0x01, // Usage Page (Generic Desktop)
  163. 0x09, 0x02, // Usage (Mouse)
  164. 0xA1, 0x01, // Collection (Application)
  165. 0x85, 0x01, // REPORT_ID (1)
  166. 0x05, 0x09, // Usage Page (Button)
  167. 0x19, 0x01, // Usage Minimum (Button #1)
  168. 0x29, 0x08, // Usage Maximum (Button #8)
  169. 0x15, 0x00, // Logical Minimum (0)
  170. 0x25, 0x01, // Logical Maximum (1)
  171. 0x95, 0x08, // Report Count (8)
  172. 0x75, 0x01, // Report Size (1)
  173. 0x81, 0x02, // Input (Data, Variable, Absolute)
  174. 0x05, 0x01, // Usage Page (Generic Desktop)
  175. 0x09, 0x30, // Usage (X)
  176. 0x09, 0x31, // Usage (Y)
  177. 0x09, 0x38, // Usage (Wheel)
  178. 0x15, 0x81, // Logical Minimum (-127)
  179. 0x25, 0x7F, // Logical Maximum (127)
  180. 0x75, 0x08, // Report Size (8),
  181. 0x95, 0x03, // Report Count (3),
  182. 0x81, 0x06, // Input (Data, Variable, Relative)
  183. 0x05, 0x0C, // Usage Page (Consumer)
  184. 0x0A, 0x38, 0x02, // Usage (AC Pan)
  185. 0x15, 0x81, // Logical Minimum (-127)
  186. 0x25, 0x7F, // Logical Maximum (127)
  187. 0x75, 0x08, // Report Size (8),
  188. 0x95, 0x01, // Report Count (1),
  189. 0x81, 0x06, // Input (Data, Variable, Relative)
  190. 0xC0, // End Collection
  191. 0x05, 0x01, // Usage Page (Generic Desktop)
  192. 0x09, 0x02, // Usage (Mouse)
  193. 0xA1, 0x01, // Collection (Application)
  194. 0x85, 0x02, // REPORT_ID (2)
  195. 0x05, 0x01, // Usage Page (Generic Desktop)
  196. 0x09, 0x30, // Usage (X)
  197. 0x09, 0x31, // Usage (Y)
  198. 0x15, 0x00, // Logical Minimum (0)
  199. 0x26, 0xFF, 0x7F, // Logical Maximum (32767)
  200. 0x75, 0x10, // Report Size (16),
  201. 0x95, 0x02, // Report Count (2),
  202. 0x81, 0x02, // Input (Data, Variable, Absolute)
  203. 0xC0 // End Collection
  204. };
  205. #endif
  206. #ifdef JOYSTICK_INTERFACE
  207. #if JOYSTICK_SIZE == 12
  208. static uint8_t joystick_report_desc[] = {
  209. 0x05, 0x01, // Usage Page (Generic Desktop)
  210. 0x09, 0x04, // Usage (Joystick)
  211. 0xA1, 0x01, // Collection (Application)
  212. 0x15, 0x00, // Logical Minimum (0)
  213. 0x25, 0x01, // Logical Maximum (1)
  214. 0x75, 0x01, // Report Size (1)
  215. 0x95, 0x20, // Report Count (32)
  216. 0x05, 0x09, // Usage Page (Button)
  217. 0x19, 0x01, // Usage Minimum (Button #1)
  218. 0x29, 0x20, // Usage Maximum (Button #32)
  219. 0x81, 0x02, // Input (variable,absolute)
  220. 0x15, 0x00, // Logical Minimum (0)
  221. 0x25, 0x07, // Logical Maximum (7)
  222. 0x35, 0x00, // Physical Minimum (0)
  223. 0x46, 0x3B, 0x01, // Physical Maximum (315)
  224. 0x75, 0x04, // Report Size (4)
  225. 0x95, 0x01, // Report Count (1)
  226. 0x65, 0x14, // Unit (20)
  227. 0x05, 0x01, // Usage Page (Generic Desktop)
  228. 0x09, 0x39, // Usage (Hat switch)
  229. 0x81, 0x42, // Input (variable,absolute,null_state)
  230. 0x05, 0x01, // Usage Page (Generic Desktop)
  231. 0x09, 0x01, // Usage (Pointer)
  232. 0xA1, 0x00, // Collection ()
  233. 0x15, 0x00, // Logical Minimum (0)
  234. 0x26, 0xFF, 0x03, // Logical Maximum (1023)
  235. 0x75, 0x0A, // Report Size (10)
  236. 0x95, 0x04, // Report Count (4)
  237. 0x09, 0x30, // Usage (X)
  238. 0x09, 0x31, // Usage (Y)
  239. 0x09, 0x32, // Usage (Z)
  240. 0x09, 0x35, // Usage (Rz)
  241. 0x81, 0x02, // Input (variable,absolute)
  242. 0xC0, // End Collection
  243. 0x15, 0x00, // Logical Minimum (0)
  244. 0x26, 0xFF, 0x03, // Logical Maximum (1023)
  245. 0x75, 0x0A, // Report Size (10)
  246. 0x95, 0x02, // Report Count (2)
  247. 0x09, 0x36, // Usage (Slider)
  248. 0x09, 0x36, // Usage (Slider)
  249. 0x81, 0x02, // Input (variable,absolute)
  250. 0xC0 // End Collection
  251. };
  252. #elif JOYSTICK_SIZE == 64
  253. // extreme joystick (to use this, edit JOYSTICK_SIZE to 64 in usb_desc.h)
  254. // 128 buttons 16
  255. // 6 axes 12
  256. // 17 sliders 34
  257. // 4 pov 2
  258. static uint8_t joystick_report_desc[] = {
  259. 0x05, 0x01, // Usage Page (Generic Desktop)
  260. 0x09, 0x04, // Usage (Joystick)
  261. 0xA1, 0x01, // Collection (Application)
  262. 0x15, 0x00, // Logical Minimum (0)
  263. 0x25, 0x01, // Logical Maximum (1)
  264. 0x75, 0x01, // Report Size (1)
  265. 0x95, 0x80, // Report Count (128)
  266. 0x05, 0x09, // Usage Page (Button)
  267. 0x19, 0x01, // Usage Minimum (Button #1)
  268. 0x29, 0x80, // Usage Maximum (Button #128)
  269. 0x81, 0x02, // Input (variable,absolute)
  270. 0x05, 0x01, // Usage Page (Generic Desktop)
  271. 0x09, 0x01, // Usage (Pointer)
  272. 0xA1, 0x00, // Collection ()
  273. 0x15, 0x00, // Logical Minimum (0)
  274. 0x27, 0xFF, 0xFF, 0, 0, // Logical Maximum (65535)
  275. 0x75, 0x10, // Report Size (16)
  276. 0x95, 23, // Report Count (23)
  277. 0x09, 0x30, // Usage (X)
  278. 0x09, 0x31, // Usage (Y)
  279. 0x09, 0x32, // Usage (Z)
  280. 0x09, 0x33, // Usage (Rx)
  281. 0x09, 0x34, // Usage (Ry)
  282. 0x09, 0x35, // Usage (Rz)
  283. 0x09, 0x36, // Usage (Slider)
  284. 0x09, 0x36, // Usage (Slider)
  285. 0x09, 0x36, // Usage (Slider)
  286. 0x09, 0x36, // Usage (Slider)
  287. 0x09, 0x36, // Usage (Slider)
  288. 0x09, 0x36, // Usage (Slider)
  289. 0x09, 0x36, // Usage (Slider)
  290. 0x09, 0x36, // Usage (Slider)
  291. 0x09, 0x36, // Usage (Slider)
  292. 0x09, 0x36, // Usage (Slider)
  293. 0x09, 0x36, // Usage (Slider)
  294. 0x09, 0x36, // Usage (Slider)
  295. 0x09, 0x36, // Usage (Slider)
  296. 0x09, 0x36, // Usage (Slider)
  297. 0x09, 0x36, // Usage (Slider)
  298. 0x09, 0x36, // Usage (Slider)
  299. 0x09, 0x36, // Usage (Slider)
  300. 0x81, 0x02, // Input (variable,absolute)
  301. 0xC0, // End Collection
  302. 0x15, 0x00, // Logical Minimum (0)
  303. 0x25, 0x07, // Logical Maximum (7)
  304. 0x35, 0x00, // Physical Minimum (0)
  305. 0x46, 0x3B, 0x01, // Physical Maximum (315)
  306. 0x75, 0x04, // Report Size (4)
  307. 0x95, 0x04, // Report Count (4)
  308. 0x65, 0x14, // Unit (20)
  309. 0x05, 0x01, // Usage Page (Generic Desktop)
  310. 0x09, 0x39, // Usage (Hat switch)
  311. 0x09, 0x39, // Usage (Hat switch)
  312. 0x09, 0x39, // Usage (Hat switch)
  313. 0x09, 0x39, // Usage (Hat switch)
  314. 0x81, 0x42, // Input (variable,absolute,null_state)
  315. 0xC0 // End Collection
  316. };
  317. #endif // JOYSTICK_SIZE
  318. #endif // JOYSTICK_INTERFACE
  319. #ifdef MULTITOUCH_INTERFACE
  320. // https://forum.pjrc.com/threads/32331-USB-HID-Touchscreen-support-needed
  321. // https://msdn.microsoft.com/en-us/library/windows/hardware/jj151563%28v=vs.85%29.aspx
  322. // https://msdn.microsoft.com/en-us/library/windows/hardware/jj151565%28v=vs.85%29.aspx
  323. // https://msdn.microsoft.com/en-us/library/windows/hardware/ff553734%28v=vs.85%29.aspx
  324. // https://msdn.microsoft.com/en-us/library/windows/hardware/jj151564%28v=vs.85%29.aspx
  325. // download.microsoft.com/download/a/d/f/adf1347d-08dc-41a4-9084-623b1194d4b2/digitizerdrvs_touch.docx
  326. static uint8_t multitouch_report_desc[] = {
  327. 0x05, 0x0D, // Usage Page (Digitizer)
  328. 0x09, 0x04, // Usage (Touch Screen)
  329. 0xa1, 0x01, // Collection (Application)
  330. 0x09, 0x22, // Usage (Finger)
  331. 0xA1, 0x02, // Collection (Logical)
  332. 0x09, 0x42, // Usage (Tip Switch)
  333. 0x15, 0x00, // Logical Minimum (0)
  334. 0x25, 0x01, // Logical Maximum (1)
  335. 0x75, 0x01, // Report Size (1)
  336. 0x95, 0x01, // Report Count (1)
  337. 0x81, 0x02, // Input (variable,absolute)
  338. 0x09, 0x51, // Usage (Contact Identifier)
  339. 0x25, 0x7F, // Logical Maximum (127)
  340. 0x75, 0x07, // Report Size (7)
  341. 0x95, 0x01, // Report Count (1)
  342. 0x81, 0x02, // Input (variable,absolute)
  343. 0x09, 0x30, // Usage (Pressure)
  344. 0x26, 0xFF, 0x00, // Logical Maximum (255)
  345. 0x75, 0x08, // Report Size (8)
  346. 0x95, 0x01, // Report Count (1)
  347. 0x81, 0x02, // Input (variable,absolute)
  348. 0x05, 0x01, // Usage Page (Generic Desktop)
  349. 0x09, 0x30, // Usage (X)
  350. 0x09, 0x31, // Usage (Y)
  351. 0x26, 0xFF, 0x7F, // Logical Maximum (32767)
  352. 0x65, 0x00, // Unit (None) <-- probably needs real units?
  353. 0x75, 0x10, // Report Size (16)
  354. 0x95, 0x02, // Report Count (2)
  355. 0x81, 0x02, // Input (variable,absolute)
  356. 0xC0, // End Collection
  357. 0x05, 0x0D, // Usage Page (Digitizer)
  358. 0x27, 0xFF, 0xFF, 0, 0, // Logical Maximum (65535)
  359. 0x75, 0x10, // Report Size (16)
  360. 0x95, 0x01, // Report Count (1)
  361. 0x09, 0x56, // Usage (Scan Time)
  362. 0x81, 0x02, // Input (variable,absolute)
  363. 0x05, 0x0D, // Usage Page (Digitizers)
  364. 0x09, 0x55, // Usage (Contact Count Maximum)
  365. 0x25, MULTITOUCH_FINGERS, // Logical Maximum (10)
  366. 0x75, 0x08, // Report Size (8)
  367. 0x95, 0x01, // Report Count (1)
  368. 0xB1, 0x02, // Feature (variable,absolute)
  369. 0xC0 // End Collection
  370. };
  371. #endif
  372. #ifdef SEREMU_INTERFACE
  373. static uint8_t seremu_report_desc[] = {
  374. 0x06, 0xC9, 0xFF, // Usage Page 0xFFC9 (vendor defined)
  375. 0x09, 0x04, // Usage 0x04
  376. 0xA1, 0x5C, // Collection 0x5C
  377. 0x75, 0x08, // report size = 8 bits (global)
  378. 0x15, 0x00, // logical minimum = 0 (global)
  379. 0x26, 0xFF, 0x00, // logical maximum = 255 (global)
  380. 0x95, SEREMU_TX_SIZE, // report count (global)
  381. 0x09, 0x75, // usage (local)
  382. 0x81, 0x02, // Input
  383. 0x95, SEREMU_RX_SIZE, // report count (global)
  384. 0x09, 0x76, // usage (local)
  385. 0x91, 0x02, // Output
  386. 0x95, 0x04, // report count (global)
  387. 0x09, 0x76, // usage (local)
  388. 0xB1, 0x02, // Feature
  389. 0xC0 // end collection
  390. };
  391. #endif
  392. #ifdef RAWHID_INTERFACE
  393. static uint8_t rawhid_report_desc[] = {
  394. 0x06, LSB(RAWHID_USAGE_PAGE), MSB(RAWHID_USAGE_PAGE),
  395. 0x0A, LSB(RAWHID_USAGE), MSB(RAWHID_USAGE),
  396. 0xA1, 0x01, // Collection 0x01
  397. 0x75, 0x08, // report size = 8 bits
  398. 0x15, 0x00, // logical minimum = 0
  399. 0x26, 0xFF, 0x00, // logical maximum = 255
  400. 0x95, RAWHID_TX_SIZE, // report count
  401. 0x09, 0x01, // usage
  402. 0x81, 0x02, // Input (array)
  403. 0x95, RAWHID_RX_SIZE, // report count
  404. 0x09, 0x02, // usage
  405. 0x91, 0x02, // Output (array)
  406. 0xC0 // end collection
  407. };
  408. #endif
  409. #ifdef FLIGHTSIM_INTERFACE
  410. static uint8_t flightsim_report_desc[] = {
  411. 0x06, 0x1C, 0xFF, // Usage page = 0xFF1C
  412. 0x0A, 0x39, 0xA7, // Usage = 0xA739
  413. 0xA1, 0x01, // Collection 0x01
  414. 0x75, 0x08, // report size = 8 bits
  415. 0x15, 0x00, // logical minimum = 0
  416. 0x26, 0xFF, 0x00, // logical maximum = 255
  417. 0x95, FLIGHTSIM_TX_SIZE, // report count
  418. 0x09, 0x01, // usage
  419. 0x81, 0x02, // Input (array)
  420. 0x95, FLIGHTSIM_RX_SIZE, // report count
  421. 0x09, 0x02, // usage
  422. 0x91, 0x02, // Output (array)
  423. 0xC0 // end collection
  424. };
  425. #endif
  426. // **************************************************************
  427. // USB Descriptor Sizes
  428. // **************************************************************
  429. // pre-compute the size and position of everything in the config descriptor
  430. //
  431. #define CONFIG_HEADER_DESCRIPTOR_SIZE 9
  432. #define CDC_IAD_DESCRIPTOR_POS CONFIG_HEADER_DESCRIPTOR_SIZE
  433. #ifdef CDC_IAD_DESCRIPTOR
  434. #define CDC_IAD_DESCRIPTOR_SIZE 8
  435. #else
  436. #define CDC_IAD_DESCRIPTOR_SIZE 0
  437. #endif
  438. #define CDC_DATA_INTERFACE_DESC_POS CDC_IAD_DESCRIPTOR_POS+CDC_IAD_DESCRIPTOR_SIZE
  439. #ifdef CDC_DATA_INTERFACE
  440. #define CDC_DATA_INTERFACE_DESC_SIZE 9+5+5+4+5+7+9+7+7
  441. #else
  442. #define CDC_DATA_INTERFACE_DESC_SIZE 0
  443. #endif
  444. #define MIDI_INTERFACE_DESC_POS CDC_DATA_INTERFACE_DESC_POS+CDC_DATA_INTERFACE_DESC_SIZE
  445. #ifdef MIDI_INTERFACE
  446. #if !defined(MIDI_NUM_CABLES) || MIDI_NUM_CABLES < 1 || MIDI_NUM_CABLES > 16
  447. #error "MIDI_NUM_CABLES must be defined between 1 to 16"
  448. #endif
  449. #define MIDI_INTERFACE_DESC_SIZE 9+7+((6+6+9+9)*MIDI_NUM_CABLES)+(9+4+MIDI_NUM_CABLES)*2
  450. #else
  451. #define MIDI_INTERFACE_DESC_SIZE 0
  452. #endif
  453. #define KEYBOARD_INTERFACE_DESC_POS MIDI_INTERFACE_DESC_POS+MIDI_INTERFACE_DESC_SIZE
  454. #ifdef KEYBOARD_INTERFACE
  455. #define KEYBOARD_INTERFACE_DESC_SIZE 9+9+7
  456. #define KEYBOARD_HID_DESC_OFFSET KEYBOARD_INTERFACE_DESC_POS+9
  457. #else
  458. #define KEYBOARD_INTERFACE_DESC_SIZE 0
  459. #endif
  460. #define MOUSE_INTERFACE_DESC_POS KEYBOARD_INTERFACE_DESC_POS+KEYBOARD_INTERFACE_DESC_SIZE
  461. #ifdef MOUSE_INTERFACE
  462. #define MOUSE_INTERFACE_DESC_SIZE 9+9+7
  463. #define MOUSE_HID_DESC_OFFSET MOUSE_INTERFACE_DESC_POS+9
  464. #else
  465. #define MOUSE_INTERFACE_DESC_SIZE 0
  466. #endif
  467. #define RAWHID_INTERFACE_DESC_POS MOUSE_INTERFACE_DESC_POS+MOUSE_INTERFACE_DESC_SIZE
  468. #ifdef RAWHID_INTERFACE
  469. #define RAWHID_INTERFACE_DESC_SIZE 9+9+7+7
  470. #define RAWHID_HID_DESC_OFFSET RAWHID_INTERFACE_DESC_POS+9
  471. #else
  472. #define RAWHID_INTERFACE_DESC_SIZE 0
  473. #endif
  474. #define FLIGHTSIM_INTERFACE_DESC_POS RAWHID_INTERFACE_DESC_POS+RAWHID_INTERFACE_DESC_SIZE
  475. #ifdef FLIGHTSIM_INTERFACE
  476. #define FLIGHTSIM_INTERFACE_DESC_SIZE 9+9+7+7
  477. #define FLIGHTSIM_HID_DESC_OFFSET FLIGHTSIM_INTERFACE_DESC_POS+9
  478. #else
  479. #define FLIGHTSIM_INTERFACE_DESC_SIZE 0
  480. #endif
  481. #define SEREMU_INTERFACE_DESC_POS FLIGHTSIM_INTERFACE_DESC_POS+FLIGHTSIM_INTERFACE_DESC_SIZE
  482. #ifdef SEREMU_INTERFACE
  483. #define SEREMU_INTERFACE_DESC_SIZE 9+9+7+7
  484. #define SEREMU_HID_DESC_OFFSET SEREMU_INTERFACE_DESC_POS+9
  485. #else
  486. #define SEREMU_INTERFACE_DESC_SIZE 0
  487. #endif
  488. #define JOYSTICK_INTERFACE_DESC_POS SEREMU_INTERFACE_DESC_POS+SEREMU_INTERFACE_DESC_SIZE
  489. #ifdef JOYSTICK_INTERFACE
  490. #define JOYSTICK_INTERFACE_DESC_SIZE 9+9+7
  491. #define JOYSTICK_HID_DESC_OFFSET JOYSTICK_INTERFACE_DESC_POS+9
  492. #else
  493. #define JOYSTICK_INTERFACE_DESC_SIZE 0
  494. #endif
  495. #define MTP_INTERFACE_DESC_POS JOYSTICK_INTERFACE_DESC_POS+JOYSTICK_INTERFACE_DESC_SIZE
  496. #ifdef MTP_INTERFACE
  497. #define MTP_INTERFACE_DESC_SIZE 9+7+7+7
  498. #else
  499. #define MTP_INTERFACE_DESC_SIZE 0
  500. #endif
  501. #define KEYMEDIA_INTERFACE_DESC_POS MTP_INTERFACE_DESC_POS+MTP_INTERFACE_DESC_SIZE
  502. #ifdef KEYMEDIA_INTERFACE
  503. #define KEYMEDIA_INTERFACE_DESC_SIZE 9+9+7
  504. #define KEYMEDIA_HID_DESC_OFFSET KEYMEDIA_INTERFACE_DESC_POS+9
  505. #else
  506. #define KEYMEDIA_INTERFACE_DESC_SIZE 0
  507. #endif
  508. #define AUDIO_INTERFACE_DESC_POS KEYMEDIA_INTERFACE_DESC_POS+KEYMEDIA_INTERFACE_DESC_SIZE
  509. #ifdef AUDIO_INTERFACE
  510. #define AUDIO_INTERFACE_DESC_SIZE 8 + 9+10+12+9+12+10+9 + 9+9+7+11+9+7 + 9+9+7+11+9+7+9
  511. #else
  512. #define AUDIO_INTERFACE_DESC_SIZE 0
  513. #endif
  514. #define MULTITOUCH_INTERFACE_DESC_POS AUDIO_INTERFACE_DESC_POS+AUDIO_INTERFACE_DESC_SIZE
  515. #ifdef MULTITOUCH_INTERFACE
  516. #define MULTITOUCH_INTERFACE_DESC_SIZE 9+9+7
  517. #define MULTITOUCH_HID_DESC_OFFSET MULTITOUCH_INTERFACE_DESC_POS+9
  518. #else
  519. #define MULTITOUCH_INTERFACE_DESC_SIZE 0
  520. #endif
  521. #define CONFIG_DESC_SIZE MULTITOUCH_INTERFACE_DESC_POS+MULTITOUCH_INTERFACE_DESC_SIZE
  522. // **************************************************************
  523. // USB Configuration
  524. // **************************************************************
  525. // USB Configuration Descriptor. This huge descriptor tells all
  526. // of the devices capbilities.
  527. static uint8_t config_descriptor[CONFIG_DESC_SIZE] = {
  528. // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
  529. 9, // bLength;
  530. 2, // bDescriptorType;
  531. LSB(CONFIG_DESC_SIZE), // wTotalLength
  532. MSB(CONFIG_DESC_SIZE),
  533. NUM_INTERFACE, // bNumInterfaces
  534. 1, // bConfigurationValue
  535. 0, // iConfiguration
  536. 0xC0, // bmAttributes
  537. 50, // bMaxPower
  538. #ifdef CDC_IAD_DESCRIPTOR
  539. // interface association descriptor, USB ECN, Table 9-Z
  540. 8, // bLength
  541. 11, // bDescriptorType
  542. CDC_STATUS_INTERFACE, // bFirstInterface
  543. 2, // bInterfaceCount
  544. 0x02, // bFunctionClass
  545. 0x02, // bFunctionSubClass
  546. 0x01, // bFunctionProtocol
  547. 4, // iFunction
  548. #endif
  549. #ifdef CDC_DATA_INTERFACE
  550. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  551. 9, // bLength
  552. 4, // bDescriptorType
  553. CDC_STATUS_INTERFACE, // bInterfaceNumber
  554. 0, // bAlternateSetting
  555. 1, // bNumEndpoints
  556. 0x02, // bInterfaceClass
  557. 0x02, // bInterfaceSubClass
  558. 0x01, // bInterfaceProtocol
  559. 0, // iInterface
  560. // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26
  561. 5, // bFunctionLength
  562. 0x24, // bDescriptorType
  563. 0x00, // bDescriptorSubtype
  564. 0x10, 0x01, // bcdCDC
  565. // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27
  566. 5, // bFunctionLength
  567. 0x24, // bDescriptorType
  568. 0x01, // bDescriptorSubtype
  569. 0x01, // bmCapabilities
  570. 1, // bDataInterface
  571. // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28
  572. 4, // bFunctionLength
  573. 0x24, // bDescriptorType
  574. 0x02, // bDescriptorSubtype
  575. 0x06, // bmCapabilities
  576. // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33
  577. 5, // bFunctionLength
  578. 0x24, // bDescriptorType
  579. 0x06, // bDescriptorSubtype
  580. CDC_STATUS_INTERFACE, // bMasterInterface
  581. CDC_DATA_INTERFACE, // bSlaveInterface0
  582. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  583. 7, // bLength
  584. 5, // bDescriptorType
  585. CDC_ACM_ENDPOINT | 0x80, // bEndpointAddress
  586. 0x03, // bmAttributes (0x03=intr)
  587. CDC_ACM_SIZE, 0, // wMaxPacketSize
  588. 64, // bInterval
  589. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  590. 9, // bLength
  591. 4, // bDescriptorType
  592. CDC_DATA_INTERFACE, // bInterfaceNumber
  593. 0, // bAlternateSetting
  594. 2, // bNumEndpoints
  595. 0x0A, // bInterfaceClass
  596. 0x00, // bInterfaceSubClass
  597. 0x00, // bInterfaceProtocol
  598. 0, // iInterface
  599. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  600. 7, // bLength
  601. 5, // bDescriptorType
  602. CDC_RX_ENDPOINT, // bEndpointAddress
  603. 0x02, // bmAttributes (0x02=bulk)
  604. CDC_RX_SIZE, 0, // wMaxPacketSize
  605. 0, // bInterval
  606. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  607. 7, // bLength
  608. 5, // bDescriptorType
  609. CDC_TX_ENDPOINT | 0x80, // bEndpointAddress
  610. 0x02, // bmAttributes (0x02=bulk)
  611. CDC_TX_SIZE, 0, // wMaxPacketSize
  612. 0, // bInterval
  613. #endif // CDC_DATA_INTERFACE
  614. #ifdef MIDI_INTERFACE
  615. // Standard MS Interface Descriptor,
  616. 9, // bLength
  617. 4, // bDescriptorType
  618. MIDI_INTERFACE, // bInterfaceNumber
  619. 0, // bAlternateSetting
  620. 2, // bNumEndpoints
  621. 0x01, // bInterfaceClass (0x01 = Audio)
  622. 0x03, // bInterfaceSubClass (0x03 = MIDI)
  623. 0x00, // bInterfaceProtocol (unused for MIDI)
  624. 0, // iInterface
  625. // MIDI MS Interface Header, USB MIDI 6.1.2.1, page 21, Table 6-2
  626. 7, // bLength
  627. 0x24, // bDescriptorType = CS_INTERFACE
  628. 0x01, // bDescriptorSubtype = MS_HEADER
  629. 0x00, 0x01, // bcdMSC = revision 01.00
  630. LSB(7+(6+6+9+9)*MIDI_NUM_CABLES), // wTotalLength
  631. MSB(7+(6+6+9+9)*MIDI_NUM_CABLES),
  632. // MIDI IN Jack Descriptor, B.4.3, Table B-7 (embedded), page 40
  633. 6, // bLength
  634. 0x24, // bDescriptorType = CS_INTERFACE
  635. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  636. 0x01, // bJackType = EMBEDDED
  637. 1, // bJackID, ID = 1
  638. 0x05, // iJack
  639. // MIDI IN Jack Descriptor, B.4.3, Table B-8 (external), page 40
  640. 6, // bLength
  641. 0x24, // bDescriptorType = CS_INTERFACE
  642. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  643. 0x02, // bJackType = EXTERNAL
  644. 2, // bJackID, ID = 2
  645. 0x05, // iJack
  646. // MIDI OUT Jack Descriptor, B.4.4, Table B-9, page 41
  647. 9,
  648. 0x24, // bDescriptorType = CS_INTERFACE
  649. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  650. 0x01, // bJackType = EMBEDDED
  651. 3, // bJackID, ID = 3
  652. 1, // bNrInputPins = 1 pin
  653. 2, // BaSourceID(1) = 2
  654. 1, // BaSourcePin(1) = first pin
  655. 0x05, // iJack
  656. // MIDI OUT Jack Descriptor, B.4.4, Table B-10, page 41
  657. 9,
  658. 0x24, // bDescriptorType = CS_INTERFACE
  659. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  660. 0x02, // bJackType = EXTERNAL
  661. 4, // bJackID, ID = 4
  662. 1, // bNrInputPins = 1 pin
  663. 1, // BaSourceID(1) = 1
  664. 1, // BaSourcePin(1) = first pin
  665. 0x05, // iJack
  666. #if MIDI_NUM_CABLES >= 2
  667. #define MIDI_INTERFACE_JACK_PAIR(a, b, c, d, e) \
  668. 6, 0x24, 0x02, 0x01, (a), (e), \
  669. 6, 0x24, 0x02, 0x02, (b), (e), \
  670. 9, 0x24, 0x03, 0x01, (c), 1, (b), 1, (e), \
  671. 9, 0x24, 0x03, 0x02, (d), 1, (a), 1, (e),
  672. MIDI_INTERFACE_JACK_PAIR(5, 6, 7, 8, 0x06)
  673. #endif
  674. #if MIDI_NUM_CABLES >= 3
  675. MIDI_INTERFACE_JACK_PAIR(9, 10, 11, 12, 0x07)
  676. #endif
  677. #if MIDI_NUM_CABLES >= 4
  678. MIDI_INTERFACE_JACK_PAIR(13, 14, 15, 16, 0x08)
  679. #endif
  680. #if MIDI_NUM_CABLES >= 5
  681. MIDI_INTERFACE_JACK_PAIR(17, 18, 19, 20, 0x09)
  682. #endif
  683. #if MIDI_NUM_CABLES >= 6
  684. MIDI_INTERFACE_JACK_PAIR(21, 22, 23, 24, 0x0A)
  685. #endif
  686. #if MIDI_NUM_CABLES >= 7
  687. MIDI_INTERFACE_JACK_PAIR(25, 26, 27, 28, 0x0B)
  688. #endif
  689. #if MIDI_NUM_CABLES >= 8
  690. MIDI_INTERFACE_JACK_PAIR(29, 30, 31, 32, 0x0C)
  691. #endif
  692. #if MIDI_NUM_CABLES >= 9
  693. MIDI_INTERFACE_JACK_PAIR(33, 34, 35, 36, 0x0D)
  694. #endif
  695. #if MIDI_NUM_CABLES >= 10
  696. MIDI_INTERFACE_JACK_PAIR(37, 38, 39, 40, 0x0E)
  697. #endif
  698. #if MIDI_NUM_CABLES >= 11
  699. MIDI_INTERFACE_JACK_PAIR(41, 42, 43, 44, 0x0F)
  700. #endif
  701. #if MIDI_NUM_CABLES >= 12
  702. MIDI_INTERFACE_JACK_PAIR(45, 46, 47, 48, 0x10)
  703. #endif
  704. #if MIDI_NUM_CABLES >= 13
  705. MIDI_INTERFACE_JACK_PAIR(49, 50, 51, 52, 0x11)
  706. #endif
  707. #if MIDI_NUM_CABLES >= 14
  708. MIDI_INTERFACE_JACK_PAIR(53, 54, 55, 56, 0x12)
  709. #endif
  710. #if MIDI_NUM_CABLES >= 15
  711. MIDI_INTERFACE_JACK_PAIR(57, 58, 59, 60, 0x13)
  712. #endif
  713. #if MIDI_NUM_CABLES >= 16
  714. MIDI_INTERFACE_JACK_PAIR(61, 62, 63, 64, 0x14)
  715. #endif
  716. // Standard Bulk OUT Endpoint Descriptor, B.5.1, Table B-11, pae 42
  717. 9, // bLength
  718. 5, // bDescriptorType = ENDPOINT
  719. MIDI_RX_ENDPOINT, // bEndpointAddress
  720. 0x02, // bmAttributes (0x02=bulk)
  721. MIDI_RX_SIZE, 0, // wMaxPacketSize
  722. 0, // bInterval
  723. 0, // bRefresh
  724. 0, // bSynchAddress
  725. // Class-specific MS Bulk OUT Endpoint Descriptor, B.5.2, Table B-12, page 42
  726. 4+MIDI_NUM_CABLES, // bLength
  727. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  728. 0x01, // bJackType = MS_GENERAL
  729. MIDI_NUM_CABLES, // bNumEmbMIDIJack = number of jacks
  730. 1, // BaAssocJackID(1) = jack ID #1
  731. #if MIDI_NUM_CABLES >= 2
  732. 5,
  733. #endif
  734. #if MIDI_NUM_CABLES >= 3
  735. 9,
  736. #endif
  737. #if MIDI_NUM_CABLES >= 4
  738. 13,
  739. #endif
  740. #if MIDI_NUM_CABLES >= 5
  741. 17,
  742. #endif
  743. #if MIDI_NUM_CABLES >= 6
  744. 21,
  745. #endif
  746. #if MIDI_NUM_CABLES >= 7
  747. 25,
  748. #endif
  749. #if MIDI_NUM_CABLES >= 8
  750. 29,
  751. #endif
  752. #if MIDI_NUM_CABLES >= 9
  753. 33,
  754. #endif
  755. #if MIDI_NUM_CABLES >= 10
  756. 37,
  757. #endif
  758. #if MIDI_NUM_CABLES >= 11
  759. 41,
  760. #endif
  761. #if MIDI_NUM_CABLES >= 12
  762. 45,
  763. #endif
  764. #if MIDI_NUM_CABLES >= 13
  765. 49,
  766. #endif
  767. #if MIDI_NUM_CABLES >= 14
  768. 53,
  769. #endif
  770. #if MIDI_NUM_CABLES >= 15
  771. 57,
  772. #endif
  773. #if MIDI_NUM_CABLES >= 16
  774. 61,
  775. #endif
  776. // Standard Bulk IN Endpoint Descriptor, B.5.1, Table B-11, pae 42
  777. 9, // bLength
  778. 5, // bDescriptorType = ENDPOINT
  779. MIDI_TX_ENDPOINT | 0x80, // bEndpointAddress
  780. 0x02, // bmAttributes (0x02=bulk)
  781. MIDI_TX_SIZE, 0, // wMaxPacketSize
  782. 0, // bInterval
  783. 0, // bRefresh
  784. 0, // bSynchAddress
  785. // Class-specific MS Bulk IN Endpoint Descriptor, B.5.2, Table B-12, page 42
  786. 4+MIDI_NUM_CABLES, // bLength
  787. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  788. 0x01, // bJackType = MS_GENERAL
  789. MIDI_NUM_CABLES, // bNumEmbMIDIJack = number of jacks
  790. 3, // BaAssocJackID(1) = jack ID #3
  791. #if MIDI_NUM_CABLES >= 2
  792. 7,
  793. #endif
  794. #if MIDI_NUM_CABLES >= 3
  795. 11,
  796. #endif
  797. #if MIDI_NUM_CABLES >= 4
  798. 15,
  799. #endif
  800. #if MIDI_NUM_CABLES >= 5
  801. 19,
  802. #endif
  803. #if MIDI_NUM_CABLES >= 6
  804. 23,
  805. #endif
  806. #if MIDI_NUM_CABLES >= 7
  807. 27,
  808. #endif
  809. #if MIDI_NUM_CABLES >= 8
  810. 31,
  811. #endif
  812. #if MIDI_NUM_CABLES >= 9
  813. 35,
  814. #endif
  815. #if MIDI_NUM_CABLES >= 10
  816. 39,
  817. #endif
  818. #if MIDI_NUM_CABLES >= 11
  819. 43,
  820. #endif
  821. #if MIDI_NUM_CABLES >= 12
  822. 47,
  823. #endif
  824. #if MIDI_NUM_CABLES >= 13
  825. 51,
  826. #endif
  827. #if MIDI_NUM_CABLES >= 14
  828. 55,
  829. #endif
  830. #if MIDI_NUM_CABLES >= 15
  831. 59,
  832. #endif
  833. #if MIDI_NUM_CABLES >= 16
  834. 63,
  835. #endif
  836. #endif // MIDI_INTERFACE
  837. #ifdef KEYBOARD_INTERFACE
  838. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  839. 9, // bLength
  840. 4, // bDescriptorType
  841. KEYBOARD_INTERFACE, // bInterfaceNumber
  842. 0, // bAlternateSetting
  843. 1, // bNumEndpoints
  844. 0x03, // bInterfaceClass (0x03 = HID)
  845. 0x01, // bInterfaceSubClass (0x01 = Boot)
  846. 0x01, // bInterfaceProtocol (0x01 = Keyboard)
  847. 0, // iInterface
  848. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  849. 9, // bLength
  850. 0x21, // bDescriptorType
  851. 0x11, 0x01, // bcdHID
  852. 0, // bCountryCode
  853. 1, // bNumDescriptors
  854. 0x22, // bDescriptorType
  855. LSB(sizeof(keyboard_report_desc)), // wDescriptorLength
  856. MSB(sizeof(keyboard_report_desc)),
  857. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  858. 7, // bLength
  859. 5, // bDescriptorType
  860. KEYBOARD_ENDPOINT | 0x80, // bEndpointAddress
  861. 0x03, // bmAttributes (0x03=intr)
  862. KEYBOARD_SIZE, 0, // wMaxPacketSize
  863. KEYBOARD_INTERVAL, // bInterval
  864. #endif // KEYBOARD_INTERFACE
  865. #ifdef MOUSE_INTERFACE
  866. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  867. 9, // bLength
  868. 4, // bDescriptorType
  869. MOUSE_INTERFACE, // bInterfaceNumber
  870. 0, // bAlternateSetting
  871. 1, // bNumEndpoints
  872. 0x03, // bInterfaceClass (0x03 = HID)
  873. 0x00, // bInterfaceSubClass (0x01 = Boot)
  874. 0x00, // bInterfaceProtocol (0x02 = Mouse)
  875. 0, // iInterface
  876. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  877. 9, // bLength
  878. 0x21, // bDescriptorType
  879. 0x11, 0x01, // bcdHID
  880. 0, // bCountryCode
  881. 1, // bNumDescriptors
  882. 0x22, // bDescriptorType
  883. LSB(sizeof(mouse_report_desc)), // wDescriptorLength
  884. MSB(sizeof(mouse_report_desc)),
  885. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  886. 7, // bLength
  887. 5, // bDescriptorType
  888. MOUSE_ENDPOINT | 0x80, // bEndpointAddress
  889. 0x03, // bmAttributes (0x03=intr)
  890. MOUSE_SIZE, 0, // wMaxPacketSize
  891. MOUSE_INTERVAL, // bInterval
  892. #endif // MOUSE_INTERFACE
  893. #ifdef RAWHID_INTERFACE
  894. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  895. 9, // bLength
  896. 4, // bDescriptorType
  897. RAWHID_INTERFACE, // bInterfaceNumber
  898. 0, // bAlternateSetting
  899. 2, // bNumEndpoints
  900. 0x03, // bInterfaceClass (0x03 = HID)
  901. 0x00, // bInterfaceSubClass
  902. 0x00, // bInterfaceProtocol
  903. 0, // iInterface
  904. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  905. 9, // bLength
  906. 0x21, // bDescriptorType
  907. 0x11, 0x01, // bcdHID
  908. 0, // bCountryCode
  909. 1, // bNumDescriptors
  910. 0x22, // bDescriptorType
  911. LSB(sizeof(rawhid_report_desc)), // wDescriptorLength
  912. MSB(sizeof(rawhid_report_desc)),
  913. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  914. 7, // bLength
  915. 5, // bDescriptorType
  916. RAWHID_TX_ENDPOINT | 0x80, // bEndpointAddress
  917. 0x03, // bmAttributes (0x03=intr)
  918. RAWHID_TX_SIZE, 0, // wMaxPacketSize
  919. RAWHID_TX_INTERVAL, // bInterval
  920. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  921. 7, // bLength
  922. 5, // bDescriptorType
  923. RAWHID_RX_ENDPOINT, // bEndpointAddress
  924. 0x03, // bmAttributes (0x03=intr)
  925. RAWHID_RX_SIZE, 0, // wMaxPacketSize
  926. RAWHID_RX_INTERVAL, // bInterval
  927. #endif // RAWHID_INTERFACE
  928. #ifdef FLIGHTSIM_INTERFACE
  929. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  930. 9, // bLength
  931. 4, // bDescriptorType
  932. FLIGHTSIM_INTERFACE, // bInterfaceNumber
  933. 0, // bAlternateSetting
  934. 2, // bNumEndpoints
  935. 0x03, // bInterfaceClass (0x03 = HID)
  936. 0x00, // bInterfaceSubClass
  937. 0x00, // bInterfaceProtocol
  938. 0, // iInterface
  939. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  940. 9, // bLength
  941. 0x21, // bDescriptorType
  942. 0x11, 0x01, // bcdHID
  943. 0, // bCountryCode
  944. 1, // bNumDescriptors
  945. 0x22, // bDescriptorType
  946. LSB(sizeof(flightsim_report_desc)), // wDescriptorLength
  947. MSB(sizeof(flightsim_report_desc)),
  948. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  949. 7, // bLength
  950. 5, // bDescriptorType
  951. FLIGHTSIM_TX_ENDPOINT | 0x80, // bEndpointAddress
  952. 0x03, // bmAttributes (0x03=intr)
  953. FLIGHTSIM_TX_SIZE, 0, // wMaxPacketSize
  954. FLIGHTSIM_TX_INTERVAL, // bInterval
  955. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  956. 7, // bLength
  957. 5, // bDescriptorType
  958. FLIGHTSIM_RX_ENDPOINT, // bEndpointAddress
  959. 0x03, // bmAttributes (0x03=intr)
  960. FLIGHTSIM_RX_SIZE, 0, // wMaxPacketSize
  961. FLIGHTSIM_RX_INTERVAL, // bInterval
  962. #endif // FLIGHTSIM_INTERFACE
  963. #ifdef SEREMU_INTERFACE
  964. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  965. 9, // bLength
  966. 4, // bDescriptorType
  967. SEREMU_INTERFACE, // bInterfaceNumber
  968. 0, // bAlternateSetting
  969. 2, // bNumEndpoints
  970. 0x03, // bInterfaceClass (0x03 = HID)
  971. 0x00, // bInterfaceSubClass
  972. 0x00, // bInterfaceProtocol
  973. 0, // iInterface
  974. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  975. 9, // bLength
  976. 0x21, // bDescriptorType
  977. 0x11, 0x01, // bcdHID
  978. 0, // bCountryCode
  979. 1, // bNumDescriptors
  980. 0x22, // bDescriptorType
  981. LSB(sizeof(seremu_report_desc)), // wDescriptorLength
  982. MSB(sizeof(seremu_report_desc)),
  983. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  984. 7, // bLength
  985. 5, // bDescriptorType
  986. SEREMU_TX_ENDPOINT | 0x80, // bEndpointAddress
  987. 0x03, // bmAttributes (0x03=intr)
  988. SEREMU_TX_SIZE, 0, // wMaxPacketSize
  989. SEREMU_TX_INTERVAL, // bInterval
  990. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  991. 7, // bLength
  992. 5, // bDescriptorType
  993. SEREMU_RX_ENDPOINT, // bEndpointAddress
  994. 0x03, // bmAttributes (0x03=intr)
  995. SEREMU_RX_SIZE, 0, // wMaxPacketSize
  996. SEREMU_RX_INTERVAL, // bInterval
  997. #endif // SEREMU_INTERFACE
  998. #ifdef JOYSTICK_INTERFACE
  999. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1000. 9, // bLength
  1001. 4, // bDescriptorType
  1002. JOYSTICK_INTERFACE, // bInterfaceNumber
  1003. 0, // bAlternateSetting
  1004. 1, // bNumEndpoints
  1005. 0x03, // bInterfaceClass (0x03 = HID)
  1006. 0x00, // bInterfaceSubClass
  1007. 0x00, // bInterfaceProtocol
  1008. 0, // iInterface
  1009. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1010. 9, // bLength
  1011. 0x21, // bDescriptorType
  1012. 0x11, 0x01, // bcdHID
  1013. 0, // bCountryCode
  1014. 1, // bNumDescriptors
  1015. 0x22, // bDescriptorType
  1016. LSB(sizeof(joystick_report_desc)), // wDescriptorLength
  1017. MSB(sizeof(joystick_report_desc)),
  1018. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1019. 7, // bLength
  1020. 5, // bDescriptorType
  1021. JOYSTICK_ENDPOINT | 0x80, // bEndpointAddress
  1022. 0x03, // bmAttributes (0x03=intr)
  1023. JOYSTICK_SIZE, 0, // wMaxPacketSize
  1024. JOYSTICK_INTERVAL, // bInterval
  1025. #endif // JOYSTICK_INTERFACE
  1026. #ifdef MTP_INTERFACE
  1027. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1028. 9, // bLength
  1029. 4, // bDescriptorType
  1030. MTP_INTERFACE, // bInterfaceNumber
  1031. 0, // bAlternateSetting
  1032. 3, // bNumEndpoints
  1033. 0x06, // bInterfaceClass (0x06 = still image)
  1034. 0x01, // bInterfaceSubClass
  1035. 0x01, // bInterfaceProtocol
  1036. 4, // iInterface
  1037. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1038. 7, // bLength
  1039. 5, // bDescriptorType
  1040. MTP_TX_ENDPOINT | 0x80, // bEndpointAddress
  1041. 0x02, // bmAttributes (0x02=bulk)
  1042. MTP_TX_SIZE, 0, // wMaxPacketSize
  1043. 0, // bInterval
  1044. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1045. 7, // bLength
  1046. 5, // bDescriptorType
  1047. MTP_RX_ENDPOINT, // bEndpointAddress
  1048. 0x02, // bmAttributes (0x02=bulk)
  1049. MTP_RX_SIZE, 0, // wMaxPacketSize
  1050. 0, // bInterval
  1051. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1052. 7, // bLength
  1053. 5, // bDescriptorType
  1054. MTP_EVENT_ENDPOINT | 0x80, // bEndpointAddress
  1055. 0x03, // bmAttributes (0x03=intr)
  1056. MTP_EVENT_SIZE, 0, // wMaxPacketSize
  1057. MTP_EVENT_INTERVAL, // bInterval
  1058. #endif // MTP_INTERFACE
  1059. #ifdef KEYMEDIA_INTERFACE
  1060. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1061. 9, // bLength
  1062. 4, // bDescriptorType
  1063. KEYMEDIA_INTERFACE, // bInterfaceNumber
  1064. 0, // bAlternateSetting
  1065. 1, // bNumEndpoints
  1066. 0x03, // bInterfaceClass (0x03 = HID)
  1067. 0x00, // bInterfaceSubClass
  1068. 0x00, // bInterfaceProtocol
  1069. 0, // iInterface
  1070. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1071. 9, // bLength
  1072. 0x21, // bDescriptorType
  1073. 0x11, 0x01, // bcdHID
  1074. 0, // bCountryCode
  1075. 1, // bNumDescriptors
  1076. 0x22, // bDescriptorType
  1077. LSB(sizeof(keymedia_report_desc)), // wDescriptorLength
  1078. MSB(sizeof(keymedia_report_desc)),
  1079. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1080. 7, // bLength
  1081. 5, // bDescriptorType
  1082. KEYMEDIA_ENDPOINT | 0x80, // bEndpointAddress
  1083. 0x03, // bmAttributes (0x03=intr)
  1084. KEYMEDIA_SIZE, 0, // wMaxPacketSize
  1085. KEYMEDIA_INTERVAL, // bInterval
  1086. #endif // KEYMEDIA_INTERFACE
  1087. #ifdef AUDIO_INTERFACE
  1088. // interface association descriptor, USB ECN, Table 9-Z
  1089. 8, // bLength
  1090. 11, // bDescriptorType
  1091. AUDIO_INTERFACE, // bFirstInterface
  1092. 3, // bInterfaceCount
  1093. 0x01, // bFunctionClass
  1094. 0x01, // bFunctionSubClass
  1095. 0x00, // bFunctionProtocol
  1096. 0, // iFunction
  1097. // Standard AudioControl (AC) Interface Descriptor
  1098. // USB DCD for Audio Devices 1.0, Table 4-1, page 36
  1099. 9, // bLength
  1100. 4, // bDescriptorType, 4 = INTERFACE
  1101. AUDIO_INTERFACE, // bInterfaceNumber
  1102. 0, // bAlternateSetting
  1103. 0, // bNumEndpoints
  1104. 1, // bInterfaceClass, 1 = AUDIO
  1105. 1, // bInterfaceSubclass, 1 = AUDIO_CONTROL
  1106. 0, // bInterfaceProtocol
  1107. 0, // iInterface
  1108. // Class-specific AC Interface Header Descriptor
  1109. // USB DCD for Audio Devices 1.0, Table 4-2, page 37-38
  1110. 10, // bLength
  1111. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1112. 0x01, // bDescriptorSubtype, 1 = HEADER
  1113. 0x00, 0x01, // bcdADC (version 1.0)
  1114. LSB(62), MSB(62), // wTotalLength
  1115. 2, // bInCollection
  1116. AUDIO_INTERFACE+1, // baInterfaceNr(1) - Transmit to PC
  1117. AUDIO_INTERFACE+2, // baInterfaceNr(2) - Receive from PC
  1118. // Input Terminal Descriptor
  1119. // USB DCD for Audio Devices 1.0, Table 4-3, page 39
  1120. 12, // bLength
  1121. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1122. 0x02, // bDescriptorSubType, 2 = INPUT_TERMINAL
  1123. 1, // bTerminalID
  1124. //0x01, 0x02, // wTerminalType, 0x0201 = MICROPHONE
  1125. //0x03, 0x06, // wTerminalType, 0x0603 = Line Connector
  1126. 0x02, 0x06, // wTerminalType, 0x0602 = Digital Audio
  1127. 0, // bAssocTerminal, 0 = unidirectional
  1128. 2, // bNrChannels
  1129. 0x03, 0x00, // wChannelConfig, 0x0003 = Left & Right Front
  1130. 0, // iChannelNames
  1131. 0, // iTerminal
  1132. // Output Terminal Descriptor
  1133. // USB DCD for Audio Devices 1.0, Table 4-4, page 40
  1134. 9, // bLength
  1135. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1136. 3, // bDescriptorSubtype, 3 = OUTPUT_TERMINAL
  1137. 2, // bTerminalID
  1138. 0x01, 0x01, // wTerminalType, 0x0101 = USB_STREAMING
  1139. 0, // bAssocTerminal, 0 = unidirectional
  1140. 1, // bCSourceID, connected to input terminal, ID=1
  1141. 0, // iTerminal
  1142. // Input Terminal Descriptor
  1143. // USB DCD for Audio Devices 1.0, Table 4-3, page 39
  1144. 12, // bLength
  1145. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1146. 2, // bDescriptorSubType, 2 = INPUT_TERMINAL
  1147. 3, // bTerminalID
  1148. 0x01, 0x01, // wTerminalType, 0x0101 = USB_STREAMING
  1149. 0, // bAssocTerminal, 0 = unidirectional
  1150. 2, // bNrChannels
  1151. 0x03, 0x00, // wChannelConfig, 0x0003 = Left & Right Front
  1152. 0, // iChannelNames
  1153. 0, // iTerminal
  1154. // Volume feature descriptor
  1155. 10, // bLength
  1156. 0x24, // bDescriptorType = CS_INTERFACE
  1157. 0x06, // bDescriptorSubType = FEATURE_UNIT
  1158. 0x31, // bUnitID
  1159. 0x03, // bSourceID (Input Terminal)
  1160. 0x01, // bControlSize (each channel is 1 byte, 3 channels)
  1161. 0x01, // bmaControls(0) Master: Mute
  1162. 0x02, // bmaControls(1) Left: Volume
  1163. 0x02, // bmaControls(2) Right: Volume
  1164. 0x00, // iFeature
  1165. // Output Terminal Descriptor
  1166. // USB DCD for Audio Devices 1.0, Table 4-4, page 40
  1167. 9, // bLength
  1168. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1169. 3, // bDescriptorSubtype, 3 = OUTPUT_TERMINAL
  1170. 4, // bTerminalID
  1171. //0x02, 0x03, // wTerminalType, 0x0302 = Headphones
  1172. 0x02, 0x06, // wTerminalType, 0x0602 = Digital Audio
  1173. 0, // bAssocTerminal, 0 = unidirectional
  1174. 0x31, // bCSourceID, connected to feature, ID=31
  1175. 0, // iTerminal
  1176. // Standard AS Interface Descriptor
  1177. // USB DCD for Audio Devices 1.0, Section 4.5.1, Table 4-18, page 59
  1178. // Alternate 0: default setting, disabled zero bandwidth
  1179. 9, // bLenght
  1180. 4, // bDescriptorType = INTERFACE
  1181. AUDIO_INTERFACE+1, // bInterfaceNumber
  1182. 0, // bAlternateSetting
  1183. 0, // bNumEndpoints
  1184. 1, // bInterfaceClass, 1 = AUDIO
  1185. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  1186. 0, // bInterfaceProtocol
  1187. 0, // iInterface
  1188. // Alternate 1: streaming data
  1189. 9, // bLenght
  1190. 4, // bDescriptorType = INTERFACE
  1191. AUDIO_INTERFACE+1, // bInterfaceNumber
  1192. 1, // bAlternateSetting
  1193. 1, // bNumEndpoints
  1194. 1, // bInterfaceClass, 1 = AUDIO
  1195. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  1196. 0, // bInterfaceProtocol
  1197. 0, // iInterface
  1198. // Class-Specific AS Interface Descriptor
  1199. // USB DCD for Audio Devices 1.0, Section 4.5.2, Table 4-19, page 60
  1200. 7, // bLength
  1201. 0x24, // bDescriptorType = CS_INTERFACE
  1202. 1, // bDescriptorSubtype, 1 = AS_GENERAL
  1203. 2, // bTerminalLink: Terminal ID = 2
  1204. 3, // bDelay (approx 3ms delay, audio lib updates)
  1205. 0x01, 0x00, // wFormatTag, 0x0001 = PCM
  1206. // Type I Format Descriptor
  1207. // USB DCD for Audio Data Formats 1.0, Section 2.2.5, Table 2-1, page 10
  1208. 11, // bLength
  1209. 0x24, // bDescriptorType = CS_INTERFACE
  1210. 2, // bDescriptorSubtype = FORMAT_TYPE
  1211. 1, // bFormatType = FORMAT_TYPE_I
  1212. 2, // bNrChannels = 2
  1213. 2, // bSubFrameSize = 2 byte
  1214. 16, // bBitResolution = 16 bits
  1215. 1, // bSamFreqType = 1 frequency
  1216. LSB(44100), MSB(44100), 0, // tSamFreq
  1217. // Standard AS Isochronous Audio Data Endpoint Descriptor
  1218. // USB DCD for Audio Devices 1.0, Section 4.6.1.1, Table 4-20, page 61-62
  1219. 9, // bLength
  1220. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  1221. AUDIO_TX_ENDPOINT | 0x80, // bEndpointAddress
  1222. 0x09, // bmAttributes = isochronous, adaptive
  1223. LSB(AUDIO_TX_SIZE), MSB(AUDIO_TX_SIZE), // wMaxPacketSize
  1224. 1, // bInterval, 1 = every frame
  1225. 0, // bRefresh
  1226. 0, // bSynchAddress
  1227. // Class-Specific AS Isochronous Audio Data Endpoint Descriptor
  1228. // USB DCD for Audio Devices 1.0, Section 4.6.1.2, Table 4-21, page 62-63
  1229. 7, // bLength
  1230. 0x25, // bDescriptorType, 0x25 = CS_ENDPOINT
  1231. 1, // bDescriptorSubtype, 1 = EP_GENERAL
  1232. 0x00, // bmAttributes
  1233. 0, // bLockDelayUnits, 1 = ms
  1234. 0x00, 0x00, // wLockDelay
  1235. // Standard AS Interface Descriptor
  1236. // USB DCD for Audio Devices 1.0, Section 4.5.1, Table 4-18, page 59
  1237. // Alternate 0: default setting, disabled zero bandwidth
  1238. 9, // bLenght
  1239. 4, // bDescriptorType = INTERFACE
  1240. AUDIO_INTERFACE+2, // bInterfaceNumber
  1241. 0, // bAlternateSetting
  1242. 0, // bNumEndpoints
  1243. 1, // bInterfaceClass, 1 = AUDIO
  1244. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  1245. 0, // bInterfaceProtocol
  1246. 0, // iInterface
  1247. // Alternate 1: streaming data
  1248. 9, // bLenght
  1249. 4, // bDescriptorType = INTERFACE
  1250. AUDIO_INTERFACE+2, // bInterfaceNumber
  1251. 1, // bAlternateSetting
  1252. 2, // bNumEndpoints
  1253. 1, // bInterfaceClass, 1 = AUDIO
  1254. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  1255. 0, // bInterfaceProtocol
  1256. 0, // iInterface
  1257. // Class-Specific AS Interface Descriptor
  1258. // USB DCD for Audio Devices 1.0, Section 4.5.2, Table 4-19, page 60
  1259. 7, // bLength
  1260. 0x24, // bDescriptorType = CS_INTERFACE
  1261. 1, // bDescriptorSubtype, 1 = AS_GENERAL
  1262. 3, // bTerminalLink: Terminal ID = 3
  1263. 3, // bDelay (approx 3ms delay, audio lib updates)
  1264. 0x01, 0x00, // wFormatTag, 0x0001 = PCM
  1265. // Type I Format Descriptor
  1266. // USB DCD for Audio Data Formats 1.0, Section 2.2.5, Table 2-1, page 10
  1267. 11, // bLength
  1268. 0x24, // bDescriptorType = CS_INTERFACE
  1269. 2, // bDescriptorSubtype = FORMAT_TYPE
  1270. 1, // bFormatType = FORMAT_TYPE_I
  1271. 2, // bNrChannels = 2
  1272. 2, // bSubFrameSize = 2 byte
  1273. 16, // bBitResolution = 16 bits
  1274. 1, // bSamFreqType = 1 frequency
  1275. LSB(44100), MSB(44100), 0, // tSamFreq
  1276. // Standard AS Isochronous Audio Data Endpoint Descriptor
  1277. // USB DCD for Audio Devices 1.0, Section 4.6.1.1, Table 4-20, page 61-62
  1278. 9, // bLength
  1279. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  1280. AUDIO_RX_ENDPOINT, // bEndpointAddress
  1281. 0x05, // bmAttributes = isochronous, asynchronous
  1282. LSB(AUDIO_RX_SIZE), MSB(AUDIO_RX_SIZE), // wMaxPacketSize
  1283. 1, // bInterval, 1 = every frame
  1284. 0, // bRefresh
  1285. AUDIO_SYNC_ENDPOINT | 0x80, // bSynchAddress
  1286. // Class-Specific AS Isochronous Audio Data Endpoint Descriptor
  1287. // USB DCD for Audio Devices 1.0, Section 4.6.1.2, Table 4-21, page 62-63
  1288. 7, // bLength
  1289. 0x25, // bDescriptorType, 0x25 = CS_ENDPOINT
  1290. 1, // bDescriptorSubtype, 1 = EP_GENERAL
  1291. 0x00, // bmAttributes
  1292. 0, // bLockDelayUnits, 1 = ms
  1293. 0x00, 0x00, // wLockDelay
  1294. // Standard AS Isochronous Audio Synch Endpoint Descriptor
  1295. // USB DCD for Audio Devices 1.0, Section 4.6.2.1, Table 4-22, page 63-64
  1296. 9, // bLength
  1297. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  1298. AUDIO_SYNC_ENDPOINT | 0x80, // bEndpointAddress
  1299. 0x11, // bmAttributes = isochronous, feedback
  1300. 3, 0, // wMaxPacketSize, 3 bytes
  1301. 1, // bInterval, 1 = every frame
  1302. 5, // bRefresh, 5 = 32ms
  1303. 0, // bSynchAddress
  1304. #endif
  1305. #ifdef MULTITOUCH_INTERFACE
  1306. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1307. 9, // bLength
  1308. 4, // bDescriptorType
  1309. MULTITOUCH_INTERFACE, // bInterfaceNumber
  1310. 0, // bAlternateSetting
  1311. 1, // bNumEndpoints
  1312. 0x03, // bInterfaceClass (0x03 = HID)
  1313. 0x00, // bInterfaceSubClass
  1314. 0x00, // bInterfaceProtocol
  1315. 0, // iInterface
  1316. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1317. 9, // bLength
  1318. 0x21, // bDescriptorType
  1319. 0x11, 0x01, // bcdHID
  1320. 0, // bCountryCode
  1321. 1, // bNumDescriptors
  1322. 0x22, // bDescriptorType
  1323. LSB(sizeof(multitouch_report_desc)), // wDescriptorLength
  1324. MSB(sizeof(multitouch_report_desc)),
  1325. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1326. 7, // bLength
  1327. 5, // bDescriptorType
  1328. MULTITOUCH_ENDPOINT | 0x80, // bEndpointAddress
  1329. 0x03, // bmAttributes (0x03=intr)
  1330. MULTITOUCH_SIZE, 0, // wMaxPacketSize
  1331. 1, // bInterval
  1332. #endif // KEYMEDIA_INTERFACE
  1333. };
  1334. // **************************************************************
  1335. // String Descriptors
  1336. // **************************************************************
  1337. // The descriptors above can provide human readable strings,
  1338. // referenced by index numbers. These descriptors are the
  1339. // actual string data
  1340. /* defined in usb_names.h
  1341. struct usb_string_descriptor_struct {
  1342. uint8_t bLength;
  1343. uint8_t bDescriptorType;
  1344. uint16_t wString[];
  1345. };
  1346. */
  1347. extern struct usb_string_descriptor_struct usb_string_manufacturer_name
  1348. __attribute__ ((weak, alias("usb_string_manufacturer_name_default")));
  1349. extern struct usb_string_descriptor_struct usb_string_product_name
  1350. __attribute__ ((weak, alias("usb_string_product_name_default")));
  1351. extern struct usb_string_descriptor_struct usb_string_serial_number
  1352. __attribute__ ((weak, alias("usb_string_serial_number_default")));
  1353. #ifdef MIDI_INTERFACE
  1354. extern struct usb_string_descriptor_struct usb_string_midi_port1
  1355. __attribute__ ((weak, alias("usb_string_midi_port1_default")));
  1356. #if MIDI_NUM_CABLES >= 2
  1357. extern struct usb_string_descriptor_struct usb_string_midi_port2
  1358. __attribute__ ((weak, alias("usb_string_midi_port2_default")));
  1359. #endif
  1360. #if MIDI_NUM_CABLES >= 3
  1361. extern struct usb_string_descriptor_struct usb_string_midi_port3
  1362. __attribute__ ((weak, alias("usb_string_midi_port3_default")));
  1363. #endif
  1364. #if MIDI_NUM_CABLES >= 4
  1365. extern struct usb_string_descriptor_struct usb_string_midi_port4
  1366. __attribute__ ((weak, alias("usb_string_midi_port4_default")));
  1367. #endif
  1368. #if MIDI_NUM_CABLES >= 5
  1369. extern struct usb_string_descriptor_struct usb_string_midi_port5
  1370. __attribute__ ((weak, alias("usb_string_midi_port5_default")));
  1371. #endif
  1372. #if MIDI_NUM_CABLES >= 6
  1373. extern struct usb_string_descriptor_struct usb_string_midi_port6
  1374. __attribute__ ((weak, alias("usb_string_midi_port6_default")));
  1375. #endif
  1376. #if MIDI_NUM_CABLES >= 7
  1377. extern struct usb_string_descriptor_struct usb_string_midi_port7
  1378. __attribute__ ((weak, alias("usb_string_midi_port7_default")));
  1379. #endif
  1380. #if MIDI_NUM_CABLES >= 8
  1381. extern struct usb_string_descriptor_struct usb_string_midi_port8
  1382. __attribute__ ((weak, alias("usb_string_midi_port8_default")));
  1383. #endif
  1384. #if MIDI_NUM_CABLES >= 9
  1385. extern struct usb_string_descriptor_struct usb_string_midi_port9
  1386. __attribute__ ((weak, alias("usb_string_midi_port9_default")));
  1387. #endif
  1388. #if MIDI_NUM_CABLES >= 10
  1389. extern struct usb_string_descriptor_struct usb_string_midi_port10
  1390. __attribute__ ((weak, alias("usb_string_midi_port10_default")));
  1391. #endif
  1392. #if MIDI_NUM_CABLES >= 11
  1393. extern struct usb_string_descriptor_struct usb_string_midi_port11
  1394. __attribute__ ((weak, alias("usb_string_midi_port11_default")));
  1395. #endif
  1396. #if MIDI_NUM_CABLES >= 12
  1397. extern struct usb_string_descriptor_struct usb_string_midi_port12
  1398. __attribute__ ((weak, alias("usb_string_midi_port12_default")));
  1399. #endif
  1400. #if MIDI_NUM_CABLES >= 13
  1401. extern struct usb_string_descriptor_struct usb_string_midi_port13
  1402. __attribute__ ((weak, alias("usb_string_midi_port13_default")));
  1403. #endif
  1404. #if MIDI_NUM_CABLES >= 14
  1405. extern struct usb_string_descriptor_struct usb_string_midi_port14
  1406. __attribute__ ((weak, alias("usb_string_midi_port14_default")));
  1407. #endif
  1408. #if MIDI_NUM_CABLES >= 15
  1409. extern struct usb_string_descriptor_struct usb_string_midi_port15
  1410. __attribute__ ((weak, alias("usb_string_midi_port15_default")));
  1411. #endif
  1412. #if MIDI_NUM_CABLES >= 16
  1413. extern struct usb_string_descriptor_struct usb_string_midi_port16
  1414. __attribute__ ((weak, alias("usb_string_midi_port16_default")));
  1415. #endif
  1416. #endif
  1417. struct usb_string_descriptor_struct string0 = {
  1418. 4,
  1419. 3,
  1420. {0x0409}
  1421. };
  1422. struct usb_string_descriptor_struct usb_string_manufacturer_name_default = {
  1423. 2 + MANUFACTURER_NAME_LEN * 2,
  1424. 3,
  1425. MANUFACTURER_NAME
  1426. };
  1427. struct usb_string_descriptor_struct usb_string_product_name_default = {
  1428. 2 + PRODUCT_NAME_LEN * 2,
  1429. 3,
  1430. PRODUCT_NAME
  1431. };
  1432. struct usb_string_descriptor_struct usb_string_serial_number_default = {
  1433. 12,
  1434. 3,
  1435. {0,0,0,0,0,0,0,0,0,0}
  1436. };
  1437. #ifdef MIDI_INTERFACE
  1438. struct usb_string_descriptor_struct usb_string_midi_port1_default = {
  1439. 14,
  1440. 3,
  1441. {'P','o','r','t',' ','1'}
  1442. };
  1443. #if MIDI_NUM_CABLES >= 2
  1444. struct usb_string_descriptor_struct usb_string_midi_port2_default = {
  1445. 14,
  1446. 3,
  1447. {'P','o','r','t',' ','2'}
  1448. };
  1449. #endif
  1450. #if MIDI_NUM_CABLES >= 3
  1451. struct usb_string_descriptor_struct usb_string_midi_port3_default = {
  1452. 14,
  1453. 3,
  1454. {'P','o','r','t',' ','3'}
  1455. };
  1456. #endif
  1457. #if MIDI_NUM_CABLES >= 4
  1458. struct usb_string_descriptor_struct usb_string_midi_port4_default = {
  1459. 14,
  1460. 3,
  1461. {'P','o','r','t',' ','4'}
  1462. };
  1463. #endif
  1464. #if MIDI_NUM_CABLES >= 5
  1465. struct usb_string_descriptor_struct usb_string_midi_port5_default = {
  1466. 14,
  1467. 3,
  1468. {'P','o','r','t',' ','5'}
  1469. };
  1470. #endif
  1471. #if MIDI_NUM_CABLES >= 6
  1472. struct usb_string_descriptor_struct usb_string_midi_port6_default = {
  1473. 14,
  1474. 3,
  1475. {'P','o','r','t',' ','6'}
  1476. };
  1477. #endif
  1478. #if MIDI_NUM_CABLES >= 7
  1479. struct usb_string_descriptor_struct usb_string_midi_port7_default = {
  1480. 14,
  1481. 3,
  1482. {'P','o','r','t',' ','7'}
  1483. };
  1484. #endif
  1485. #if MIDI_NUM_CABLES >= 8
  1486. struct usb_string_descriptor_struct usb_string_midi_port8_default = {
  1487. 14,
  1488. 3,
  1489. {'P','o','r','t',' ','8'}
  1490. };
  1491. #endif
  1492. #if MIDI_NUM_CABLES >= 9
  1493. struct usb_string_descriptor_struct usb_string_midi_port9_default = {
  1494. 14,
  1495. 3,
  1496. {'P','o','r','t',' ','9'}
  1497. };
  1498. #endif
  1499. #if MIDI_NUM_CABLES >= 10
  1500. struct usb_string_descriptor_struct usb_string_midi_port10_default = {
  1501. 16,
  1502. 3,
  1503. {'P','o','r','t',' ','1','0'}
  1504. };
  1505. #endif
  1506. #if MIDI_NUM_CABLES >= 11
  1507. struct usb_string_descriptor_struct usb_string_midi_port11_default = {
  1508. 16,
  1509. 3,
  1510. {'P','o','r','t',' ','1','1'}
  1511. };
  1512. #endif
  1513. #if MIDI_NUM_CABLES >= 12
  1514. struct usb_string_descriptor_struct usb_string_midi_port12_default = {
  1515. 16,
  1516. 3,
  1517. {'P','o','r','t',' ','1','2'}
  1518. };
  1519. #endif
  1520. #if MIDI_NUM_CABLES >= 13
  1521. struct usb_string_descriptor_struct usb_string_midi_port13_default = {
  1522. 16,
  1523. 3,
  1524. {'P','o','r','t',' ','1','3'}
  1525. };
  1526. #endif
  1527. #if MIDI_NUM_CABLES >= 14
  1528. struct usb_string_descriptor_struct usb_string_midi_port14_default = {
  1529. 16,
  1530. 3,
  1531. {'P','o','r','t',' ','1','4'}
  1532. };
  1533. #endif
  1534. #if MIDI_NUM_CABLES >= 15
  1535. struct usb_string_descriptor_struct usb_string_midi_port15_default = {
  1536. 16,
  1537. 3,
  1538. {'P','o','r','t',' ','1','5'}
  1539. };
  1540. #endif
  1541. #if MIDI_NUM_CABLES >= 16
  1542. struct usb_string_descriptor_struct usb_string_midi_port16_default = {
  1543. 16,
  1544. 3,
  1545. {'P','o','r','t',' ','1','6'}
  1546. };
  1547. #endif
  1548. #endif
  1549. #ifdef MTP_INTERFACE
  1550. struct usb_string_descriptor_struct usb_string_mtp = {
  1551. 2 + 3 * 2,
  1552. 3,
  1553. {'M','T','P'}
  1554. };
  1555. #endif
  1556. void usb_init_serialnumber(void)
  1557. {
  1558. char buf[11];
  1559. uint32_t i, num;
  1560. __disable_irq();
  1561. #if defined(HAS_KINETIS_FLASH_FTFA) || defined(HAS_KINETIS_FLASH_FTFL)
  1562. FTFL_FSTAT = FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL;
  1563. FTFL_FCCOB0 = 0x41;
  1564. FTFL_FCCOB1 = 15;
  1565. FTFL_FSTAT = FTFL_FSTAT_CCIF;
  1566. while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF)) ; // wait
  1567. num = *(uint32_t *)&FTFL_FCCOB7;
  1568. #elif defined(HAS_KINETIS_FLASH_FTFE)
  1569. kinetis_hsrun_disable();
  1570. FTFL_FSTAT = FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL;
  1571. *(uint32_t *)&FTFL_FCCOB3 = 0x41070000;
  1572. FTFL_FSTAT = FTFL_FSTAT_CCIF;
  1573. while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF)) ; // wait
  1574. num = *(uint32_t *)&FTFL_FCCOBB;
  1575. kinetis_hsrun_enable();
  1576. #endif
  1577. __enable_irq();
  1578. // add extra zero to work around OS-X CDC-ACM driver bug
  1579. if (num < 10000000) num = num * 10;
  1580. ultoa(num, buf, 10);
  1581. for (i=0; i<10; i++) {
  1582. char c = buf[i];
  1583. if (!c) break;
  1584. usb_string_serial_number_default.wString[i] = c;
  1585. }
  1586. usb_string_serial_number_default.bLength = i * 2 + 2;
  1587. }
  1588. // **************************************************************
  1589. // Descriptors List
  1590. // **************************************************************
  1591. // This table provides access to all the descriptor data above.
  1592. const usb_descriptor_list_t usb_descriptor_list[] = {
  1593. //wValue, wIndex, address, length
  1594. {0x0100, 0x0000, device_descriptor, sizeof(device_descriptor)},
  1595. {0x0200, 0x0000, config_descriptor, sizeof(config_descriptor)},
  1596. #ifdef SEREMU_INTERFACE
  1597. {0x2200, SEREMU_INTERFACE, seremu_report_desc, sizeof(seremu_report_desc)},
  1598. {0x2100, SEREMU_INTERFACE, config_descriptor+SEREMU_HID_DESC_OFFSET, 9},
  1599. #endif
  1600. #ifdef KEYBOARD_INTERFACE
  1601. {0x2200, KEYBOARD_INTERFACE, keyboard_report_desc, sizeof(keyboard_report_desc)},
  1602. {0x2100, KEYBOARD_INTERFACE, config_descriptor+KEYBOARD_HID_DESC_OFFSET, 9},
  1603. #endif
  1604. #ifdef MOUSE_INTERFACE
  1605. {0x2200, MOUSE_INTERFACE, mouse_report_desc, sizeof(mouse_report_desc)},
  1606. {0x2100, MOUSE_INTERFACE, config_descriptor+MOUSE_HID_DESC_OFFSET, 9},
  1607. #endif
  1608. #ifdef JOYSTICK_INTERFACE
  1609. {0x2200, JOYSTICK_INTERFACE, joystick_report_desc, sizeof(joystick_report_desc)},
  1610. {0x2100, JOYSTICK_INTERFACE, config_descriptor+JOYSTICK_HID_DESC_OFFSET, 9},
  1611. #endif
  1612. #ifdef RAWHID_INTERFACE
  1613. {0x2200, RAWHID_INTERFACE, rawhid_report_desc, sizeof(rawhid_report_desc)},
  1614. {0x2100, RAWHID_INTERFACE, config_descriptor+RAWHID_HID_DESC_OFFSET, 9},
  1615. #endif
  1616. #ifdef FLIGHTSIM_INTERFACE
  1617. {0x2200, FLIGHTSIM_INTERFACE, flightsim_report_desc, sizeof(flightsim_report_desc)},
  1618. {0x2100, FLIGHTSIM_INTERFACE, config_descriptor+FLIGHTSIM_HID_DESC_OFFSET, 9},
  1619. #endif
  1620. #ifdef KEYMEDIA_INTERFACE
  1621. {0x2200, KEYMEDIA_INTERFACE, keymedia_report_desc, sizeof(keymedia_report_desc)},
  1622. {0x2100, KEYMEDIA_INTERFACE, config_descriptor+KEYMEDIA_HID_DESC_OFFSET, 9},
  1623. #endif
  1624. #ifdef MULTITOUCH_INTERFACE
  1625. {0x2200, MULTITOUCH_INTERFACE, multitouch_report_desc, sizeof(multitouch_report_desc)},
  1626. {0x2100, MULTITOUCH_INTERFACE, config_descriptor+MULTITOUCH_HID_DESC_OFFSET, 9},
  1627. #endif
  1628. #ifdef MTP_INTERFACE
  1629. {0x0304, 0x0409, (const uint8_t *)&usb_string_mtp, 0},
  1630. #endif
  1631. #ifdef MIDI_INTERFACE
  1632. {0x0305, 0x0409, (const uint8_t *)&usb_string_midi_port1, 0},
  1633. #if MIDI_NUM_CABLES >= 2
  1634. {0x0306, 0x0409, (const uint8_t *)&usb_string_midi_port2, 0},
  1635. #endif
  1636. #if MIDI_NUM_CABLES >= 3
  1637. {0x0307, 0x0409, (const uint8_t *)&usb_string_midi_port3, 0},
  1638. #endif
  1639. #if MIDI_NUM_CABLES >= 4
  1640. {0x0308, 0x0409, (const uint8_t *)&usb_string_midi_port4, 0},
  1641. #endif
  1642. #if MIDI_NUM_CABLES >= 5
  1643. {0x0309, 0x0409, (const uint8_t *)&usb_string_midi_port5, 0},
  1644. #endif
  1645. #if MIDI_NUM_CABLES >= 6
  1646. {0x030A, 0x0409, (const uint8_t *)&usb_string_midi_port6, 0},
  1647. #endif
  1648. #if MIDI_NUM_CABLES >= 7
  1649. {0x030B, 0x0409, (const uint8_t *)&usb_string_midi_port7, 0},
  1650. #endif
  1651. #if MIDI_NUM_CABLES >= 8
  1652. {0x030C, 0x0409, (const uint8_t *)&usb_string_midi_port8, 0},
  1653. #endif
  1654. #if MIDI_NUM_CABLES >= 9
  1655. {0x030D, 0x0409, (const uint8_t *)&usb_string_midi_port9, 0},
  1656. #endif
  1657. #if MIDI_NUM_CABLES >= 10
  1658. {0x030E, 0x0409, (const uint8_t *)&usb_string_midi_port10, 0},
  1659. #endif
  1660. #if MIDI_NUM_CABLES >= 11
  1661. {0x030F, 0x0409, (const uint8_t *)&usb_string_midi_port11, 0},
  1662. #endif
  1663. #if MIDI_NUM_CABLES >= 12
  1664. {0x0310, 0x0409, (const uint8_t *)&usb_string_midi_port12, 0},
  1665. #endif
  1666. #if MIDI_NUM_CABLES >= 13
  1667. {0x0311, 0x0409, (const uint8_t *)&usb_string_midi_port13, 0},
  1668. #endif
  1669. #if MIDI_NUM_CABLES >= 14
  1670. {0x0312, 0x0409, (const uint8_t *)&usb_string_midi_port14, 0},
  1671. #endif
  1672. #if MIDI_NUM_CABLES >= 15
  1673. {0x0313, 0x0409, (const uint8_t *)&usb_string_midi_port15, 0},
  1674. #endif
  1675. #if MIDI_NUM_CABLES >= 16
  1676. {0x0314, 0x0409, (const uint8_t *)&usb_string_midi_port16, 0},
  1677. #endif
  1678. #endif
  1679. {0x0300, 0x0000, (const uint8_t *)&string0, 0},
  1680. {0x0301, 0x0409, (const uint8_t *)&usb_string_manufacturer_name, 0},
  1681. {0x0302, 0x0409, (const uint8_t *)&usb_string_product_name, 0},
  1682. {0x0303, 0x0409, (const uint8_t *)&usb_string_serial_number, 0},
  1683. {0, 0, NULL, 0}
  1684. };
  1685. // **************************************************************
  1686. // Endpoint Configuration
  1687. // **************************************************************
  1688. #if 0
  1689. // 0x00 = not used
  1690. // 0x19 = Recieve only
  1691. // 0x15 = Transmit only
  1692. // 0x1D = Transmit & Recieve
  1693. //
  1694. const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS] =
  1695. {
  1696. 0x00, 0x15, 0x19, 0x15, 0x00, 0x00, 0x00, 0x00,
  1697. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1698. };
  1699. #endif
  1700. const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS] =
  1701. {
  1702. #if (defined(ENDPOINT1_CONFIG) && NUM_ENDPOINTS >= 1)
  1703. ENDPOINT1_CONFIG,
  1704. #elif (NUM_ENDPOINTS >= 1)
  1705. ENDPOINT_UNUSED,
  1706. #endif
  1707. #if (defined(ENDPOINT2_CONFIG) && NUM_ENDPOINTS >= 2)
  1708. ENDPOINT2_CONFIG,
  1709. #elif (NUM_ENDPOINTS >= 2)
  1710. ENDPOINT_UNUSED,
  1711. #endif
  1712. #if (defined(ENDPOINT3_CONFIG) && NUM_ENDPOINTS >= 3)
  1713. ENDPOINT3_CONFIG,
  1714. #elif (NUM_ENDPOINTS >= 3)
  1715. ENDPOINT_UNUSED,
  1716. #endif
  1717. #if (defined(ENDPOINT4_CONFIG) && NUM_ENDPOINTS >= 4)
  1718. ENDPOINT4_CONFIG,
  1719. #elif (NUM_ENDPOINTS >= 4)
  1720. ENDPOINT_UNUSED,
  1721. #endif
  1722. #if (defined(ENDPOINT5_CONFIG) && NUM_ENDPOINTS >= 5)
  1723. ENDPOINT5_CONFIG,
  1724. #elif (NUM_ENDPOINTS >= 5)
  1725. ENDPOINT_UNUSED,
  1726. #endif
  1727. #if (defined(ENDPOINT6_CONFIG) && NUM_ENDPOINTS >= 6)
  1728. ENDPOINT6_CONFIG,
  1729. #elif (NUM_ENDPOINTS >= 6)
  1730. ENDPOINT_UNUSED,
  1731. #endif
  1732. #if (defined(ENDPOINT7_CONFIG) && NUM_ENDPOINTS >= 7)
  1733. ENDPOINT7_CONFIG,
  1734. #elif (NUM_ENDPOINTS >= 7)
  1735. ENDPOINT_UNUSED,
  1736. #endif
  1737. #if (defined(ENDPOINT8_CONFIG) && NUM_ENDPOINTS >= 8)
  1738. ENDPOINT8_CONFIG,
  1739. #elif (NUM_ENDPOINTS >= 8)
  1740. ENDPOINT_UNUSED,
  1741. #endif
  1742. #if (defined(ENDPOINT9_CONFIG) && NUM_ENDPOINTS >= 9)
  1743. ENDPOINT9_CONFIG,
  1744. #elif (NUM_ENDPOINTS >= 9)
  1745. ENDPOINT_UNUSED,
  1746. #endif
  1747. #if (defined(ENDPOINT10_CONFIG) && NUM_ENDPOINTS >= 10)
  1748. ENDPOINT10_CONFIG,
  1749. #elif (NUM_ENDPOINTS >= 10)
  1750. ENDPOINT_UNUSED,
  1751. #endif
  1752. #if (defined(ENDPOINT11_CONFIG) && NUM_ENDPOINTS >= 11)
  1753. ENDPOINT11_CONFIG,
  1754. #elif (NUM_ENDPOINTS >= 11)
  1755. ENDPOINT_UNUSED,
  1756. #endif
  1757. #if (defined(ENDPOINT12_CONFIG) && NUM_ENDPOINTS >= 12)
  1758. ENDPOINT12_CONFIG,
  1759. #elif (NUM_ENDPOINTS >= 12)
  1760. ENDPOINT_UNUSED,
  1761. #endif
  1762. #if (defined(ENDPOINT13_CONFIG) && NUM_ENDPOINTS >= 13)
  1763. ENDPOINT13_CONFIG,
  1764. #elif (NUM_ENDPOINTS >= 13)
  1765. ENDPOINT_UNUSED,
  1766. #endif
  1767. #if (defined(ENDPOINT14_CONFIG) && NUM_ENDPOINTS >= 14)
  1768. ENDPOINT14_CONFIG,
  1769. #elif (NUM_ENDPOINTS >= 14)
  1770. ENDPOINT_UNUSED,
  1771. #endif
  1772. #if (defined(ENDPOINT15_CONFIG) && NUM_ENDPOINTS >= 15)
  1773. ENDPOINT15_CONFIG,
  1774. #elif (NUM_ENDPOINTS >= 15)
  1775. ENDPOINT_UNUSED,
  1776. #endif
  1777. };
  1778. #endif // NUM_ENDPOINTS
  1779. #endif // F_CPU >= 20 MHz