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