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.

1072 lines
52KB

  1. /* Teensyduino Core Library
  2. * http://www.pjrc.com/teensy/
  3. * Copyright (c) 2013 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. 0x00, 0x02, // 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. 0x00, 0x02, // bcdDevice
  82. 1, // iManufacturer
  83. 2, // iProduct
  84. 3, // iSerialNumber
  85. 1 // bNumConfigurations
  86. };
  87. // These descriptors must NOT be "const", because the USB DMA
  88. // has trouble accessing flash memory with enough bandwidth
  89. // while the processor is executing from flash.
  90. // **************************************************************
  91. // HID Report Descriptors
  92. // **************************************************************
  93. // Each HID interface needs a special report descriptor that tells
  94. // the meaning and format of the data.
  95. #ifdef KEYBOARD_INTERFACE
  96. // Keyboard Protocol 1, HID 1.11 spec, Appendix B, page 59-60
  97. static uint8_t keyboard_report_desc[] = {
  98. 0x05, 0x01, // Usage Page (Generic Desktop),
  99. 0x09, 0x06, // Usage (Keyboard),
  100. 0xA1, 0x01, // Collection (Application),
  101. 0x75, 0x01, // Report Size (1),
  102. 0x95, 0x08, // Report Count (8),
  103. 0x05, 0x07, // Usage Page (Key Codes),
  104. 0x19, 0xE0, // Usage Minimum (224),
  105. 0x29, 0xE7, // Usage Maximum (231),
  106. 0x15, 0x00, // Logical Minimum (0),
  107. 0x25, 0x01, // Logical Maximum (1),
  108. 0x81, 0x02, // Input (Data, Variable, Absolute), ;Modifier keys
  109. 0x95, 0x01, // Report Count (1),
  110. 0x75, 0x08, // Report Size (8),
  111. 0x81, 0x03, // Input (Constant), ;Reserved byte
  112. 0x95, 0x05, // Report Count (5),
  113. 0x75, 0x01, // Report Size (1),
  114. 0x05, 0x08, // Usage Page (LEDs),
  115. 0x19, 0x01, // Usage Minimum (1),
  116. 0x29, 0x05, // Usage Maximum (5),
  117. 0x91, 0x02, // Output (Data, Variable, Absolute), ;LED report
  118. 0x95, 0x01, // Report Count (1),
  119. 0x75, 0x03, // Report Size (3),
  120. 0x91, 0x03, // Output (Constant), ;LED report padding
  121. 0x95, 0x06, // Report Count (6),
  122. 0x75, 0x08, // Report Size (8),
  123. 0x15, 0x00, // Logical Minimum (0),
  124. 0x25, 0x7F, // Logical Maximum(104),
  125. 0x05, 0x07, // Usage Page (Key Codes),
  126. 0x19, 0x00, // Usage Minimum (0),
  127. 0x29, 0x7F, // Usage Maximum (104),
  128. 0x81, 0x00, // Input (Data, Array), ;Normal keys
  129. 0xC0 // End Collection
  130. };
  131. #endif
  132. #ifdef KEYMEDIA_INTERFACE
  133. static uint8_t keymedia_report_desc[] = {
  134. 0x05, 0x0C, // Usage Page (Consumer)
  135. 0x09, 0x01, // Usage (Consumer Controls)
  136. 0xA1, 0x01, // Collection (Application)
  137. 0x75, 0x0A, // Report Size (10)
  138. 0x95, 0x04, // Report Count (4)
  139. 0x19, 0x00, // Usage Minimum (0)
  140. 0x2A, 0x9C, 0x02, // Usage Maximum (0x29C)
  141. 0x15, 0x00, // Logical Minimum (0)
  142. 0x26, 0x9C, 0x02, // Logical Maximum (0x29C)
  143. 0x81, 0x00, // Input (Data, Array)
  144. 0xC0, // End Collection
  145. 0x05, 0x01, // Usage Page (Generic Desktop)
  146. 0x09, 0x80, // Usage (System Control)
  147. 0xA1, 0x01, // Collection (Application)
  148. 0x75, 0x08, // Report Size (8)
  149. 0x95, 0x03, // Report Count (3)
  150. 0x19, 0x00, // Usage Minimum (0)
  151. 0x29, 0xB7, // Usage Maximum (0xB7)
  152. 0x15, 0x00, // Logical Minimum (0)
  153. 0x26, 0xB7, 0x00, // Logical Maximum (0xB7)
  154. 0x81, 0x00, // Input (Data, Array)
  155. 0xC0 // End Collection
  156. };
  157. #endif
  158. #ifdef MOUSE_INTERFACE
  159. // Mouse Protocol 1, HID 1.11 spec, Appendix B, page 59-60, with wheel extension
  160. static uint8_t mouse_report_desc[] = {
  161. 0x05, 0x01, // Usage Page (Generic Desktop)
  162. 0x09, 0x02, // Usage (Mouse)
  163. 0xA1, 0x01, // Collection (Application)
  164. 0x85, 0x01, // REPORT_ID (1)
  165. 0x05, 0x09, // Usage Page (Button)
  166. 0x19, 0x01, // Usage Minimum (Button #1)
  167. 0x29, 0x08, // Usage Maximum (Button #8)
  168. 0x15, 0x00, // Logical Minimum (0)
  169. 0x25, 0x01, // Logical Maximum (1)
  170. 0x95, 0x08, // Report Count (8)
  171. 0x75, 0x01, // Report Size (1)
  172. 0x81, 0x02, // Input (Data, Variable, Absolute)
  173. 0x05, 0x01, // Usage Page (Generic Desktop)
  174. 0x09, 0x30, // Usage (X)
  175. 0x09, 0x31, // Usage (Y)
  176. 0x09, 0x38, // Usage (Wheel)
  177. 0x15, 0x81, // Logical Minimum (-127)
  178. 0x25, 0x7F, // Logical Maximum (127)
  179. 0x75, 0x08, // Report Size (8),
  180. 0x95, 0x03, // Report Count (3),
  181. 0x81, 0x06, // Input (Data, Variable, Relative)
  182. 0xC0, // End Collection
  183. 0x05, 0x01, // Usage Page (Generic Desktop)
  184. 0x09, 0x02, // Usage (Mouse)
  185. 0xA1, 0x01, // Collection (Application)
  186. 0x85, 0x02, // REPORT_ID (2)
  187. 0x05, 0x01, // Usage Page (Generic Desktop)
  188. 0x09, 0x30, // Usage (X)
  189. 0x09, 0x31, // Usage (Y)
  190. 0x15, 0x00, // Logical Minimum (0)
  191. 0x26, 0xFF, 0x7F, // Logical Maximum (32767)
  192. 0x75, 0x10, // Report Size (16),
  193. 0x95, 0x02, // Report Count (2),
  194. 0x81, 0x02, // Input (Data, Variable, Absolute)
  195. 0xC0 // End Collection
  196. };
  197. #endif
  198. #ifdef JOYSTICK_INTERFACE
  199. static uint8_t joystick_report_desc[] = {
  200. 0x05, 0x01, // Usage Page (Generic Desktop)
  201. 0x09, 0x04, // Usage (Joystick)
  202. 0xA1, 0x01, // Collection (Application)
  203. 0x15, 0x00, // Logical Minimum (0)
  204. 0x25, 0x01, // Logical Maximum (1)
  205. 0x75, 0x01, // Report Size (1)
  206. 0x95, 0x20, // Report Count (32)
  207. 0x05, 0x09, // Usage Page (Button)
  208. 0x19, 0x01, // Usage Minimum (Button #1)
  209. 0x29, 0x20, // Usage Maximum (Button #32)
  210. 0x81, 0x02, // Input (variable,absolute)
  211. 0x15, 0x00, // Logical Minimum (0)
  212. 0x25, 0x07, // Logical Maximum (7)
  213. 0x35, 0x00, // Physical Minimum (0)
  214. 0x46, 0x3B, 0x01, // Physical Maximum (315)
  215. 0x75, 0x04, // Report Size (4)
  216. 0x95, 0x01, // Report Count (1)
  217. 0x65, 0x14, // Unit (20)
  218. 0x05, 0x01, // Usage Page (Generic Desktop)
  219. 0x09, 0x39, // Usage (Hat switch)
  220. 0x81, 0x42, // Input (variable,absolute,null_state)
  221. 0x05, 0x01, // Usage Page (Generic Desktop)
  222. 0x09, 0x01, // Usage (Pointer)
  223. 0xA1, 0x00, // Collection ()
  224. 0x15, 0x00, // Logical Minimum (0)
  225. 0x26, 0xFF, 0x03, // Logical Maximum (1023)
  226. 0x75, 0x0A, // Report Size (10)
  227. 0x95, 0x04, // Report Count (4)
  228. 0x09, 0x30, // Usage (X)
  229. 0x09, 0x31, // Usage (Y)
  230. 0x09, 0x32, // Usage (Z)
  231. 0x09, 0x35, // Usage (Rz)
  232. 0x81, 0x02, // Input (variable,absolute)
  233. 0xC0, // End Collection
  234. 0x15, 0x00, // Logical Minimum (0)
  235. 0x26, 0xFF, 0x03, // Logical Maximum (1023)
  236. 0x75, 0x0A, // Report Size (10)
  237. 0x95, 0x02, // Report Count (2)
  238. 0x09, 0x36, // Usage (Slider)
  239. 0x09, 0x36, // Usage (Slider)
  240. 0x81, 0x02, // Input (variable,absolute)
  241. 0xC0 // End Collection
  242. };
  243. #endif
  244. #ifdef SEREMU_INTERFACE
  245. static uint8_t seremu_report_desc[] = {
  246. 0x06, 0xC9, 0xFF, // Usage Page 0xFFC9 (vendor defined)
  247. 0x09, 0x04, // Usage 0x04
  248. 0xA1, 0x5C, // Collection 0x5C
  249. 0x75, 0x08, // report size = 8 bits (global)
  250. 0x15, 0x00, // logical minimum = 0 (global)
  251. 0x26, 0xFF, 0x00, // logical maximum = 255 (global)
  252. 0x95, SEREMU_TX_SIZE, // report count (global)
  253. 0x09, 0x75, // usage (local)
  254. 0x81, 0x02, // Input
  255. 0x95, SEREMU_RX_SIZE, // report count (global)
  256. 0x09, 0x76, // usage (local)
  257. 0x91, 0x02, // Output
  258. 0x95, 0x04, // report count (global)
  259. 0x09, 0x76, // usage (local)
  260. 0xB1, 0x02, // Feature
  261. 0xC0 // end collection
  262. };
  263. #endif
  264. #ifdef RAWHID_INTERFACE
  265. static uint8_t rawhid_report_desc[] = {
  266. 0x06, LSB(RAWHID_USAGE_PAGE), MSB(RAWHID_USAGE_PAGE),
  267. 0x0A, LSB(RAWHID_USAGE), MSB(RAWHID_USAGE),
  268. 0xA1, 0x01, // Collection 0x01
  269. 0x75, 0x08, // report size = 8 bits
  270. 0x15, 0x00, // logical minimum = 0
  271. 0x26, 0xFF, 0x00, // logical maximum = 255
  272. 0x95, RAWHID_TX_SIZE, // report count
  273. 0x09, 0x01, // usage
  274. 0x81, 0x02, // Input (array)
  275. 0x95, RAWHID_RX_SIZE, // report count
  276. 0x09, 0x02, // usage
  277. 0x91, 0x02, // Output (array)
  278. 0xC0 // end collection
  279. };
  280. #endif
  281. #ifdef FLIGHTSIM_INTERFACE
  282. static uint8_t flightsim_report_desc[] = {
  283. 0x06, 0x1C, 0xFF, // Usage page = 0xFF1C
  284. 0x0A, 0x39, 0xA7, // Usage = 0xA739
  285. 0xA1, 0x01, // Collection 0x01
  286. 0x75, 0x08, // report size = 8 bits
  287. 0x15, 0x00, // logical minimum = 0
  288. 0x26, 0xFF, 0x00, // logical maximum = 255
  289. 0x95, FLIGHTSIM_TX_SIZE, // report count
  290. 0x09, 0x01, // usage
  291. 0x81, 0x02, // Input (array)
  292. 0x95, FLIGHTSIM_RX_SIZE, // report count
  293. 0x09, 0x02, // usage
  294. 0x91, 0x02, // Output (array)
  295. 0xC0 // end collection
  296. };
  297. #endif
  298. // **************************************************************
  299. // USB Descriptor Sizes
  300. // **************************************************************
  301. // pre-compute the size and position of everything in the config descriptor
  302. //
  303. #define CONFIG_HEADER_DESCRIPTOR_SIZE 9
  304. #define CDC_IAD_DESCRIPTOR_POS CONFIG_HEADER_DESCRIPTOR_SIZE
  305. #ifdef CDC_IAD_DESCRIPTOR
  306. #define CDC_IAD_DESCRIPTOR_SIZE 8
  307. #else
  308. #define CDC_IAD_DESCRIPTOR_SIZE 0
  309. #endif
  310. #define CDC_DATA_INTERFACE_DESC_POS CDC_IAD_DESCRIPTOR_POS+CDC_IAD_DESCRIPTOR_SIZE
  311. #ifdef CDC_DATA_INTERFACE
  312. #define CDC_DATA_INTERFACE_DESC_SIZE 9+5+5+4+5+7+9+7+7
  313. #else
  314. #define CDC_DATA_INTERFACE_DESC_SIZE 0
  315. #endif
  316. #define MIDI_INTERFACE_DESC_POS CDC_DATA_INTERFACE_DESC_POS+CDC_DATA_INTERFACE_DESC_SIZE
  317. #ifdef MIDI_INTERFACE
  318. #define MIDI_INTERFACE_DESC_SIZE 9+7+6+6+9+9+9+5+9+5
  319. #else
  320. #define MIDI_INTERFACE_DESC_SIZE 0
  321. #endif
  322. #define KEYBOARD_INTERFACE_DESC_POS MIDI_INTERFACE_DESC_POS+MIDI_INTERFACE_DESC_SIZE
  323. #ifdef KEYBOARD_INTERFACE
  324. #define KEYBOARD_INTERFACE_DESC_SIZE 9+9+7
  325. #define KEYBOARD_HID_DESC_OFFSET KEYBOARD_INTERFACE_DESC_POS+9
  326. #else
  327. #define KEYBOARD_INTERFACE_DESC_SIZE 0
  328. #endif
  329. #define MOUSE_INTERFACE_DESC_POS KEYBOARD_INTERFACE_DESC_POS+KEYBOARD_INTERFACE_DESC_SIZE
  330. #ifdef MOUSE_INTERFACE
  331. #define MOUSE_INTERFACE_DESC_SIZE 9+9+7
  332. #define MOUSE_HID_DESC_OFFSET MOUSE_INTERFACE_DESC_POS+9
  333. #else
  334. #define MOUSE_INTERFACE_DESC_SIZE 0
  335. #endif
  336. #define RAWHID_INTERFACE_DESC_POS MOUSE_INTERFACE_DESC_POS+MOUSE_INTERFACE_DESC_SIZE
  337. #ifdef RAWHID_INTERFACE
  338. #define RAWHID_INTERFACE_DESC_SIZE 9+9+7+7
  339. #define RAWHID_HID_DESC_OFFSET RAWHID_INTERFACE_DESC_POS+9
  340. #else
  341. #define RAWHID_INTERFACE_DESC_SIZE 0
  342. #endif
  343. #define FLIGHTSIM_INTERFACE_DESC_POS RAWHID_INTERFACE_DESC_POS+RAWHID_INTERFACE_DESC_SIZE
  344. #ifdef FLIGHTSIM_INTERFACE
  345. #define FLIGHTSIM_INTERFACE_DESC_SIZE 9+9+7+7
  346. #define FLIGHTSIM_HID_DESC_OFFSET FLIGHTSIM_INTERFACE_DESC_POS+9
  347. #else
  348. #define FLIGHTSIM_INTERFACE_DESC_SIZE 0
  349. #endif
  350. #define SEREMU_INTERFACE_DESC_POS FLIGHTSIM_INTERFACE_DESC_POS+FLIGHTSIM_INTERFACE_DESC_SIZE
  351. #ifdef SEREMU_INTERFACE
  352. #define SEREMU_INTERFACE_DESC_SIZE 9+9+7+7
  353. #define SEREMU_HID_DESC_OFFSET SEREMU_INTERFACE_DESC_POS+9
  354. #else
  355. #define SEREMU_INTERFACE_DESC_SIZE 0
  356. #endif
  357. #define JOYSTICK_INTERFACE_DESC_POS SEREMU_INTERFACE_DESC_POS+SEREMU_INTERFACE_DESC_SIZE
  358. #ifdef JOYSTICK_INTERFACE
  359. #define JOYSTICK_INTERFACE_DESC_SIZE 9+9+7
  360. #define JOYSTICK_HID_DESC_OFFSET JOYSTICK_INTERFACE_DESC_POS+9
  361. #else
  362. #define JOYSTICK_INTERFACE_DESC_SIZE 0
  363. #endif
  364. #define MTP_INTERFACE_DESC_POS JOYSTICK_INTERFACE_DESC_POS+JOYSTICK_INTERFACE_DESC_SIZE
  365. #ifdef MTP_INTERFACE
  366. #define MTP_INTERFACE_DESC_SIZE 9+7+7+7
  367. #else
  368. #define MTP_INTERFACE_DESC_SIZE 0
  369. #endif
  370. #define KEYMEDIA_INTERFACE_DESC_POS MTP_INTERFACE_DESC_POS+MTP_INTERFACE_DESC_SIZE
  371. #ifdef KEYMEDIA_INTERFACE
  372. #define KEYMEDIA_INTERFACE_DESC_SIZE 9+9+7
  373. #define KEYMEDIA_HID_DESC_OFFSET KEYMEDIA_INTERFACE_DESC_POS+9
  374. #else
  375. #define KEYMEDIA_INTERFACE_DESC_SIZE 0
  376. #endif
  377. #define CONFIG_DESC_SIZE KEYMEDIA_INTERFACE_DESC_POS+KEYMEDIA_INTERFACE_DESC_SIZE
  378. // **************************************************************
  379. // USB Configuration
  380. // **************************************************************
  381. // USB Configuration Descriptor. This huge descriptor tells all
  382. // of the devices capbilities.
  383. static uint8_t config_descriptor[CONFIG_DESC_SIZE] = {
  384. // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
  385. 9, // bLength;
  386. 2, // bDescriptorType;
  387. LSB(CONFIG_DESC_SIZE), // wTotalLength
  388. MSB(CONFIG_DESC_SIZE),
  389. NUM_INTERFACE, // bNumInterfaces
  390. 1, // bConfigurationValue
  391. 0, // iConfiguration
  392. 0xC0, // bmAttributes
  393. 50, // bMaxPower
  394. #ifdef CDC_IAD_DESCRIPTOR
  395. // interface association descriptor, USB ECN, Table 9-Z
  396. 8, // bLength
  397. 11, // bDescriptorType
  398. CDC_STATUS_INTERFACE, // bFirstInterface
  399. 2, // bInterfaceCount
  400. 0x02, // bFunctionClass
  401. 0x02, // bFunctionSubClass
  402. 0x01, // bFunctionProtocol
  403. 4, // iFunction
  404. #endif
  405. #ifdef CDC_DATA_INTERFACE
  406. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  407. 9, // bLength
  408. 4, // bDescriptorType
  409. CDC_STATUS_INTERFACE, // bInterfaceNumber
  410. 0, // bAlternateSetting
  411. 1, // bNumEndpoints
  412. 0x02, // bInterfaceClass
  413. 0x02, // bInterfaceSubClass
  414. 0x01, // bInterfaceProtocol
  415. 0, // iInterface
  416. // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26
  417. 5, // bFunctionLength
  418. 0x24, // bDescriptorType
  419. 0x00, // bDescriptorSubtype
  420. 0x10, 0x01, // bcdCDC
  421. // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27
  422. 5, // bFunctionLength
  423. 0x24, // bDescriptorType
  424. 0x01, // bDescriptorSubtype
  425. 0x01, // bmCapabilities
  426. 1, // bDataInterface
  427. // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28
  428. 4, // bFunctionLength
  429. 0x24, // bDescriptorType
  430. 0x02, // bDescriptorSubtype
  431. 0x06, // bmCapabilities
  432. // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33
  433. 5, // bFunctionLength
  434. 0x24, // bDescriptorType
  435. 0x06, // bDescriptorSubtype
  436. CDC_STATUS_INTERFACE, // bMasterInterface
  437. CDC_DATA_INTERFACE, // bSlaveInterface0
  438. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  439. 7, // bLength
  440. 5, // bDescriptorType
  441. CDC_ACM_ENDPOINT | 0x80, // bEndpointAddress
  442. 0x03, // bmAttributes (0x03=intr)
  443. CDC_ACM_SIZE, 0, // wMaxPacketSize
  444. 64, // bInterval
  445. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  446. 9, // bLength
  447. 4, // bDescriptorType
  448. CDC_DATA_INTERFACE, // bInterfaceNumber
  449. 0, // bAlternateSetting
  450. 2, // bNumEndpoints
  451. 0x0A, // bInterfaceClass
  452. 0x00, // bInterfaceSubClass
  453. 0x00, // bInterfaceProtocol
  454. 0, // iInterface
  455. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  456. 7, // bLength
  457. 5, // bDescriptorType
  458. CDC_RX_ENDPOINT, // bEndpointAddress
  459. 0x02, // bmAttributes (0x02=bulk)
  460. CDC_RX_SIZE, 0, // wMaxPacketSize
  461. 0, // bInterval
  462. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  463. 7, // bLength
  464. 5, // bDescriptorType
  465. CDC_TX_ENDPOINT | 0x80, // bEndpointAddress
  466. 0x02, // bmAttributes (0x02=bulk)
  467. CDC_TX_SIZE, 0, // wMaxPacketSize
  468. 0, // bInterval
  469. #endif // CDC_DATA_INTERFACE
  470. #ifdef MIDI_INTERFACE
  471. // Standard MS Interface Descriptor,
  472. 9, // bLength
  473. 4, // bDescriptorType
  474. MIDI_INTERFACE, // bInterfaceNumber
  475. 0, // bAlternateSetting
  476. 2, // bNumEndpoints
  477. 0x01, // bInterfaceClass (0x01 = Audio)
  478. 0x03, // bInterfaceSubClass (0x03 = MIDI)
  479. 0x00, // bInterfaceProtocol (unused for MIDI)
  480. 0, // iInterface
  481. // MIDI MS Interface Header, USB MIDI 6.1.2.1, page 21, Table 6-2
  482. 7, // bLength
  483. 0x24, // bDescriptorType = CS_INTERFACE
  484. 0x01, // bDescriptorSubtype = MS_HEADER
  485. 0x00, 0x01, // bcdMSC = revision 01.00
  486. 0x41, 0x00, // wTotalLength
  487. // MIDI IN Jack Descriptor, B.4.3, Table B-7 (embedded), page 40
  488. 6, // bLength
  489. 0x24, // bDescriptorType = CS_INTERFACE
  490. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  491. 0x01, // bJackType = EMBEDDED
  492. 1, // bJackID, ID = 1
  493. 0, // iJack
  494. // MIDI IN Jack Descriptor, B.4.3, Table B-8 (external), page 40
  495. 6, // bLength
  496. 0x24, // bDescriptorType = CS_INTERFACE
  497. 0x02, // bDescriptorSubtype = MIDI_IN_JACK
  498. 0x02, // bJackType = EXTERNAL
  499. 2, // bJackID, ID = 2
  500. 0, // iJack
  501. // MIDI OUT Jack Descriptor, B.4.4, Table B-9, page 41
  502. 9,
  503. 0x24, // bDescriptorType = CS_INTERFACE
  504. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  505. 0x01, // bJackType = EMBEDDED
  506. 3, // bJackID, ID = 3
  507. 1, // bNrInputPins = 1 pin
  508. 2, // BaSourceID(1) = 2
  509. 1, // BaSourcePin(1) = first pin
  510. 0, // iJack
  511. // MIDI OUT Jack Descriptor, B.4.4, Table B-10, page 41
  512. 9,
  513. 0x24, // bDescriptorType = CS_INTERFACE
  514. 0x03, // bDescriptorSubtype = MIDI_OUT_JACK
  515. 0x02, // bJackType = EXTERNAL
  516. 4, // bJackID, ID = 4
  517. 1, // bNrInputPins = 1 pin
  518. 1, // BaSourceID(1) = 1
  519. 1, // BaSourcePin(1) = first pin
  520. 0, // iJack
  521. // Standard Bulk OUT Endpoint Descriptor, B.5.1, Table B-11, pae 42
  522. 9, // bLength
  523. 5, // bDescriptorType = ENDPOINT
  524. MIDI_RX_ENDPOINT, // bEndpointAddress
  525. 0x02, // bmAttributes (0x02=bulk)
  526. MIDI_RX_SIZE, 0, // wMaxPacketSize
  527. 0, // bInterval
  528. 0, // bRefresh
  529. 0, // bSynchAddress
  530. // Class-specific MS Bulk OUT Endpoint Descriptor, B.5.2, Table B-12, page 42
  531. 5, // bLength
  532. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  533. 0x01, // bJackType = MS_GENERAL
  534. 1, // bNumEmbMIDIJack = 1 jack
  535. 1, // BaAssocJackID(1) = jack ID #1
  536. // Standard Bulk IN Endpoint Descriptor, B.5.1, Table B-11, pae 42
  537. 9, // bLength
  538. 5, // bDescriptorType = ENDPOINT
  539. MIDI_TX_ENDPOINT | 0x80, // bEndpointAddress
  540. 0x02, // bmAttributes (0x02=bulk)
  541. MIDI_TX_SIZE, 0, // wMaxPacketSize
  542. 0, // bInterval
  543. 0, // bRefresh
  544. 0, // bSynchAddress
  545. // Class-specific MS Bulk IN Endpoint Descriptor, B.5.2, Table B-12, page 42
  546. 5, // bLength
  547. 0x25, // bDescriptorSubtype = CS_ENDPOINT
  548. 0x01, // bJackType = MS_GENERAL
  549. 1, // bNumEmbMIDIJack = 1 jack
  550. 3, // BaAssocJackID(1) = jack ID #3
  551. #endif // MIDI_INTERFACE
  552. #ifdef KEYBOARD_INTERFACE
  553. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  554. 9, // bLength
  555. 4, // bDescriptorType
  556. KEYBOARD_INTERFACE, // bInterfaceNumber
  557. 0, // bAlternateSetting
  558. 1, // bNumEndpoints
  559. 0x03, // bInterfaceClass (0x03 = HID)
  560. 0x01, // bInterfaceSubClass (0x01 = Boot)
  561. 0x01, // bInterfaceProtocol (0x01 = Keyboard)
  562. 0, // iInterface
  563. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  564. 9, // bLength
  565. 0x21, // bDescriptorType
  566. 0x11, 0x01, // bcdHID
  567. 0, // bCountryCode
  568. 1, // bNumDescriptors
  569. 0x22, // bDescriptorType
  570. LSB(sizeof(keyboard_report_desc)), // wDescriptorLength
  571. MSB(sizeof(keyboard_report_desc)),
  572. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  573. 7, // bLength
  574. 5, // bDescriptorType
  575. KEYBOARD_ENDPOINT | 0x80, // bEndpointAddress
  576. 0x03, // bmAttributes (0x03=intr)
  577. KEYBOARD_SIZE, 0, // wMaxPacketSize
  578. KEYBOARD_INTERVAL, // bInterval
  579. #endif // KEYBOARD_INTERFACE
  580. #ifdef MOUSE_INTERFACE
  581. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  582. 9, // bLength
  583. 4, // bDescriptorType
  584. MOUSE_INTERFACE, // bInterfaceNumber
  585. 0, // bAlternateSetting
  586. 1, // bNumEndpoints
  587. 0x03, // bInterfaceClass (0x03 = HID)
  588. 0x00, // bInterfaceSubClass (0x01 = Boot)
  589. 0x00, // bInterfaceProtocol (0x02 = Mouse)
  590. 0, // iInterface
  591. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  592. 9, // bLength
  593. 0x21, // bDescriptorType
  594. 0x11, 0x01, // bcdHID
  595. 0, // bCountryCode
  596. 1, // bNumDescriptors
  597. 0x22, // bDescriptorType
  598. LSB(sizeof(mouse_report_desc)), // wDescriptorLength
  599. MSB(sizeof(mouse_report_desc)),
  600. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  601. 7, // bLength
  602. 5, // bDescriptorType
  603. MOUSE_ENDPOINT | 0x80, // bEndpointAddress
  604. 0x03, // bmAttributes (0x03=intr)
  605. MOUSE_SIZE, 0, // wMaxPacketSize
  606. MOUSE_INTERVAL, // bInterval
  607. #endif // MOUSE_INTERFACE
  608. #ifdef RAWHID_INTERFACE
  609. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  610. 9, // bLength
  611. 4, // bDescriptorType
  612. RAWHID_INTERFACE, // bInterfaceNumber
  613. 0, // bAlternateSetting
  614. 2, // bNumEndpoints
  615. 0x03, // bInterfaceClass (0x03 = HID)
  616. 0x00, // bInterfaceSubClass
  617. 0x00, // bInterfaceProtocol
  618. 0, // iInterface
  619. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  620. 9, // bLength
  621. 0x21, // bDescriptorType
  622. 0x11, 0x01, // bcdHID
  623. 0, // bCountryCode
  624. 1, // bNumDescriptors
  625. 0x22, // bDescriptorType
  626. LSB(sizeof(rawhid_report_desc)), // wDescriptorLength
  627. MSB(sizeof(rawhid_report_desc)),
  628. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  629. 7, // bLength
  630. 5, // bDescriptorType
  631. RAWHID_TX_ENDPOINT | 0x80, // bEndpointAddress
  632. 0x03, // bmAttributes (0x03=intr)
  633. RAWHID_TX_SIZE, 0, // wMaxPacketSize
  634. RAWHID_TX_INTERVAL, // bInterval
  635. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  636. 7, // bLength
  637. 5, // bDescriptorType
  638. RAWHID_RX_ENDPOINT, // bEndpointAddress
  639. 0x03, // bmAttributes (0x03=intr)
  640. RAWHID_RX_SIZE, 0, // wMaxPacketSize
  641. RAWHID_RX_INTERVAL, // bInterval
  642. #endif // RAWHID_INTERFACE
  643. #ifdef FLIGHTSIM_INTERFACE
  644. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  645. 9, // bLength
  646. 4, // bDescriptorType
  647. FLIGHTSIM_INTERFACE, // bInterfaceNumber
  648. 0, // bAlternateSetting
  649. 2, // bNumEndpoints
  650. 0x03, // bInterfaceClass (0x03 = HID)
  651. 0x00, // bInterfaceSubClass
  652. 0x00, // bInterfaceProtocol
  653. 0, // iInterface
  654. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  655. 9, // bLength
  656. 0x21, // bDescriptorType
  657. 0x11, 0x01, // bcdHID
  658. 0, // bCountryCode
  659. 1, // bNumDescriptors
  660. 0x22, // bDescriptorType
  661. LSB(sizeof(flightsim_report_desc)), // wDescriptorLength
  662. MSB(sizeof(flightsim_report_desc)),
  663. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  664. 7, // bLength
  665. 5, // bDescriptorType
  666. FLIGHTSIM_TX_ENDPOINT | 0x80, // bEndpointAddress
  667. 0x03, // bmAttributes (0x03=intr)
  668. FLIGHTSIM_TX_SIZE, 0, // wMaxPacketSize
  669. FLIGHTSIM_TX_INTERVAL, // bInterval
  670. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  671. 7, // bLength
  672. 5, // bDescriptorType
  673. FLIGHTSIM_RX_ENDPOINT, // bEndpointAddress
  674. 0x03, // bmAttributes (0x03=intr)
  675. FLIGHTSIM_RX_SIZE, 0, // wMaxPacketSize
  676. FLIGHTSIM_RX_INTERVAL, // bInterval
  677. #endif // FLIGHTSIM_INTERFACE
  678. #ifdef SEREMU_INTERFACE
  679. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  680. 9, // bLength
  681. 4, // bDescriptorType
  682. SEREMU_INTERFACE, // bInterfaceNumber
  683. 0, // bAlternateSetting
  684. 2, // bNumEndpoints
  685. 0x03, // bInterfaceClass (0x03 = HID)
  686. 0x00, // bInterfaceSubClass
  687. 0x00, // bInterfaceProtocol
  688. 0, // iInterface
  689. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  690. 9, // bLength
  691. 0x21, // bDescriptorType
  692. 0x11, 0x01, // bcdHID
  693. 0, // bCountryCode
  694. 1, // bNumDescriptors
  695. 0x22, // bDescriptorType
  696. LSB(sizeof(seremu_report_desc)), // wDescriptorLength
  697. MSB(sizeof(seremu_report_desc)),
  698. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  699. 7, // bLength
  700. 5, // bDescriptorType
  701. SEREMU_TX_ENDPOINT | 0x80, // bEndpointAddress
  702. 0x03, // bmAttributes (0x03=intr)
  703. SEREMU_TX_SIZE, 0, // wMaxPacketSize
  704. SEREMU_TX_INTERVAL, // bInterval
  705. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  706. 7, // bLength
  707. 5, // bDescriptorType
  708. SEREMU_RX_ENDPOINT, // bEndpointAddress
  709. 0x03, // bmAttributes (0x03=intr)
  710. SEREMU_RX_SIZE, 0, // wMaxPacketSize
  711. SEREMU_RX_INTERVAL, // bInterval
  712. #endif // SEREMU_INTERFACE
  713. #ifdef JOYSTICK_INTERFACE
  714. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  715. 9, // bLength
  716. 4, // bDescriptorType
  717. JOYSTICK_INTERFACE, // bInterfaceNumber
  718. 0, // bAlternateSetting
  719. 1, // bNumEndpoints
  720. 0x03, // bInterfaceClass (0x03 = HID)
  721. 0x00, // bInterfaceSubClass
  722. 0x00, // bInterfaceProtocol
  723. 0, // iInterface
  724. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  725. 9, // bLength
  726. 0x21, // bDescriptorType
  727. 0x11, 0x01, // bcdHID
  728. 0, // bCountryCode
  729. 1, // bNumDescriptors
  730. 0x22, // bDescriptorType
  731. LSB(sizeof(joystick_report_desc)), // wDescriptorLength
  732. MSB(sizeof(joystick_report_desc)),
  733. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  734. 7, // bLength
  735. 5, // bDescriptorType
  736. JOYSTICK_ENDPOINT | 0x80, // bEndpointAddress
  737. 0x03, // bmAttributes (0x03=intr)
  738. JOYSTICK_SIZE, 0, // wMaxPacketSize
  739. JOYSTICK_INTERVAL, // bInterval
  740. #endif // JOYSTICK_INTERFACE
  741. #ifdef MTP_INTERFACE
  742. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  743. 9, // bLength
  744. 4, // bDescriptorType
  745. MTP_INTERFACE, // bInterfaceNumber
  746. 0, // bAlternateSetting
  747. 3, // bNumEndpoints
  748. 0x06, // bInterfaceClass (0x06 = still image)
  749. 0x01, // bInterfaceSubClass
  750. 0x01, // bInterfaceProtocol
  751. 0, // iInterface
  752. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  753. 7, // bLength
  754. 5, // bDescriptorType
  755. MTP_TX_ENDPOINT | 0x80, // bEndpointAddress
  756. 0x02, // bmAttributes (0x02=bulk)
  757. MTP_TX_SIZE, 0, // wMaxPacketSize
  758. 0, // bInterval
  759. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  760. 7, // bLength
  761. 5, // bDescriptorType
  762. MTP_RX_ENDPOINT, // bEndpointAddress
  763. 0x02, // bmAttributes (0x02=bulk)
  764. MTP_RX_SIZE, 0, // wMaxPacketSize
  765. 0, // bInterval
  766. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  767. 7, // bLength
  768. 5, // bDescriptorType
  769. MTP_EVENT_ENDPOINT | 0x80, // bEndpointAddress
  770. 0x03, // bmAttributes (0x03=intr)
  771. MTP_EVENT_SIZE, 0, // wMaxPacketSize
  772. MTP_EVENT_INTERVAL, // bInterval
  773. #endif // MTP_INTERFACE
  774. #ifdef KEYMEDIA_INTERFACE
  775. // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
  776. 9, // bLength
  777. 4, // bDescriptorType
  778. KEYMEDIA_INTERFACE, // bInterfaceNumber
  779. 0, // bAlternateSetting
  780. 1, // bNumEndpoints
  781. 0x03, // bInterfaceClass (0x03 = HID)
  782. 0x00, // bInterfaceSubClass
  783. 0x00, // bInterfaceProtocol
  784. 0, // iInterface
  785. // HID interface descriptor, HID 1.11 spec, section 6.2.1
  786. 9, // bLength
  787. 0x21, // bDescriptorType
  788. 0x11, 0x01, // bcdHID
  789. 0, // bCountryCode
  790. 1, // bNumDescriptors
  791. 0x22, // bDescriptorType
  792. LSB(sizeof(keymedia_report_desc)), // wDescriptorLength
  793. MSB(sizeof(keymedia_report_desc)),
  794. // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
  795. 7, // bLength
  796. 5, // bDescriptorType
  797. KEYMEDIA_ENDPOINT | 0x80, // bEndpointAddress
  798. 0x03, // bmAttributes (0x03=intr)
  799. KEYMEDIA_SIZE, 0, // wMaxPacketSize
  800. KEYMEDIA_INTERVAL, // bInterval
  801. #endif // KEYMEDIA_INTERFACE
  802. };
  803. // **************************************************************
  804. // String Descriptors
  805. // **************************************************************
  806. // The descriptors above can provide human readable strings,
  807. // referenced by index numbers. These descriptors are the
  808. // actual string data
  809. /* defined in usb_names.h
  810. struct usb_string_descriptor_struct {
  811. uint8_t bLength;
  812. uint8_t bDescriptorType;
  813. uint16_t wString[];
  814. };
  815. */
  816. extern struct usb_string_descriptor_struct usb_string_manufacturer_name
  817. __attribute__ ((weak, alias("usb_string_manufacturer_name_default")));
  818. extern struct usb_string_descriptor_struct usb_string_product_name
  819. __attribute__ ((weak, alias("usb_string_product_name_default")));
  820. extern struct usb_string_descriptor_struct usb_string_serial_number
  821. __attribute__ ((weak, alias("usb_string_serial_number_default")));
  822. struct usb_string_descriptor_struct string0 = {
  823. 4,
  824. 3,
  825. {0x0409}
  826. };
  827. struct usb_string_descriptor_struct usb_string_manufacturer_name_default = {
  828. 2 + MANUFACTURER_NAME_LEN * 2,
  829. 3,
  830. MANUFACTURER_NAME
  831. };
  832. struct usb_string_descriptor_struct usb_string_product_name_default = {
  833. 2 + PRODUCT_NAME_LEN * 2,
  834. 3,
  835. PRODUCT_NAME
  836. };
  837. struct usb_string_descriptor_struct usb_string_serial_number_default = {
  838. 12,
  839. 3,
  840. {0,0,0,0,0,0,0,0,0,0}
  841. };
  842. void usb_init_serialnumber(void)
  843. {
  844. char buf[11];
  845. uint32_t i, num;
  846. __disable_irq();
  847. FTFL_FSTAT = FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL;
  848. FTFL_FCCOB0 = 0x41;
  849. FTFL_FCCOB1 = 15;
  850. FTFL_FSTAT = FTFL_FSTAT_CCIF;
  851. while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF)) ; // wait
  852. num = *(uint32_t *)&FTFL_FCCOB7;
  853. __enable_irq();
  854. // add extra zero to work around OS-X CDC-ACM driver bug
  855. if (num < 10000000) num = num * 10;
  856. ultoa(num, buf, 10);
  857. for (i=0; i<10; i++) {
  858. char c = buf[i];
  859. if (!c) break;
  860. usb_string_serial_number_default.wString[i] = c;
  861. }
  862. usb_string_serial_number_default.bLength = i * 2 + 2;
  863. }
  864. // **************************************************************
  865. // Descriptors List
  866. // **************************************************************
  867. // This table provides access to all the descriptor data above.
  868. const usb_descriptor_list_t usb_descriptor_list[] = {
  869. //wValue, wIndex, address, length
  870. {0x0100, 0x0000, device_descriptor, sizeof(device_descriptor)},
  871. {0x0200, 0x0000, config_descriptor, sizeof(config_descriptor)},
  872. #ifdef SEREMU_INTERFACE
  873. {0x2200, SEREMU_INTERFACE, seremu_report_desc, sizeof(seremu_report_desc)},
  874. {0x2100, SEREMU_INTERFACE, config_descriptor+SEREMU_HID_DESC_OFFSET, 9},
  875. #endif
  876. #ifdef KEYBOARD_INTERFACE
  877. {0x2200, KEYBOARD_INTERFACE, keyboard_report_desc, sizeof(keyboard_report_desc)},
  878. {0x2100, KEYBOARD_INTERFACE, config_descriptor+KEYBOARD_HID_DESC_OFFSET, 9},
  879. #endif
  880. #ifdef MOUSE_INTERFACE
  881. {0x2200, MOUSE_INTERFACE, mouse_report_desc, sizeof(mouse_report_desc)},
  882. {0x2100, MOUSE_INTERFACE, config_descriptor+MOUSE_HID_DESC_OFFSET, 9},
  883. #endif
  884. #ifdef JOYSTICK_INTERFACE
  885. {0x2200, JOYSTICK_INTERFACE, joystick_report_desc, sizeof(joystick_report_desc)},
  886. {0x2100, JOYSTICK_INTERFACE, config_descriptor+JOYSTICK_HID_DESC_OFFSET, 9},
  887. #endif
  888. #ifdef RAWHID_INTERFACE
  889. {0x2200, RAWHID_INTERFACE, rawhid_report_desc, sizeof(rawhid_report_desc)},
  890. {0x2100, RAWHID_INTERFACE, config_descriptor+RAWHID_HID_DESC_OFFSET, 9},
  891. #endif
  892. #ifdef FLIGHTSIM_INTERFACE
  893. {0x2200, FLIGHTSIM_INTERFACE, flightsim_report_desc, sizeof(flightsim_report_desc)},
  894. {0x2100, FLIGHTSIM_INTERFACE, config_descriptor+FLIGHTSIM_HID_DESC_OFFSET, 9},
  895. #endif
  896. #ifdef KEYMEDIA_INTERFACE
  897. {0x2200, KEYMEDIA_INTERFACE, keymedia_report_desc, sizeof(keymedia_report_desc)},
  898. {0x2100, KEYMEDIA_INTERFACE, config_descriptor+KEYMEDIA_HID_DESC_OFFSET, 9},
  899. #endif
  900. {0x0300, 0x0000, (const uint8_t *)&string0, 0},
  901. {0x0301, 0x0409, (const uint8_t *)&usb_string_manufacturer_name, 0},
  902. {0x0302, 0x0409, (const uint8_t *)&usb_string_product_name, 0},
  903. {0x0303, 0x0409, (const uint8_t *)&usb_string_serial_number, 0},
  904. {0, 0, NULL, 0}
  905. };
  906. // **************************************************************
  907. // Endpoint Configuration
  908. // **************************************************************
  909. #if 0
  910. // 0x00 = not used
  911. // 0x19 = Recieve only
  912. // 0x15 = Transmit only
  913. // 0x1D = Transmit & Recieve
  914. //
  915. const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS] =
  916. {
  917. 0x00, 0x15, 0x19, 0x15, 0x00, 0x00, 0x00, 0x00,
  918. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  919. };
  920. #endif
  921. const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS] =
  922. {
  923. #if (defined(ENDPOINT1_CONFIG) && NUM_ENDPOINTS >= 1)
  924. ENDPOINT1_CONFIG,
  925. #elif (NUM_ENDPOINTS >= 1)
  926. ENDPOINT_UNUSED,
  927. #endif
  928. #if (defined(ENDPOINT2_CONFIG) && NUM_ENDPOINTS >= 2)
  929. ENDPOINT2_CONFIG,
  930. #elif (NUM_ENDPOINTS >= 2)
  931. ENDPOINT_UNUSED,
  932. #endif
  933. #if (defined(ENDPOINT3_CONFIG) && NUM_ENDPOINTS >= 3)
  934. ENDPOINT3_CONFIG,
  935. #elif (NUM_ENDPOINTS >= 3)
  936. ENDPOINT_UNUSED,
  937. #endif
  938. #if (defined(ENDPOINT4_CONFIG) && NUM_ENDPOINTS >= 4)
  939. ENDPOINT4_CONFIG,
  940. #elif (NUM_ENDPOINTS >= 4)
  941. ENDPOINT_UNUSED,
  942. #endif
  943. #if (defined(ENDPOINT5_CONFIG) && NUM_ENDPOINTS >= 5)
  944. ENDPOINT5_CONFIG,
  945. #elif (NUM_ENDPOINTS >= 5)
  946. ENDPOINT_UNUSED,
  947. #endif
  948. #if (defined(ENDPOINT6_CONFIG) && NUM_ENDPOINTS >= 6)
  949. ENDPOINT6_CONFIG,
  950. #elif (NUM_ENDPOINTS >= 6)
  951. ENDPOINT_UNUSED,
  952. #endif
  953. #if (defined(ENDPOINT7_CONFIG) && NUM_ENDPOINTS >= 7)
  954. ENDPOINT7_CONFIG,
  955. #elif (NUM_ENDPOINTS >= 7)
  956. ENDPOINT_UNUSED,
  957. #endif
  958. #if (defined(ENDPOINT8_CONFIG) && NUM_ENDPOINTS >= 8)
  959. ENDPOINT8_CONFIG,
  960. #elif (NUM_ENDPOINTS >= 8)
  961. ENDPOINT_UNUSED,
  962. #endif
  963. #if (defined(ENDPOINT9_CONFIG) && NUM_ENDPOINTS >= 9)
  964. ENDPOINT9_CONFIG,
  965. #elif (NUM_ENDPOINTS >= 9)
  966. ENDPOINT_UNUSED,
  967. #endif
  968. #if (defined(ENDPOINT10_CONFIG) && NUM_ENDPOINTS >= 10)
  969. ENDPOINT10_CONFIG,
  970. #elif (NUM_ENDPOINTS >= 10)
  971. ENDPOINT_UNUSED,
  972. #endif
  973. #if (defined(ENDPOINT11_CONFIG) && NUM_ENDPOINTS >= 11)
  974. ENDPOINT11_CONFIG,
  975. #elif (NUM_ENDPOINTS >= 11)
  976. ENDPOINT_UNUSED,
  977. #endif
  978. #if (defined(ENDPOINT12_CONFIG) && NUM_ENDPOINTS >= 12)
  979. ENDPOINT12_CONFIG,
  980. #elif (NUM_ENDPOINTS >= 12)
  981. ENDPOINT_UNUSED,
  982. #endif
  983. #if (defined(ENDPOINT13_CONFIG) && NUM_ENDPOINTS >= 13)
  984. ENDPOINT13_CONFIG,
  985. #elif (NUM_ENDPOINTS >= 13)
  986. ENDPOINT_UNUSED,
  987. #endif
  988. #if (defined(ENDPOINT14_CONFIG) && NUM_ENDPOINTS >= 14)
  989. ENDPOINT14_CONFIG,
  990. #elif (NUM_ENDPOINTS >= 14)
  991. ENDPOINT_UNUSED,
  992. #endif
  993. #if (defined(ENDPOINT15_CONFIG) && NUM_ENDPOINTS >= 15)
  994. ENDPOINT15_CONFIG,
  995. #elif (NUM_ENDPOINTS >= 15)
  996. ENDPOINT_UNUSED,
  997. #endif
  998. };
  999. #endif // NUM_ENDPOINTS
  1000. #endif // F_CPU >= 20 MHz