comparison Output/pjrcUSB/arm/usb_desc.c @ 308:ab4515606277

Fix whitespace Use a consistent standard - Tabs in front for indenting, spaces after for anything else. This way everything stays nice and lined up while also letting users change there prefered indent level. Most of the new files from Haata where already in this format.
author Rowan Decker <Smasher816@gmail.com>
date Sun, 08 Mar 2015 18:40:01 -0700
parents 708af1b9bc55
children 06a54d582bf8
comparison
equal deleted inserted replaced
305:4617ef5e06f1 308:ab4515606277
46 // ----- USB Device Descriptor ----- 46 // ----- USB Device Descriptor -----
47 47
48 // USB Device Descriptor. The USB host reads this first, to learn 48 // USB Device Descriptor. The USB host reads this first, to learn
49 // what type of device is connected. 49 // what type of device is connected.
50 static uint8_t device_descriptor[] = { 50 static uint8_t device_descriptor[] = {
51 18, // bLength 51 18, // bLength
52 1, // bDescriptorType 52 1, // bDescriptorType
53 0x00, 0x02, // bcdUSB 53 0x00, 0x02, // bcdUSB
54 DEVICE_CLASS, // bDeviceClass 54 DEVICE_CLASS, // bDeviceClass
55 DEVICE_SUBCLASS, // bDeviceSubClass 55 DEVICE_SUBCLASS, // bDeviceSubClass
56 DEVICE_PROTOCOL, // bDeviceProtocol 56 DEVICE_PROTOCOL, // bDeviceProtocol
57 EP0_SIZE, // bMaxPacketSize0 57 EP0_SIZE, // bMaxPacketSize0
58 LSB(VENDOR_ID), MSB(VENDOR_ID), // idVendor 58 LSB(VENDOR_ID), MSB(VENDOR_ID), // idVendor
59 LSB(PRODUCT_ID), MSB(PRODUCT_ID), // idProduct 59 LSB(PRODUCT_ID), MSB(PRODUCT_ID), // idProduct
60 0x00, 0x01, // bcdDevice 60 0x00, 0x01, // bcdDevice
61 1, // iManufacturer 61 1, // iManufacturer
62 2, // iProduct 62 2, // iProduct
63 3, // iSerialNumber 63 3, // iSerialNumber
64 1 // bNumConfigurations 64 1 // bNumConfigurations
65 }; 65 };
66 66
67 // USB Device Qualifier Descriptor 67 // USB Device Qualifier Descriptor
68 static uint8_t device_qualifier_descriptor[] = { 68 static uint8_t device_qualifier_descriptor[] = {
69 0 // Indicate only single speed 69 0 // Indicate only single speed
70 /* Device qualifier example (used for specifying multiple USB speeds) 70 /* Device qualifier example (used for specifying multiple USB speeds)
71 10, // bLength 71 10, // bLength
72 6, // bDescriptorType 72 6, // bDescriptorType
73 0x00, 0x02, // bcdUSB 73 0x00, 0x02, // bcdUSB
74 DEVICE_CLASS, // bDeviceClass 74 DEVICE_CLASS, // bDeviceClass
75 DEVICE_SUBCLASS, // bDeviceSubClass 75 DEVICE_SUBCLASS, // bDeviceSubClass
76 DEVICE_PROTOCOL, // bDeviceProtocol 76 DEVICE_PROTOCOL, // bDeviceProtocol
77 EP0_SIZE, // bMaxPacketSize0 77 EP0_SIZE, // bMaxPacketSize0
78 0, // bNumOtherSpeedConfigurations 78 0, // bNumOtherSpeedConfigurations
79 0 // bReserved 79 0 // bReserved
80 */ 80 */
81 }; 81 };
82 82
100 // the meaning and format of the data. 100 // the meaning and format of the data.
101 101
102 // Keyboard Protocol 1, HID 1.11 spec, Appendix B, page 59-60 102 // Keyboard Protocol 1, HID 1.11 spec, Appendix B, page 59-60
103 static uint8_t keyboard_report_desc[] = { 103 static uint8_t keyboard_report_desc[] = {
104 // Keyboard Collection 104 // Keyboard Collection
105 0x05, 0x01, // Usage Page (Generic Desktop), 105 0x05, 0x01, // Usage Page (Generic Desktop),
106 0x09, 0x06, // Usage (Keyboard), 106 0x09, 0x06, // Usage (Keyboard),
107 0xA1, 0x01, // Collection (Application) - Keyboard, 107 0xA1, 0x01, // Collection (Application) - Keyboard,
108 108
109 // Modifier Byte 109 // Modifier Byte
110 0x75, 0x01, // Report Size (1), 110 0x75, 0x01, // Report Size (1),
111 0x95, 0x08, // Report Count (8), 111 0x95, 0x08, // Report Count (8),
112 0x05, 0x07, // Usage Page (Key Codes), 112 0x05, 0x07, // Usage Page (Key Codes),
113 0x19, 0xE0, // Usage Minimum (224), 113 0x19, 0xE0, // Usage Minimum (224),
114 0x29, 0xE7, // Usage Maximum (231), 114 0x29, 0xE7, // Usage Maximum (231),
115 0x15, 0x00, // Logical Minimum (0), 115 0x15, 0x00, // Logical Minimum (0),
116 0x25, 0x01, // Logical Maximum (1), 116 0x25, 0x01, // Logical Maximum (1),
117 0x81, 0x02, // Input (Data, Variable, Absolute), 117 0x81, 0x02, // Input (Data, Variable, Absolute),
118 118
119 // Reserved Byte 119 // Reserved Byte
120 0x75, 0x08, // Report Size (8), 120 0x75, 0x08, // Report Size (8),
121 0x95, 0x01, // Report Count (1), 121 0x95, 0x01, // Report Count (1),
122 0x81, 0x03, // Output (Constant), 122 0x81, 0x03, // Output (Constant),
123 123
124 // LED Report 124 // LED Report
125 0x75, 0x01, // Report Size (1), 125 0x75, 0x01, // Report Size (1),
126 0x95, 0x05, // Report Count (5), 126 0x95, 0x05, // Report Count (5),
127 0x05, 0x08, // Usage Page (LEDs), 127 0x05, 0x08, // Usage Page (LEDs),
128 0x19, 0x01, // Usage Minimum (1), 128 0x19, 0x01, // Usage Minimum (1),
129 0x29, 0x05, // Usage Maximum (5), 129 0x29, 0x05, // Usage Maximum (5),
130 0x91, 0x02, // Output (Data, Variable, Absolute), 130 0x91, 0x02, // Output (Data, Variable, Absolute),
131 131
132 // LED Report Padding 132 // LED Report Padding
133 0x75, 0x03, // Report Size (3), 133 0x75, 0x03, // Report Size (3),
134 0x95, 0x01, // Report Count (1), 134 0x95, 0x01, // Report Count (1),
135 0x91, 0x03, // Output (Constant), 135 0x91, 0x03, // Output (Constant),
136 136
137 // Normal Keys 137 // Normal Keys
138 0x75, 0x08, // Report Size (8), 138 0x75, 0x08, // Report Size (8),
139 0x95, 0x06, // Report Count (6), 139 0x95, 0x06, // Report Count (6),
140 0x15, 0x00, // Logical Minimum (0), 140 0x15, 0x00, // Logical Minimum (0),
141 0x25, 0x7F, // Logical Maximum(104), 141 0x25, 0x7F, // Logical Maximum(104),
142 0x05, 0x07, // Usage Page (Key Codes), 142 0x05, 0x07, // Usage Page (Key Codes),
143 0x19, 0x00, // Usage Minimum (0), 143 0x19, 0x00, // Usage Minimum (0),
144 0x29, 0x7F, // Usage Maximum (104), 144 0x29, 0x7F, // Usage Maximum (104),
145 0x81, 0x00, // Input (Data, Array), 145 0x81, 0x00, // Input (Data, Array),
146 0xc0, // End Collection - Keyboard 146 0xc0, // End Collection - Keyboard
147 }; 147 };
148 148
149 // Keyboard Protocol 1, HID 1.11 spec, Appendix B, page 59-60 149 // Keyboard Protocol 1, HID 1.11 spec, Appendix B, page 59-60
150 static uint8_t nkro_keyboard_report_desc[] = { 150 static uint8_t nkro_keyboard_report_desc[] = {
151 // Keyboard Collection 151 // Keyboard Collection
152 0x05, 0x01, // Usage Page (Generic Desktop), 152 0x05, 0x01, // Usage Page (Generic Desktop),
153 0x09, 0x06, // Usage (Keyboard), 153 0x09, 0x06, // Usage (Keyboard),
154 0xA1, 0x01, // Collection (Application) - Keyboard, 154 0xA1, 0x01, // Collection (Application) - Keyboard,
155 155
156 // LED Report 156 // LED Report
157 0x85, 0x01, // Report ID (1), 157 0x85, 0x01, // Report ID (1),
158 0x75, 0x01, // Report Size (1), 158 0x75, 0x01, // Report Size (1),
159 0x95, 0x05, // Report Count (5), 159 0x95, 0x05, // Report Count (5),
160 0x05, 0x08, // Usage Page (LEDs), 160 0x05, 0x08, // Usage Page (LEDs),
161 0x19, 0x01, // Usage Minimum (1), 161 0x19, 0x01, // Usage Minimum (1),
162 0x29, 0x05, // Usage Maximum (5), 162 0x29, 0x05, // Usage Maximum (5),
163 0x91, 0x02, // Output (Data, Variable, Absolute), 163 0x91, 0x02, // Output (Data, Variable, Absolute),
164 164
165 // LED Report Padding 165 // LED Report Padding
166 0x75, 0x03, // Report Size (3), 166 0x75, 0x03, // Report Size (3),
167 0x95, 0x01, // Report Count (1), 167 0x95, 0x01, // Report Count (1),
168 0x91, 0x03, // Output (Constant), 168 0x91, 0x03, // Output (Constant),
169 169
170 // Normal Keys - Using an NKRO Bitmap 170 // Normal Keys - Using an NKRO Bitmap
171 // 171 //
172 // NOTES: 172 // NOTES:
173 // Supports all keys defined by the spec, except 1-3 which define error events 173 // Supports all keys defined by the spec, except 1-3 which define error events
194 // 157-164 : 1 byte (0x9D-0xA4) ( 8 bits) 194 // 157-164 : 1 byte (0x9D-0xA4) ( 8 bits)
195 // 176-221 : 6 bytes (0xB0-0xDD) ( 46 bits + 2 padding bits for 6 bytes total) 195 // 176-221 : 6 bytes (0xB0-0xDD) ( 46 bits + 2 padding bits for 6 bytes total)
196 // 224-231 : 1 byte (0xE0-0xE7) ( 8 bits) 196 // 224-231 : 1 byte (0xE0-0xE7) ( 8 bits)
197 197
198 // Modifier Byte 198 // Modifier Byte
199 0x75, 0x01, // Report Size (1), 199 0x75, 0x01, // Report Size (1),
200 0x95, 0x08, // Report Count (8), 200 0x95, 0x08, // Report Count (8),
201 0x15, 0x00, // Logical Minimum (0), 201 0x15, 0x00, // Logical Minimum (0),
202 0x25, 0x01, // Logical Maximum (1), 202 0x25, 0x01, // Logical Maximum (1),
203 0x05, 0x07, // Usage Page (Key Codes), 203 0x05, 0x07, // Usage Page (Key Codes),
204 0x19, 0xE0, // Usage Minimum (224), 204 0x19, 0xE0, // Usage Minimum (224),
205 0x29, 0xE7, // Usage Maximum (231), 205 0x29, 0xE7, // Usage Maximum (231),
206 0x81, 0x02, // Input (Data, Variable, Absolute), 206 0x81, 0x02, // Input (Data, Variable, Absolute),
207 207
208 // 4-49 (6 bytes/46 bits) - MainKeys 208 // 4-49 (6 bytes/46 bits) - MainKeys
209 0x75, 0x01, // Report Size (1), 209 0x75, 0x01, // Report Size (1),
210 0x95, 0x2E, // Report Count (46), 210 0x95, 0x2E, // Report Count (46),
211 0x15, 0x00, // Logical Minimum (0), 211 0x15, 0x00, // Logical Minimum (0),
212 0x25, 0x01, // Logical Maximum (1), 212 0x25, 0x01, // Logical Maximum (1),
213 0x05, 0x07, // Usage Page (Key Codes), 213 0x05, 0x07, // Usage Page (Key Codes),
214 0x19, 0x04, // Usage Minimum (4), 214 0x19, 0x04, // Usage Minimum (4),
215 0x29, 0x31, // Usage Maximum (49), 215 0x29, 0x31, // Usage Maximum (49),
216 0x81, 0x02, // Input (Data, Variable, Absolute, Bitfield), 216 0x81, 0x02, // Input (Data, Variable, Absolute, Bitfield),
217 217
218 // Padding (2 bits) 218 // Padding (2 bits)
219 0x75, 0x02, // Report Size (2), 219 0x75, 0x02, // Report Size (2),
220 0x95, 0x01, // Report Count (1), 220 0x95, 0x01, // Report Count (1),
221 0x81, 0x03, // Input (Constant), 221 0x81, 0x03, // Input (Constant),
222 222
223 // 51-155 (14 bytes/105 bits) - SecondaryKeys 223 // 51-155 (14 bytes/105 bits) - SecondaryKeys
224 0x75, 0x01, // Report Size (1), 224 0x75, 0x01, // Report Size (1),
225 0x95, 0x69, // Report Count (105), 225 0x95, 0x69, // Report Count (105),
226 0x15, 0x00, // Logical Minimum (0), 226 0x15, 0x00, // Logical Minimum (0),
227 0x25, 0x01, // Logical Maximum (1), 227 0x25, 0x01, // Logical Maximum (1),
228 0x05, 0x07, // Usage Page (Key Codes), 228 0x05, 0x07, // Usage Page (Key Codes),
229 0x19, 0x33, // Usage Minimum (51), 229 0x19, 0x33, // Usage Minimum (51),
230 0x29, 0x9B, // Usage Maximum (155), 230 0x29, 0x9B, // Usage Maximum (155),
231 0x81, 0x02, // Input (Data, Variable, Absolute, Bitfield), 231 0x81, 0x02, // Input (Data, Variable, Absolute, Bitfield),
232 232
233 // Padding (7 bits) 233 // Padding (7 bits)
234 0x75, 0x07, // Report Size (7), 234 0x75, 0x07, // Report Size (7),
235 0x95, 0x01, // Report Count (1), 235 0x95, 0x01, // Report Count (1),
236 0x81, 0x03, // Input (Constant), 236 0x81, 0x03, // Input (Constant),
237 237
238 // 157-164 (1 byte/8 bits) - TertiaryKeys 238 // 157-164 (1 byte/8 bits) - TertiaryKeys
239 0x75, 0x01, // Report Size (1), 239 0x75, 0x01, // Report Size (1),
240 0x95, 0x08, // Report Count (8), 240 0x95, 0x08, // Report Count (8),
241 0x15, 0x00, // Logical Minimum (0), 241 0x15, 0x00, // Logical Minimum (0),
242 0x25, 0x01, // Logical Maximum (1), 242 0x25, 0x01, // Logical Maximum (1),
243 0x05, 0x07, // Usage Page (Key Codes), 243 0x05, 0x07, // Usage Page (Key Codes),
244 0x19, 0x9D, // Usage Minimum (157), 244 0x19, 0x9D, // Usage Minimum (157),
245 0x29, 0xA4, // Usage Maximum (164), 245 0x29, 0xA4, // Usage Maximum (164),
246 0x81, 0x02, // Input (Data, Variable, Absolute, Bitfield), 246 0x81, 0x02, // Input (Data, Variable, Absolute, Bitfield),
247 247
248 // 176-221 (6 bytes/46 bits) - QuartiaryKeys 248 // 176-221 (6 bytes/46 bits) - QuartiaryKeys
249 0x75, 0x01, // Report Size (1), 249 0x75, 0x01, // Report Size (1),
250 0x95, 0x2E, // Report Count (46), 250 0x95, 0x2E, // Report Count (46),
251 0x15, 0x00, // Logical Minimum (0), 251 0x15, 0x00, // Logical Minimum (0),
252 0x25, 0x01, // Logical Maximum (1), 252 0x25, 0x01, // Logical Maximum (1),
253 0x05, 0x07, // Usage Page (Key Codes), 253 0x05, 0x07, // Usage Page (Key Codes),
254 0x19, 0xB0, // Usage Minimum (176), 254 0x19, 0xB0, // Usage Minimum (176),
255 0x29, 0xDD, // Usage Maximum (221), 255 0x29, 0xDD, // Usage Maximum (221),
256 0x81, 0x02, // Input (Data, Variable, Absolute, Bitfield), 256 0x81, 0x02, // Input (Data, Variable, Absolute, Bitfield),
257 257
258 // Padding (2 bits) 258 // Padding (2 bits)
259 0x75, 0x02, // Report Size (2), 259 0x75, 0x02, // Report Size (2),
260 0x95, 0x01, // Report Count (1), 260 0x95, 0x01, // Report Count (1),
261 0x81, 0x03, // Input (Constant), 261 0x81, 0x03, // Input (Constant),
262 0xc0, // End Collection - Keyboard 262 0xc0, // End Collection - Keyboard
263 263
264 // System Control Collection 264 // System Control Collection
265 // 265 //
266 // NOTES: 266 // NOTES:
267 // Not bothering with NKRO for this table. If there's need, I can implement it. -HaaTa 267 // Not bothering with NKRO for this table. If there's need, I can implement it. -HaaTa
268 // Using a 1KRO scheme 268 // Using a 1KRO scheme
269 0x05, 0x01, // Usage Page (Generic Desktop), 269 0x05, 0x01, // Usage Page (Generic Desktop),
270 0x09, 0x80, // Usage (System Control), 270 0x09, 0x80, // Usage (System Control),
271 0xA1, 0x01, // Collection (Application), 271 0xA1, 0x01, // Collection (Application),
272 0x85, 0x02, // Report ID (2), 272 0x85, 0x02, // Report ID (2),
273 0x75, 0x08, // Report Size (8), 273 0x75, 0x08, // Report Size (8),
274 0x95, 0x01, // Report Count (1), 274 0x95, 0x01, // Report Count (1),
275 0x16, 0x81, 0x00, // Logical Minimum (129), 275 0x16, 0x81, 0x00, // Logical Minimum (129),
276 0x26, 0xB7, 0x00, // Logical Maximum (183), 276 0x26, 0xB7, 0x00, // Logical Maximum (183),
277 0x19, 0x81, // Usage Minimum (129), 277 0x19, 0x81, // Usage Minimum (129),
278 0x29, 0xB7, // Usage Maximum (183), 278 0x29, 0xB7, // Usage Maximum (183),
279 0x81, 0x00, // Input (Data, Array), 279 0x81, 0x00, // Input (Data, Array),
280 0xc0, // End Collection - System Control 280 0xc0, // End Collection - System Control
281 281
282 // Consumer Control Collection - Media Keys 282 // Consumer Control Collection - Media Keys
283 // 283 //
284 // NOTES: 284 // NOTES:
285 // Not bothering with NKRO for this table. If there's a need, I can implement it. -HaaTa 285 // Not bothering with NKRO for this table. If there's a need, I can implement it. -HaaTa
286 // Using a 1KRO scheme 286 // Using a 1KRO scheme
287 0x05, 0x0c, // Usage Page (Consumer), 287 0x05, 0x0c, // Usage Page (Consumer),
288 0x09, 0x01, // Usage (Consumer Control), 288 0x09, 0x01, // Usage (Consumer Control),
289 0xA1, 0x01, // Collection (Application), 289 0xA1, 0x01, // Collection (Application),
290 0x85, 0x03, // Report ID (3), 290 0x85, 0x03, // Report ID (3),
291 0x75, 0x10, // Report Size (16), 291 0x75, 0x10, // Report Size (16),
292 0x95, 0x01, // Report Count (1), 292 0x95, 0x01, // Report Count (1),
293 0x16, 0x20, 0x00, // Logical Minimum (32), 293 0x16, 0x20, 0x00, // Logical Minimum (32),
294 0x26, 0x9C, 0x02, // Logical Maximum (668), 294 0x26, 0x9C, 0x02, // Logical Maximum (668),
295 0x05, 0x0C, // Usage Page (Consumer), 295 0x05, 0x0C, // Usage Page (Consumer),
296 0x19, 0x20, // Usage Minimum (32), 296 0x19, 0x20, // Usage Minimum (32),
297 0x2A, 0x9C, 0x02, // Usage Maximum (668), 297 0x2A, 0x9C, 0x02, // Usage Maximum (668),
298 0x81, 0x00, // Input (Data, Array), 298 0x81, 0x00, // Input (Data, Array),
299 0xc0, // End Collection - Consumer Control 299 0xc0, // End Collection - Consumer Control
300 }; 300 };
301 301
302 /* MOUSE 302 /* MOUSE
303 // Mouse Protocol 1, HID 1.11 spec, Appendix B, page 59-60, with wheel extension 303 // Mouse Protocol 1, HID 1.11 spec, Appendix B, page 59-60, with wheel extension
304 static uint8_t mouse_report_desc[] = { 304 static uint8_t mouse_report_desc[] = {
305 0x05, 0x01, // Usage Page (Generic Desktop) 305 0x05, 0x01, // Usage Page (Generic Desktop)
306 0x09, 0x02, // Usage (Mouse) 306 0x09, 0x02, // Usage (Mouse)
307 0xA1, 0x01, // Collection (Application) 307 0xA1, 0x01, // Collection (Application)
308 0x05, 0x09, // Usage Page (Button) 308 0x05, 0x09, // Usage Page (Button)
309 0x19, 0x01, // Usage Minimum (Button #1) 309 0x19, 0x01, // Usage Minimum (Button #1)
310 0x29, 0x03, // Usage Maximum (Button #3) 310 0x29, 0x03, // Usage Maximum (Button #3)
311 0x15, 0x00, // Logical Minimum (0) 311 0x15, 0x00, // Logical Minimum (0)
312 0x25, 0x01, // Logical Maximum (1) 312 0x25, 0x01, // Logical Maximum (1)
313 0x95, 0x03, // Report Count (3) 313 0x95, 0x03, // Report Count (3)
314 0x75, 0x01, // Report Size (1) 314 0x75, 0x01, // Report Size (1)
315 0x81, 0x02, // Input (Data, Variable, Absolute) 315 0x81, 0x02, // Input (Data, Variable, Absolute)
316 0x95, 0x01, // Report Count (1) 316 0x95, 0x01, // Report Count (1)
317 0x75, 0x05, // Report Size (5) 317 0x75, 0x05, // Report Size (5)
318 0x81, 0x03, // Input (Constant) 318 0x81, 0x03, // Input (Constant)
319 0x05, 0x01, // Usage Page (Generic Desktop) 319 0x05, 0x01, // Usage Page (Generic Desktop)
320 0x09, 0x30, // Usage (X) 320 0x09, 0x30, // Usage (X)
321 0x09, 0x31, // Usage (Y) 321 0x09, 0x31, // Usage (Y)
322 0x15, 0x00, // Logical Minimum (0) 322 0x15, 0x00, // Logical Minimum (0)
323 0x26, 0xFF, 0x7F, // Logical Maximum (32767) 323 0x26, 0xFF, 0x7F, // Logical Maximum (32767)
324 0x75, 0x10, // Report Size (16), 324 0x75, 0x10, // Report Size (16),
325 0x95, 0x02, // Report Count (2), 325 0x95, 0x02, // Report Count (2),
326 0x81, 0x02, // Input (Data, Variable, Absolute) 326 0x81, 0x02, // Input (Data, Variable, Absolute)
327 0x09, 0x38, // Usage (Wheel) 327 0x09, 0x38, // Usage (Wheel)
328 0x15, 0x81, // Logical Minimum (-127) 328 0x15, 0x81, // Logical Minimum (-127)
329 0x25, 0x7F, // Logical Maximum (127) 329 0x25, 0x7F, // Logical Maximum (127)
330 0x75, 0x08, // Report Size (8), 330 0x75, 0x08, // Report Size (8),
331 0x95, 0x01, // Report Count (1), 331 0x95, 0x01, // Report Count (1),
332 0x81, 0x06, // Input (Data, Variable, Relative) 332 0x81, 0x06, // Input (Data, Variable, Relative)
333 0xC0 // End Collection 333 0xC0 // End Collection
334 }; 334 };
335 */ 335 */
336 336
337 337
338 338
341 // USB Configuration Descriptor. This huge descriptor tells all 341 // USB Configuration Descriptor. This huge descriptor tells all
342 // of the devices capbilities. 342 // of the devices capbilities.
343 static uint8_t config_descriptor[CONFIG_DESC_SIZE] = { 343 static uint8_t config_descriptor[CONFIG_DESC_SIZE] = {
344 // --- Configuration --- 344 // --- Configuration ---
345 // - 9 bytes - 345 // - 9 bytes -
346 // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10 346 // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
347 9, // bLength; 347 9, // bLength;
348 2, // bDescriptorType; 348 2, // bDescriptorType;
349 LSB(CONFIG_DESC_SIZE), // wTotalLength 349 LSB(CONFIG_DESC_SIZE), // wTotalLength
350 MSB(CONFIG_DESC_SIZE), 350 MSB(CONFIG_DESC_SIZE),
351 NUM_INTERFACE, // bNumInterfaces 351 NUM_INTERFACE, // bNumInterfaces
352 1, // bConfigurationValue 352 1, // bConfigurationValue
353 0, // iConfiguration 353 0, // iConfiguration
354 0xA0, // bmAttributes 354 0xA0, // bmAttributes
355 250, // bMaxPower 355 250, // bMaxPower
356 356
357 // --- Keyboard HID --- Boot Mode Keyboard Interface 357 // --- Keyboard HID --- Boot Mode Keyboard Interface
358 // - 9 bytes - 358 // - 9 bytes -
359 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 359 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
360 9, // bLength 360 9, // bLength
361 4, // bDescriptorType 361 4, // bDescriptorType
362 KEYBOARD_INTERFACE, // bInterfaceNumber 362 KEYBOARD_INTERFACE, // bInterfaceNumber
363 0, // bAlternateSetting 363 0, // bAlternateSetting
364 1, // bNumEndpoints 364 1, // bNumEndpoints
365 0x03, // bInterfaceClass (0x03 = HID) 365 0x03, // bInterfaceClass (0x03 = HID)
366 0x01, // bInterfaceSubClass (0x00 = Non-Boot, 0x01 = Boot) 366 0x01, // bInterfaceSubClass (0x00 = Non-Boot, 0x01 = Boot)
367 0x01, // bInterfaceProtocol (0x01 = Keyboard) 367 0x01, // bInterfaceProtocol (0x01 = Keyboard)
368 0, // iInterface 368 0, // iInterface
369 // - 9 bytes - 369 // - 9 bytes -
370 // HID interface descriptor, HID 1.11 spec, section 6.2.1 370 // HID interface descriptor, HID 1.11 spec, section 6.2.1
371 9, // bLength 371 9, // bLength
372 0x21, // bDescriptorType 372 0x21, // bDescriptorType
373 0x11, 0x01, // bcdHID 373 0x11, 0x01, // bcdHID
374 0, // bCountryCode 374 0, // bCountryCode
375 1, // bNumDescriptors 375 1, // bNumDescriptors
376 0x22, // bDescriptorType 376 0x22, // bDescriptorType
377 LSB(sizeof(keyboard_report_desc)), // wDescriptorLength 377 LSB(sizeof(keyboard_report_desc)), // wDescriptorLength
378 MSB(sizeof(keyboard_report_desc)), 378 MSB(sizeof(keyboard_report_desc)),
379 // - 7 bytes - 379 // - 7 bytes -
380 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13 380 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
381 7, // bLength 381 7, // bLength
382 5, // bDescriptorType 382 5, // bDescriptorType
383 KEYBOARD_ENDPOINT | 0x80, // bEndpointAddress 383 KEYBOARD_ENDPOINT | 0x80, // bEndpointAddress
384 0x03, // bmAttributes (0x03=intr) 384 0x03, // bmAttributes (0x03=intr)
385 KEYBOARD_SIZE, 0, // wMaxPacketSize 385 KEYBOARD_SIZE, 0, // wMaxPacketSize
386 KEYBOARD_INTERVAL, // bInterval 386 KEYBOARD_INTERVAL, // bInterval
387 387
388 // --- NKRO Keyboard HID --- OS Mode Keyboard Interface 388 // --- NKRO Keyboard HID --- OS Mode Keyboard Interface
389 // - 9 bytes - 389 // - 9 bytes -
390 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 390 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
391 9, // bLength 391 9, // bLength
392 4, // bDescriptorType 392 4, // bDescriptorType
393 NKRO_KEYBOARD_INTERFACE, // bInterfaceNumber 393 NKRO_KEYBOARD_INTERFACE, // bInterfaceNumber
394 0, // bAlternateSetting 394 0, // bAlternateSetting
395 1, // bNumEndpoints 395 1, // bNumEndpoints
396 0x03, // bInterfaceClass (0x03 = HID) 396 0x03, // bInterfaceClass (0x03 = HID)
397 0x00, // bInterfaceSubClass (0x00 = Non-Boot, 0x01 = Boot) 397 0x00, // bInterfaceSubClass (0x00 = Non-Boot, 0x01 = Boot)
398 0x01, // bInterfaceProtocol (0x01 = Keyboard) 398 0x01, // bInterfaceProtocol (0x01 = Keyboard)
399 0, // iInterface 399 0, // iInterface
400 // - 9 bytes - 400 // - 9 bytes -
401 // HID interface descriptor, HID 1.11 spec, section 6.2.1 401 // HID interface descriptor, HID 1.11 spec, section 6.2.1
402 9, // bLength 402 9, // bLength
403 0x21, // bDescriptorType 403 0x21, // bDescriptorType
404 0x11, 0x01, // bcdHID 404 0x11, 0x01, // bcdHID
405 0, // bCountryCode 405 0, // bCountryCode
406 1, // bNumDescriptors 406 1, // bNumDescriptors
407 0x22, // bDescriptorType 407 0x22, // bDescriptorType
408 LSB(sizeof(nkro_keyboard_report_desc)), // wDescriptorLength 408 LSB(sizeof(nkro_keyboard_report_desc)), // wDescriptorLength
409 MSB(sizeof(nkro_keyboard_report_desc)), 409 MSB(sizeof(nkro_keyboard_report_desc)),
410 // - 7 bytes - 410 // - 7 bytes -
411 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13 411 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
412 7, // bLength 412 7, // bLength
413 5, // bDescriptorType 413 5, // bDescriptorType
414 NKRO_KEYBOARD_ENDPOINT | 0x80, // bEndpointAddress 414 NKRO_KEYBOARD_ENDPOINT | 0x80, // bEndpointAddress
415 0x03, // bmAttributes (0x03=intr) 415 0x03, // bmAttributes (0x03=intr)
416 NKRO_KEYBOARD_SIZE, 0, // wMaxPacketSize 416 NKRO_KEYBOARD_SIZE, 0, // wMaxPacketSize
417 NKRO_KEYBOARD_INTERVAL, // bInterval 417 NKRO_KEYBOARD_INTERVAL, // bInterval
418 418
419 // --- Serial CDC --- CDC IAD Descriptor 419 // --- Serial CDC --- CDC IAD Descriptor
420 // - 8 bytes - 420 // - 8 bytes -
421 // interface association descriptor, USB ECN, Table 9-Z 421 // interface association descriptor, USB ECN, Table 9-Z
422 8, // bLength 422 8, // bLength
423 11, // bDescriptorType 423 11, // bDescriptorType
424 CDC_STATUS_INTERFACE, // bFirstInterface 424 CDC_STATUS_INTERFACE, // bFirstInterface
425 2, // bInterfaceCount 425 2, // bInterfaceCount
426 0x02, // bFunctionClass 426 0x02, // bFunctionClass
427 0x02, // bFunctionSubClass 427 0x02, // bFunctionSubClass
428 0x01, // bFunctionProtocol 428 0x01, // bFunctionProtocol
429 0, // iFunction 429 0, // iFunction
430 430
431 // --- Serial CDC --- CDC Data Interface 431 // --- Serial CDC --- CDC Data Interface
432 // - 9 bytes - 432 // - 9 bytes -
433 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 433 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
434 9, // bLength 434 9, // bLength
435 4, // bDescriptorType 435 4, // bDescriptorType
436 CDC_STATUS_INTERFACE, // bInterfaceNumber 436 CDC_STATUS_INTERFACE, // bInterfaceNumber
437 0, // bAlternateSetting 437 0, // bAlternateSetting
438 1, // bNumEndpoints 438 1, // bNumEndpoints
439 0x02, // bInterfaceClass 439 0x02, // bInterfaceClass
440 0x02, // bInterfaceSubClass 440 0x02, // bInterfaceSubClass
441 0x01, // bInterfaceProtocol 441 0x01, // bInterfaceProtocol
442 0, // iInterface 442 0, // iInterface
443 // - 5 bytes - 443 // - 5 bytes -
444 // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26 444 // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26
445 5, // bFunctionLength 445 5, // bFunctionLength
446 0x24, // bDescriptorType 446 0x24, // bDescriptorType
447 0x00, // bDescriptorSubtype 447 0x00, // bDescriptorSubtype
448 0x10, 0x01, // bcdCDC 448 0x10, 0x01, // bcdCDC
449 // - 5 bytes - 449 // - 5 bytes -
450 // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27 450 // Call Management Functional Descriptor, CDC Spec 5.2.3.2, Table 27
451 5, // bFunctionLength 451 5, // bFunctionLength
452 0x24, // bDescriptorType 452 0x24, // bDescriptorType
453 0x01, // bDescriptorSubtype 453 0x01, // bDescriptorSubtype
454 0x01, // bmCapabilities 454 0x01, // bmCapabilities
455 CDC_DATA_INTERFACE, // bDataInterface 455 CDC_DATA_INTERFACE, // bDataInterface
456 // - 4 bytes - 456 // - 4 bytes -
457 // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28 457 // Abstract Control Management Functional Descriptor, CDC Spec 5.2.3.3, Table 28
458 4, // bFunctionLength 458 4, // bFunctionLength
459 0x24, // bDescriptorType 459 0x24, // bDescriptorType
460 0x02, // bDescriptorSubtype 460 0x02, // bDescriptorSubtype
461 0x06, // bmCapabilities 461 0x06, // bmCapabilities
462 // - 5 bytes - 462 // - 5 bytes -
463 // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33 463 // Union Functional Descriptor, CDC Spec 5.2.3.8, Table 33
464 5, // bFunctionLength 464 5, // bFunctionLength
465 0x24, // bDescriptorType 465 0x24, // bDescriptorType
466 0x06, // bDescriptorSubtype 466 0x06, // bDescriptorSubtype
467 CDC_STATUS_INTERFACE, // bMasterInterface 467 CDC_STATUS_INTERFACE, // bMasterInterface
468 CDC_DATA_INTERFACE, // bSlaveInterface0 468 CDC_DATA_INTERFACE, // bSlaveInterface0
469 // - 7 bytes - 469 // - 7 bytes -
470 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13 470 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
471 7, // bLength 471 7, // bLength
472 5, // bDescriptorType 472 5, // bDescriptorType
473 CDC_ACM_ENDPOINT | 0x80, // bEndpointAddress 473 CDC_ACM_ENDPOINT | 0x80, // bEndpointAddress
474 0x03, // bmAttributes (0x03=intr) 474 0x03, // bmAttributes (0x03=intr)
475 CDC_ACM_SIZE, 0, // wMaxPacketSize 475 CDC_ACM_SIZE, 0, // wMaxPacketSize
476 64, // bInterval 476 64, // bInterval
477 // - 9 bytes - 477 // - 9 bytes -
478 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 478 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
479 9, // bLength 479 9, // bLength
480 4, // bDescriptorType 480 4, // bDescriptorType
481 CDC_DATA_INTERFACE, // bInterfaceNumber 481 CDC_DATA_INTERFACE, // bInterfaceNumber
482 0, // bAlternateSetting 482 0, // bAlternateSetting
483 2, // bNumEndpoints 483 2, // bNumEndpoints
484 0x0A, // bInterfaceClass 484 0x0A, // bInterfaceClass
485 0x00, // bInterfaceSubClass 485 0x00, // bInterfaceSubClass
486 0x00, // bInterfaceProtocol 486 0x00, // bInterfaceProtocol
487 0, // iInterface 487 0, // iInterface
488 // - 7 bytes - 488 // - 7 bytes -
489 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13 489 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
490 7, // bLength 490 7, // bLength
491 5, // bDescriptorType 491 5, // bDescriptorType
492 CDC_RX_ENDPOINT, // bEndpointAddress 492 CDC_RX_ENDPOINT, // bEndpointAddress
493 0x02, // bmAttributes (0x02=bulk) 493 0x02, // bmAttributes (0x02=bulk)
494 CDC_RX_SIZE, 0, // wMaxPacketSize 494 CDC_RX_SIZE, 0, // wMaxPacketSize
495 0, // bInterval 495 0, // bInterval
496 // - 7 bytes - 496 // - 7 bytes -
497 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13 497 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
498 7, // bLength 498 7, // bLength
499 5, // bDescriptorType 499 5, // bDescriptorType
500 CDC_TX_ENDPOINT | 0x80, // bEndpointAddress 500 CDC_TX_ENDPOINT | 0x80, // bEndpointAddress
501 0x02, // bmAttributes (0x02=bulk) 501 0x02, // bmAttributes (0x02=bulk)
502 CDC_TX_SIZE, 0, // wMaxPacketSize 502 CDC_TX_SIZE, 0, // wMaxPacketSize
503 0, // bInterval 503 0, // bInterval
504 504
505 /* 505 /*
506 // Mouse Interface 506 // Mouse Interface
507 // - 9 bytes - 507 // - 9 bytes -
508 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 508 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
509 9, // bLength 509 9, // bLength
510 4, // bDescriptorType 510 4, // bDescriptorType
511 MOUSE_INTERFACE, // bInterfaceNumber 511 MOUSE_INTERFACE, // bInterfaceNumber
512 0, // bAlternateSetting 512 0, // bAlternateSetting
513 1, // bNumEndpoints 513 1, // bNumEndpoints
514 0x03, // bInterfaceClass (0x03 = HID) 514 0x03, // bInterfaceClass (0x03 = HID)
515 0x00, // bInterfaceSubClass (0x01 = Boot) 515 0x00, // bInterfaceSubClass (0x01 = Boot)
516 0x00, // bInterfaceProtocol (0x02 = Mouse) 516 0x00, // bInterfaceProtocol (0x02 = Mouse)
517 0, // iInterface 517 0, // iInterface
518 // - 9 bytes - 518 // - 9 bytes -
519 // HID interface descriptor, HID 1.11 spec, section 6.2.1 519 // HID interface descriptor, HID 1.11 spec, section 6.2.1
520 9, // bLength 520 9, // bLength
521 0x21, // bDescriptorType 521 0x21, // bDescriptorType
522 0x11, 0x01, // bcdHID 522 0x11, 0x01, // bcdHID
523 0, // bCountryCode 523 0, // bCountryCode
524 1, // bNumDescriptors 524 1, // bNumDescriptors
525 0x22, // bDescriptorType 525 0x22, // bDescriptorType
526 LSB(sizeof(mouse_report_desc)), // wDescriptorLength 526 LSB(sizeof(mouse_report_desc)), // wDescriptorLength
527 MSB(sizeof(mouse_report_desc)), 527 MSB(sizeof(mouse_report_desc)),
528 // - 7 bytes - 528 // - 7 bytes -
529 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13 529 // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
530 7, // bLength 530 7, // bLength
531 5, // bDescriptorType 531 5, // bDescriptorType
532 MOUSE_ENDPOINT | 0x80, // bEndpointAddress 532 MOUSE_ENDPOINT | 0x80, // bEndpointAddress
533 0x03, // bmAttributes (0x03=intr) 533 0x03, // bmAttributes (0x03=intr)
534 MOUSE_SIZE, 0, // wMaxPacketSize 534 MOUSE_SIZE, 0, // wMaxPacketSize
535 MOUSE_INTERVAL, // bInterval 535 MOUSE_INTERVAL, // bInterval
536 #endif // MOUSE_INTERFACE 536 #endif // MOUSE_INTERFACE
537 */ 537 */
538 }; 538 };
539 539
540 540
544 // The descriptors above can provide human readable strings, 544 // The descriptors above can provide human readable strings,
545 // referenced by index numbers. These descriptors are the 545 // referenced by index numbers. These descriptors are the
546 // actual string data 546 // actual string data
547 547
548 struct usb_string_descriptor_struct { 548 struct usb_string_descriptor_struct {
549 uint8_t bLength; 549 uint8_t bLength;
550 uint8_t bDescriptorType; 550 uint8_t bDescriptorType;
551 uint16_t wString[]; 551 uint16_t wString[];
552 }; 552 };
553 553
554 extern struct usb_string_descriptor_struct usb_string_manufacturer_name 554 extern struct usb_string_descriptor_struct usb_string_manufacturer_name
555 __attribute__ ((weak, alias("usb_string_manufacturer_name_default"))); 555 __attribute__ ((weak, alias("usb_string_manufacturer_name_default")));
556 extern struct usb_string_descriptor_struct usb_string_product_name 556 extern struct usb_string_descriptor_struct usb_string_product_name
557 __attribute__ ((weak, alias("usb_string_product_name_default"))); 557 __attribute__ ((weak, alias("usb_string_product_name_default")));
558 extern struct usb_string_descriptor_struct usb_string_serial_number 558 extern struct usb_string_descriptor_struct usb_string_serial_number
559 __attribute__ ((weak, alias("usb_string_serial_number_default"))); 559 __attribute__ ((weak, alias("usb_string_serial_number_default")));
560 560
561 struct usb_string_descriptor_struct string0 = { 561 struct usb_string_descriptor_struct string0 = {
562 4, 562 4,
563 3, 563 3,
564 {0x0409} 564 {0x0409}
565 }; 565 };
566 566
567 struct usb_string_descriptor_struct usb_string_manufacturer_name_default = { 567 struct usb_string_descriptor_struct usb_string_manufacturer_name_default = {
568 sizeof(STR_MANUFACTURER), 568 sizeof(STR_MANUFACTURER),
569 3, 569 3,
570 {STR_MANUFACTURER} 570 {STR_MANUFACTURER}
571 }; 571 };
572 struct usb_string_descriptor_struct usb_string_product_name_default = { 572 struct usb_string_descriptor_struct usb_string_product_name_default = {
573 sizeof(STR_PRODUCT), 573 sizeof(STR_PRODUCT),
574 3, 574 3,
575 {STR_PRODUCT} 575 {STR_PRODUCT}
576 }; 576 };
577 struct usb_string_descriptor_struct usb_string_serial_number_default = { 577 struct usb_string_descriptor_struct usb_string_serial_number_default = {
578 sizeof(STR_SERIAL), 578 sizeof(STR_SERIAL),
579 3, 579 3,
580 {STR_SERIAL} 580 {STR_SERIAL}
581 }; 581 };
582 582
583 583
584 584
590 //wValue, wIndex, address, length 590 //wValue, wIndex, address, length
591 {0x0100, 0x0000, device_descriptor, sizeof(device_descriptor)}, 591 {0x0100, 0x0000, device_descriptor, sizeof(device_descriptor)},
592 {0x0200, 0x0000, config_descriptor, sizeof(config_descriptor)}, 592 {0x0200, 0x0000, config_descriptor, sizeof(config_descriptor)},
593 {0x0600, 0x0000, device_qualifier_descriptor, sizeof(device_qualifier_descriptor)}, 593 {0x0600, 0x0000, device_qualifier_descriptor, sizeof(device_qualifier_descriptor)},
594 {0x0A00, 0x0000, usb_debug_descriptor, sizeof(usb_debug_descriptor)}, 594 {0x0A00, 0x0000, usb_debug_descriptor, sizeof(usb_debug_descriptor)},
595 {0x2200, KEYBOARD_INTERFACE, keyboard_report_desc, sizeof(keyboard_report_desc)}, 595 {0x2200, KEYBOARD_INTERFACE, keyboard_report_desc, sizeof(keyboard_report_desc)},
596 {0x2100, KEYBOARD_INTERFACE, config_descriptor + KEYBOARD_DESC_OFFSET, 9}, 596 {0x2100, KEYBOARD_INTERFACE, config_descriptor + KEYBOARD_DESC_OFFSET, 9},
597 {0x2200, NKRO_KEYBOARD_INTERFACE, nkro_keyboard_report_desc, sizeof(nkro_keyboard_report_desc)}, 597 {0x2200, NKRO_KEYBOARD_INTERFACE, nkro_keyboard_report_desc, sizeof(nkro_keyboard_report_desc)},
598 {0x2100, NKRO_KEYBOARD_INTERFACE, config_descriptor + NKRO_KEYBOARD_DESC_OFFSET, 9}, 598 {0x2100, NKRO_KEYBOARD_INTERFACE, config_descriptor + NKRO_KEYBOARD_DESC_OFFSET, 9},
599 /* MOUSE 599 /* MOUSE
600 {0x2200, MOUSE_INTERFACE, mouse_report_desc, sizeof(mouse_report_desc)}, 600 {0x2200, MOUSE_INTERFACE, mouse_report_desc, sizeof(mouse_report_desc)},
601 {0x2100, MOUSE_INTERFACE, config_descriptor+MOUSE_DESC_OFFSET, 9}, 601 {0x2100, MOUSE_INTERFACE, config_descriptor+MOUSE_DESC_OFFSET, 9},
602 */ 602 */
603 {0x0300, 0x0000, (const uint8_t *)&string0, 0}, 603 {0x0300, 0x0000, (const uint8_t *)&string0, 0},
604 {0x0301, 0x0409, (const uint8_t *)&usb_string_manufacturer_name, 0}, 604 {0x0301, 0x0409, (const uint8_t *)&usb_string_manufacturer_name, 0},
605 {0x0302, 0x0409, (const uint8_t *)&usb_string_product_name, 0}, 605 {0x0302, 0x0409, (const uint8_t *)&usb_string_product_name, 0},
606 {0x0303, 0x0409, (const uint8_t *)&usb_string_serial_number, 0}, 606 {0x0303, 0x0409, (const uint8_t *)&usb_string_serial_number, 0},
607 {0, 0, NULL, 0} 607 {0, 0, NULL, 0}
608 }; 608 };
609 609
610 610
611 611