No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

usb_desc.c 114KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409
  1. /* Teensyduino Core Library
  2. * http://www.pjrc.com/teensy/
  3. * Copyright (c) 2019 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 "imxrt.h"
  36. #include "avr_functions.h"
  37. #include "avr/pgmspace.h"
  38. // USB Descriptors are binary data which the USB host reads to
  39. // automatically detect a USB device's capabilities. The format
  40. // and meaning of every field is documented in numerous USB
  41. // standards. When working with USB descriptors, despite the
  42. // complexity of the standards and poor writing quality in many
  43. // of those documents, remember descriptors are nothing more
  44. // than constant binary data that tells the USB host what the
  45. // device can do. Computers will load drivers based on this data.
  46. // Those drivers then communicate on the endpoints specified by
  47. // the descriptors.
  48. // To configure a new combination of interfaces or make minor
  49. // changes to existing configuration (eg, change the name or ID
  50. // numbers), usually you would edit "usb_desc.h". This file
  51. // is meant to be configured by the header, so generally it is
  52. // only edited to add completely new USB interfaces or features.
  53. // **************************************************************
  54. // USB Device
  55. // **************************************************************
  56. #define LSB(n) ((n) & 255)
  57. #define MSB(n) (((n) >> 8) & 255)
  58. // USB Device Descriptor. The USB host reads this first, to learn
  59. // what type of device is connected.
  60. static uint8_t device_descriptor[] = {
  61. 18, // bLength
  62. 1, // bDescriptorType
  63. 0x00, 0x02, // bcdUSB
  64. #ifdef DEVICE_CLASS
  65. DEVICE_CLASS, // bDeviceClass
  66. #else
  67. 0,
  68. #endif
  69. #ifdef DEVICE_SUBCLASS
  70. DEVICE_SUBCLASS, // bDeviceSubClass
  71. #else
  72. 0,
  73. #endif
  74. #ifdef DEVICE_PROTOCOL
  75. DEVICE_PROTOCOL, // bDeviceProtocol
  76. #else
  77. 0,
  78. #endif
  79. EP0_SIZE, // bMaxPacketSize0
  80. LSB(VENDOR_ID), MSB(VENDOR_ID), // idVendor
  81. LSB(PRODUCT_ID), MSB(PRODUCT_ID), // idProduct
  82. #ifdef BCD_DEVICE
  83. LSB(BCD_DEVICE), MSB(BCD_DEVICE), // bcdDevice
  84. #else
  85. // For USB types that don't explicitly define BCD_DEVICE,
  86. // use the minor version number to help teensy_ports
  87. // identify which Teensy model is used.
  88. #if defined(__IMXRT1062__) && defined(ARDUINO_TEENSY40)
  89. 0x79, 0x02, // Teensy 4.0
  90. #elif defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41)
  91. 0x80, 0x02, // Teensy 4.1
  92. #else
  93. 0x00, 0x02,
  94. #endif
  95. #endif
  96. 1, // iManufacturer
  97. 2, // iProduct
  98. 3, // iSerialNumber
  99. 1 // bNumConfigurations
  100. };
  101. PROGMEM static const uint8_t qualifier_descriptor[] = { // 9.6.2 Device_Qualifier, page 264
  102. 10, // bLength
  103. 6, // bDescriptorType
  104. 0x00, 0x02, // bcdUSB
  105. #ifdef DEVICE_CLASS
  106. DEVICE_CLASS, // bDeviceClass
  107. #else
  108. 0,
  109. #endif
  110. #ifdef DEVICE_SUBCLASS
  111. DEVICE_SUBCLASS, // bDeviceSubClass
  112. #else
  113. 0,
  114. #endif
  115. #ifdef DEVICE_PROTOCOL
  116. DEVICE_PROTOCOL, // bDeviceProtocol
  117. #else
  118. 0,
  119. #endif
  120. EP0_SIZE, // bMaxPacketSize0
  121. 1, // bNumConfigurations
  122. 0 // bReserved
  123. };
  124. // These descriptors must NOT be "const", because the USB DMA
  125. // has trouble accessing flash memory with enough bandwidth
  126. // while the processor is executing from flash.
  127. // **************************************************************
  128. // HID Report Descriptors
  129. // **************************************************************
  130. // Each HID interface needs a special report descriptor that tells
  131. // the meaning and format of the data.
  132. #ifdef KEYBOARD_INTERFACE
  133. // Keyboard Protocol 1, HID 1.11 spec, Appendix B, page 59-60
  134. static uint8_t keyboard_report_desc[] = {
  135. 0x05, 0x01, // Usage Page (Generic Desktop),
  136. 0x09, 0x06, // Usage (Keyboard),
  137. 0xA1, 0x01, // Collection (Application),
  138. 0x75, 0x01, // Report Size (1),
  139. 0x95, 0x08, // Report Count (8),
  140. 0x05, 0x07, // Usage Page (Key Codes),
  141. 0x19, 0xE0, // Usage Minimum (224),
  142. 0x29, 0xE7, // Usage Maximum (231),
  143. 0x15, 0x00, // Logical Minimum (0),
  144. 0x25, 0x01, // Logical Maximum (1),
  145. 0x81, 0x02, // Input (Data, Variable, Absolute), ;Modifier keys
  146. 0x95, 0x01, // Report Count (1),
  147. 0x75, 0x08, // Report Size (8),
  148. 0x81, 0x03, // Input (Constant), ;Reserved byte
  149. 0x95, 0x05, // Report Count (5),
  150. 0x75, 0x01, // Report Size (1),
  151. 0x05, 0x08, // Usage Page (LEDs),
  152. 0x19, 0x01, // Usage Minimum (1),
  153. 0x29, 0x05, // Usage Maximum (5),
  154. 0x91, 0x02, // Output (Data, Variable, Absolute), ;LED report
  155. 0x95, 0x01, // Report Count (1),
  156. 0x75, 0x03, // Report Size (3),
  157. 0x91, 0x03, // Output (Constant), ;LED report padding
  158. 0x95, 0x06, // Report Count (6),
  159. 0x75, 0x08, // Report Size (8),
  160. 0x15, 0x00, // Logical Minimum (0),
  161. 0x25, 0x7F, // Logical Maximum(104),
  162. 0x05, 0x07, // Usage Page (Key Codes),
  163. 0x19, 0x00, // Usage Minimum (0),
  164. 0x29, 0x7F, // Usage Maximum (104),
  165. 0x81, 0x00, // Input (Data, Array), ;Normal keys
  166. 0xC0 // End Collection
  167. };
  168. #endif
  169. #ifdef KEYMEDIA_INTERFACE
  170. static uint8_t keymedia_report_desc[] = {
  171. 0x05, 0x0C, // Usage Page (Consumer)
  172. 0x09, 0x01, // Usage (Consumer Controls)
  173. 0xA1, 0x01, // Collection (Application)
  174. 0x75, 0x0A, // Report Size (10)
  175. 0x95, 0x04, // Report Count (4)
  176. 0x19, 0x00, // Usage Minimum (0)
  177. 0x2A, 0x9C, 0x02, // Usage Maximum (0x29C)
  178. 0x15, 0x00, // Logical Minimum (0)
  179. 0x26, 0x9C, 0x02, // Logical Maximum (0x29C)
  180. 0x81, 0x00, // Input (Data, Array)
  181. 0x05, 0x01, // Usage Page (Generic Desktop)
  182. 0x75, 0x08, // Report Size (8)
  183. 0x95, 0x03, // Report Count (3)
  184. 0x19, 0x00, // Usage Minimum (0)
  185. 0x29, 0xB7, // Usage Maximum (0xB7)
  186. 0x15, 0x00, // Logical Minimum (0)
  187. 0x26, 0xB7, 0x00, // Logical Maximum (0xB7)
  188. 0x81, 0x00, // Input (Data, Array)
  189. 0xC0 // End Collection
  190. };
  191. #endif
  192. #ifdef MOUSE_INTERFACE
  193. // Mouse Protocol 1, HID 1.11 spec, Appendix B, page 59-60, with wheel extension
  194. static uint8_t mouse_report_desc[] = {
  195. 0x05, 0x01, // Usage Page (Generic Desktop)
  196. 0x09, 0x02, // Usage (Mouse)
  197. 0xA1, 0x01, // Collection (Application)
  198. 0x85, 0x01, // REPORT_ID (1)
  199. 0x05, 0x09, // Usage Page (Button)
  200. 0x19, 0x01, // Usage Minimum (Button #1)
  201. 0x29, 0x08, // Usage Maximum (Button #8)
  202. 0x15, 0x00, // Logical Minimum (0)
  203. 0x25, 0x01, // Logical Maximum (1)
  204. 0x95, 0x08, // Report Count (8)
  205. 0x75, 0x01, // Report Size (1)
  206. 0x81, 0x02, // Input (Data, Variable, Absolute)
  207. 0x05, 0x01, // Usage Page (Generic Desktop)
  208. 0x09, 0x30, // Usage (X)
  209. 0x09, 0x31, // Usage (Y)
  210. 0x09, 0x38, // Usage (Wheel)
  211. 0x15, 0x81, // Logical Minimum (-127)
  212. 0x25, 0x7F, // Logical Maximum (127)
  213. 0x75, 0x08, // Report Size (8),
  214. 0x95, 0x03, // Report Count (3),
  215. 0x81, 0x06, // Input (Data, Variable, Relative)
  216. 0x05, 0x0C, // Usage Page (Consumer)
  217. 0x0A, 0x38, 0x02, // Usage (AC Pan)
  218. 0x15, 0x81, // Logical Minimum (-127)
  219. 0x25, 0x7F, // Logical Maximum (127)
  220. 0x75, 0x08, // Report Size (8),
  221. 0x95, 0x01, // Report Count (1),
  222. 0x81, 0x06, // Input (Data, Variable, Relative)
  223. 0xC0, // End Collection
  224. 0x05, 0x01, // Usage Page (Generic Desktop)
  225. 0x09, 0x02, // Usage (Mouse)
  226. 0xA1, 0x01, // Collection (Application)
  227. 0x85, 0x02, // REPORT_ID (2)
  228. 0x05, 0x01, // Usage Page (Generic Desktop)
  229. 0x09, 0x30, // Usage (X)
  230. 0x09, 0x31, // Usage (Y)
  231. 0x15, 0x00, // Logical Minimum (0)
  232. 0x26, 0xFF, 0x7F, // Logical Maximum (32767)
  233. 0x75, 0x10, // Report Size (16),
  234. 0x95, 0x02, // Report Count (2),
  235. 0x81, 0x02, // Input (Data, Variable, Absolute)
  236. 0xC0 // End Collection
  237. };
  238. #endif
  239. #ifdef JOYSTICK_INTERFACE
  240. #if JOYSTICK_SIZE == 12
  241. static uint8_t joystick_report_desc[] = {
  242. 0x05, 0x01, // Usage Page (Generic Desktop)
  243. 0x09, 0x04, // Usage (Joystick)
  244. 0xA1, 0x01, // Collection (Application)
  245. 0x15, 0x00, // Logical Minimum (0)
  246. 0x25, 0x01, // Logical Maximum (1)
  247. 0x75, 0x01, // Report Size (1)
  248. 0x95, 0x20, // Report Count (32)
  249. 0x05, 0x09, // Usage Page (Button)
  250. 0x19, 0x01, // Usage Minimum (Button #1)
  251. 0x29, 0x20, // Usage Maximum (Button #32)
  252. 0x81, 0x02, // Input (variable,absolute)
  253. 0x15, 0x00, // Logical Minimum (0)
  254. 0x25, 0x07, // Logical Maximum (7)
  255. 0x35, 0x00, // Physical Minimum (0)
  256. 0x46, 0x3B, 0x01, // Physical Maximum (315)
  257. 0x75, 0x04, // Report Size (4)
  258. 0x95, 0x01, // Report Count (1)
  259. 0x65, 0x14, // Unit (20)
  260. 0x05, 0x01, // Usage Page (Generic Desktop)
  261. 0x09, 0x39, // Usage (Hat switch)
  262. 0x81, 0x42, // Input (variable,absolute,null_state)
  263. 0x05, 0x01, // Usage Page (Generic Desktop)
  264. 0x09, 0x01, // Usage (Pointer)
  265. 0xA1, 0x00, // Collection ()
  266. 0x15, 0x00, // Logical Minimum (0)
  267. 0x26, 0xFF, 0x03, // Logical Maximum (1023)
  268. 0x75, 0x0A, // Report Size (10)
  269. 0x95, 0x04, // Report Count (4)
  270. 0x09, 0x30, // Usage (X)
  271. 0x09, 0x31, // Usage (Y)
  272. 0x09, 0x32, // Usage (Z)
  273. 0x09, 0x35, // Usage (Rz)
  274. 0x81, 0x02, // Input (variable,absolute)
  275. 0xC0, // End Collection
  276. 0x15, 0x00, // Logical Minimum (0)
  277. 0x26, 0xFF, 0x03, // Logical Maximum (1023)
  278. 0x75, 0x0A, // Report Size (10)
  279. 0x95, 0x02, // Report Count (2)
  280. 0x09, 0x36, // Usage (Slider)
  281. 0x09, 0x36, // Usage (Slider)
  282. 0x81, 0x02, // Input (variable,absolute)
  283. 0xC0 // End Collection
  284. };
  285. #elif JOYSTICK_SIZE == 64
  286. // extreme joystick (to use this, edit JOYSTICK_SIZE to 64 in usb_desc.h)
  287. // 128 buttons 16
  288. // 6 axes 12
  289. // 17 sliders 34
  290. // 4 pov 2
  291. static uint8_t joystick_report_desc[] = {
  292. 0x05, 0x01, // Usage Page (Generic Desktop)
  293. 0x09, 0x04, // Usage (Joystick)
  294. 0xA1, 0x01, // Collection (Application)
  295. 0x15, 0x00, // Logical Minimum (0)
  296. 0x25, 0x01, // Logical Maximum (1)
  297. 0x75, 0x01, // Report Size (1)
  298. 0x95, 0x80, // Report Count (128)
  299. 0x05, 0x09, // Usage Page (Button)
  300. 0x19, 0x01, // Usage Minimum (Button #1)
  301. 0x29, 0x80, // Usage Maximum (Button #128)
  302. 0x81, 0x02, // Input (variable,absolute)
  303. 0x05, 0x01, // Usage Page (Generic Desktop)
  304. 0x09, 0x01, // Usage (Pointer)
  305. 0xA1, 0x00, // Collection ()
  306. 0x15, 0x00, // Logical Minimum (0)
  307. 0x27, 0xFF, 0xFF, 0, 0, // Logical Maximum (65535)
  308. 0x75, 0x10, // Report Size (16)
  309. 0x95, 23, // Report Count (23)
  310. 0x09, 0x30, // Usage (X)
  311. 0x09, 0x31, // Usage (Y)
  312. 0x09, 0x32, // Usage (Z)
  313. 0x09, 0x33, // Usage (Rx)
  314. 0x09, 0x34, // Usage (Ry)
  315. 0x09, 0x35, // Usage (Rz)
  316. 0x09, 0x36, // Usage (Slider)
  317. 0x09, 0x36, // Usage (Slider)
  318. 0x09, 0x36, // Usage (Slider)
  319. 0x09, 0x36, // Usage (Slider)
  320. 0x09, 0x36, // Usage (Slider)
  321. 0x09, 0x36, // Usage (Slider)
  322. 0x09, 0x36, // Usage (Slider)
  323. 0x09, 0x36, // Usage (Slider)
  324. 0x09, 0x36, // Usage (Slider)
  325. 0x09, 0x36, // Usage (Slider)
  326. 0x09, 0x36, // Usage (Slider)
  327. 0x09, 0x36, // Usage (Slider)
  328. 0x09, 0x36, // Usage (Slider)
  329. 0x09, 0x36, // Usage (Slider)
  330. 0x09, 0x36, // Usage (Slider)
  331. 0x09, 0x36, // Usage (Slider)
  332. 0x09, 0x36, // Usage (Slider)
  333. 0x81, 0x02, // Input (variable,absolute)
  334. 0xC0, // End Collection
  335. 0x15, 0x00, // Logical Minimum (0)
  336. 0x25, 0x07, // Logical Maximum (7)
  337. 0x35, 0x00, // Physical Minimum (0)
  338. 0x46, 0x3B, 0x01, // Physical Maximum (315)
  339. 0x75, 0x04, // Report Size (4)
  340. 0x95, 0x04, // Report Count (4)
  341. 0x65, 0x14, // Unit (20)
  342. 0x05, 0x01, // Usage Page (Generic Desktop)
  343. 0x09, 0x39, // Usage (Hat switch)
  344. 0x09, 0x39, // Usage (Hat switch)
  345. 0x09, 0x39, // Usage (Hat switch)
  346. 0x09, 0x39, // Usage (Hat switch)
  347. 0x81, 0x42, // Input (variable,absolute,null_state)
  348. 0xC0 // End Collection
  349. };
  350. #endif // JOYSTICK_SIZE
  351. #endif // JOYSTICK_INTERFACE
  352. #ifdef MULTITOUCH_INTERFACE
  353. // https://forum.pjrc.com/threads/32331-USB-HID-Touchscreen-support-needed
  354. // https://msdn.microsoft.com/en-us/library/windows/hardware/jj151563%28v=vs.85%29.aspx
  355. // https://msdn.microsoft.com/en-us/library/windows/hardware/jj151565%28v=vs.85%29.aspx
  356. // https://msdn.microsoft.com/en-us/library/windows/hardware/ff553734%28v=vs.85%29.aspx
  357. // https://msdn.microsoft.com/en-us/library/windows/hardware/jj151564%28v=vs.85%29.aspx
  358. // download.microsoft.com/download/a/d/f/adf1347d-08dc-41a4-9084-623b1194d4b2/digitizerdrvs_touch.docx
  359. static uint8_t multitouch_report_desc[] = {
  360. 0x05, 0x0D, // Usage Page (Digitizer)
  361. 0x09, 0x04, // Usage (Touch Screen)
  362. 0xa1, 0x01, // Collection (Application)
  363. 0x09, 0x22, // Usage (Finger)
  364. 0xA1, 0x02, // Collection (Logical)
  365. 0x09, 0x42, // Usage (Tip Switch)
  366. 0x15, 0x00, // Logical Minimum (0)
  367. 0x25, 0x01, // Logical Maximum (1)
  368. 0x75, 0x01, // Report Size (1)
  369. 0x95, 0x01, // Report Count (1)
  370. 0x81, 0x02, // Input (variable,absolute)
  371. 0x09, 0x51, // Usage (Contact Identifier)
  372. 0x25, 0x7F, // Logical Maximum (127)
  373. 0x75, 0x07, // Report Size (7)
  374. 0x95, 0x01, // Report Count (1)
  375. 0x81, 0x02, // Input (variable,absolute)
  376. 0x09, 0x30, // Usage (Pressure)
  377. 0x26, 0xFF, 0x00, // Logical Maximum (255)
  378. 0x75, 0x08, // Report Size (8)
  379. 0x95, 0x01, // Report Count (1)
  380. 0x81, 0x02, // Input (variable,absolute)
  381. 0x05, 0x01, // Usage Page (Generic Desktop)
  382. 0x09, 0x30, // Usage (X)
  383. 0x09, 0x31, // Usage (Y)
  384. 0x26, 0xFF, 0x7F, // Logical Maximum (32767)
  385. 0x65, 0x00, // Unit (None) <-- probably needs real units?
  386. 0x75, 0x10, // Report Size (16)
  387. 0x95, 0x02, // Report Count (2)
  388. 0x81, 0x02, // Input (variable,absolute)
  389. 0xC0, // End Collection
  390. 0x05, 0x0D, // Usage Page (Digitizer)
  391. 0x27, 0xFF, 0xFF, 0, 0, // Logical Maximum (65535)
  392. 0x75, 0x10, // Report Size (16)
  393. 0x95, 0x01, // Report Count (1)
  394. 0x09, 0x56, // Usage (Scan Time)
  395. 0x81, 0x02, // Input (variable,absolute)
  396. 0x05, 0x0D, // Usage Page (Digitizers)
  397. 0x09, 0x55, // Usage (Contact Count Maximum)
  398. 0x25, MULTITOUCH_FINGERS, // Logical Maximum (10)
  399. 0x75, 0x08, // Report Size (8)
  400. 0x95, 0x01, // Report Count (1)
  401. 0xB1, 0x02, // Feature (variable,absolute)
  402. 0xC0 // End Collection
  403. };
  404. #endif
  405. #ifdef SEREMU_INTERFACE
  406. static uint8_t seremu_report_desc[] = {
  407. 0x06, 0xC9, 0xFF, // Usage Page 0xFFC9 (vendor defined)
  408. 0x09, 0x04, // Usage 0x04
  409. 0xA1, 0x5C, // Collection 0x5C
  410. 0x75, 0x08, // report size = 8 bits (global)
  411. 0x15, 0x00, // logical minimum = 0 (global)
  412. 0x26, 0xFF, 0x00, // logical maximum = 255 (global)
  413. 0x95, SEREMU_TX_SIZE, // report count (global)
  414. 0x09, 0x75, // usage (local)
  415. 0x81, 0x02, // Input
  416. 0x95, SEREMU_RX_SIZE, // report count (global)
  417. 0x09, 0x76, // usage (local)
  418. 0x91, 0x02, // Output
  419. 0x95, 0x04, // report count (global)
  420. 0x09, 0x76, // usage (local)
  421. 0xB1, 0x02, // Feature
  422. 0xC0 // end collection
  423. };
  424. #endif
  425. #ifdef RAWHID_INTERFACE
  426. static uint8_t rawhid_report_desc[] = {
  427. 0x06, LSB(RAWHID_USAGE_PAGE), MSB(RAWHID_USAGE_PAGE),
  428. 0x0A, LSB(RAWHID_USAGE), MSB(RAWHID_USAGE),
  429. 0xA1, 0x01, // Collection 0x01
  430. 0x75, 0x08, // report size = 8 bits
  431. 0x15, 0x00, // logical minimum = 0
  432. 0x26, 0xFF, 0x00, // logical maximum = 255
  433. 0x95, RAWHID_TX_SIZE, // report count
  434. 0x09, 0x01, // usage
  435. 0x81, 0x02, // Input (array)
  436. 0x95, RAWHID_RX_SIZE, // report count
  437. 0x09, 0x02, // usage
  438. 0x91, 0x02, // Output (array)
  439. 0xC0 // end collection
  440. };
  441. #endif
  442. #ifdef FLIGHTSIM_INTERFACE
  443. static uint8_t flightsim_report_desc[] = {
  444. 0x06, 0x1C, 0xFF, // Usage page = 0xFF1C
  445. 0x0A, 0x39, 0xA7, // Usage = 0xA739
  446. 0xA1, 0x01, // Collection 0x01
  447. 0x75, 0x08, // report size = 8 bits
  448. 0x15, 0x00, // logical minimum = 0
  449. 0x26, 0xFF, 0x00, // logical maximum = 255
  450. 0x95, FLIGHTSIM_TX_SIZE, // report count
  451. 0x09, 0x01, // usage
  452. 0x81, 0x02, // Input (array)
  453. 0x95, FLIGHTSIM_RX_SIZE, // report count
  454. 0x09, 0x02, // usage
  455. 0x91, 0x02, // Output (array)
  456. 0xC0 // end collection
  457. };
  458. #endif
  459. // **************************************************************
  460. // USB Descriptor Sizes
  461. // **************************************************************
  462. // pre-compute the size and position of everything in the config descriptor
  463. //
  464. #define CONFIG_HEADER_DESCRIPTOR_SIZE 9
  465. #define CDC_IAD_DESCRIPTOR_POS CONFIG_HEADER_DESCRIPTOR_SIZE
  466. #ifdef CDC_IAD_DESCRIPTOR
  467. #define CDC_IAD_DESCRIPTOR_SIZE 8
  468. #else
  469. #define CDC_IAD_DESCRIPTOR_SIZE 0
  470. #endif
  471. #define CDC_DATA_INTERFACE_DESC_POS CDC_IAD_DESCRIPTOR_POS+CDC_IAD_DESCRIPTOR_SIZE
  472. #ifdef CDC_DATA_INTERFACE
  473. #define CDC_DATA_INTERFACE_DESC_SIZE 9+5+5+4+5+7+9+7+7
  474. #else
  475. #define CDC_DATA_INTERFACE_DESC_SIZE 0
  476. #endif
  477. #define MIDI_INTERFACE_DESC_POS CDC_DATA_INTERFACE_DESC_POS+CDC_DATA_INTERFACE_DESC_SIZE
  478. #ifdef MIDI_INTERFACE
  479. #if !defined(MIDI_NUM_CABLES) || MIDI_NUM_CABLES < 1 || MIDI_NUM_CABLES > 16
  480. #error "MIDI_NUM_CABLES must be defined between 1 to 16"
  481. #endif
  482. #define MIDI_INTERFACE_DESC_SIZE 9+7+((6+6+9+9)*MIDI_NUM_CABLES)+(9+4+MIDI_NUM_CABLES)*2
  483. #else
  484. #define MIDI_INTERFACE_DESC_SIZE 0
  485. #endif
  486. #define KEYBOARD_INTERFACE_DESC_POS MIDI_INTERFACE_DESC_POS+MIDI_INTERFACE_DESC_SIZE
  487. #ifdef KEYBOARD_INTERFACE
  488. #define KEYBOARD_INTERFACE_DESC_SIZE 9+9+7
  489. #define KEYBOARD_HID_DESC_OFFSET KEYBOARD_INTERFACE_DESC_POS+9
  490. #else
  491. #define KEYBOARD_INTERFACE_DESC_SIZE 0
  492. #endif
  493. #define MOUSE_INTERFACE_DESC_POS KEYBOARD_INTERFACE_DESC_POS+KEYBOARD_INTERFACE_DESC_SIZE
  494. #ifdef MOUSE_INTERFACE
  495. #define MOUSE_INTERFACE_DESC_SIZE 9+9+7
  496. #define MOUSE_HID_DESC_OFFSET MOUSE_INTERFACE_DESC_POS+9
  497. #else
  498. #define MOUSE_INTERFACE_DESC_SIZE 0
  499. #endif
  500. #define RAWHID_INTERFACE_DESC_POS MOUSE_INTERFACE_DESC_POS+MOUSE_INTERFACE_DESC_SIZE
  501. #ifdef RAWHID_INTERFACE
  502. #define RAWHID_INTERFACE_DESC_SIZE 9+9+7+7
  503. #define RAWHID_HID_DESC_OFFSET RAWHID_INTERFACE_DESC_POS+9
  504. #else
  505. #define RAWHID_INTERFACE_DESC_SIZE 0
  506. #endif
  507. #define FLIGHTSIM_INTERFACE_DESC_POS RAWHID_INTERFACE_DESC_POS+RAWHID_INTERFACE_DESC_SIZE
  508. #ifdef FLIGHTSIM_INTERFACE
  509. #define FLIGHTSIM_INTERFACE_DESC_SIZE 9+9+7+7
  510. #define FLIGHTSIM_HID_DESC_OFFSET FLIGHTSIM_INTERFACE_DESC_POS+9
  511. #else
  512. #define FLIGHTSIM_INTERFACE_DESC_SIZE 0
  513. #endif
  514. #define SEREMU_INTERFACE_DESC_POS FLIGHTSIM_INTERFACE_DESC_POS+FLIGHTSIM_INTERFACE_DESC_SIZE
  515. #ifdef SEREMU_INTERFACE
  516. #define SEREMU_INTERFACE_DESC_SIZE 9+9+7+7
  517. #define SEREMU_HID_DESC_OFFSET SEREMU_INTERFACE_DESC_POS+9
  518. #else
  519. #define SEREMU_INTERFACE_DESC_SIZE 0
  520. #endif
  521. #define JOYSTICK_INTERFACE_DESC_POS SEREMU_INTERFACE_DESC_POS+SEREMU_INTERFACE_DESC_SIZE
  522. #ifdef JOYSTICK_INTERFACE
  523. #define JOYSTICK_INTERFACE_DESC_SIZE 9+9+7
  524. #define JOYSTICK_HID_DESC_OFFSET JOYSTICK_INTERFACE_DESC_POS+9
  525. #else
  526. #define JOYSTICK_INTERFACE_DESC_SIZE 0
  527. #endif
  528. #define MTP_INTERFACE_DESC_POS JOYSTICK_INTERFACE_DESC_POS+JOYSTICK_INTERFACE_DESC_SIZE
  529. #ifdef MTP_INTERFACE
  530. #define MTP_INTERFACE_DESC_SIZE 9+7+7+7
  531. #else
  532. #define MTP_INTERFACE_DESC_SIZE 0
  533. #endif
  534. #define KEYMEDIA_INTERFACE_DESC_POS MTP_INTERFACE_DESC_POS+MTP_INTERFACE_DESC_SIZE
  535. #ifdef KEYMEDIA_INTERFACE
  536. #define KEYMEDIA_INTERFACE_DESC_SIZE 9+9+7
  537. #define KEYMEDIA_HID_DESC_OFFSET KEYMEDIA_INTERFACE_DESC_POS+9
  538. #else
  539. #define KEYMEDIA_INTERFACE_DESC_SIZE 0
  540. #endif
  541. #define AUDIO_INTERFACE_DESC_POS KEYMEDIA_INTERFACE_DESC_POS+KEYMEDIA_INTERFACE_DESC_SIZE
  542. #ifdef AUDIO_INTERFACE
  543. #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
  544. #else
  545. #define AUDIO_INTERFACE_DESC_SIZE 0
  546. #endif
  547. #define MULTITOUCH_INTERFACE_DESC_POS AUDIO_INTERFACE_DESC_POS+AUDIO_INTERFACE_DESC_SIZE
  548. #ifdef MULTITOUCH_INTERFACE
  549. #define MULTITOUCH_INTERFACE_DESC_SIZE 9+9+7
  550. #define MULTITOUCH_HID_DESC_OFFSET MULTITOUCH_INTERFACE_DESC_POS+9
  551. #else
  552. #define MULTITOUCH_INTERFACE_DESC_SIZE 0
  553. #endif
  554. #define CONFIG_DESC_SIZE MULTITOUCH_INTERFACE_DESC_POS+MULTITOUCH_INTERFACE_DESC_SIZE
  555. // **************************************************************
  556. // USB Configuration
  557. // **************************************************************
  558. // USB Configuration Descriptor. This huge descriptor tells all
  559. // of the devices capbilities.
  560. PROGMEM const uint8_t usb_config_descriptor_480[CONFIG_DESC_SIZE] = {
  561. // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
  562. 9, // bLength;
  563. 2, // bDescriptorType;
  564. LSB(CONFIG_DESC_SIZE), // wTotalLength
  565. MSB(CONFIG_DESC_SIZE),
  566. NUM_INTERFACE, // bNumInterfaces
  567. 1, // bConfigurationValue
  568. 0, // iConfiguration
  569. 0xC0, // bmAttributes
  570. 50, // bMaxPower
  571. #ifdef CDC_IAD_DESCRIPTOR
  572. // interface association descriptor, USB ECN, Table 9-Z
  573. 8, // bLength
  574. 11, // bDescriptorType
  575. CDC_STATUS_INTERFACE, // bFirstInterface
  576. 2, // bInterfaceCount
  577. 0x02, // bFunctionClass
  578. 0x02, // bFunctionSubClass
  579. 0x01, // bFunctionProtocol
  580. 0, // iFunction
  581. #endif
  582. #ifdef CDC_DATA_INTERFACE
  583. // configuration for 480 Mbit/sec speed
  584. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  585. 9, // bLength
  586. 4, // bDescriptorType
  587. CDC_STATUS_INTERFACE, // bInterfaceNumber
  588. 0, // bAlternateSetting
  589. 1, // bNumEndpoints
  590. 0x02, // bInterfaceClass
  591. 0x02, // bInterfaceSubClass
  592. 0x01, // bInterfaceProtocol
  593. 0, // iInterface
  594. // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26
  595. 5, // bFunctionLength
  596. 0x24, // bDescriptorType
  597. 0x00, // bDescriptorSubtype
  598. 0x10, 0x01, // bcdCDC
  599. // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27
  600. 5, // bFunctionLength
  601. 0x24, // bDescriptorType
  602. 0x01, // bDescriptorSubtype
  603. 0x01, // bmCapabilities
  604. 1, // bDataInterface
  605. // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28
  606. 4, // bFunctionLength
  607. 0x24, // bDescriptorType
  608. 0x02, // bDescriptorSubtype
  609. 0x06, // bmCapabilities
  610. // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33
  611. 5, // bFunctionLength
  612. 0x24, // bDescriptorType
  613. 0x06, // bDescriptorSubtype
  614. CDC_STATUS_INTERFACE, // bMasterInterface
  615. CDC_DATA_INTERFACE, // bSlaveInterface0
  616. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  617. 7, // bLength
  618. 5, // bDescriptorType
  619. CDC_ACM_ENDPOINT | 0x80, // bEndpointAddress
  620. 0x03, // bmAttributes (0x03=intr)
  621. LSB(CDC_ACM_SIZE),MSB(CDC_ACM_SIZE), // wMaxPacketSize
  622. 16, // bInterval
  623. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  624. 9, // bLength
  625. 4, // bDescriptorType
  626. CDC_DATA_INTERFACE, // bInterfaceNumber
  627. 0, // bAlternateSetting
  628. 2, // bNumEndpoints
  629. 0x0A, // bInterfaceClass
  630. 0x00, // bInterfaceSubClass
  631. 0x00, // bInterfaceProtocol
  632. 0, // iInterface
  633. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  634. 7, // bLength
  635. 5, // bDescriptorType
  636. CDC_RX_ENDPOINT, // bEndpointAddress
  637. 0x02, // bmAttributes (0x02=bulk)
  638. LSB(CDC_RX_SIZE_480),MSB(CDC_RX_SIZE_480),// wMaxPacketSize
  639. 0, // bInterval
  640. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  641. 7, // bLength
  642. 5, // bDescriptorType
  643. CDC_TX_ENDPOINT | 0x80, // bEndpointAddress
  644. 0x02, // bmAttributes (0x02=bulk)
  645. LSB(CDC_TX_SIZE_480),MSB(CDC_TX_SIZE_480),// wMaxPacketSize
  646. 0, // bInterval
  647. #endif // CDC_DATA_INTERFACE
  648. #ifdef MIDI_INTERFACE
  649. // configuration for 480 Mbit/sec speed
  650. // Standard MS Interface Descriptor,
  651. 9, // bLength
  652. 4, // bDescriptorType
  653. MIDI_INTERFACE, // bInterfaceNumber
  654. 0, // bAlternateSetting
  655. 2, // bNumEndpoints
  656. 0x01, // bInterfaceClass (0x01 = Audio)
  657. 0x03, // bInterfaceSubClass (0x03 = MIDI)
  658. 0x00, // bInterfaceProtocol (unused for MIDI)
  659. 0, // iInterface
  660. // MIDI MS Interface Header, USB MIDI 6.1.2.1, page 21, Table 6-2
  661. 7, // bLength
  662. 0x24, // bDescriptorType = CS_INTERFACE
  663. 0x01, // bDescriptorSubtype = MS_HEADER
  664. 0x00, 0x01, // bcdMSC = revision 01.00
  665. LSB(7+(6+6+9+9)*MIDI_NUM_CABLES), // wTotalLength
  666. MSB(7+(6+6+9+9)*MIDI_NUM_CABLES),
  667. // MIDI IN Jack Descriptor, B.4.3, Table B-7 (embedded), page 40
  668. 6, // bLength
  669. 0x24, // bDescriptorType = CS_INTERFACE
  670. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  671. 0x01, // bJackType = EMBEDDED
  672. 1, // bJackID, ID = 1
  673. 0, // iJack
  674. // MIDI IN Jack Descriptor, B.4.3, Table B-8 (external), page 40
  675. 6, // bLength
  676. 0x24, // bDescriptorType = CS_INTERFACE
  677. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  678. 0x02, // bJackType = EXTERNAL
  679. 2, // bJackID, ID = 2
  680. 0, // iJack
  681. // MIDI OUT Jack Descriptor, B.4.4, Table B-9, page 41
  682. 9,
  683. 0x24, // bDescriptorType = CS_INTERFACE
  684. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  685. 0x01, // bJackType = EMBEDDED
  686. 3, // bJackID, ID = 3
  687. 1, // bNrInputPins = 1 pin
  688. 2, // BaSourceID(1) = 2
  689. 1, // BaSourcePin(1) = first pin
  690. 0, // iJack
  691. // MIDI OUT Jack Descriptor, B.4.4, Table B-10, page 41
  692. 9,
  693. 0x24, // bDescriptorType = CS_INTERFACE
  694. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  695. 0x02, // bJackType = EXTERNAL
  696. 4, // bJackID, ID = 4
  697. 1, // bNrInputPins = 1 pin
  698. 1, // BaSourceID(1) = 1
  699. 1, // BaSourcePin(1) = first pin
  700. 0, // iJack
  701. #if MIDI_NUM_CABLES >= 2
  702. #define MIDI_INTERFACE_JACK_PAIR(a, b, c, d) \
  703. 6, 0x24, 0x02, 0x01, (a), 0, \
  704. 6, 0x24, 0x02, 0x02, (b), 0, \
  705. 9, 0x24, 0x03, 0x01, (c), 1, (b), 1, 0, \
  706. 9, 0x24, 0x03, 0x02, (d), 1, (a), 1, 0,
  707. MIDI_INTERFACE_JACK_PAIR(5, 6, 7, 8)
  708. #endif
  709. #if MIDI_NUM_CABLES >= 3
  710. MIDI_INTERFACE_JACK_PAIR(9, 10, 11, 12)
  711. #endif
  712. #if MIDI_NUM_CABLES >= 4
  713. MIDI_INTERFACE_JACK_PAIR(13, 14, 15, 16)
  714. #endif
  715. #if MIDI_NUM_CABLES >= 5
  716. MIDI_INTERFACE_JACK_PAIR(17, 18, 19, 20)
  717. #endif
  718. #if MIDI_NUM_CABLES >= 6
  719. MIDI_INTERFACE_JACK_PAIR(21, 22, 23, 24)
  720. #endif
  721. #if MIDI_NUM_CABLES >= 7
  722. MIDI_INTERFACE_JACK_PAIR(25, 26, 27, 28)
  723. #endif
  724. #if MIDI_NUM_CABLES >= 8
  725. MIDI_INTERFACE_JACK_PAIR(29, 30, 31, 32)
  726. #endif
  727. #if MIDI_NUM_CABLES >= 9
  728. MIDI_INTERFACE_JACK_PAIR(33, 34, 35, 36)
  729. #endif
  730. #if MIDI_NUM_CABLES >= 10
  731. MIDI_INTERFACE_JACK_PAIR(37, 38, 39, 40)
  732. #endif
  733. #if MIDI_NUM_CABLES >= 11
  734. MIDI_INTERFACE_JACK_PAIR(41, 42, 43, 44)
  735. #endif
  736. #if MIDI_NUM_CABLES >= 12
  737. MIDI_INTERFACE_JACK_PAIR(45, 46, 47, 48)
  738. #endif
  739. #if MIDI_NUM_CABLES >= 13
  740. MIDI_INTERFACE_JACK_PAIR(49, 50, 51, 52)
  741. #endif
  742. #if MIDI_NUM_CABLES >= 14
  743. MIDI_INTERFACE_JACK_PAIR(53, 54, 55, 56)
  744. #endif
  745. #if MIDI_NUM_CABLES >= 15
  746. MIDI_INTERFACE_JACK_PAIR(57, 58, 59, 60)
  747. #endif
  748. #if MIDI_NUM_CABLES >= 16
  749. MIDI_INTERFACE_JACK_PAIR(61, 62, 63, 64)
  750. #endif
  751. // Standard Bulk OUT Endpoint Descriptor, B.5.1, Table B-11, pae 42
  752. 9, // bLength
  753. 5, // bDescriptorType = ENDPOINT
  754. MIDI_RX_ENDPOINT, // bEndpointAddress
  755. 0x02, // bmAttributes (0x02=bulk)
  756. LSB(MIDI_RX_SIZE_480),MSB(MIDI_RX_SIZE_480),// wMaxPacketSize
  757. 0, // bInterval
  758. 0, // bRefresh
  759. 0, // bSynchAddress
  760. // Class-specific MS Bulk OUT Endpoint Descriptor, B.5.2, Table B-12, page 42
  761. 4+MIDI_NUM_CABLES, // bLength
  762. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  763. 0x01, // bJackType = MS_GENERAL
  764. MIDI_NUM_CABLES, // bNumEmbMIDIJack = number of jacks
  765. 1, // BaAssocJackID(1) = jack ID #1
  766. #if MIDI_NUM_CABLES >= 2
  767. 5,
  768. #endif
  769. #if MIDI_NUM_CABLES >= 3
  770. 9,
  771. #endif
  772. #if MIDI_NUM_CABLES >= 4
  773. 13,
  774. #endif
  775. #if MIDI_NUM_CABLES >= 5
  776. 17,
  777. #endif
  778. #if MIDI_NUM_CABLES >= 6
  779. 21,
  780. #endif
  781. #if MIDI_NUM_CABLES >= 7
  782. 25,
  783. #endif
  784. #if MIDI_NUM_CABLES >= 8
  785. 29,
  786. #endif
  787. #if MIDI_NUM_CABLES >= 9
  788. 33,
  789. #endif
  790. #if MIDI_NUM_CABLES >= 10
  791. 37,
  792. #endif
  793. #if MIDI_NUM_CABLES >= 11
  794. 41,
  795. #endif
  796. #if MIDI_NUM_CABLES >= 12
  797. 45,
  798. #endif
  799. #if MIDI_NUM_CABLES >= 13
  800. 49,
  801. #endif
  802. #if MIDI_NUM_CABLES >= 14
  803. 53,
  804. #endif
  805. #if MIDI_NUM_CABLES >= 15
  806. 57,
  807. #endif
  808. #if MIDI_NUM_CABLES >= 16
  809. 61,
  810. #endif
  811. // Standard Bulk IN Endpoint Descriptor, B.5.1, Table B-11, pae 42
  812. 9, // bLength
  813. 5, // bDescriptorType = ENDPOINT
  814. MIDI_TX_ENDPOINT | 0x80, // bEndpointAddress
  815. 0x02, // bmAttributes (0x02=bulk)
  816. LSB(MIDI_TX_SIZE_480),MSB(MIDI_TX_SIZE_480),// wMaxPacketSize
  817. 0, // bInterval
  818. 0, // bRefresh
  819. 0, // bSynchAddress
  820. // Class-specific MS Bulk IN Endpoint Descriptor, B.5.2, Table B-12, page 42
  821. 4+MIDI_NUM_CABLES, // bLength
  822. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  823. 0x01, // bJackType = MS_GENERAL
  824. MIDI_NUM_CABLES, // bNumEmbMIDIJack = number of jacks
  825. 3, // BaAssocJackID(1) = jack ID #3
  826. #if MIDI_NUM_CABLES >= 2
  827. 7,
  828. #endif
  829. #if MIDI_NUM_CABLES >= 3
  830. 11,
  831. #endif
  832. #if MIDI_NUM_CABLES >= 4
  833. 15,
  834. #endif
  835. #if MIDI_NUM_CABLES >= 5
  836. 19,
  837. #endif
  838. #if MIDI_NUM_CABLES >= 6
  839. 23,
  840. #endif
  841. #if MIDI_NUM_CABLES >= 7
  842. 27,
  843. #endif
  844. #if MIDI_NUM_CABLES >= 8
  845. 31,
  846. #endif
  847. #if MIDI_NUM_CABLES >= 9
  848. 35,
  849. #endif
  850. #if MIDI_NUM_CABLES >= 10
  851. 39,
  852. #endif
  853. #if MIDI_NUM_CABLES >= 11
  854. 43,
  855. #endif
  856. #if MIDI_NUM_CABLES >= 12
  857. 47,
  858. #endif
  859. #if MIDI_NUM_CABLES >= 13
  860. 51,
  861. #endif
  862. #if MIDI_NUM_CABLES >= 14
  863. 55,
  864. #endif
  865. #if MIDI_NUM_CABLES >= 15
  866. 59,
  867. #endif
  868. #if MIDI_NUM_CABLES >= 16
  869. 63,
  870. #endif
  871. #endif // MIDI_INTERFACE
  872. #ifdef KEYBOARD_INTERFACE
  873. // configuration for 480 Mbit/sec speed
  874. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  875. 9, // bLength
  876. 4, // bDescriptorType
  877. KEYBOARD_INTERFACE, // bInterfaceNumber
  878. 0, // bAlternateSetting
  879. 1, // bNumEndpoints
  880. 0x03, // bInterfaceClass (0x03 = HID)
  881. 0x01, // bInterfaceSubClass (0x01 = Boot)
  882. 0x01, // bInterfaceProtocol (0x01 = Keyboard)
  883. 0, // iInterface
  884. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  885. 9, // bLength
  886. 0x21, // bDescriptorType
  887. 0x11, 0x01, // bcdHID
  888. 0, // bCountryCode
  889. 1, // bNumDescriptors
  890. 0x22, // bDescriptorType
  891. LSB(sizeof(keyboard_report_desc)), // wDescriptorLength
  892. MSB(sizeof(keyboard_report_desc)),
  893. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  894. 7, // bLength
  895. 5, // bDescriptorType
  896. KEYBOARD_ENDPOINT | 0x80, // bEndpointAddress
  897. 0x03, // bmAttributes (0x03=intr)
  898. KEYBOARD_SIZE, 0, // wMaxPacketSize
  899. KEYBOARD_INTERVAL, // bInterval
  900. #endif // KEYBOARD_INTERFACE
  901. #ifdef MOUSE_INTERFACE
  902. // configuration for 480 Mbit/sec speed
  903. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  904. 9, // bLength
  905. 4, // bDescriptorType
  906. MOUSE_INTERFACE, // bInterfaceNumber
  907. 0, // bAlternateSetting
  908. 1, // bNumEndpoints
  909. 0x03, // bInterfaceClass (0x03 = HID)
  910. 0x00, // bInterfaceSubClass (0x01 = Boot)
  911. 0x00, // bInterfaceProtocol (0x02 = Mouse)
  912. 0, // iInterface
  913. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  914. 9, // bLength
  915. 0x21, // bDescriptorType
  916. 0x11, 0x01, // bcdHID
  917. 0, // bCountryCode
  918. 1, // bNumDescriptors
  919. 0x22, // bDescriptorType
  920. LSB(sizeof(mouse_report_desc)), // wDescriptorLength
  921. MSB(sizeof(mouse_report_desc)),
  922. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  923. 7, // bLength
  924. 5, // bDescriptorType
  925. MOUSE_ENDPOINT | 0x80, // bEndpointAddress
  926. 0x03, // bmAttributes (0x03=intr)
  927. MOUSE_SIZE, 0, // wMaxPacketSize
  928. MOUSE_INTERVAL, // bInterval
  929. #endif // MOUSE_INTERFACE
  930. #ifdef RAWHID_INTERFACE
  931. // configuration for 480 Mbit/sec speed
  932. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  933. 9, // bLength
  934. 4, // bDescriptorType
  935. RAWHID_INTERFACE, // bInterfaceNumber
  936. 0, // bAlternateSetting
  937. 2, // bNumEndpoints
  938. 0x03, // bInterfaceClass (0x03 = HID)
  939. 0x00, // bInterfaceSubClass
  940. 0x00, // bInterfaceProtocol
  941. 0, // iInterface
  942. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  943. 9, // bLength
  944. 0x21, // bDescriptorType
  945. 0x11, 0x01, // bcdHID
  946. 0, // bCountryCode
  947. 1, // bNumDescriptors
  948. 0x22, // bDescriptorType
  949. LSB(sizeof(rawhid_report_desc)), // wDescriptorLength
  950. MSB(sizeof(rawhid_report_desc)),
  951. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  952. 7, // bLength
  953. 5, // bDescriptorType
  954. RAWHID_TX_ENDPOINT | 0x80, // bEndpointAddress
  955. 0x03, // bmAttributes (0x03=intr)
  956. RAWHID_TX_SIZE, 0, // wMaxPacketSize
  957. RAWHID_TX_INTERVAL, // bInterval
  958. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  959. 7, // bLength
  960. 5, // bDescriptorType
  961. RAWHID_RX_ENDPOINT, // bEndpointAddress
  962. 0x03, // bmAttributes (0x03=intr)
  963. RAWHID_RX_SIZE, 0, // wMaxPacketSize
  964. RAWHID_RX_INTERVAL, // bInterval
  965. #endif // RAWHID_INTERFACE
  966. #ifdef FLIGHTSIM_INTERFACE
  967. // configuration for 480 Mbit/sec speed
  968. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  969. 9, // bLength
  970. 4, // bDescriptorType
  971. FLIGHTSIM_INTERFACE, // bInterfaceNumber
  972. 0, // bAlternateSetting
  973. 2, // bNumEndpoints
  974. 0x03, // bInterfaceClass (0x03 = HID)
  975. 0x00, // bInterfaceSubClass
  976. 0x00, // bInterfaceProtocol
  977. 0, // iInterface
  978. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  979. 9, // bLength
  980. 0x21, // bDescriptorType
  981. 0x11, 0x01, // bcdHID
  982. 0, // bCountryCode
  983. 1, // bNumDescriptors
  984. 0x22, // bDescriptorType
  985. LSB(sizeof(flightsim_report_desc)), // wDescriptorLength
  986. MSB(sizeof(flightsim_report_desc)),
  987. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  988. 7, // bLength
  989. 5, // bDescriptorType
  990. FLIGHTSIM_TX_ENDPOINT | 0x80, // bEndpointAddress
  991. 0x03, // bmAttributes (0x03=intr)
  992. FLIGHTSIM_TX_SIZE, 0, // wMaxPacketSize
  993. FLIGHTSIM_TX_INTERVAL, // bInterval
  994. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  995. 7, // bLength
  996. 5, // bDescriptorType
  997. FLIGHTSIM_RX_ENDPOINT, // bEndpointAddress
  998. 0x03, // bmAttributes (0x03=intr)
  999. FLIGHTSIM_RX_SIZE, 0, // wMaxPacketSize
  1000. FLIGHTSIM_RX_INTERVAL, // bInterval
  1001. #endif // FLIGHTSIM_INTERFACE
  1002. #ifdef SEREMU_INTERFACE
  1003. // configuration for 480 Mbit/sec speed
  1004. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1005. 9, // bLength
  1006. 4, // bDescriptorType
  1007. SEREMU_INTERFACE, // bInterfaceNumber
  1008. 0, // bAlternateSetting
  1009. 2, // bNumEndpoints
  1010. 0x03, // bInterfaceClass (0x03 = HID)
  1011. 0x00, // bInterfaceSubClass
  1012. 0x00, // bInterfaceProtocol
  1013. 0, // iInterface
  1014. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1015. 9, // bLength
  1016. 0x21, // bDescriptorType
  1017. 0x11, 0x01, // bcdHID
  1018. 0, // bCountryCode
  1019. 1, // bNumDescriptors
  1020. 0x22, // bDescriptorType
  1021. LSB(sizeof(seremu_report_desc)), // wDescriptorLength
  1022. MSB(sizeof(seremu_report_desc)),
  1023. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1024. 7, // bLength
  1025. 5, // bDescriptorType
  1026. SEREMU_TX_ENDPOINT | 0x80, // bEndpointAddress
  1027. 0x03, // bmAttributes (0x03=intr)
  1028. SEREMU_TX_SIZE, 0, // wMaxPacketSize
  1029. SEREMU_TX_INTERVAL, // bInterval
  1030. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1031. 7, // bLength
  1032. 5, // bDescriptorType
  1033. SEREMU_RX_ENDPOINT, // bEndpointAddress
  1034. 0x03, // bmAttributes (0x03=intr)
  1035. SEREMU_RX_SIZE, 0, // wMaxPacketSize
  1036. SEREMU_RX_INTERVAL, // bInterval
  1037. #endif // SEREMU_INTERFACE
  1038. #ifdef JOYSTICK_INTERFACE
  1039. // configuration for 480 Mbit/sec speed
  1040. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1041. 9, // bLength
  1042. 4, // bDescriptorType
  1043. JOYSTICK_INTERFACE, // bInterfaceNumber
  1044. 0, // bAlternateSetting
  1045. 1, // bNumEndpoints
  1046. 0x03, // bInterfaceClass (0x03 = HID)
  1047. 0x00, // bInterfaceSubClass
  1048. 0x00, // bInterfaceProtocol
  1049. 0, // iInterface
  1050. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1051. 9, // bLength
  1052. 0x21, // bDescriptorType
  1053. 0x11, 0x01, // bcdHID
  1054. 0, // bCountryCode
  1055. 1, // bNumDescriptors
  1056. 0x22, // bDescriptorType
  1057. LSB(sizeof(joystick_report_desc)), // wDescriptorLength
  1058. MSB(sizeof(joystick_report_desc)),
  1059. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1060. 7, // bLength
  1061. 5, // bDescriptorType
  1062. JOYSTICK_ENDPOINT | 0x80, // bEndpointAddress
  1063. 0x03, // bmAttributes (0x03=intr)
  1064. JOYSTICK_SIZE, 0, // wMaxPacketSize
  1065. JOYSTICK_INTERVAL, // bInterval
  1066. #endif // JOYSTICK_INTERFACE
  1067. #ifdef MTP_INTERFACE
  1068. // configuration for 480 Mbit/sec speed
  1069. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1070. 9, // bLength
  1071. 4, // bDescriptorType
  1072. MTP_INTERFACE, // bInterfaceNumber
  1073. 0, // bAlternateSetting
  1074. 3, // bNumEndpoints
  1075. 0x06, // bInterfaceClass (0x06 = still image)
  1076. 0x01, // bInterfaceSubClass
  1077. 0x01, // bInterfaceProtocol
  1078. 0, // iInterface
  1079. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1080. 7, // bLength
  1081. 5, // bDescriptorType
  1082. MTP_TX_ENDPOINT | 0x80, // bEndpointAddress
  1083. 0x02, // bmAttributes (0x02=bulk)
  1084. MTP_TX_SIZE, 0, // wMaxPacketSize
  1085. 0, // bInterval
  1086. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1087. 7, // bLength
  1088. 5, // bDescriptorType
  1089. MTP_RX_ENDPOINT, // bEndpointAddress
  1090. 0x02, // bmAttributes (0x02=bulk)
  1091. MTP_RX_SIZE, 0, // wMaxPacketSize
  1092. 0, // bInterval
  1093. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1094. 7, // bLength
  1095. 5, // bDescriptorType
  1096. MTP_EVENT_ENDPOINT | 0x80, // bEndpointAddress
  1097. 0x03, // bmAttributes (0x03=intr)
  1098. MTP_EVENT_SIZE, 0, // wMaxPacketSize
  1099. MTP_EVENT_INTERVAL, // bInterval
  1100. #endif // MTP_INTERFACE
  1101. #ifdef KEYMEDIA_INTERFACE
  1102. // configuration for 480 Mbit/sec speed
  1103. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1104. 9, // bLength
  1105. 4, // bDescriptorType
  1106. KEYMEDIA_INTERFACE, // bInterfaceNumber
  1107. 0, // bAlternateSetting
  1108. 1, // bNumEndpoints
  1109. 0x03, // bInterfaceClass (0x03 = HID)
  1110. 0x00, // bInterfaceSubClass
  1111. 0x00, // bInterfaceProtocol
  1112. 0, // iInterface
  1113. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1114. 9, // bLength
  1115. 0x21, // bDescriptorType
  1116. 0x11, 0x01, // bcdHID
  1117. 0, // bCountryCode
  1118. 1, // bNumDescriptors
  1119. 0x22, // bDescriptorType
  1120. LSB(sizeof(keymedia_report_desc)), // wDescriptorLength
  1121. MSB(sizeof(keymedia_report_desc)),
  1122. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1123. 7, // bLength
  1124. 5, // bDescriptorType
  1125. KEYMEDIA_ENDPOINT | 0x80, // bEndpointAddress
  1126. 0x03, // bmAttributes (0x03=intr)
  1127. KEYMEDIA_SIZE, 0, // wMaxPacketSize
  1128. KEYMEDIA_INTERVAL, // bInterval
  1129. #endif // KEYMEDIA_INTERFACE
  1130. #ifdef AUDIO_INTERFACE
  1131. // configuration for 480 Mbit/sec speed
  1132. // interface association descriptor, USB ECN, Table 9-Z
  1133. 8, // bLength
  1134. 11, // bDescriptorType
  1135. AUDIO_INTERFACE, // bFirstInterface
  1136. 3, // bInterfaceCount
  1137. 0x01, // bFunctionClass
  1138. 0x01, // bFunctionSubClass
  1139. 0x00, // bFunctionProtocol
  1140. 0, // iFunction
  1141. // Standard AudioControl (AC) Interface Descriptor
  1142. // USB DCD for Audio Devices 1.0, Table 4-1, page 36
  1143. 9, // bLength
  1144. 4, // bDescriptorType, 4 = INTERFACE
  1145. AUDIO_INTERFACE, // bInterfaceNumber
  1146. 0, // bAlternateSetting
  1147. 0, // bNumEndpoints
  1148. 1, // bInterfaceClass, 1 = AUDIO
  1149. 1, // bInterfaceSubclass, 1 = AUDIO_CONTROL
  1150. 0, // bInterfaceProtocol
  1151. 0, // iInterface
  1152. // Class-specific AC Interface Header Descriptor
  1153. // USB DCD for Audio Devices 1.0, Table 4-2, page 37-38
  1154. 10, // bLength
  1155. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1156. 0x01, // bDescriptorSubtype, 1 = HEADER
  1157. 0x00, 0x01, // bcdADC (version 1.0)
  1158. LSB(62), MSB(62), // wTotalLength
  1159. 2, // bInCollection
  1160. AUDIO_INTERFACE+1, // baInterfaceNr(1) - Transmit to PC
  1161. AUDIO_INTERFACE+2, // baInterfaceNr(2) - Receive from PC
  1162. // Input Terminal Descriptor
  1163. // USB DCD for Audio Devices 1.0, Table 4-3, page 39
  1164. 12, // bLength
  1165. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1166. 0x02, // bDescriptorSubType, 2 = INPUT_TERMINAL
  1167. 1, // bTerminalID
  1168. //0x01, 0x02, // wTerminalType, 0x0201 = MICROPHONE
  1169. //0x03, 0x06, // wTerminalType, 0x0603 = Line Connector
  1170. 0x02, 0x06, // wTerminalType, 0x0602 = Digital Audio
  1171. 0, // bAssocTerminal, 0 = unidirectional
  1172. 2, // bNrChannels
  1173. 0x03, 0x00, // wChannelConfig, 0x0003 = Left & Right Front
  1174. 0, // iChannelNames
  1175. 0, // iTerminal
  1176. // Output Terminal Descriptor
  1177. // USB DCD for Audio Devices 1.0, Table 4-4, page 40
  1178. 9, // bLength
  1179. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1180. 3, // bDescriptorSubtype, 3 = OUTPUT_TERMINAL
  1181. 2, // bTerminalID
  1182. 0x01, 0x01, // wTerminalType, 0x0101 = USB_STREAMING
  1183. 0, // bAssocTerminal, 0 = unidirectional
  1184. 1, // bCSourceID, connected to input terminal, ID=1
  1185. 0, // iTerminal
  1186. // Input Terminal Descriptor
  1187. // USB DCD for Audio Devices 1.0, Table 4-3, page 39
  1188. 12, // bLength
  1189. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1190. 2, // bDescriptorSubType, 2 = INPUT_TERMINAL
  1191. 3, // bTerminalID
  1192. 0x01, 0x01, // wTerminalType, 0x0101 = USB_STREAMING
  1193. 0, // bAssocTerminal, 0 = unidirectional
  1194. 2, // bNrChannels
  1195. 0x03, 0x00, // wChannelConfig, 0x0003 = Left & Right Front
  1196. 0, // iChannelNames
  1197. 0, // iTerminal
  1198. // Volume feature descriptor
  1199. 10, // bLength
  1200. 0x24, // bDescriptorType = CS_INTERFACE
  1201. 0x06, // bDescriptorSubType = FEATURE_UNIT
  1202. 0x31, // bUnitID
  1203. 0x03, // bSourceID (Input Terminal)
  1204. 0x01, // bControlSize (each channel is 1 byte, 3 channels)
  1205. 0x01, // bmaControls(0) Master: Mute
  1206. 0x02, // bmaControls(1) Left: Volume
  1207. 0x02, // bmaControls(2) Right: Volume
  1208. 0x00, // iFeature
  1209. // Output Terminal Descriptor
  1210. // USB DCD for Audio Devices 1.0, Table 4-4, page 40
  1211. 9, // bLength
  1212. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1213. 3, // bDescriptorSubtype, 3 = OUTPUT_TERMINAL
  1214. 4, // bTerminalID
  1215. //0x02, 0x03, // wTerminalType, 0x0302 = Headphones
  1216. 0x02, 0x06, // wTerminalType, 0x0602 = Digital Audio
  1217. 0, // bAssocTerminal, 0 = unidirectional
  1218. 0x31, // bCSourceID, connected to feature, ID=31
  1219. 0, // iTerminal
  1220. // Standard AS Interface Descriptor
  1221. // USB DCD for Audio Devices 1.0, Section 4.5.1, Table 4-18, page 59
  1222. // Alternate 0: default setting, disabled zero bandwidth
  1223. 9, // bLenght
  1224. 4, // bDescriptorType = INTERFACE
  1225. AUDIO_INTERFACE+1, // bInterfaceNumber
  1226. 0, // bAlternateSetting
  1227. 0, // bNumEndpoints
  1228. 1, // bInterfaceClass, 1 = AUDIO
  1229. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  1230. 0, // bInterfaceProtocol
  1231. 0, // iInterface
  1232. // Alternate 1: streaming data
  1233. 9, // bLenght
  1234. 4, // bDescriptorType = INTERFACE
  1235. AUDIO_INTERFACE+1, // bInterfaceNumber
  1236. 1, // bAlternateSetting
  1237. 1, // bNumEndpoints
  1238. 1, // bInterfaceClass, 1 = AUDIO
  1239. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  1240. 0, // bInterfaceProtocol
  1241. 0, // iInterface
  1242. // Class-Specific AS Interface Descriptor
  1243. // USB DCD for Audio Devices 1.0, Section 4.5.2, Table 4-19, page 60
  1244. 7, // bLength
  1245. 0x24, // bDescriptorType = CS_INTERFACE
  1246. 1, // bDescriptorSubtype, 1 = AS_GENERAL
  1247. 2, // bTerminalLink: Terminal ID = 2
  1248. 3, // bDelay (approx 3ms delay, audio lib updates)
  1249. 0x01, 0x00, // wFormatTag, 0x0001 = PCM
  1250. // Type I Format Descriptor
  1251. // USB DCD for Audio Data Formats 1.0, Section 2.2.5, Table 2-1, page 10
  1252. 11, // bLength
  1253. 0x24, // bDescriptorType = CS_INTERFACE
  1254. 2, // bDescriptorSubtype = FORMAT_TYPE
  1255. 1, // bFormatType = FORMAT_TYPE_I
  1256. 2, // bNrChannels = 2
  1257. 2, // bSubFrameSize = 2 byte
  1258. 16, // bBitResolution = 16 bits
  1259. 1, // bSamFreqType = 1 frequency
  1260. LSB(44100), MSB(44100), 0, // tSamFreq
  1261. // Standard AS Isochronous Audio Data Endpoint Descriptor
  1262. // USB DCD for Audio Devices 1.0, Section 4.6.1.1, Table 4-20, page 61-62
  1263. 9, // bLength
  1264. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  1265. AUDIO_TX_ENDPOINT | 0x80, // bEndpointAddress
  1266. 0x09, // bmAttributes = isochronous, adaptive
  1267. LSB(AUDIO_TX_SIZE), MSB(AUDIO_TX_SIZE), // wMaxPacketSize
  1268. 1, // bInterval, 1 = every frame
  1269. 0, // bRefresh
  1270. 0, // bSynchAddress
  1271. // Class-Specific AS Isochronous Audio Data Endpoint Descriptor
  1272. // USB DCD for Audio Devices 1.0, Section 4.6.1.2, Table 4-21, page 62-63
  1273. 7, // bLength
  1274. 0x25, // bDescriptorType, 0x25 = CS_ENDPOINT
  1275. 1, // bDescriptorSubtype, 1 = EP_GENERAL
  1276. 0x00, // bmAttributes
  1277. 0, // bLockDelayUnits, 1 = ms
  1278. 0x00, 0x00, // wLockDelay
  1279. // Standard AS Interface Descriptor
  1280. // USB DCD for Audio Devices 1.0, Section 4.5.1, Table 4-18, page 59
  1281. // Alternate 0: default setting, disabled zero bandwidth
  1282. 9, // bLenght
  1283. 4, // bDescriptorType = INTERFACE
  1284. AUDIO_INTERFACE+2, // bInterfaceNumber
  1285. 0, // bAlternateSetting
  1286. 0, // bNumEndpoints
  1287. 1, // bInterfaceClass, 1 = AUDIO
  1288. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  1289. 0, // bInterfaceProtocol
  1290. 0, // iInterface
  1291. // Alternate 1: streaming data
  1292. 9, // bLenght
  1293. 4, // bDescriptorType = INTERFACE
  1294. AUDIO_INTERFACE+2, // bInterfaceNumber
  1295. 1, // bAlternateSetting
  1296. 2, // bNumEndpoints
  1297. 1, // bInterfaceClass, 1 = AUDIO
  1298. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  1299. 0, // bInterfaceProtocol
  1300. 0, // iInterface
  1301. // Class-Specific AS Interface Descriptor
  1302. // USB DCD for Audio Devices 1.0, Section 4.5.2, Table 4-19, page 60
  1303. 7, // bLength
  1304. 0x24, // bDescriptorType = CS_INTERFACE
  1305. 1, // bDescriptorSubtype, 1 = AS_GENERAL
  1306. 3, // bTerminalLink: Terminal ID = 3
  1307. 3, // bDelay (approx 3ms delay, audio lib updates)
  1308. 0x01, 0x00, // wFormatTag, 0x0001 = PCM
  1309. // Type I Format Descriptor
  1310. // USB DCD for Audio Data Formats 1.0, Section 2.2.5, Table 2-1, page 10
  1311. 11, // bLength
  1312. 0x24, // bDescriptorType = CS_INTERFACE
  1313. 2, // bDescriptorSubtype = FORMAT_TYPE
  1314. 1, // bFormatType = FORMAT_TYPE_I
  1315. 2, // bNrChannels = 2
  1316. 2, // bSubFrameSize = 2 byte
  1317. 16, // bBitResolution = 16 bits
  1318. 1, // bSamFreqType = 1 frequency
  1319. LSB(44100), MSB(44100), 0, // tSamFreq
  1320. // Standard AS Isochronous Audio Data Endpoint Descriptor
  1321. // USB DCD for Audio Devices 1.0, Section 4.6.1.1, Table 4-20, page 61-62
  1322. 9, // bLength
  1323. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  1324. AUDIO_RX_ENDPOINT, // bEndpointAddress
  1325. 0x05, // bmAttributes = isochronous, asynchronous
  1326. LSB(AUDIO_RX_SIZE), MSB(AUDIO_RX_SIZE), // wMaxPacketSize
  1327. 1, // bInterval, 1 = every frame
  1328. 0, // bRefresh
  1329. AUDIO_SYNC_ENDPOINT | 0x80, // bSynchAddress
  1330. // Class-Specific AS Isochronous Audio Data Endpoint Descriptor
  1331. // USB DCD for Audio Devices 1.0, Section 4.6.1.2, Table 4-21, page 62-63
  1332. 7, // bLength
  1333. 0x25, // bDescriptorType, 0x25 = CS_ENDPOINT
  1334. 1, // bDescriptorSubtype, 1 = EP_GENERAL
  1335. 0x00, // bmAttributes
  1336. 0, // bLockDelayUnits, 1 = ms
  1337. 0x00, 0x00, // wLockDelay
  1338. // Standard AS Isochronous Audio Synch Endpoint Descriptor
  1339. // USB DCD for Audio Devices 1.0, Section 4.6.2.1, Table 4-22, page 63-64
  1340. 9, // bLength
  1341. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  1342. AUDIO_SYNC_ENDPOINT | 0x80, // bEndpointAddress
  1343. 0x11, // bmAttributes = isochronous, feedback
  1344. 3, 0, // wMaxPacketSize, 3 bytes
  1345. 1, // bInterval, 1 = every frame
  1346. 5, // bRefresh, 5 = 32ms
  1347. 0, // bSynchAddress
  1348. #endif
  1349. #ifdef MULTITOUCH_INTERFACE
  1350. // configuration for 480 Mbit/sec speed
  1351. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1352. 9, // bLength
  1353. 4, // bDescriptorType
  1354. MULTITOUCH_INTERFACE, // bInterfaceNumber
  1355. 0, // bAlternateSetting
  1356. 1, // bNumEndpoints
  1357. 0x03, // bInterfaceClass (0x03 = HID)
  1358. 0x00, // bInterfaceSubClass
  1359. 0x00, // bInterfaceProtocol
  1360. 0, // iInterface
  1361. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1362. 9, // bLength
  1363. 0x21, // bDescriptorType
  1364. 0x11, 0x01, // bcdHID
  1365. 0, // bCountryCode
  1366. 1, // bNumDescriptors
  1367. 0x22, // bDescriptorType
  1368. LSB(sizeof(multitouch_report_desc)), // wDescriptorLength
  1369. MSB(sizeof(multitouch_report_desc)),
  1370. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1371. 7, // bLength
  1372. 5, // bDescriptorType
  1373. MULTITOUCH_ENDPOINT | 0x80, // bEndpointAddress
  1374. 0x03, // bmAttributes (0x03=intr)
  1375. MULTITOUCH_SIZE, 0, // wMaxPacketSize
  1376. 4, // bInterval, 4 = 1ms
  1377. #endif // KEYMEDIA_INTERFACE
  1378. };
  1379. PROGMEM const uint8_t usb_config_descriptor_12[CONFIG_DESC_SIZE] = {
  1380. // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
  1381. 9, // bLength;
  1382. 2, // bDescriptorType;
  1383. LSB(CONFIG_DESC_SIZE), // wTotalLength
  1384. MSB(CONFIG_DESC_SIZE),
  1385. NUM_INTERFACE, // bNumInterfaces
  1386. 1, // bConfigurationValue
  1387. 0, // iConfiguration
  1388. 0xC0, // bmAttributes
  1389. 50, // bMaxPower
  1390. #ifdef CDC_IAD_DESCRIPTOR
  1391. // interface association descriptor, USB ECN, Table 9-Z
  1392. 8, // bLength
  1393. 11, // bDescriptorType
  1394. CDC_STATUS_INTERFACE, // bFirstInterface
  1395. 2, // bInterfaceCount
  1396. 0x02, // bFunctionClass
  1397. 0x02, // bFunctionSubClass
  1398. 0x01, // bFunctionProtocol
  1399. 0, // iFunction
  1400. #endif
  1401. #ifdef CDC_DATA_INTERFACE
  1402. // configuration for 12 Mbit/sec speed
  1403. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1404. 9, // bLength
  1405. 4, // bDescriptorType
  1406. CDC_STATUS_INTERFACE, // bInterfaceNumber
  1407. 0, // bAlternateSetting
  1408. 1, // bNumEndpoints
  1409. 0x02, // bInterfaceClass
  1410. 0x02, // bInterfaceSubClass
  1411. 0x01, // bInterfaceProtocol
  1412. 0, // iInterface
  1413. // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26
  1414. 5, // bFunctionLength
  1415. 0x24, // bDescriptorType
  1416. 0x00, // bDescriptorSubtype
  1417. 0x10, 0x01, // bcdCDC
  1418. // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27
  1419. 5, // bFunctionLength
  1420. 0x24, // bDescriptorType
  1421. 0x01, // bDescriptorSubtype
  1422. 0x01, // bmCapabilities
  1423. 1, // bDataInterface
  1424. // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28
  1425. 4, // bFunctionLength
  1426. 0x24, // bDescriptorType
  1427. 0x02, // bDescriptorSubtype
  1428. 0x06, // bmCapabilities
  1429. // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33
  1430. 5, // bFunctionLength
  1431. 0x24, // bDescriptorType
  1432. 0x06, // bDescriptorSubtype
  1433. CDC_STATUS_INTERFACE, // bMasterInterface
  1434. CDC_DATA_INTERFACE, // bSlaveInterface0
  1435. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1436. 7, // bLength
  1437. 5, // bDescriptorType
  1438. CDC_ACM_ENDPOINT | 0x80, // bEndpointAddress
  1439. 0x03, // bmAttributes (0x03=intr)
  1440. CDC_ACM_SIZE, 0, // wMaxPacketSize
  1441. 16, // bInterval
  1442. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1443. 9, // bLength
  1444. 4, // bDescriptorType
  1445. CDC_DATA_INTERFACE, // bInterfaceNumber
  1446. 0, // bAlternateSetting
  1447. 2, // bNumEndpoints
  1448. 0x0A, // bInterfaceClass
  1449. 0x00, // bInterfaceSubClass
  1450. 0x00, // bInterfaceProtocol
  1451. 0, // iInterface
  1452. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1453. 7, // bLength
  1454. 5, // bDescriptorType
  1455. CDC_RX_ENDPOINT, // bEndpointAddress
  1456. 0x02, // bmAttributes (0x02=bulk)
  1457. LSB(CDC_RX_SIZE_12),MSB(CDC_RX_SIZE_12),// wMaxPacketSize
  1458. 0, // bInterval
  1459. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1460. 7, // bLength
  1461. 5, // bDescriptorType
  1462. CDC_TX_ENDPOINT | 0x80, // bEndpointAddress
  1463. 0x02, // bmAttributes (0x02=bulk)
  1464. LSB(CDC_TX_SIZE_12),MSB(CDC_TX_SIZE_12),// wMaxPacketSize
  1465. 0, // bInterval
  1466. #endif // CDC_DATA_INTERFACE
  1467. #ifdef MIDI_INTERFACE
  1468. // configuration for 12 Mbit/sec speed
  1469. // Standard MS Interface Descriptor,
  1470. 9, // bLength
  1471. 4, // bDescriptorType
  1472. MIDI_INTERFACE, // bInterfaceNumber
  1473. 0, // bAlternateSetting
  1474. 2, // bNumEndpoints
  1475. 0x01, // bInterfaceClass (0x01 = Audio)
  1476. 0x03, // bInterfaceSubClass (0x03 = MIDI)
  1477. 0x00, // bInterfaceProtocol (unused for MIDI)
  1478. 0, // iInterface
  1479. // MIDI MS Interface Header, USB MIDI 6.1.2.1, page 21, Table 6-2
  1480. 7, // bLength
  1481. 0x24, // bDescriptorType = CS_INTERFACE
  1482. 0x01, // bDescriptorSubtype = MS_HEADER
  1483. 0x00, 0x01, // bcdMSC = revision 01.00
  1484. LSB(7+(6+6+9+9)*MIDI_NUM_CABLES), // wTotalLength
  1485. MSB(7+(6+6+9+9)*MIDI_NUM_CABLES),
  1486. // MIDI IN Jack Descriptor, B.4.3, Table B-7 (embedded), page 40
  1487. 6, // bLength
  1488. 0x24, // bDescriptorType = CS_INTERFACE
  1489. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  1490. 0x01, // bJackType = EMBEDDED
  1491. 1, // bJackID, ID = 1
  1492. 0, // iJack
  1493. // MIDI IN Jack Descriptor, B.4.3, Table B-8 (external), page 40
  1494. 6, // bLength
  1495. 0x24, // bDescriptorType = CS_INTERFACE
  1496. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  1497. 0x02, // bJackType = EXTERNAL
  1498. 2, // bJackID, ID = 2
  1499. 0, // iJack
  1500. // MIDI OUT Jack Descriptor, B.4.4, Table B-9, page 41
  1501. 9,
  1502. 0x24, // bDescriptorType = CS_INTERFACE
  1503. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  1504. 0x01, // bJackType = EMBEDDED
  1505. 3, // bJackID, ID = 3
  1506. 1, // bNrInputPins = 1 pin
  1507. 2, // BaSourceID(1) = 2
  1508. 1, // BaSourcePin(1) = first pin
  1509. 0, // iJack
  1510. // MIDI OUT Jack Descriptor, B.4.4, Table B-10, page 41
  1511. 9,
  1512. 0x24, // bDescriptorType = CS_INTERFACE
  1513. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  1514. 0x02, // bJackType = EXTERNAL
  1515. 4, // bJackID, ID = 4
  1516. 1, // bNrInputPins = 1 pin
  1517. 1, // BaSourceID(1) = 1
  1518. 1, // BaSourcePin(1) = first pin
  1519. 0, // iJack
  1520. #if MIDI_NUM_CABLES >= 2
  1521. #define MIDI_INTERFACE_JACK_PAIR(a, b, c, d) \
  1522. 6, 0x24, 0x02, 0x01, (a), 0, \
  1523. 6, 0x24, 0x02, 0x02, (b), 0, \
  1524. 9, 0x24, 0x03, 0x01, (c), 1, (b), 1, 0, \
  1525. 9, 0x24, 0x03, 0x02, (d), 1, (a), 1, 0,
  1526. MIDI_INTERFACE_JACK_PAIR(5, 6, 7, 8)
  1527. #endif
  1528. #if MIDI_NUM_CABLES >= 3
  1529. MIDI_INTERFACE_JACK_PAIR(9, 10, 11, 12)
  1530. #endif
  1531. #if MIDI_NUM_CABLES >= 4
  1532. MIDI_INTERFACE_JACK_PAIR(13, 14, 15, 16)
  1533. #endif
  1534. #if MIDI_NUM_CABLES >= 5
  1535. MIDI_INTERFACE_JACK_PAIR(17, 18, 19, 20)
  1536. #endif
  1537. #if MIDI_NUM_CABLES >= 6
  1538. MIDI_INTERFACE_JACK_PAIR(21, 22, 23, 24)
  1539. #endif
  1540. #if MIDI_NUM_CABLES >= 7
  1541. MIDI_INTERFACE_JACK_PAIR(25, 26, 27, 28)
  1542. #endif
  1543. #if MIDI_NUM_CABLES >= 8
  1544. MIDI_INTERFACE_JACK_PAIR(29, 30, 31, 32)
  1545. #endif
  1546. #if MIDI_NUM_CABLES >= 9
  1547. MIDI_INTERFACE_JACK_PAIR(33, 34, 35, 36)
  1548. #endif
  1549. #if MIDI_NUM_CABLES >= 10
  1550. MIDI_INTERFACE_JACK_PAIR(37, 38, 39, 40)
  1551. #endif
  1552. #if MIDI_NUM_CABLES >= 11
  1553. MIDI_INTERFACE_JACK_PAIR(41, 42, 43, 44)
  1554. #endif
  1555. #if MIDI_NUM_CABLES >= 12
  1556. MIDI_INTERFACE_JACK_PAIR(45, 46, 47, 48)
  1557. #endif
  1558. #if MIDI_NUM_CABLES >= 13
  1559. MIDI_INTERFACE_JACK_PAIR(49, 50, 51, 52)
  1560. #endif
  1561. #if MIDI_NUM_CABLES >= 14
  1562. MIDI_INTERFACE_JACK_PAIR(53, 54, 55, 56)
  1563. #endif
  1564. #if MIDI_NUM_CABLES >= 15
  1565. MIDI_INTERFACE_JACK_PAIR(57, 58, 59, 60)
  1566. #endif
  1567. #if MIDI_NUM_CABLES >= 16
  1568. MIDI_INTERFACE_JACK_PAIR(61, 62, 63, 64)
  1569. #endif
  1570. // Standard Bulk OUT Endpoint Descriptor, B.5.1, Table B-11, pae 42
  1571. 9, // bLength
  1572. 5, // bDescriptorType = ENDPOINT
  1573. MIDI_RX_ENDPOINT, // bEndpointAddress
  1574. 0x02, // bmAttributes (0x02=bulk)
  1575. LSB(MIDI_RX_SIZE_12),MSB(MIDI_RX_SIZE_12),// wMaxPacketSize
  1576. 0, // bInterval
  1577. 0, // bRefresh
  1578. 0, // bSynchAddress
  1579. // Class-specific MS Bulk OUT Endpoint Descriptor, B.5.2, Table B-12, page 42
  1580. 4+MIDI_NUM_CABLES, // bLength
  1581. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  1582. 0x01, // bJackType = MS_GENERAL
  1583. MIDI_NUM_CABLES, // bNumEmbMIDIJack = number of jacks
  1584. 1, // BaAssocJackID(1) = jack ID #1
  1585. #if MIDI_NUM_CABLES >= 2
  1586. 5,
  1587. #endif
  1588. #if MIDI_NUM_CABLES >= 3
  1589. 9,
  1590. #endif
  1591. #if MIDI_NUM_CABLES >= 4
  1592. 13,
  1593. #endif
  1594. #if MIDI_NUM_CABLES >= 5
  1595. 17,
  1596. #endif
  1597. #if MIDI_NUM_CABLES >= 6
  1598. 21,
  1599. #endif
  1600. #if MIDI_NUM_CABLES >= 7
  1601. 25,
  1602. #endif
  1603. #if MIDI_NUM_CABLES >= 8
  1604. 29,
  1605. #endif
  1606. #if MIDI_NUM_CABLES >= 9
  1607. 33,
  1608. #endif
  1609. #if MIDI_NUM_CABLES >= 10
  1610. 37,
  1611. #endif
  1612. #if MIDI_NUM_CABLES >= 11
  1613. 41,
  1614. #endif
  1615. #if MIDI_NUM_CABLES >= 12
  1616. 45,
  1617. #endif
  1618. #if MIDI_NUM_CABLES >= 13
  1619. 49,
  1620. #endif
  1621. #if MIDI_NUM_CABLES >= 14
  1622. 53,
  1623. #endif
  1624. #if MIDI_NUM_CABLES >= 15
  1625. 57,
  1626. #endif
  1627. #if MIDI_NUM_CABLES >= 16
  1628. 61,
  1629. #endif
  1630. // Standard Bulk IN Endpoint Descriptor, B.5.1, Table B-11, pae 42
  1631. 9, // bLength
  1632. 5, // bDescriptorType = ENDPOINT
  1633. MIDI_TX_ENDPOINT | 0x80, // bEndpointAddress
  1634. 0x02, // bmAttributes (0x02=bulk)
  1635. LSB(MIDI_TX_SIZE_12),MSB(MIDI_TX_SIZE_12),// wMaxPacketSize
  1636. 0, // bInterval
  1637. 0, // bRefresh
  1638. 0, // bSynchAddress
  1639. // Class-specific MS Bulk IN Endpoint Descriptor, B.5.2, Table B-12, page 42
  1640. 4+MIDI_NUM_CABLES, // bLength
  1641. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  1642. 0x01, // bJackType = MS_GENERAL
  1643. MIDI_NUM_CABLES, // bNumEmbMIDIJack = number of jacks
  1644. 3, // BaAssocJackID(1) = jack ID #3
  1645. #if MIDI_NUM_CABLES >= 2
  1646. 7,
  1647. #endif
  1648. #if MIDI_NUM_CABLES >= 3
  1649. 11,
  1650. #endif
  1651. #if MIDI_NUM_CABLES >= 4
  1652. 15,
  1653. #endif
  1654. #if MIDI_NUM_CABLES >= 5
  1655. 19,
  1656. #endif
  1657. #if MIDI_NUM_CABLES >= 6
  1658. 23,
  1659. #endif
  1660. #if MIDI_NUM_CABLES >= 7
  1661. 27,
  1662. #endif
  1663. #if MIDI_NUM_CABLES >= 8
  1664. 31,
  1665. #endif
  1666. #if MIDI_NUM_CABLES >= 9
  1667. 35,
  1668. #endif
  1669. #if MIDI_NUM_CABLES >= 10
  1670. 39,
  1671. #endif
  1672. #if MIDI_NUM_CABLES >= 11
  1673. 43,
  1674. #endif
  1675. #if MIDI_NUM_CABLES >= 12
  1676. 47,
  1677. #endif
  1678. #if MIDI_NUM_CABLES >= 13
  1679. 51,
  1680. #endif
  1681. #if MIDI_NUM_CABLES >= 14
  1682. 55,
  1683. #endif
  1684. #if MIDI_NUM_CABLES >= 15
  1685. 59,
  1686. #endif
  1687. #if MIDI_NUM_CABLES >= 16
  1688. 63,
  1689. #endif
  1690. #endif // MIDI_INTERFACE
  1691. #ifdef KEYBOARD_INTERFACE
  1692. // configuration for 12 Mbit/sec speed
  1693. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1694. 9, // bLength
  1695. 4, // bDescriptorType
  1696. KEYBOARD_INTERFACE, // bInterfaceNumber
  1697. 0, // bAlternateSetting
  1698. 1, // bNumEndpoints
  1699. 0x03, // bInterfaceClass (0x03 = HID)
  1700. 0x01, // bInterfaceSubClass (0x01 = Boot)
  1701. 0x01, // bInterfaceProtocol (0x01 = Keyboard)
  1702. 0, // iInterface
  1703. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1704. 9, // bLength
  1705. 0x21, // bDescriptorType
  1706. 0x11, 0x01, // bcdHID
  1707. 0, // bCountryCode
  1708. 1, // bNumDescriptors
  1709. 0x22, // bDescriptorType
  1710. LSB(sizeof(keyboard_report_desc)), // wDescriptorLength
  1711. MSB(sizeof(keyboard_report_desc)),
  1712. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1713. 7, // bLength
  1714. 5, // bDescriptorType
  1715. KEYBOARD_ENDPOINT | 0x80, // bEndpointAddress
  1716. 0x03, // bmAttributes (0x03=intr)
  1717. KEYBOARD_SIZE, 0, // wMaxPacketSize
  1718. KEYBOARD_INTERVAL, // bInterval
  1719. #endif // KEYBOARD_INTERFACE
  1720. #ifdef MOUSE_INTERFACE
  1721. // configuration for 12 Mbit/sec speed
  1722. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1723. 9, // bLength
  1724. 4, // bDescriptorType
  1725. MOUSE_INTERFACE, // bInterfaceNumber
  1726. 0, // bAlternateSetting
  1727. 1, // bNumEndpoints
  1728. 0x03, // bInterfaceClass (0x03 = HID)
  1729. 0x00, // bInterfaceSubClass (0x01 = Boot)
  1730. 0x00, // bInterfaceProtocol (0x02 = Mouse)
  1731. 0, // iInterface
  1732. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1733. 9, // bLength
  1734. 0x21, // bDescriptorType
  1735. 0x11, 0x01, // bcdHID
  1736. 0, // bCountryCode
  1737. 1, // bNumDescriptors
  1738. 0x22, // bDescriptorType
  1739. LSB(sizeof(mouse_report_desc)), // wDescriptorLength
  1740. MSB(sizeof(mouse_report_desc)),
  1741. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1742. 7, // bLength
  1743. 5, // bDescriptorType
  1744. MOUSE_ENDPOINT | 0x80, // bEndpointAddress
  1745. 0x03, // bmAttributes (0x03=intr)
  1746. MOUSE_SIZE, 0, // wMaxPacketSize
  1747. MOUSE_INTERVAL, // bInterval
  1748. #endif // MOUSE_INTERFACE
  1749. #ifdef RAWHID_INTERFACE
  1750. // configuration for 12 Mbit/sec speed
  1751. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1752. 9, // bLength
  1753. 4, // bDescriptorType
  1754. RAWHID_INTERFACE, // bInterfaceNumber
  1755. 0, // bAlternateSetting
  1756. 2, // bNumEndpoints
  1757. 0x03, // bInterfaceClass (0x03 = HID)
  1758. 0x00, // bInterfaceSubClass
  1759. 0x00, // bInterfaceProtocol
  1760. 0, // iInterface
  1761. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1762. 9, // bLength
  1763. 0x21, // bDescriptorType
  1764. 0x11, 0x01, // bcdHID
  1765. 0, // bCountryCode
  1766. 1, // bNumDescriptors
  1767. 0x22, // bDescriptorType
  1768. LSB(sizeof(rawhid_report_desc)), // wDescriptorLength
  1769. MSB(sizeof(rawhid_report_desc)),
  1770. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1771. 7, // bLength
  1772. 5, // bDescriptorType
  1773. RAWHID_TX_ENDPOINT | 0x80, // bEndpointAddress
  1774. 0x03, // bmAttributes (0x03=intr)
  1775. RAWHID_TX_SIZE, 0, // wMaxPacketSize
  1776. RAWHID_TX_INTERVAL, // bInterval
  1777. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1778. 7, // bLength
  1779. 5, // bDescriptorType
  1780. RAWHID_RX_ENDPOINT, // bEndpointAddress
  1781. 0x03, // bmAttributes (0x03=intr)
  1782. RAWHID_RX_SIZE, 0, // wMaxPacketSize
  1783. RAWHID_RX_INTERVAL, // bInterval
  1784. #endif // RAWHID_INTERFACE
  1785. #ifdef FLIGHTSIM_INTERFACE
  1786. // configuration for 12 Mbit/sec speed
  1787. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1788. 9, // bLength
  1789. 4, // bDescriptorType
  1790. FLIGHTSIM_INTERFACE, // bInterfaceNumber
  1791. 0, // bAlternateSetting
  1792. 2, // bNumEndpoints
  1793. 0x03, // bInterfaceClass (0x03 = HID)
  1794. 0x00, // bInterfaceSubClass
  1795. 0x00, // bInterfaceProtocol
  1796. 0, // iInterface
  1797. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1798. 9, // bLength
  1799. 0x21, // bDescriptorType
  1800. 0x11, 0x01, // bcdHID
  1801. 0, // bCountryCode
  1802. 1, // bNumDescriptors
  1803. 0x22, // bDescriptorType
  1804. LSB(sizeof(flightsim_report_desc)), // wDescriptorLength
  1805. MSB(sizeof(flightsim_report_desc)),
  1806. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1807. 7, // bLength
  1808. 5, // bDescriptorType
  1809. FLIGHTSIM_TX_ENDPOINT | 0x80, // bEndpointAddress
  1810. 0x03, // bmAttributes (0x03=intr)
  1811. FLIGHTSIM_TX_SIZE, 0, // wMaxPacketSize
  1812. FLIGHTSIM_TX_INTERVAL, // bInterval
  1813. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1814. 7, // bLength
  1815. 5, // bDescriptorType
  1816. FLIGHTSIM_RX_ENDPOINT, // bEndpointAddress
  1817. 0x03, // bmAttributes (0x03=intr)
  1818. FLIGHTSIM_RX_SIZE, 0, // wMaxPacketSize
  1819. FLIGHTSIM_RX_INTERVAL, // bInterval
  1820. #endif // FLIGHTSIM_INTERFACE
  1821. #ifdef SEREMU_INTERFACE
  1822. // configuration for 12 Mbit/sec speed
  1823. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1824. 9, // bLength
  1825. 4, // bDescriptorType
  1826. SEREMU_INTERFACE, // bInterfaceNumber
  1827. 0, // bAlternateSetting
  1828. 2, // bNumEndpoints
  1829. 0x03, // bInterfaceClass (0x03 = HID)
  1830. 0x00, // bInterfaceSubClass
  1831. 0x00, // bInterfaceProtocol
  1832. 0, // iInterface
  1833. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1834. 9, // bLength
  1835. 0x21, // bDescriptorType
  1836. 0x11, 0x01, // bcdHID
  1837. 0, // bCountryCode
  1838. 1, // bNumDescriptors
  1839. 0x22, // bDescriptorType
  1840. LSB(sizeof(seremu_report_desc)), // wDescriptorLength
  1841. MSB(sizeof(seremu_report_desc)),
  1842. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1843. 7, // bLength
  1844. 5, // bDescriptorType
  1845. SEREMU_TX_ENDPOINT | 0x80, // bEndpointAddress
  1846. 0x03, // bmAttributes (0x03=intr)
  1847. SEREMU_TX_SIZE, 0, // wMaxPacketSize
  1848. SEREMU_TX_INTERVAL, // bInterval
  1849. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1850. 7, // bLength
  1851. 5, // bDescriptorType
  1852. SEREMU_RX_ENDPOINT, // bEndpointAddress
  1853. 0x03, // bmAttributes (0x03=intr)
  1854. SEREMU_RX_SIZE, 0, // wMaxPacketSize
  1855. SEREMU_RX_INTERVAL, // bInterval
  1856. #endif // SEREMU_INTERFACE
  1857. #ifdef JOYSTICK_INTERFACE
  1858. // configuration for 12 Mbit/sec speed
  1859. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1860. 9, // bLength
  1861. 4, // bDescriptorType
  1862. JOYSTICK_INTERFACE, // bInterfaceNumber
  1863. 0, // bAlternateSetting
  1864. 1, // bNumEndpoints
  1865. 0x03, // bInterfaceClass (0x03 = HID)
  1866. 0x00, // bInterfaceSubClass
  1867. 0x00, // bInterfaceProtocol
  1868. 0, // iInterface
  1869. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1870. 9, // bLength
  1871. 0x21, // bDescriptorType
  1872. 0x11, 0x01, // bcdHID
  1873. 0, // bCountryCode
  1874. 1, // bNumDescriptors
  1875. 0x22, // bDescriptorType
  1876. LSB(sizeof(joystick_report_desc)), // wDescriptorLength
  1877. MSB(sizeof(joystick_report_desc)),
  1878. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1879. 7, // bLength
  1880. 5, // bDescriptorType
  1881. JOYSTICK_ENDPOINT | 0x80, // bEndpointAddress
  1882. 0x03, // bmAttributes (0x03=intr)
  1883. JOYSTICK_SIZE, 0, // wMaxPacketSize
  1884. JOYSTICK_INTERVAL, // bInterval
  1885. #endif // JOYSTICK_INTERFACE
  1886. #ifdef MTP_INTERFACE
  1887. // configuration for 12 Mbit/sec speed
  1888. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1889. 9, // bLength
  1890. 4, // bDescriptorType
  1891. MTP_INTERFACE, // bInterfaceNumber
  1892. 0, // bAlternateSetting
  1893. 3, // bNumEndpoints
  1894. 0x06, // bInterfaceClass (0x06 = still image)
  1895. 0x01, // bInterfaceSubClass
  1896. 0x01, // bInterfaceProtocol
  1897. 0, // iInterface
  1898. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1899. 7, // bLength
  1900. 5, // bDescriptorType
  1901. MTP_TX_ENDPOINT | 0x80, // bEndpointAddress
  1902. 0x02, // bmAttributes (0x02=bulk)
  1903. MTP_TX_SIZE, 0, // wMaxPacketSize
  1904. 0, // bInterval
  1905. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1906. 7, // bLength
  1907. 5, // bDescriptorType
  1908. MTP_RX_ENDPOINT, // bEndpointAddress
  1909. 0x02, // bmAttributes (0x02=bulk)
  1910. MTP_RX_SIZE, 0, // wMaxPacketSize
  1911. 0, // bInterval
  1912. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1913. 7, // bLength
  1914. 5, // bDescriptorType
  1915. MTP_EVENT_ENDPOINT | 0x80, // bEndpointAddress
  1916. 0x03, // bmAttributes (0x03=intr)
  1917. MTP_EVENT_SIZE, 0, // wMaxPacketSize
  1918. MTP_EVENT_INTERVAL, // bInterval
  1919. #endif // MTP_INTERFACE
  1920. #ifdef KEYMEDIA_INTERFACE
  1921. // configuration for 12 Mbit/sec speed
  1922. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  1923. 9, // bLength
  1924. 4, // bDescriptorType
  1925. KEYMEDIA_INTERFACE, // bInterfaceNumber
  1926. 0, // bAlternateSetting
  1927. 1, // bNumEndpoints
  1928. 0x03, // bInterfaceClass (0x03 = HID)
  1929. 0x00, // bInterfaceSubClass
  1930. 0x00, // bInterfaceProtocol
  1931. 0, // iInterface
  1932. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  1933. 9, // bLength
  1934. 0x21, // bDescriptorType
  1935. 0x11, 0x01, // bcdHID
  1936. 0, // bCountryCode
  1937. 1, // bNumDescriptors
  1938. 0x22, // bDescriptorType
  1939. LSB(sizeof(keymedia_report_desc)), // wDescriptorLength
  1940. MSB(sizeof(keymedia_report_desc)),
  1941. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  1942. 7, // bLength
  1943. 5, // bDescriptorType
  1944. KEYMEDIA_ENDPOINT | 0x80, // bEndpointAddress
  1945. 0x03, // bmAttributes (0x03=intr)
  1946. KEYMEDIA_SIZE, 0, // wMaxPacketSize
  1947. KEYMEDIA_INTERVAL, // bInterval
  1948. #endif // KEYMEDIA_INTERFACE
  1949. #ifdef AUDIO_INTERFACE
  1950. // configuration for 12 Mbit/sec speed
  1951. // interface association descriptor, USB ECN, Table 9-Z
  1952. 8, // bLength
  1953. 11, // bDescriptorType
  1954. AUDIO_INTERFACE, // bFirstInterface
  1955. 3, // bInterfaceCount
  1956. 0x01, // bFunctionClass
  1957. 0x01, // bFunctionSubClass
  1958. 0x00, // bFunctionProtocol
  1959. 0, // iFunction
  1960. // Standard AudioControl (AC) Interface Descriptor
  1961. // USB DCD for Audio Devices 1.0, Table 4-1, page 36
  1962. 9, // bLength
  1963. 4, // bDescriptorType, 4 = INTERFACE
  1964. AUDIO_INTERFACE, // bInterfaceNumber
  1965. 0, // bAlternateSetting
  1966. 0, // bNumEndpoints
  1967. 1, // bInterfaceClass, 1 = AUDIO
  1968. 1, // bInterfaceSubclass, 1 = AUDIO_CONTROL
  1969. 0, // bInterfaceProtocol
  1970. 0, // iInterface
  1971. // Class-specific AC Interface Header Descriptor
  1972. // USB DCD for Audio Devices 1.0, Table 4-2, page 37-38
  1973. 10, // bLength
  1974. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1975. 0x01, // bDescriptorSubtype, 1 = HEADER
  1976. 0x00, 0x01, // bcdADC (version 1.0)
  1977. LSB(62), MSB(62), // wTotalLength
  1978. 2, // bInCollection
  1979. AUDIO_INTERFACE+1, // baInterfaceNr(1) - Transmit to PC
  1980. AUDIO_INTERFACE+2, // baInterfaceNr(2) - Receive from PC
  1981. // Input Terminal Descriptor
  1982. // USB DCD for Audio Devices 1.0, Table 4-3, page 39
  1983. 12, // bLength
  1984. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1985. 0x02, // bDescriptorSubType, 2 = INPUT_TERMINAL
  1986. 1, // bTerminalID
  1987. //0x01, 0x02, // wTerminalType, 0x0201 = MICROPHONE
  1988. //0x03, 0x06, // wTerminalType, 0x0603 = Line Connector
  1989. 0x02, 0x06, // wTerminalType, 0x0602 = Digital Audio
  1990. 0, // bAssocTerminal, 0 = unidirectional
  1991. 2, // bNrChannels
  1992. 0x03, 0x00, // wChannelConfig, 0x0003 = Left & Right Front
  1993. 0, // iChannelNames
  1994. 0, // iTerminal
  1995. // Output Terminal Descriptor
  1996. // USB DCD for Audio Devices 1.0, Table 4-4, page 40
  1997. 9, // bLength
  1998. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  1999. 3, // bDescriptorSubtype, 3 = OUTPUT_TERMINAL
  2000. 2, // bTerminalID
  2001. 0x01, 0x01, // wTerminalType, 0x0101 = USB_STREAMING
  2002. 0, // bAssocTerminal, 0 = unidirectional
  2003. 1, // bCSourceID, connected to input terminal, ID=1
  2004. 0, // iTerminal
  2005. // Input Terminal Descriptor
  2006. // USB DCD for Audio Devices 1.0, Table 4-3, page 39
  2007. 12, // bLength
  2008. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  2009. 2, // bDescriptorSubType, 2 = INPUT_TERMINAL
  2010. 3, // bTerminalID
  2011. 0x01, 0x01, // wTerminalType, 0x0101 = USB_STREAMING
  2012. 0, // bAssocTerminal, 0 = unidirectional
  2013. 2, // bNrChannels
  2014. 0x03, 0x00, // wChannelConfig, 0x0003 = Left & Right Front
  2015. 0, // iChannelNames
  2016. 0, // iTerminal
  2017. // Volume feature descriptor
  2018. 10, // bLength
  2019. 0x24, // bDescriptorType = CS_INTERFACE
  2020. 0x06, // bDescriptorSubType = FEATURE_UNIT
  2021. 0x31, // bUnitID
  2022. 0x03, // bSourceID (Input Terminal)
  2023. 0x01, // bControlSize (each channel is 1 byte, 3 channels)
  2024. 0x01, // bmaControls(0) Master: Mute
  2025. 0x02, // bmaControls(1) Left: Volume
  2026. 0x02, // bmaControls(2) Right: Volume
  2027. 0x00, // iFeature
  2028. // Output Terminal Descriptor
  2029. // USB DCD for Audio Devices 1.0, Table 4-4, page 40
  2030. 9, // bLength
  2031. 0x24, // bDescriptorType, 0x24 = CS_INTERFACE
  2032. 3, // bDescriptorSubtype, 3 = OUTPUT_TERMINAL
  2033. 4, // bTerminalID
  2034. //0x02, 0x03, // wTerminalType, 0x0302 = Headphones
  2035. 0x02, 0x06, // wTerminalType, 0x0602 = Digital Audio
  2036. 0, // bAssocTerminal, 0 = unidirectional
  2037. 0x31, // bCSourceID, connected to feature, ID=31
  2038. 0, // iTerminal
  2039. // Standard AS Interface Descriptor
  2040. // USB DCD for Audio Devices 1.0, Section 4.5.1, Table 4-18, page 59
  2041. // Alternate 0: default setting, disabled zero bandwidth
  2042. 9, // bLenght
  2043. 4, // bDescriptorType = INTERFACE
  2044. AUDIO_INTERFACE+1, // bInterfaceNumber
  2045. 0, // bAlternateSetting
  2046. 0, // bNumEndpoints
  2047. 1, // bInterfaceClass, 1 = AUDIO
  2048. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  2049. 0, // bInterfaceProtocol
  2050. 0, // iInterface
  2051. // Alternate 1: streaming data
  2052. 9, // bLenght
  2053. 4, // bDescriptorType = INTERFACE
  2054. AUDIO_INTERFACE+1, // bInterfaceNumber
  2055. 1, // bAlternateSetting
  2056. 1, // bNumEndpoints
  2057. 1, // bInterfaceClass, 1 = AUDIO
  2058. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  2059. 0, // bInterfaceProtocol
  2060. 0, // iInterface
  2061. // Class-Specific AS Interface Descriptor
  2062. // USB DCD for Audio Devices 1.0, Section 4.5.2, Table 4-19, page 60
  2063. 7, // bLength
  2064. 0x24, // bDescriptorType = CS_INTERFACE
  2065. 1, // bDescriptorSubtype, 1 = AS_GENERAL
  2066. 2, // bTerminalLink: Terminal ID = 2
  2067. 3, // bDelay (approx 3ms delay, audio lib updates)
  2068. 0x01, 0x00, // wFormatTag, 0x0001 = PCM
  2069. // Type I Format Descriptor
  2070. // USB DCD for Audio Data Formats 1.0, Section 2.2.5, Table 2-1, page 10
  2071. 11, // bLength
  2072. 0x24, // bDescriptorType = CS_INTERFACE
  2073. 2, // bDescriptorSubtype = FORMAT_TYPE
  2074. 1, // bFormatType = FORMAT_TYPE_I
  2075. 2, // bNrChannels = 2
  2076. 2, // bSubFrameSize = 2 byte
  2077. 16, // bBitResolution = 16 bits
  2078. 1, // bSamFreqType = 1 frequency
  2079. LSB(44100), MSB(44100), 0, // tSamFreq
  2080. // Standard AS Isochronous Audio Data Endpoint Descriptor
  2081. // USB DCD for Audio Devices 1.0, Section 4.6.1.1, Table 4-20, page 61-62
  2082. 9, // bLength
  2083. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  2084. AUDIO_TX_ENDPOINT | 0x80, // bEndpointAddress
  2085. 0x09, // bmAttributes = isochronous, adaptive
  2086. LSB(AUDIO_TX_SIZE), MSB(AUDIO_TX_SIZE), // wMaxPacketSize
  2087. 1, // bInterval, 1 = every frame
  2088. 0, // bRefresh
  2089. 0, // bSynchAddress
  2090. // Class-Specific AS Isochronous Audio Data Endpoint Descriptor
  2091. // USB DCD for Audio Devices 1.0, Section 4.6.1.2, Table 4-21, page 62-63
  2092. 7, // bLength
  2093. 0x25, // bDescriptorType, 0x25 = CS_ENDPOINT
  2094. 1, // bDescriptorSubtype, 1 = EP_GENERAL
  2095. 0x00, // bmAttributes
  2096. 0, // bLockDelayUnits, 1 = ms
  2097. 0x00, 0x00, // wLockDelay
  2098. // Standard AS Interface Descriptor
  2099. // USB DCD for Audio Devices 1.0, Section 4.5.1, Table 4-18, page 59
  2100. // Alternate 0: default setting, disabled zero bandwidth
  2101. 9, // bLenght
  2102. 4, // bDescriptorType = INTERFACE
  2103. AUDIO_INTERFACE+2, // bInterfaceNumber
  2104. 0, // bAlternateSetting
  2105. 0, // bNumEndpoints
  2106. 1, // bInterfaceClass, 1 = AUDIO
  2107. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  2108. 0, // bInterfaceProtocol
  2109. 0, // iInterface
  2110. // Alternate 1: streaming data
  2111. 9, // bLenght
  2112. 4, // bDescriptorType = INTERFACE
  2113. AUDIO_INTERFACE+2, // bInterfaceNumber
  2114. 1, // bAlternateSetting
  2115. 2, // bNumEndpoints
  2116. 1, // bInterfaceClass, 1 = AUDIO
  2117. 2, // bInterfaceSubclass, 2 = AUDIO_STREAMING
  2118. 0, // bInterfaceProtocol
  2119. 0, // iInterface
  2120. // Class-Specific AS Interface Descriptor
  2121. // USB DCD for Audio Devices 1.0, Section 4.5.2, Table 4-19, page 60
  2122. 7, // bLength
  2123. 0x24, // bDescriptorType = CS_INTERFACE
  2124. 1, // bDescriptorSubtype, 1 = AS_GENERAL
  2125. 3, // bTerminalLink: Terminal ID = 3
  2126. 3, // bDelay (approx 3ms delay, audio lib updates)
  2127. 0x01, 0x00, // wFormatTag, 0x0001 = PCM
  2128. // Type I Format Descriptor
  2129. // USB DCD for Audio Data Formats 1.0, Section 2.2.5, Table 2-1, page 10
  2130. 11, // bLength
  2131. 0x24, // bDescriptorType = CS_INTERFACE
  2132. 2, // bDescriptorSubtype = FORMAT_TYPE
  2133. 1, // bFormatType = FORMAT_TYPE_I
  2134. 2, // bNrChannels = 2
  2135. 2, // bSubFrameSize = 2 byte
  2136. 16, // bBitResolution = 16 bits
  2137. 1, // bSamFreqType = 1 frequency
  2138. LSB(44100), MSB(44100), 0, // tSamFreq
  2139. // Standard AS Isochronous Audio Data Endpoint Descriptor
  2140. // USB DCD for Audio Devices 1.0, Section 4.6.1.1, Table 4-20, page 61-62
  2141. 9, // bLength
  2142. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  2143. AUDIO_RX_ENDPOINT, // bEndpointAddress
  2144. 0x05, // bmAttributes = isochronous, asynchronous
  2145. LSB(AUDIO_RX_SIZE), MSB(AUDIO_RX_SIZE), // wMaxPacketSize
  2146. 1, // bInterval, 1 = every frame
  2147. 0, // bRefresh
  2148. AUDIO_SYNC_ENDPOINT | 0x80, // bSynchAddress
  2149. // Class-Specific AS Isochronous Audio Data Endpoint Descriptor
  2150. // USB DCD for Audio Devices 1.0, Section 4.6.1.2, Table 4-21, page 62-63
  2151. 7, // bLength
  2152. 0x25, // bDescriptorType, 0x25 = CS_ENDPOINT
  2153. 1, // bDescriptorSubtype, 1 = EP_GENERAL
  2154. 0x00, // bmAttributes
  2155. 0, // bLockDelayUnits, 1 = ms
  2156. 0x00, 0x00, // wLockDelay
  2157. // Standard AS Isochronous Audio Synch Endpoint Descriptor
  2158. // USB DCD for Audio Devices 1.0, Section 4.6.2.1, Table 4-22, page 63-64
  2159. 9, // bLength
  2160. 5, // bDescriptorType, 5 = ENDPOINT_DESCRIPTOR
  2161. AUDIO_SYNC_ENDPOINT | 0x80, // bEndpointAddress
  2162. 0x11, // bmAttributes = isochronous, feedback
  2163. 3, 0, // wMaxPacketSize, 3 bytes
  2164. 1, // bInterval, 1 = every frame
  2165. 5, // bRefresh, 5 = 32ms
  2166. 0, // bSynchAddress
  2167. #endif
  2168. #ifdef MULTITOUCH_INTERFACE
  2169. // configuration for 12 Mbit/sec speed
  2170. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  2171. 9, // bLength
  2172. 4, // bDescriptorType
  2173. MULTITOUCH_INTERFACE, // bInterfaceNumber
  2174. 0, // bAlternateSetting
  2175. 1, // bNumEndpoints
  2176. 0x03, // bInterfaceClass (0x03 = HID)
  2177. 0x00, // bInterfaceSubClass
  2178. 0x00, // bInterfaceProtocol
  2179. 0, // iInterface
  2180. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  2181. 9, // bLength
  2182. 0x21, // bDescriptorType
  2183. 0x11, 0x01, // bcdHID
  2184. 0, // bCountryCode
  2185. 1, // bNumDescriptors
  2186. 0x22, // bDescriptorType
  2187. LSB(sizeof(multitouch_report_desc)), // wDescriptorLength
  2188. MSB(sizeof(multitouch_report_desc)),
  2189. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  2190. 7, // bLength
  2191. 5, // bDescriptorType
  2192. MULTITOUCH_ENDPOINT | 0x80, // bEndpointAddress
  2193. 0x03, // bmAttributes (0x03=intr)
  2194. MULTITOUCH_SIZE, 0, // wMaxPacketSize
  2195. 1, // bInterval
  2196. #endif // KEYMEDIA_INTERFACE
  2197. };
  2198. __attribute__ ((section(".dmabuffers"), aligned(32)))
  2199. uint8_t usb_descriptor_buffer[CONFIG_DESC_SIZE];
  2200. // **************************************************************
  2201. // String Descriptors
  2202. // **************************************************************
  2203. // The descriptors above can provide human readable strings,
  2204. // referenced by index numbers. These descriptors are the
  2205. // actual string data
  2206. /* defined in usb_names.h
  2207. struct usb_string_descriptor_struct {
  2208. uint8_t bLength;
  2209. uint8_t bDescriptorType;
  2210. uint16_t wString[];
  2211. };
  2212. */
  2213. extern struct usb_string_descriptor_struct usb_string_manufacturer_name
  2214. __attribute__ ((weak, alias("usb_string_manufacturer_name_default")));
  2215. extern struct usb_string_descriptor_struct usb_string_product_name
  2216. __attribute__ ((weak, alias("usb_string_product_name_default")));
  2217. extern struct usb_string_descriptor_struct usb_string_serial_number
  2218. __attribute__ ((weak, alias("usb_string_serial_number_default")));
  2219. PROGMEM const struct usb_string_descriptor_struct string0 = {
  2220. 4,
  2221. 3,
  2222. {0x0409}
  2223. };
  2224. PROGMEM const struct usb_string_descriptor_struct usb_string_manufacturer_name_default = {
  2225. 2 + MANUFACTURER_NAME_LEN * 2,
  2226. 3,
  2227. MANUFACTURER_NAME
  2228. };
  2229. PROGMEM const struct usb_string_descriptor_struct usb_string_product_name_default = {
  2230. 2 + PRODUCT_NAME_LEN * 2,
  2231. 3,
  2232. PRODUCT_NAME
  2233. };
  2234. struct usb_string_descriptor_struct usb_string_serial_number_default = {
  2235. 12,
  2236. 3,
  2237. {0,0,0,0,0,0,0,0,0,0}
  2238. };
  2239. #ifdef MTP_INTERFACE
  2240. PROGMEM const struct usb_string_descriptor_struct usb_string_mtp = {
  2241. 2 + 3 * 2,
  2242. 3,
  2243. {'M','T','P'}
  2244. };
  2245. #endif
  2246. void usb_init_serialnumber(void)
  2247. {
  2248. char buf[11];
  2249. uint32_t i, num;
  2250. num = HW_OCOTP_MAC0 & 0xFFFFFF;
  2251. // add extra zero to work around OS-X CDC-ACM driver bug
  2252. if (num < 10000000) num = num * 10;
  2253. ultoa(num, buf, 10);
  2254. for (i=0; i<10; i++) {
  2255. char c = buf[i];
  2256. if (!c) break;
  2257. usb_string_serial_number_default.wString[i] = c;
  2258. }
  2259. usb_string_serial_number_default.bLength = i * 2 + 2;
  2260. }
  2261. // **************************************************************
  2262. // Descriptors List
  2263. // **************************************************************
  2264. // This table provides access to all the descriptor data above.
  2265. const usb_descriptor_list_t usb_descriptor_list[] = {
  2266. //wValue, wIndex, address, length
  2267. {0x0100, 0x0000, device_descriptor, sizeof(device_descriptor)},
  2268. {0x0600, 0x0000, qualifier_descriptor, sizeof(qualifier_descriptor)},
  2269. {0x0200, 0x0000, usb_config_descriptor_480, CONFIG_DESC_SIZE},
  2270. {0x0700, 0x0000, usb_config_descriptor_12, CONFIG_DESC_SIZE},
  2271. #ifdef SEREMU_INTERFACE
  2272. {0x2200, SEREMU_INTERFACE, seremu_report_desc, sizeof(seremu_report_desc)},
  2273. {0x2100, SEREMU_INTERFACE, usb_config_descriptor_480+SEREMU_HID_DESC_OFFSET, 9},
  2274. #endif
  2275. #ifdef KEYBOARD_INTERFACE
  2276. {0x2200, KEYBOARD_INTERFACE, keyboard_report_desc, sizeof(keyboard_report_desc)},
  2277. {0x2100, KEYBOARD_INTERFACE, usb_config_descriptor_480+KEYBOARD_HID_DESC_OFFSET, 9},
  2278. #endif
  2279. #ifdef MOUSE_INTERFACE
  2280. {0x2200, MOUSE_INTERFACE, mouse_report_desc, sizeof(mouse_report_desc)},
  2281. {0x2100, MOUSE_INTERFACE, usb_config_descriptor_480+MOUSE_HID_DESC_OFFSET, 9},
  2282. #endif
  2283. #ifdef JOYSTICK_INTERFACE
  2284. {0x2200, JOYSTICK_INTERFACE, joystick_report_desc, sizeof(joystick_report_desc)},
  2285. {0x2100, JOYSTICK_INTERFACE, usb_config_descriptor_480+JOYSTICK_HID_DESC_OFFSET, 9},
  2286. #endif
  2287. #ifdef RAWHID_INTERFACE
  2288. {0x2200, RAWHID_INTERFACE, rawhid_report_desc, sizeof(rawhid_report_desc)},
  2289. {0x2100, RAWHID_INTERFACE, usb_config_descriptor_480+RAWHID_HID_DESC_OFFSET, 9},
  2290. #endif
  2291. #ifdef FLIGHTSIM_INTERFACE
  2292. {0x2200, FLIGHTSIM_INTERFACE, flightsim_report_desc, sizeof(flightsim_report_desc)},
  2293. {0x2100, FLIGHTSIM_INTERFACE, usb_config_descriptor_480+FLIGHTSIM_HID_DESC_OFFSET, 9},
  2294. #endif
  2295. #ifdef KEYMEDIA_INTERFACE
  2296. {0x2200, KEYMEDIA_INTERFACE, keymedia_report_desc, sizeof(keymedia_report_desc)},
  2297. {0x2100, KEYMEDIA_INTERFACE, usb_config_descriptor_480+KEYMEDIA_HID_DESC_OFFSET, 9},
  2298. #endif
  2299. #ifdef MULTITOUCH_INTERFACE
  2300. {0x2200, MULTITOUCH_INTERFACE, multitouch_report_desc, sizeof(multitouch_report_desc)},
  2301. {0x2100, MULTITOUCH_INTERFACE, usb_config_descriptor_480+MULTITOUCH_HID_DESC_OFFSET, 9},
  2302. #endif
  2303. #ifdef MTP_INTERFACE
  2304. {0x0304, 0x0409, (const uint8_t *)&usb_string_mtp, 0},
  2305. #endif
  2306. {0x0300, 0x0000, (const uint8_t *)&string0, 0},
  2307. {0x0301, 0x0409, (const uint8_t *)&usb_string_manufacturer_name, 0},
  2308. {0x0302, 0x0409, (const uint8_t *)&usb_string_product_name, 0},
  2309. {0x0303, 0x0409, (const uint8_t *)&usb_string_serial_number, 0},
  2310. {0, 0, NULL, 0}
  2311. };
  2312. #endif // NUM_ENDPOINTS
  2313. //#endif // F_CPU >= 20 MHz