1 /* This test ensures that the parser handles the example pwr report descriptor
2 from the USB HID report descriptor tool. Why direct: the device's control transfer
3 data buffer's default size (256 bytes) is not large enough for this report
4 descriptor (over 800 bytes); thus, we reallocate the buffer with a larger size. */
5
6 #include "usbx_test_common_hid.h"
7 #include "ux_host_class_hid_keyboard.h"
8
9 static UCHAR hid_report_descriptor[] = {
10
11 0x05, 0x84, // USAGE_PAGE (Power Device)
12 0x09, 0x04, // USAGE (UPS)
13 0xa1, 0x01, // COLLECTION (Application)
14 0x09, 0x1e, // USAGE (Flow)
15 0xa1, 0x02, // COLLECTION (Logical)
16 0x85, 0x01, // REPORT_ID (1)
17 0x09, 0x1f, // USAGE (FlowID)
18 0x75, 0x04, // REPORT_SIZE (4)
19 0x95, 0x01, // REPORT_COUNT (1)
20 0x15, 0x00, // LOGICAL_MINIMUM (0)
21 0x25, 0x0f, // LOGICAL_MAXIMUM (15)
22 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
23 0x75, 0x04, // REPORT_SIZE (4)
24 0x95, 0x01, // REPORT_COUNT (1)
25 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
26 0x09, 0x01, // USAGE (iName)
27 0x75, 0x08, // REPORT_SIZE (8)
28 0x95, 0x01, // REPORT_COUNT (1)
29 0x15, 0x00, // LOGICAL_MINIMUM (0)
30 0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
31 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
32 0x09, 0x40, // USAGE (ConfigVoltage)
33 0x75, 0x08, // REPORT_SIZE (8)
34 0x95, 0x01, // REPORT_COUNT (1)
35 0x67, 0x21, 0xd1, 0xf0, 0x00, // UNIT (SI Lin:Volts)
36 0x55, 0x07, // UNIT_EXPONENT (7)
37 0x15, 0x00, // LOGICAL_MINIMUM (0)
38 0x26, 0xfa, 0x00, // LOGICAL_MAXIMUM (250)
39 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
40 0x09, 0x42, // USAGE (ConfigFrequency)
41 0x75, 0x08, // REPORT_SIZE (8)
42 0x95, 0x01, // REPORT_COUNT (1)
43 0x66, 0x01, 0xf0, // UNIT (SI Lin:Hertz)
44 0x55, 0x00, // UNIT_EXPONENT (0)
45 0x15, 0x00, // LOGICAL_MINIMUM (0)
46 0x25, 0x3c, // LOGICAL_MAXIMUM (60)
47 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
48 0x65, 0x00, // UNIT (None)
49 0xc0, // END_COLLECTION
50 0x09, 0x1e, // USAGE (Flow)
51 0xa1, 0x02, // COLLECTION (Logical)
52 0x85, 0x02, // REPORT_ID (2)
53 0x09, 0x1f, // USAGE (FlowID)
54 0x75, 0x04, // REPORT_SIZE (4)
55 0x95, 0x01, // REPORT_COUNT (1)
56 0x15, 0x00, // LOGICAL_MINIMUM (0)
57 0x25, 0x0f, // LOGICAL_MAXIMUM (15)
58 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
59 0x75, 0x04, // REPORT_SIZE (4)
60 0x95, 0x01, // REPORT_COUNT (1)
61 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
62 0x09, 0x01, // USAGE (iName)
63 0x75, 0x08, // REPORT_SIZE (8)
64 0x95, 0x01, // REPORT_COUNT (1)
65 0x15, 0x00, // LOGICAL_MINIMUM (0)
66 0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
67 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
68 0x09, 0x40, // USAGE (ConfigVoltage)
69 0x75, 0x10, // REPORT_SIZE (16)
70 0x95, 0x01, // REPORT_COUNT (1)
71 0x67, 0x21, 0xd1, 0xf0, 0x00, // UNIT (SI Lin:Volts)
72 0x55, 0x05, // UNIT_EXPONENT (5)
73 0x15, 0x00, // LOGICAL_MINIMUM (0)
74 0x27, 0xfe, 0xff, 0x00, 0x00, // LOGICAL_MAXIMUM (65534)
75 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
76 0x09, 0x42, // USAGE (ConfigFrequency)
77 0x75, 0x08, // REPORT_SIZE (8)
78 0x95, 0x01, // REPORT_COUNT (1)
79 0x66, 0x01, 0xf0, // UNIT (SI Lin:Hertz)
80 0x55, 0x00, // UNIT_EXPONENT (0)
81 0x15, 0x00, // LOGICAL_MINIMUM (0)
82 0x25, 0x60, // LOGICAL_MAXIMUM (96)
83 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
84 0x65, 0x00, // UNIT (None)
85 0xc0, // END_COLLECTION
86 0x09, 0x1e, // USAGE (Flow)
87 0xa1, 0x02, // COLLECTION (Logical)
88 0x75, 0x04, // REPORT_SIZE (4)
89 0x95, 0x01, // REPORT_COUNT (1)
90 0x15, 0x00, // LOGICAL_MINIMUM (0)
91 0x25, 0x0f, // LOGICAL_MAXIMUM (15)
92 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
93 0x75, 0x04, // REPORT_SIZE (4)
94 0x95, 0x01, // REPORT_COUNT (1)
95 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
96 0x09, 0x01, // USAGE (iName)
97 0x75, 0x08, // REPORT_SIZE (8)
98 0x95, 0x01, // REPORT_COUNT (1)
99 0x15, 0x00, // LOGICAL_MINIMUM (0)
100 0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
101 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
102 0x09, 0x40, // USAGE (ConfigVoltage)
103 0x75, 0x08, // REPORT_SIZE (8)
104 0x95, 0x01, // REPORT_COUNT (1)
105 0x67, 0x21, 0xd1, 0xf0, 0x00, // UNIT (SI Lin:Volts)
106 0x55, 0x07, // UNIT_EXPONENT (7)
107 0x15, 0x00, // LOGICAL_MINIMUM (0)
108 0x26, 0xfa, 0x00, // LOGICAL_MAXIMUM (250)
109 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
110 0x09, 0x42, // USAGE (ConfigFrequency)
111 0x75, 0x08, // REPORT_SIZE (8)
112 0x95, 0x01, // REPORT_COUNT (1)
113 0x66, 0x01, 0xf0, // UNIT (SI Lin:Hertz)
114 0x55, 0x00, // UNIT_EXPONENT (0)
115 0x15, 0x00, // LOGICAL_MINIMUM (0)
116 0x25, 0x3c, // LOGICAL_MAXIMUM (60)
117 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
118 0x09, 0x43, // USAGE (ConfigApparentPower)
119 0x75, 0x10, // REPORT_SIZE (16)
120 0x95, 0x01, // REPORT_COUNT (1)
121 0x66, 0x21, 0xd1, // UNIT (SI Lin:Power)
122 0x55, 0x07, // UNIT_EXPONENT (7)
123 0x15, 0x00, // LOGICAL_MINIMUM (0)
124 0x27, 0xfe, 0xff, 0x00, 0x00, // LOGICAL_MAXIMUM (65534)
125 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
126 0x65, 0x00, // UNIT (None)
127 0xc0, // END_COLLECTION
128 0x09, 0x10, // USAGE (BatterySystem)
129 0xa1, 0x02, // COLLECTION (Logical)
130 0x85, 0x04, // REPORT_ID (4)
131 0x09, 0x11, // USAGE (BatterySystemID)
132 0x75, 0x04, // REPORT_SIZE (4)
133 0x95, 0x01, // REPORT_COUNT (1)
134 0x15, 0x00, // LOGICAL_MINIMUM (0)
135 0x25, 0x0f, // LOGICAL_MAXIMUM (15)
136 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
137 0x75, 0x04, // REPORT_SIZE (4)
138 0x95, 0x01, // REPORT_COUNT (1)
139 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
140 0x09, 0x1a, // USAGE (Input)
141 0xa1, 0x02, // COLLECTION (Logical)
142 0x09, 0x1b, // USAGE (InputID)
143 0x09, 0x1f, // USAGE (FlowID)
144 0x75, 0x04, // REPORT_SIZE (4)
145 0x95, 0x02, // REPORT_COUNT (2)
146 0x15, 0x00, // LOGICAL_MINIMUM (0)
147 0x25, 0x0f, // LOGICAL_MAXIMUM (15)
148 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
149 0x09, 0x02, // USAGE (PresentStatus)
150 0xa1, 0x02, // COLLECTION (Logical)
151 0x09, 0x6d, // USAGE (Used)
152 0x09, 0x61, // USAGE (Good)
153 0x75, 0x01, // REPORT_SIZE (1)
154 0x95, 0x02, // REPORT_COUNT (2)
155 0x15, 0x00, // LOGICAL_MINIMUM (0)
156 0x25, 0x01, // LOGICAL_MAXIMUM (1)
157 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
158 0xc0, // END_COLLECTION
159 0x09, 0x03, // USAGE (ChangedStatus)
160 0xa1, 0x02, // COLLECTION (Logical)
161 0x09, 0x6d, // USAGE (Used)
162 0x09, 0x61, // USAGE (Good)
163 0x75, 0x02, // REPORT_SIZE (2)
164 0x95, 0x02, // REPORT_COUNT (2)
165 0x15, 0x00, // LOGICAL_MINIMUM (0)
166 0x25, 0x01, // LOGICAL_MAXIMUM (1)
167 0x81, 0x02, // INPUT (Data,Var,Abs)
168 0xc0, // END_COLLECTION
169 0xc0, // END_COLLECTION
170 0x09, 0x14, // USAGE (Charger)
171 0xa1, 0x02, // COLLECTION (Logical)
172 0x85, 0x05, // REPORT_ID (5)
173 0x09, 0x15, // USAGE (ChargerID)
174 0x75, 0x04, // REPORT_SIZE (4)
175 0x95, 0x01, // REPORT_COUNT (1)
176 0x15, 0x00, // LOGICAL_MINIMUM (0)
177 0x25, 0x0f, // LOGICAL_MAXIMUM (15)
178 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
179 0xc0, // END_COLLECTION
180 0x09, 0x1c, // USAGE (Output)
181 0xa1, 0x02, // COLLECTION (Logical)
182 0x09, 0x1d, // USAGE (OutputID)
183 0x09, 0x1f, // USAGE (FlowID)
184 0x75, 0x04, // REPORT_SIZE (4)
185 0x95, 0x02, // REPORT_COUNT (2)
186 0x15, 0x00, // LOGICAL_MINIMUM (0)
187 0x25, 0x0f, // LOGICAL_MAXIMUM (15)
188 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
189 0xc0, // END_COLLECTION
190 0x09, 0x12, // USAGE (Battery)
191 0xa1, 0x02, // COLLECTION (Logical)
192 0x85, 0x06, // REPORT_ID (6)
193 0x09, 0x13, // USAGE (BatteryID)
194 0x85, 0x04, // REPORT_ID (4)
195 0x95, 0x01, // REPORT_COUNT (1)
196 0x15, 0x00, // LOGICAL_MINIMUM (0)
197 0x25, 0x0f, // LOGICAL_MAXIMUM (15)
198 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
199 0x05, 0x85, // USAGE_PAGE (Battery System)
200 0x09, 0x2c, // USAGE (CapacityMode)
201 0x75, 0x01, // REPORT_SIZE (1)
202 0x95, 0x01, // REPORT_COUNT (1)
203 0x15, 0x00, // LOGICAL_MINIMUM (0)
204 0x25, 0x01, // LOGICAL_MAXIMUM (1)
205 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
206 0x75, 0x03, // REPORT_SIZE (3)
207 0x95, 0x01, // REPORT_COUNT (1)
208 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
209 0x09, 0x83, // USAGE (DesignCapacity)
210 0x75, 0x18, // REPORT_SIZE (24)
211 0x95, 0x01, // REPORT_COUNT (1)
212 0x67, 0x01, 0x10, 0x10, 0x00, // UNIT (SI Lin:Battery Capacity)
213 0x55, 0x00, // UNIT_EXPONENT (0)
214 0x15, 0x00, // LOGICAL_MINIMUM (0)
215 0x27, 0xfe, 0xff, 0xff, 0x00, // LOGICAL_MAXIMUM (16777214)
216 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
217 0x05, 0x84, // USAGE_PAGE (Power Device)
218 0x09, 0x40, // USAGE (ConfigVoltage)
219 0x75, 0x10, // REPORT_SIZE (16)
220 0x95, 0x01, // REPORT_COUNT (1)
221 0x67, 0x21, 0xd1, 0xf0, 0x00, // UNIT (SI Lin:Volts)
222 0x55, 0x05, // UNIT_EXPONENT (5)
223 0x15, 0x00, // LOGICAL_MINIMUM (0)
224 0x27, 0xfe, 0xff, 0x00, 0x00, // LOGICAL_MAXIMUM (65534)
225 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
226 0x05, 0x85, // USAGE_PAGE (Battery System)
227 0x09, 0x29, // USAGE (RemainingCapacityLimit)
228 0x75, 0x24, // REPORT_SIZE (36)
229 0x95, 0x01, // REPORT_COUNT (1)
230 0x67, 0x01, 0x10, 0x10, 0x00, // UNIT (SI Lin:Battery Capacity)
231 0x55, 0x00, // UNIT_EXPONENT (0)
232 0x15, 0x00, // LOGICAL_MINIMUM (0)
233 0x27, 0xfe, 0xff, 0xff, 0x00, // LOGICAL_MAXIMUM (16777214)
234 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
235 0x65, 0x00, // UNIT (None)
236 0x05, 0x84, // USAGE_PAGE (Power Device)
237 0x09, 0x02, // USAGE (PresentStatus)
238 0xa1, 0x02, // COLLECTION (Logical)
239 0x05, 0x85, // USAGE_PAGE (Battery System)
240 0x0b, 0x61, 0x00, 0x84, 0x00, // USAGE (Power Device:Good)
241 0x09, 0x42, // USAGE (BelowRemainingCapacityLimit)
242 0x09, 0x44, // USAGE (Charging)
243 0x09, 0x45, // USAGE (Discharging)
244 0x75, 0x01, // REPORT_SIZE (1)
245 0x95, 0x04, // REPORT_COUNT (4)
246 0x15, 0x00, // LOGICAL_MINIMUM (0)
247 0x25, 0x01, // LOGICAL_MAXIMUM (1)
248 0xb1, 0x02, // FEATURE (Data,Var,Abs)
249 0xc0, // END_COLLECTION
250 0x05, 0x84, // USAGE_PAGE (Power Device)
251 0x09, 0x03, // USAGE (ChangedStatus)
252 0xa1, 0x02, // COLLECTION (Logical)
253 0x05, 0x85, // USAGE_PAGE (Battery System)
254 0x0b, 0x61, 0x00, 0x84, 0x00, // USAGE (Power Device:Good)
255 0x09, 0x42, // USAGE (BelowRemainingCapacityLimit)
256 0x09, 0x44, // USAGE (Charging)
257 0x09, 0x45, // USAGE (Discharging)
258 0x75, 0x02, // REPORT_SIZE (2)
259 0x95, 0x04, // REPORT_COUNT (4)
260 0x15, 0x00, // LOGICAL_MINIMUM (0)
261 0x25, 0x01, // LOGICAL_MAXIMUM (1)
262 0x81, 0x02, // INPUT (Data,Var,Abs)
263 0xc0, // END_COLLECTION
264 0xc0, // END_COLLECTION
265 0xc0, // END_COLLECTION
266 0x05, 0x84, // USAGE_PAGE (Power Device)
267 0x09, 0x16, // USAGE (PowerConverter)
268 0xa1, 0x02, // COLLECTION (Logical)
269 0x85, 0x08, // REPORT_ID (8)
270 0x09, 0x17, // USAGE (PowerConverterID)
271 0x75, 0x04, // REPORT_SIZE (4)
272 0x95, 0x01, // REPORT_COUNT (1)
273 0x15, 0x00, // LOGICAL_MINIMUM (0)
274 0x25, 0x0f, // LOGICAL_MAXIMUM (15)
275 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
276 0x09, 0x1a, // USAGE (Input)
277 0xa1, 0x02, // COLLECTION (Logical)
278 0x09, 0x1b, // USAGE (InputID)
279 0x09, 0x1f, // USAGE (FlowID)
280 0x75, 0x04, // REPORT_SIZE (4)
281 0x95, 0x02, // REPORT_COUNT (2)
282 0x15, 0x00, // LOGICAL_MINIMUM (0)
283 0x25, 0x0f, // LOGICAL_MAXIMUM (15)
284 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
285 0x09, 0x02, // USAGE (PresentStatus)
286 0xa1, 0x02, // COLLECTION (Logical)
287 0x09, 0x6d, // USAGE (Used)
288 0x09, 0x61, // USAGE (Good)
289 0x75, 0x01, // REPORT_SIZE (1)
290 0x95, 0x02, // REPORT_COUNT (2)
291 0x15, 0x00, // LOGICAL_MINIMUM (0)
292 0x25, 0x01, // LOGICAL_MAXIMUM (1)
293 0xb1, 0x02, // FEATURE (Data,Var,Abs)
294 0xc0, // END_COLLECTION
295 0x09, 0x03, // USAGE (ChangedStatus)
296 0xa1, 0x02, // COLLECTION (Logical)
297 0x09, 0x6d, // USAGE (Used)
298 0x09, 0x61, // USAGE (Good)
299 0x75, 0x02, // REPORT_SIZE (2)
300 0x95, 0x02, // REPORT_COUNT (2)
301 0x15, 0x00, // LOGICAL_MINIMUM (0)
302 0x25, 0x01, // LOGICAL_MAXIMUM (1)
303 0x81, 0x02, // INPUT (Data,Var,Abs)
304 0xc0, // END_COLLECTION
305 0xc0, // END_COLLECTION
306 0x09, 0x1c, // USAGE (Output)
307 0xa1, 0x02, // COLLECTION (Logical)
308 0x85, 0x09, // REPORT_ID (9)
309 0x09, 0x1d, // USAGE (OutputID)
310 0x09, 0x1f, // USAGE (FlowID)
311 0x75, 0x04, // REPORT_SIZE (4)
312 0x95, 0x02, // REPORT_COUNT (2)
313 0x15, 0x00, // LOGICAL_MINIMUM (0)
314 0x25, 0x0f, // LOGICAL_MAXIMUM (15)
315 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
316 0x09, 0x35, // USAGE (PercentLoad)
317 0x75, 0x08, // REPORT_SIZE (8)
318 0x95, 0x01, // REPORT_COUNT (1)
319 0x15, 0x00, // LOGICAL_MINIMUM (0)
320 0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
321 0x81, 0x02, // INPUT (Data,Var,Abs)
322 0x09, 0x02, // USAGE (PresentStatus)
323 0xa1, 0x02, // COLLECTION (Logical)
324 0x09, 0x6d, // USAGE (Used)
325 0x09, 0x61, // USAGE (Good)
326 0x09, 0x64, // USAGE (FrequencyOutOfRange)
327 0x09, 0x69, // USAGE (ShutdownImminent)
328 0x75, 0x01, // REPORT_SIZE (1)
329 0x95, 0x04, // REPORT_COUNT (4)
330 0x15, 0x00, // LOGICAL_MINIMUM (0)
331 0x25, 0x01, // LOGICAL_MAXIMUM (1)
332 0xb1, 0x02, // FEATURE (Data,Var,Abs)
333 0xc0, // END_COLLECTION
334 0x09, 0x03, // USAGE (ChangedStatus)
335 0xa1, 0x02, // COLLECTION (Logical)
336 0x09, 0x6d, // USAGE (Used)
337 0x09, 0x61, // USAGE (Good)
338 0x09, 0x64, // USAGE (FrequencyOutOfRange)
339 0x09, 0x69, // USAGE (ShutdownImminent)
340 0x75, 0x02, // REPORT_SIZE (2)
341 0x95, 0x04, // REPORT_COUNT (4)
342 0x15, 0x00, // LOGICAL_MINIMUM (0)
343 0x25, 0x01, // LOGICAL_MAXIMUM (1)
344 0x81, 0x02, // INPUT (Data,Var,Abs)
345 0xc0, // END_COLLECTION
346 0xc0, // END_COLLECTION
347 0x09, 0x1a, // USAGE (Input)
348 0xa1, 0x02, // COLLECTION (Logical)
349 0x85, 0x0a, // REPORT_ID (10)
350 0x09, 0x1b, // USAGE (InputID)
351 0x09, 0x1f, // USAGE (FlowID)
352 0x75, 0x04, // REPORT_SIZE (4)
353 0x95, 0x02, // REPORT_COUNT (2)
354 0x15, 0x00, // LOGICAL_MINIMUM (0)
355 0x25, 0x0f, // LOGICAL_MAXIMUM (15)
356 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
357 0x09, 0x02, // USAGE (PresentStatus)
358 0xa1, 0x02, // COLLECTION (Logical)
359 0x09, 0x6d, // USAGE (Used)
360 0x09, 0x61, // USAGE (Good)
361 0x75, 0x01, // REPORT_SIZE (1)
362 0x95, 0x02, // REPORT_COUNT (2)
363 0x15, 0x00, // LOGICAL_MINIMUM (0)
364 0x25, 0x01, // LOGICAL_MAXIMUM (1)
365 0xb1, 0x02, // FEATURE (Data,Var,Abs)
366 0xc0, // END_COLLECTION
367 0x09, 0x03, // USAGE (ChangedStatus)
368 0xa1, 0x02, // COLLECTION (Logical)
369 0x09, 0x6d, // USAGE (Used)
370 0x09, 0x61, // USAGE (Good)
371 0x75, 0x02, // REPORT_SIZE (2)
372 0x95, 0x02, // REPORT_COUNT (2)
373 0x15, 0x00, // LOGICAL_MINIMUM (0)
374 0x25, 0x01, // LOGICAL_MAXIMUM (1)
375 0x81, 0x02, // INPUT (Data,Var,Abs)
376 0xc0, // END_COLLECTION
377 0xc0, // END_COLLECTION
378 0xc0, // END_COLLECTION
379 0x09, 0x24, // USAGE (Sink)
380 0xa1, 0x02, // COLLECTION (Logical)
381 0x85, 0x0b, // REPORT_ID (11)
382 0x09, 0x25, // USAGE (SinkID)
383 0x09, 0x1f, // USAGE (FlowID)
384 0x09, 0x1d, // USAGE (OutputID)
385 0x75, 0x04, // REPORT_SIZE (4)
386 0x95, 0x03, // REPORT_COUNT (3)
387 0x15, 0x00, // LOGICAL_MINIMUM (0)
388 0x25, 0x0f, // LOGICAL_MAXIMUM (15)
389 0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
390 0x09, 0x1b, // USAGE (InputID)
391 0x09, 0x13, // USAGE (BatteryID)
392 0x75, 0x04, // REPORT_SIZE (4)
393 0x95, 0x04, // REPORT_COUNT (4)
394 0x15, 0x00, // LOGICAL_MINIMUM (0)
395 0x25, 0x0f, // LOGICAL_MAXIMUM (15)
396 0x81, 0x02, // INPUT (Data,Var,Abs)
397 0x09, 0x35, // USAGE (PercentLoad)
398 0x75, 0x08, // REPORT_SIZE (8)
399 0x95, 0x01, // REPORT_COUNT (1)
400 0x15, 0x00, // LOGICAL_MINIMUM (0)
401 0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
402 0x81, 0x02, // INPUT (Data,Var,Abs)
403 0x05, 0x85, // USAGE_PAGE (Battery System)
404 0x09, 0x66, // USAGE (RemainingCapacity)
405 0x75, 0x18, // REPORT_SIZE (24)
406 0x95, 0x01, // REPORT_COUNT (1)
407 0x67, 0x01, 0x10, 0x10, 0x00, // UNIT (SI Lin:Battery Capacity)
408 0x55, 0x00, // UNIT_EXPONENT (0)
409 0x15, 0x00, // LOGICAL_MINIMUM (0)
410 0x27, 0xfe, 0xff, 0xff, 0x00, // LOGICAL_MAXIMUM (16777214)
411 0x81, 0x02, // INPUT (Data,Var,Abs)
412 0x65, 0x00, // UNIT (None)
413 0x09, 0x42, // USAGE (BelowRemainingCapacityLimit)
414 0x09, 0x44, // USAGE (Charging)
415 0x09, 0x45, // USAGE (Discharging)
416 0x0b, 0x64, 0x00, 0x84, 0x00, // USAGE (Power Device:FrequencyOutOfRange)
417 0x0b, 0x69, 0x00, 0x84, 0x00, // USAGE (Power Device:ShutdownImminent)
418 0x75, 0x02, // REPORT_SIZE (2)
419 0x95, 0x05, // REPORT_COUNT (5)
420 0x15, 0x00, // LOGICAL_MINIMUM (0)
421 0x25, 0x01, // LOGICAL_MAXIMUM (1)
422 0x81, 0x02, // INPUT (Data,Var,Abs)
423 0xc0, // END_COLLECTION
424 0xc0 // END_COLLECTION
425 };
426 #define HID_REPORT_LENGTH sizeof(hid_report_descriptor)/sizeof(hid_report_descriptor[0])
427
428
429 #define DEVICE_FRAMEWORK_LENGTH_FULL_SPEED 52
430 static UCHAR device_framework_full_speed[DEVICE_FRAMEWORK_LENGTH_FULL_SPEED] = {
431
432 /* Device descriptor */
433 0x12, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x08,
434 0x81, 0x0A, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
435 0x00, 0x01,
436
437 /* Configuration descriptor */
438 0x09, 0x02, 0x22, 0x00, 0x01, 0x01, 0x00, 0xc0,
439 0x32,
440
441 /* Interface descriptor */
442 0x09, 0x04, 0x02, 0x00, 0x01, 0x03, 0x00, 0x00,
443 0x00,
444
445 /* HID descriptor */
446 0x09, 0x21, 0x10, 0x01, 0x21, 0x01, 0x22, LSB(HID_REPORT_LENGTH),
447 MSB(HID_REPORT_LENGTH),
448
449 /* Endpoint descriptor (Interrupt) */
450 0x07, 0x05, 0x82, 0x03, 0x08, 0x00, 0x08
451
452 };
453
454
455 #define DEVICE_FRAMEWORK_LENGTH_HIGH_SPEED 62
456 static UCHAR device_framework_high_speed[DEVICE_FRAMEWORK_LENGTH_HIGH_SPEED] = {
457
458 /* Device descriptor */
459 0x12, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x40,
460 0x0a, 0x07, 0x25, 0x40, 0x01, 0x00, 0x01, 0x02,
461 0x03, 0x01,
462
463 /* Device qualifier descriptor */
464 0x0a, 0x06, 0x00, 0x02, 0x00, 0x00, 0x00, 0x40,
465 0x01, 0x00,
466
467 /* Configuration descriptor */
468 0x09, 0x02, 0x22, 0x00, 0x01, 0x01, 0x00, 0xc0,
469 0x32,
470
471 /* Interface descriptor */
472 0x09, 0x04, 0x02, 0x00, 0x01, 0x03, 0x00, 0x00,
473 0x00,
474
475 /* HID descriptor */
476 0x09, 0x21, 0x10, 0x01, 0x21, 0x01, 0x22, LSB(HID_REPORT_LENGTH),
477 MSB(HID_REPORT_LENGTH),
478
479 /* Endpoint descriptor (Interrupt) */
480 0x07, 0x05, 0x82, 0x03, 0x08, 0x00, 0x08
481
482 };
483
484
485 /* String Device Framework :
486 Byte 0 and 1 : Word containing the language ID : 0x0904 for US
487 Byte 2 : Byte containing the index of the descriptor
488 Byte 3 : Byte containing the length of the descriptor string
489 */
490
491 #define STRING_FRAMEWORK_LENGTH 40
492 static UCHAR string_framework[] = {
493
494 /* Manufacturer string descriptor : Index 1 */
495 0x09, 0x04, 0x01, 0x0c,
496 0x45, 0x78, 0x70, 0x72,0x65, 0x73, 0x20, 0x4c,
497 0x6f, 0x67, 0x69, 0x63,
498
499 /* Product string descriptor : Index 2 */
500 0x09, 0x04, 0x02, 0x0c,
501 0x55, 0x53, 0x42, 0x20, 0x4b, 0x65, 0x79, 0x62,
502 0x6f, 0x61, 0x72, 0x64,
503
504 /* Serial Number string descriptor : Index 3 */
505 0x09, 0x04, 0x03, 0x04,
506 0x30, 0x30, 0x30, 0x31
507 };
508
509
510 /* Multiple languages are supported on the device, to add
511 a language besides english, the unicode language code must
512 be appended to the language_id_framework array and the length
513 adjusted accordingly. */
514 #define LANGUAGE_ID_FRAMEWORK_LENGTH 2
515 static UCHAR language_id_framework[] = {
516
517 /* English. */
518 0x09, 0x04
519 };
520
521
error_callback(UINT system_level,UINT system_context,UINT error_code)522 static VOID error_callback(UINT system_level, UINT system_context, UINT error_code)
523 {
524
525 /* Failed test. */
526 printf("Error on line %d, system_level: %d, system_context: %d, error code: %d\n", __LINE__, system_level, system_context, error_code);
527 test_control_return(1);
528 }
529
530 /* Define what the initial system looks like. */
531
532 #ifdef CTEST
test_application_define(void * first_unused_memory)533 void test_application_define(void *first_unused_memory)
534 #else
535 void usbx_hid_report_descriptor_example_pwr_test_application_define(void *first_unused_memory)
536 #endif
537 {
538
539 UINT status;
540 CHAR * stack_pointer;
541 CHAR * memory_pointer;
542 UINT descriptor_size = HID_REPORT_LENGTH;
543 UX_SLAVE_TRANSFER * slave_transfer_request;
544
545
546 /* Inform user. */
547 printf("Running HID Report Descriptor Example pwr Test....................... ");
548
549 /* Initialize the free memory pointer */
550 stack_pointer = (CHAR *) usbx_memory;
551 memory_pointer = stack_pointer + (UX_DEMO_STACK_SIZE * 2);
552
553 /* Initialize USBX. Memory */
554 status = ux_system_initialize(memory_pointer, UX_DEMO_MEMORY_SIZE, UX_NULL,0);
555
556 /* Check for error. */
557 if (status != UX_SUCCESS)
558 {
559
560 printf("Error on line %d\n", __LINE__);
561 test_control_return(1);
562 }
563
564 /* Register the error callback. */
565 _ux_utility_error_callback_register(error_callback);
566
567 /* The code below is required for installing the host portion of USBX */
568 status = ux_host_stack_initialize(UX_NULL);
569 if (status != UX_SUCCESS)
570 {
571
572 printf("Error on line %d\n", __LINE__);
573 test_control_return(1);
574 }
575
576 status = ux_host_stack_class_register(_ux_system_host_class_hid_name, ux_host_class_hid_entry);
577 if (status != UX_SUCCESS)
578 {
579
580 printf("Error on line %d\n", __LINE__);
581 test_control_return(1);
582 }
583
584 /* Register the HID client(s). */
585 status = ux_host_class_hid_client_register(_ux_system_host_class_hid_client_keyboard_name, ux_host_class_hid_keyboard_entry);
586 if (status != UX_SUCCESS)
587 {
588
589 printf("Error on line %d, error code: %d\n", __LINE__, status);
590 test_control_return(1);
591 }
592
593 /* The code below is required for installing the device portion of USBX. No call back for
594 device status change in this example. */
595 status = ux_device_stack_initialize(device_framework_high_speed, DEVICE_FRAMEWORK_LENGTH_HIGH_SPEED,
596 device_framework_full_speed, DEVICE_FRAMEWORK_LENGTH_FULL_SPEED,
597 string_framework, STRING_FRAMEWORK_LENGTH,
598 language_id_framework, LANGUAGE_ID_FRAMEWORK_LENGTH,UX_NULL);
599 if(status!=UX_SUCCESS)
600 {
601
602 printf("Error on line %d\n", __LINE__);
603 test_control_return(1);
604 }
605
606 /* UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH defined in ux_port.h is not sufficient for this
607 report descriptor. We need to allocate a larger buffer. */
608
609 slave_transfer_request = &_ux_system_slave -> ux_system_slave_device.ux_slave_device_control_endpoint.ux_slave_endpoint_transfer_request;
610
611 ux_utility_memory_free(slave_transfer_request -> ux_slave_transfer_request_data_pointer);
612
613 slave_transfer_request -> ux_slave_transfer_request_data_pointer = ux_utility_memory_allocate(UX_NO_ALIGN, UX_CACHE_SAFE_MEMORY, 1024);
614 if(slave_transfer_request -> ux_slave_transfer_request_data_pointer == UX_NULL)
615 {
616
617 printf("Error on line %d\n", __LINE__);
618 test_control_return(1);
619 }
620
621 /* Initialize the hid class parameters. */
622 hid_parameter.ux_device_class_hid_parameter_report_address = hid_report_descriptor;
623 hid_parameter.ux_device_class_hid_parameter_report_length = HID_REPORT_LENGTH;
624 hid_parameter.ux_device_class_hid_parameter_callback = demo_thread_hid_callback;
625
626 /* Initilize the device hid class. The class is connected with interface 2 */
627 status = ux_device_stack_class_register(_ux_system_slave_class_hid_name, ux_device_class_hid_entry,
628 1,2, (VOID *)&hid_parameter);
629 if(status!=UX_SUCCESS)
630 {
631
632 printf("Error on line %d\n", __LINE__);
633 test_control_return(1);
634 }
635
636
637 /* Initialize the simulated device controller. */
638 status = _ux_dcd_sim_slave_initialize();
639
640 /* Check for error. */
641 if (status != UX_SUCCESS)
642 {
643
644 printf("Error on line %d\n", __LINE__);
645 test_control_return(1);
646 }
647
648 /* Register all the USB host controllers available in this system */
649 status = ux_host_stack_hcd_register(_ux_system_host_hcd_simulator_name, ux_hcd_sim_host_initialize,0,0);
650
651 /* Check for error. */
652 if (status != UX_SUCCESS)
653 {
654
655 printf("Error on line %d\n", __LINE__);
656 test_control_return(1);
657 }
658
659 /* Create the main host simulation thread. */
660 status = tx_thread_create(&tx_demo_thread_host_simulation, "tx demo host simulation", tx_demo_thread_host_simulation_entry, 0,
661 stack_pointer, UX_DEMO_STACK_SIZE,
662 20, 20, 1, TX_AUTO_START);
663
664 /* Check for error. */
665 if (status != TX_SUCCESS)
666 {
667
668 printf("Error on line %d\n", __LINE__);
669 test_control_return(1);
670 }
671 }
672
673
tx_demo_thread_host_simulation_entry(ULONG arg)674 static void tx_demo_thread_host_simulation_entry(ULONG arg)
675 {
676
677 UINT status;
678 UX_HOST_CLASS_HID_REPORT_GET_ID report_id;
679
680
681 /* Find the HID class */
682 status = demo_class_hid_get();
683 if (status != UX_SUCCESS)
684 {
685
686 printf("Error on line %d\n", __LINE__);
687 test_control_return(1);
688 }
689
690 /* Get the input report descriptor. */
691 report_id.ux_host_class_hid_report_get_report = UX_NULL;
692 report_id.ux_host_class_hid_report_get_type = UX_HOST_CLASS_HID_REPORT_TYPE_INPUT;
693 status = ux_host_class_hid_report_id_get(hid, &report_id);
694 if (status != UX_SUCCESS)
695 {
696
697 printf("Error on line %d\n", __LINE__);
698 test_control_return(1);
699 }
700
701 /* Do minimal error-checking. */
702 if (report_id.ux_host_class_hid_report_get_report == UX_NULL)
703 {
704
705 printf("Error on line %d\n", __LINE__);
706 test_control_return(1);
707 }
708
709 /* Now disconnect the device. */
710 _ux_device_stack_disconnect();
711
712 /* And deinitialize the class. */
713 status = ux_device_stack_class_unregister(_ux_system_slave_class_hid_name, ux_device_class_hid_entry);
714
715 /* Deinitialize the device side of usbx. */
716 _ux_device_stack_uninitialize();
717
718 /* And finally the usbx system resources. */
719 _ux_system_uninitialize();
720
721 /* Successful test. */
722 printf("SUCCESS!\n");
723 test_control_return(0);
724 }
725
demo_thread_hid_callback(UX_SLAVE_CLASS_HID * class,UX_SLAVE_CLASS_HID_EVENT * event)726 static UINT demo_thread_hid_callback(UX_SLAVE_CLASS_HID *class, UX_SLAVE_CLASS_HID_EVENT *event)
727 {
728 return(UX_SUCCESS);
729 }
730