Teensy 4.1 core updated for C++20
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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