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