Teensy 4.1 core updated for C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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