Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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