| 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 | |
| 31 | #ifndef _usb_desc_h_ |
| 32 | #define _usb_desc_h_ |
| 33 | |
| 34 | // This header is NOT meant to be included when compiling |
| 35 | // user sketches in Arduino. The low-level functions |
| 36 | // provided by usb_dev.c are meant to be called only by |
| 37 | // code which provides higher-level interfaces to the user. |
| 38 | |
| 39 | #include <stdint.h> |
| 40 | #include <stddef.h> |
| 41 | |
| 42 | #define ENDPOINT_UNUSED 0x00 |
| 43 | #define ENDPOINT_TRANSIMIT_ONLY 0x15 |
| 44 | #define ENDPOINT_RECEIVE_ONLY 0x19 |
| 45 | #define ENDPOINT_TRANSMIT_AND_RECEIVE 0x1D |
| 46 | |
| 47 | /* |
| 48 | To modify a USB Type to have different interfaces, start in this |
| 49 | file. Delete the XYZ_INTERFACE lines for any interfaces you |
| 50 | wish to remove, and copy them from another USB Type for any you |
| 51 | want to add. |
| 52 | |
| 53 | Give each interface a unique number, and edit NUM_INTERFACE to |
| 54 | reflect the number of interfaces. |
| 55 | |
| 56 | Within each interface, make sure it uses a unique set of endpoints. |
| 57 | Edit NUM_ENDPOINTS to be at least the largest endpoint number used. |
| 58 | Then edit the ENDPOINT*_CONFIG lines so each endpoint is configured |
| 59 | the proper way (transmit, receive, or both). |
| 60 | |
| 61 | The CONFIG_DESC_SIZE and any XYZ_DESC_OFFSET numbers must be |
| 62 | edited to the correct sizes. See usb_desc.c for the giant array |
| 63 | of bytes. Someday these may be done automatically..... (but how?) |
| 64 | |
| 65 | If you are using existing interfaces, the code in each file should |
| 66 | automatically adapt to the changes you specify. If you need to |
| 67 | create a new type of interface, you'll need to write the code which |
| 68 | sends and receives packets, and presents an API to the user. |
| 69 | |
| 70 | Finally, edit usb_inst.cpp, which creats instances of the C++ |
| 71 | objects for each combination. |
| 72 | |
| 73 | Some operating systems, especially Windows, may cache USB device |
| 74 | info. Changes to the device name may not update on the same |
| 75 | computer unless the vendor or product ID numbers change, or the |
| 76 | "bcdDevice" revision code is increased. |
| 77 | |
| 78 | If these instructions are missing steps or could be improved, please |
| 79 | let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports |
| 80 | */ |
| 81 | |
| 82 | |
| 83 | |
| 84 | #if defined(USB_SERIAL) |
| 85 | #define VENDOR_ID 0x16C0 |
| 86 | #define PRODUCT_ID 0x0483 |
| 87 | #define DEVICE_CLASS 2 // 2 = Communication Class |
| 88 | #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'} |
| 89 | #define MANUFACTURER_NAME_LEN 11 |
| 90 | #define PRODUCT_NAME {'U','S','B',' ','S','e','r','i','a','l'} |
| 91 | #define PRODUCT_NAME_LEN 10 |
| 92 | #define EP0_SIZE 64 |
| 93 | #define NUM_ENDPOINTS 4 |
| 94 | #define NUM_USB_BUFFERS 12 |
| 95 | #define NUM_INTERFACE 2 |
| 96 | #define CDC_STATUS_INTERFACE 0 |
| 97 | #define CDC_DATA_INTERFACE 1 |
| 98 | #define CDC_ACM_ENDPOINT 2 |
| 99 | #define CDC_RX_ENDPOINT 3 |
| 100 | #define CDC_TX_ENDPOINT 4 |
| 101 | #define CDC_ACM_SIZE 16 |
| 102 | #define CDC_RX_SIZE 64 |
| 103 | #define CDC_TX_SIZE 64 |
| 104 | #define CONFIG_DESC_SIZE (9+9+5+5+4+5+7+9+7+7) |
| 105 | #define ENDPOINT2_CONFIG ENDPOINT_TRANSIMIT_ONLY |
| 106 | #define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_ONLY |
| 107 | #define ENDPOINT4_CONFIG ENDPOINT_TRANSIMIT_ONLY |
| 108 | |
| 109 | #elif defined(USB_HID) |
| 110 | #define VENDOR_ID 0x16C0 |
| 111 | #define PRODUCT_ID 0x0482 |
| 112 | #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'} |
| 113 | #define MANUFACTURER_NAME_LEN 11 |
| 114 | #define PRODUCT_NAME {'K','e','y','b','o','a','r','d','/','M','o','u','s','e','/','J','o','y','s','t','i','c','k'} |
| 115 | #define PRODUCT_NAME_LEN 23 |
| 116 | #define EP0_SIZE 64 |
| 117 | #define NUM_ENDPOINTS 5 |
| 118 | #define NUM_USB_BUFFERS 24 |
| 119 | #define NUM_INTERFACE 4 |
| 120 | #define SEREMU_INTERFACE 2 // Serial emulation |
| 121 | #define SEREMU_TX_ENDPOINT 1 |
| 122 | #define SEREMU_TX_SIZE 64 |
| 123 | #define SEREMU_TX_INTERVAL 1 |
| 124 | #define SEREMU_RX_ENDPOINT 2 |
| 125 | #define SEREMU_RX_SIZE 32 |
| 126 | #define SEREMU_RX_INTERVAL 2 |
| 127 | #define KEYBOARD_INTERFACE 0 // Keyboard |
| 128 | #define KEYBOARD_ENDPOINT 3 |
| 129 | #define KEYBOARD_SIZE 8 |
| 130 | #define KEYBOARD_INTERVAL 1 |
| 131 | #define MOUSE_INTERFACE 1 // Mouse |
| 132 | #define MOUSE_ENDPOINT 5 |
| 133 | #define MOUSE_SIZE 8 |
| 134 | #define MOUSE_INTERVAL 1 |
| 135 | #define JOYSTICK_INTERFACE 3 // Joystick |
| 136 | #define JOYSTICK_ENDPOINT 4 |
| 137 | #define JOYSTICK_SIZE 16 |
| 138 | #define JOYSTICK_INTERVAL 2 |
| 139 | #define KEYBOARD_DESC_OFFSET (9 + 9) |
| 140 | #define MOUSE_DESC_OFFSET (9 + 9+9+7 + 9) |
| 141 | #define SEREMU_DESC_OFFSET (9 + 9+9+7 + 9+9+7 + 9) |
| 142 | #define JOYSTICK_DESC_OFFSET (9 + 9+9+7 + 9+9+7 + 9+9+7+7 + 9) |
| 143 | #define CONFIG_DESC_SIZE (9 + 9+9+7 + 9+9+7 + 9+9+7+7 + 9+9+7) |
| 144 | #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY |
| 145 | #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY |
| 146 | #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY |
| 147 | #define ENDPOINT4_CONFIG ENDPOINT_TRANSIMIT_ONLY |
| 148 | #define ENDPOINT5_CONFIG ENDPOINT_TRANSIMIT_ONLY |
| 149 | |
| 150 | #elif defined(USB_SERIAL_HID) |
| 151 | #define VENDOR_ID 0x16C0 |
| 152 | #define PRODUCT_ID 0x0487 |
| 153 | #define DEVICE_CLASS 0xEF |
| 154 | #define DEVICE_SUBCLASS 0x02 |
| 155 | #define DEVICE_PROTOCOL 0x01 |
| 156 | #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'} |
| 157 | #define MANUFACTURER_NAME_LEN 11 |
| 158 | #define PRODUCT_NAME {'S','e','r','i','a','l','/','K','e','y','b','o','a','r','d','/','M','o','u','s','e','/','J','o','y','s','t','i','c','k'} |
| 159 | #define PRODUCT_NAME_LEN 30 |
| 160 | #define EP0_SIZE 64 |
| 161 | #define NUM_ENDPOINTS 6 |
| 162 | #define NUM_USB_BUFFERS 30 |
| 163 | #define NUM_INTERFACE 5 |
| 164 | #define CDC_IAD_DESCRIPTOR 1 |
| 165 | #define CDC_STATUS_INTERFACE 0 |
| 166 | #define CDC_DATA_INTERFACE 1 // Serial |
| 167 | #define CDC_ACM_ENDPOINT 2 |
| 168 | #define CDC_RX_ENDPOINT 3 |
| 169 | #define CDC_TX_ENDPOINT 4 |
| 170 | #define CDC_ACM_SIZE 16 |
| 171 | #define CDC_RX_SIZE 64 |
| 172 | #define CDC_TX_SIZE 64 |
| 173 | #define KEYBOARD_INTERFACE 2 // Keyboard |
| 174 | #define KEYBOARD_ENDPOINT 1 |
| 175 | #define KEYBOARD_SIZE 8 |
| 176 | #define KEYBOARD_INTERVAL 1 |
| 177 | #define MOUSE_INTERFACE 3 // Mouse |
| 178 | #define MOUSE_ENDPOINT 5 |
| 179 | #define MOUSE_SIZE 8 |
| 180 | #define MOUSE_INTERVAL 2 |
| 181 | #define JOYSTICK_INTERFACE 4 // Joystick |
| 182 | #define JOYSTICK_ENDPOINT 6 |
| 183 | #define JOYSTICK_SIZE 16 |
| 184 | #define JOYSTICK_INTERVAL 1 |
| 185 | #define KEYBOARD_DESC_OFFSET (9+8 + 9+5+5+4+5+7+9+7+7 + 9) |
| 186 | #define MOUSE_DESC_OFFSET (9+8 + 9+5+5+4+5+7+9+7+7 + 9+9+7 + 9) |
| 187 | #define JOYSTICK_DESC_OFFSET (9+8 + 9+5+5+4+5+7+9+7+7 + 9+9+7 + 9+9+7 + 9) |
| 188 | #define CONFIG_DESC_SIZE (9+8 + 9+5+5+4+5+7+9+7+7 + 9+9+7 + 9+9+7 + 9+9+7) |
| 189 | #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY |
| 190 | #define ENDPOINT2_CONFIG ENDPOINT_TRANSIMIT_ONLY |
| 191 | #define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_ONLY |
| 192 | #define ENDPOINT4_CONFIG ENDPOINT_TRANSIMIT_ONLY |
| 193 | #define ENDPOINT5_CONFIG ENDPOINT_TRANSIMIT_ONLY |
| 194 | #define ENDPOINT6_CONFIG ENDPOINT_TRANSIMIT_ONLY |
| 195 | |
| 196 | #elif defined(USB_MIDI) |
| 197 | #define VENDOR_ID 0x16C0 |
| 198 | #define PRODUCT_ID 0x0485 |
| 199 | #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'} |
| 200 | #define MANUFACTURER_NAME_LEN 11 |
| 201 | #define PRODUCT_NAME {'T','e','e','n','s','y',' ','M','I','D','I'} |
| 202 | #define PRODUCT_NAME_LEN 11 |
| 203 | #define EP0_SIZE 64 |
| 204 | #define NUM_ENDPOINTS 4 |
| 205 | #define NUM_USB_BUFFERS 16 |
| 206 | #define NUM_INTERFACE 2 |
| 207 | #define SEREMU_INTERFACE 1 // Serial emulation |
| 208 | #define SEREMU_TX_ENDPOINT 1 |
| 209 | #define SEREMU_TX_SIZE 64 |
| 210 | #define SEREMU_TX_INTERVAL 1 |
| 211 | #define SEREMU_RX_ENDPOINT 2 |
| 212 | #define SEREMU_RX_SIZE 32 |
| 213 | #define SEREMU_RX_INTERVAL 2 |
| 214 | #define MIDI_INTERFACE 0 // MIDI |
| 215 | #define MIDI_TX_ENDPOINT 3 |
| 216 | #define MIDI_TX_SIZE 64 |
| 217 | #define MIDI_RX_ENDPOINT 4 |
| 218 | #define MIDI_RX_SIZE 64 |
| 219 | #define SEREMU_DESC_OFFSET (9 + 9+7+6+6+9+9+9+5+9+5 + 9) |
| 220 | #define CONFIG_DESC_SIZE (9 + 9+7+6+6+9+9+9+5+9+5 + 9+9+7+7) |
| 221 | #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY |
| 222 | #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY |
| 223 | #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY |
| 224 | #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ONLY |
| 225 | |
| 226 | #elif defined(USB_RAWHID) |
| 227 | #define VENDOR_ID 0x16C0 |
| 228 | #define PRODUCT_ID 0x0486 |
| 229 | #define RAWHID_USAGE_PAGE 0xFFAB // recommended: 0xFF00 to 0xFFFF |
| 230 | #define RAWHID_USAGE 0x0200 // recommended: 0x0100 to 0xFFFF |
| 231 | #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'} |
| 232 | #define MANUFACTURER_NAME_LEN 11 |
| 233 | #define PRODUCT_NAME {'T','e','e','n','s','y','d','u','i','n','o',' ','R','a','w','H','I','D'} |
| 234 | #define PRODUCT_NAME_LEN 18 |
| 235 | #define EP0_SIZE 64 |
| 236 | #define NUM_ENDPOINTS 6 |
| 237 | #define NUM_USB_BUFFERS 12 |
| 238 | #define NUM_INTERFACE 2 |
| 239 | #define RAWHID_INTERFACE 0 // RawHID |
| 240 | #define RAWHID_TX_ENDPOINT 3 |
| 241 | #define RAWHID_TX_SIZE 64 |
| 242 | #define RAWHID_TX_INTERVAL 1 |
| 243 | #define RAWHID_RX_ENDPOINT 4 |
| 244 | #define RAWHID_RX_SIZE 64 |
| 245 | #define RAWHID_RX_INTERVAL 1 |
| 246 | #define SEREMU_INTERFACE 1 // Serial emulation |
| 247 | #define SEREMU_TX_ENDPOINT 1 |
| 248 | #define SEREMU_TX_SIZE 64 |
| 249 | #define SEREMU_TX_INTERVAL 1 |
| 250 | #define SEREMU_RX_ENDPOINT 2 |
| 251 | #define SEREMU_RX_SIZE 32 |
| 252 | #define SEREMU_RX_INTERVAL 2 |
| 253 | #define RAWHID_DESC_OFFSET (9 + 9) |
| 254 | #define SEREMU_DESC_OFFSET (9 + 9+9+7+7 + 9) |
| 255 | #define CONFIG_DESC_SIZE (9 + 9+9+7+7 + 9+9+7+7) |
| 256 | #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY |
| 257 | #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY |
| 258 | #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY |
| 259 | #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ONLY |
| 260 | |
| 261 | #elif defined(USB_FLIGHTSIM) |
| 262 | #define VENDOR_ID 0x16C0 |
| 263 | #define PRODUCT_ID 0x0488 |
| 264 | #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'} |
| 265 | #define MANUFACTURER_NAME_LEN 11 |
| 266 | #define PRODUCT_NAME {'T','e','e','n','s','y',' ','F','l','i','g','h','t',' ','S','i','m',' ','C','o','n','t','r','o','l','s'} |
| 267 | #define PRODUCT_NAME_LEN 26 |
| 268 | #define EP0_SIZE 64 |
| 269 | #define NUM_ENDPOINTS 4 |
| 270 | #define NUM_USB_BUFFERS 20 |
| 271 | #define NUM_INTERFACE 2 |
| 272 | #define FLIGHTSIM_INTERFACE 0 // Flight Sim Control |
| 273 | #define FLIGHTSIM_TX_ENDPOINT 3 |
| 274 | #define FLIGHTSIM_TX_SIZE 64 |
| 275 | #define FLIGHTSIM_TX_INTERVAL 1 |
| 276 | #define FLIGHTSIM_RX_ENDPOINT 4 |
| 277 | #define FLIGHTSIM_RX_SIZE 64 |
| 278 | #define FLIGHTSIM_RX_INTERVAL 1 |
| 279 | #define SEREMU_INTERFACE 1 // Serial emulation |
| 280 | #define SEREMU_TX_ENDPOINT 1 |
| 281 | #define SEREMU_TX_SIZE 64 |
| 282 | #define SEREMU_TX_INTERVAL 1 |
| 283 | #define SEREMU_RX_ENDPOINT 2 |
| 284 | #define SEREMU_RX_SIZE 32 |
| 285 | #define SEREMU_RX_INTERVAL 2 |
| 286 | #define FLIGHTSIM_DESC_OFFSET (9 + 9) |
| 287 | #define SEREMU_DESC_OFFSET (9 + 9+9+7+7 + 9) |
| 288 | #define CONFIG_DESC_SIZE (9 + 9+9+7+7 + 9+9+7+7) |
| 289 | #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY |
| 290 | #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY |
| 291 | #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY |
| 292 | #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ONLY |
| 293 | |
| 294 | #endif |
| 295 | |
| 296 | // NUM_ENDPOINTS = number of non-zero endpoints (0 to 15) |
| 297 | extern const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS]; |
| 298 | |
| 299 | typedef struct { |
| 300 | uint16_t wValue; |
| 301 | uint16_t wIndex; |
| 302 | const uint8_t *addr; |
| 303 | uint16_t length; |
| 304 | } usb_descriptor_list_t; |
| 305 | |
| 306 | extern const usb_descriptor_list_t usb_descriptor_list[]; |
| 307 | |
| 308 | |
| 309 | #endif |