1 /* This test ensures that the parser generates an error upon encountering an invalid close delimiter tag. */
2
3 #include "usbx_test_common_hid.h"
4 #include "ux_host_class_hid_keyboard.h"
5
6 #include "ux_test.h"
7 #include "ux_test_hcd_sim_host.h"
8
9 #define TEST_SLAVE_REQUEST_CONTROL_MAX_LENGTH 8192
10
11 #define REP2_0(v0,v1)
12 #define REP2_1(v0,v1) v0,v1,
13 #define REP2_2(v0,v1) REP2_1(v0,v1) v0,v1,
14 #define REP2_3(v0,v1) REP2_2(v0,v1) v0,v1,
15 #define REP2_4(v0,v1) REP2_3(v0,v1) v0,v1,
16 #define REP2_5(v0,v1) REP2_4(v0,v1) v0,v1,
17 #define REP2_6(v0,v1) REP2_5(v0,v1) v0,v1,
18 #define REP2_7(v0,v1) REP2_6(v0,v1) v0,v1,
19 #define REP2_8(v0,v1) REP2_7(v0,v1) v0,v1,
20 #define REP2_9(v0,v1) REP2_8(v0,v1) v0,v1,
21 #define REP2_10(v0,v1) REP2_9(v0,v1) v0,v1,
22 #define REP2_20(v0,v1) REP2_10(v0,v1) REP2_10(v0,v1)
23 #define REP2_50(v0,v1) REP2_10(v0,v1) REP2_10(v0,v1) REP2_10(v0,v1) REP2_10(v0,v1) REP2_10(v0,v1)
24 #define REP2_100(v0,v1) REP2_50(v0,v1) REP2_50(v0,v1)
25 #define REP2_200(v0,v1) REP2_100(v0,v1) REP2_100(v0,v1)
26 #define REP2_500(v0,v1) REP2_100(v0,v1) REP2_100(v0,v1) REP2_100(v0,v1) REP2_100(v0,v1) REP2_100(v0,v1)
27 #define REP2_1000(v0,v1) REP2_500(v0,v1) REP2_500(v0,v1)
28
29 #define REP4_0(v0,v1,v2,v3)
30 #define REP4_1(v0,v1,v2,v3) v0,v1,v2,v3,
31 #define REP4_2(v0,v1,v2,v3) REP4_1(v0,v1,v2,v3) v0,v1,v2,v3,
32 #define REP4_3(v0,v1,v2,v3) REP4_2(v0,v1,v2,v3) v0,v1,v2,v3,
33 #define REP4_4(v0,v1,v2,v3) REP4_3(v0,v1,v2,v3) v0,v1,v2,v3,
34 #define REP4_5(v0,v1,v2,v3) REP4_4(v0,v1,v2,v3) v0,v1,v2,v3,
35 #define REP4_6(v0,v1,v2,v3) REP4_5(v0,v1,v2,v3) v0,v1,v2,v3,
36 #define REP4_7(v0,v1,v2,v3) REP4_6(v0,v1,v2,v3) v0,v1,v2,v3,
37 #define REP4_8(v0,v1,v2,v3) REP4_7(v0,v1,v2,v3) v0,v1,v2,v3,
38 #define REP4_9(v0,v1,v2,v3) REP4_8(v0,v1,v2,v3) v0,v1,v2,v3,
39 #define REP4_10(v0,v1,v2,v3) REP4_9(v0,v1,v2,v3) v0,v1,v2,v3,
40 #define REP4_20(v0,v1,v2,v3) REP4_10(v0,v1,v2,v3) REP4_10(v0,v1,v2,v3)
41 #define REP4_50(v0,v1,v2,v3) REP4_10(v0,v1,v2,v3) REP4_10(v0,v1,v2,v3) REP4_10(v0,v1,v2,v3) REP4_10(v0,v1,v2,v3) REP4_10(v0,v1,v2,v3)
42 #define REP4_100(v0,v1,v2,v3) REP4_50(v0,v1,v2,v3) REP4_50(v0,v1,v2,v3)
43 #define REP4_200(v0,v1,v2,v3) REP4_100(v0,v1,v2,v3) REP4_100(v0,v1,v2,v3)
44 #define REP4_500(v0,v1,v2,v3) REP4_100(v0,v1,v2,v3) REP4_100(v0,v1,v2,v3) REP4_100(v0,v1,v2,v3) REP4_100(v0,v1,v2,v3) REP4_100(v0,v1,v2,v3)
45 #define REP4_1000(v0,v1,v2,v3) REP4_500(v0,v1,v2,v3) REP4_500(v0,v1,v2,v3)
46
47 static UINT callback_error_code;
48
49 static UCHAR hid_report_descriptor[] = {
50
51 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
52 0x09, 0x06, // USAGE (Keyboard)
53 0xa1, 0x01, // COLLECTION (Application)
54 0xa9, 0x01, // DELIMITER (Open)
55 0x0b, 0x20, 0x00, 0x05, 0x00, // USAGE (Gaming Controls:Point of View)
56 0x0b, 0x39, 0x00, 0x01, 0x00, // USAGE (Generic Desktop:Hat switch)
57 0x0b, 0x20, 0x00, 0x05, 0x00, // USAGE (Gaming Controls:Point of View)
58 0xa9, 0x00, // DELIMITER (Close)
59 0x15, 0x00, // LOGICAL_MINIMUM (0)
60 0x25, 0x03, // LOGICAL_MAXIMUM (3)
61 0x35, 0x00, // PHYSICAL_MINIMUM (0)
62 0x46, 0x0e, 0x01, // PHYSICAL_MAXIMUM (270)
63 0x65, 0x14, // UNIT (Eng Rot:Angular Pos)
64 0x55, 0x00, // UNIT_EXPONENT (0)
65 0x75, 0x04, // REPORT_SIZE (4)
66 0x95, 0x01, // REPORT_COUNT (1)
67 0x81, 0x02, // INPUT (Data,Var,Abs)
68 0xc0 // END_COLLECTION
69 };
70 #define HID_REPORT_LENGTH sizeof(hid_report_descriptor)/sizeof(hid_report_descriptor[0])
71
72 #if UX_HOST_CLASS_HID_USAGES == 1024
73 static UCHAR hid_report_descriptor1[] = {
74
75 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
76 0x09, 0x06, // USAGE (Keyboard)
77 0xa1, 0x01, // COLLECTION (Application)
78 0xa9, 0x01, // DELIMITER (Open)
79 REP4_5(0x19, 1, 0x29, 200)
80 REP4_1(0x19, 1, 0x29, 23)
81 REP2_5(0x09, 0x30)
82 0x0b, 0x20, 0x00, 0x05, 0x00, // USAGE (Gaming Controls:Point of View)
83 0x0b, 0x39, 0x00, 0x01, 0x00, // USAGE (Generic Desktop:Hat switch)
84 0x0b, 0x20, 0x00, 0x05, 0x00, // USAGE (Gaming Controls:Point of View)
85 0xa9, 0x00, // DELIMITER (Close)
86 0x15, 0x00, // LOGICAL_MINIMUM (0)
87 0x25, 0x03, // LOGICAL_MAXIMUM (3)
88 0x35, 0x00, // PHYSICAL_MINIMUM (0)
89 0x46, 0x0e, 0x01, // PHYSICAL_MAXIMUM (270)
90 0x65, 0x14, // UNIT (Eng Rot:Angular Pos)
91 0x55, 0x00, // UNIT_EXPONENT (0)
92 0x75, 0x04, // REPORT_SIZE (4)
93 0x95, 0x01, // REPORT_COUNT (1)
94 0x81, 0x02, // INPUT (Data,Var,Abs)
95 0xc0 // END_COLLECTION
96 };
97 #define HID_REPORT_LENGTH1 sizeof(hid_report_descriptor1)/sizeof(hid_report_descriptor1[0])
98
99 static UCHAR hid_report_descriptor2[] = {
100
101 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
102 0x09, 0x06, // USAGE (Keyboard)
103 0xa1, 0x01, // COLLECTION (Application)
104 0xa9, 0x01, // DELIMITER (Open)
105 REP4_5(0x19, 1, 0x29, 200)
106 REP4_1(0x19, 1, 0x29, 30)
107 0x0b, 0x20, 0x00, 0x05, 0x00, // USAGE (Gaming Controls:Point of View)
108 0x0b, 0x39, 0x00, 0x01, 0x00, // USAGE (Generic Desktop:Hat switch)
109 0x0b, 0x20, 0x00, 0x05, 0x00, // USAGE (Gaming Controls:Point of View)
110 0xa9, 0x00, // DELIMITER (Close)
111 0x15, 0x00, // LOGICAL_MINIMUM (0)
112 0x25, 0x03, // LOGICAL_MAXIMUM (3)
113 0x35, 0x00, // PHYSICAL_MINIMUM (0)
114 0x46, 0x0e, 0x01, // PHYSICAL_MAXIMUM (270)
115 0x65, 0x14, // UNIT (Eng Rot:Angular Pos)
116 0x55, 0x00, // UNIT_EXPONENT (0)
117 0x75, 0x04, // REPORT_SIZE (4)
118 0x95, 0x01, // REPORT_COUNT (1)
119 0x81, 0x02, // INPUT (Data,Var,Abs)
120 0xc0 // END_COLLECTION
121 };
122 #define HID_REPORT_LENGTH2 sizeof(hid_report_descriptor2)/sizeof(hid_report_descriptor2[0])
123 #else /* UX_HOST_CLASS_HID_USAGES == 1024 */
hid_usage_min_max_add(UCHAR * ptr,UCHAR min,UCHAR max)124 static inline void hid_usage_min_max_add(UCHAR *ptr, UCHAR min, UCHAR max)
125 {
126 ptr[0] = 0x19;
127 ptr[1] = min;
128 ptr[2] = 0x29;
129 ptr[3] = max;
130 }
131
hid_usage_add(UCHAR * ptr,UCHAR usage)132 static inline void hid_usage_add(UCHAR *ptr, UCHAR usage)
133 {
134 ptr[0] = 0x09;
135 ptr[1] = usage;
136 }
137
138 /* usage : 200 x N + M */
139 #define _DIV200(V) ((V)/200)
140 #define _MOD200(V) ((V)%200)
141 #define _P1_START (0)
142 #define _P1_SIZE (8)
143 #define _P2_START (_P1_SIZE)
144 #define _P2_SIZE (HID_REPORT_LENGTH - _P1_SIZE)
145 static UCHAR hid_report_descriptor_mem[HID_REPORT_LENGTH + _DIV200(UX_HOST_CLASS_HID_USAGES + 10) * 4 + 10 * 4];
146 static UCHAR *hid_report_descriptor1 = hid_report_descriptor_mem;
147 static UCHAR *hid_report_descriptor2 = hid_report_descriptor_mem;
148 #define HID_REPORT_LENGTH1 (HID_REPORT_LENGTH+_DIV200(UX_HOST_CLASS_HID_USAGES-1)*4+1*4+5*2)
149 #define HID_REPORT_LENGTH2 (HID_REPORT_LENGTH+_DIV200(UX_HOST_CLASS_HID_USAGES+5)*4+2*4)
hid_report_descriptor_generate(ULONG length)150 static void hid_report_descriptor_generate(ULONG length)
151 {
152
153 UINT i;
154 UCHAR *ptr = hid_report_descriptor_mem;
155 UINT nb_min_max0, nb_min_max1, nb_usage;
156
157
158 _ux_utility_memory_copy(ptr, hid_report_descriptor + _P1_START, _P1_SIZE);
159 ptr += _P1_SIZE;
160
161 /* Build descriptor. */
162 switch(length)
163 {
164 case HID_REPORT_LENGTH1:
165 nb_min_max0 = _DIV200(UX_HOST_CLASS_HID_USAGES-1);
166 nb_min_max1 = 1;
167 nb_usage = 5;
168 break;
169
170 case HID_REPORT_LENGTH2:
171 nb_min_max0 = _DIV200(UX_HOST_CLASS_HID_USAGES+5);
172 nb_min_max1 = 2;
173 nb_usage = 0;
174 break;
175
176 default:
177 nb_min_max0 = 0;
178 nb_min_max1 = 0;
179 nb_usage = 0;
180 }
181 for (i = 0; i < nb_min_max0; i ++)
182 {
183 hid_usage_min_max_add(ptr, 1, 200);
184 ptr += 4;
185 }
186 for (i = 0; i < nb_min_max1; i ++)
187 {
188 hid_usage_min_max_add(ptr, 1, _MOD200(UX_HOST_CLASS_HID_USAGES));
189 ptr += 4;
190 }
191 for (i = 0; i < nb_usage; i ++)
192 {
193 hid_usage_add(ptr, 0x30);
194 ptr += 2;
195 }
196
197 _ux_utility_memory_copy(ptr, hid_report_descriptor + _P2_START, _P2_SIZE);
198 #if 0
199 printf("N usage max: %d\n", UX_HOST_CLASS_HID_USAGES);
200 printf("Len %ld or (%d, %d) - %d, %d, %d\n", length, HID_REPORT_LENGTH1, HID_REPORT_LENGTH2, nb_min_max0, nb_min_max1, nb_usage);
201 printf("hid_report_descriptor:");
202 for (i = 0; i < HID_REPORT_LENGTH; i ++)
203 {
204 if ((i & 3) == 0) printf("\n");
205 printf(" %2x", hid_report_descriptor[i]);
206 }
207 printf("\n");
208 printf("hid_report_descriptor_mem:");
209 for (i = 0; i < length; i ++)
210 {
211 if ((i & 3) == 0) printf("\n");
212 printf(" %2x", hid_report_descriptor_mem[i]);
213 }
214 printf("\n");
215 #endif
216 }
217 #endif
218
219 #define DEVICE_FRAMEWORK_LENGTH_FULL_SPEED 52
220 static UCHAR device_framework_full_speed[DEVICE_FRAMEWORK_LENGTH_FULL_SPEED] = {
221
222 /* Device descriptor */
223 0x12, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x08,
224 0x81, 0x0A, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
225 0x00, 0x01,
226
227 /* Configuration descriptor */
228 0x09, 0x02, 0x22, 0x00, 0x01, 0x01, 0x00, 0xc0,
229 0x32,
230
231 /* Interface descriptor */
232 0x09, 0x04, 0x02, 0x00, 0x01, 0x03, 0x00, 0x00,
233 0x00,
234
235 /* HID descriptor */
236 0x09, 0x21, 0x10, 0x01, 0x21, 0x01, 0x22, LSB(HID_REPORT_LENGTH),
237 MSB(HID_REPORT_LENGTH),
238
239 /* Endpoint descriptor (Interrupt) */
240 0x07, 0x05, 0x82, 0x03, 0x08, 0x00, 0x08
241
242 };
243
244
245 #define DEVICE_FRAMEWORK_LENGTH_HIGH_SPEED 62
246 static UCHAR device_framework_high_speed[DEVICE_FRAMEWORK_LENGTH_HIGH_SPEED] = {
247
248 /* Device descriptor */
249 0x12, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x40,
250 0x0a, 0x07, 0x25, 0x40, 0x01, 0x00, 0x01, 0x02,
251 0x03, 0x01,
252
253 /* Device qualifier descriptor */
254 0x0a, 0x06, 0x00, 0x02, 0x00, 0x00, 0x00, 0x40,
255 0x01, 0x00,
256
257 /* Configuration descriptor */
258 0x09, 0x02, 0x22, 0x00, 0x01, 0x01, 0x00, 0xc0,
259 0x32,
260
261 /* Interface descriptor */
262 0x09, 0x04, 0x02, 0x00, 0x01, 0x03, 0x00, 0x00,
263 0x00,
264
265 /* HID descriptor */
266 0x09, 0x21, 0x10, 0x01, 0x21, 0x01, 0x22, LSB(HID_REPORT_LENGTH),
267 MSB(HID_REPORT_LENGTH),
268
269 /* Endpoint descriptor (Interrupt) */
270 0x07, 0x05, 0x82, 0x03, 0x08, 0x00, 0x08
271
272 };
273
274
275 /* String Device Framework :
276 Byte 0 and 1 : Word containing the language ID : 0x0904 for US
277 Byte 2 : Byte containing the index of the descriptor
278 Byte 3 : Byte containing the length of the descriptor string
279 */
280
281 #define STRING_FRAMEWORK_LENGTH 40
282 static UCHAR string_framework[] = {
283
284 /* Manufacturer string descriptor : Index 1 */
285 0x09, 0x04, 0x01, 0x0c,
286 0x45, 0x78, 0x70, 0x72,0x65, 0x73, 0x20, 0x4c,
287 0x6f, 0x67, 0x69, 0x63,
288
289 /* Product string descriptor : Index 2 */
290 0x09, 0x04, 0x02, 0x0c,
291 0x55, 0x53, 0x42, 0x20, 0x4b, 0x65, 0x79, 0x62,
292 0x6f, 0x61, 0x72, 0x64,
293
294 /* Serial Number string descriptor : Index 3 */
295 0x09, 0x04, 0x03, 0x04,
296 0x30, 0x30, 0x30, 0x31
297 };
298
299
300 /* Multiple languages are supported on the device, to add
301 a language besides english, the unicode language code must
302 be appended to the language_id_framework array and the length
303 adjusted accordingly. */
304 #define LANGUAGE_ID_FRAMEWORK_LENGTH 2
305 static UCHAR language_id_framework[] = {
306
307 /* English. */
308 0x09, 0x04
309 };
310
311
312
error_callback(UINT system_level,UINT system_context,UINT error_code)313 static VOID error_callback(UINT system_level, UINT system_context, UINT error_code)
314 {
315 if (error_code != UX_HOST_CLASS_HID_USAGE_OVERFLOW &&
316 error_code != UX_DEVICE_ENUMERATION_FAILURE &&
317 error_code != UX_HOST_CLASS_INSTANCE_UNKNOWN &&
318 error_code != UX_DESCRIPTOR_CORRUPTED)
319 {
320
321 /* Something went wrong. */
322 printf("Error on line %d: code 0x%x\n", __LINE__, error_code);
323 test_control_return(1);
324 }
325 }
326
set_hid_descriptor(UCHAR * descriptor,ULONG length)327 static VOID set_hid_descriptor(UCHAR *descriptor, ULONG length)
328 {
329
330 UX_SLAVE_CLASS *class;
331 UX_SLAVE_CLASS_HID *hid_class;
332
333
334 device_framework_full_speed[DEVICE_FRAMEWORK_LENGTH_FULL_SPEED - 9] = LSB(length);
335 device_framework_full_speed[DEVICE_FRAMEWORK_LENGTH_FULL_SPEED - 8] = MSB(length);
336 device_framework_high_speed[DEVICE_FRAMEWORK_LENGTH_HIGH_SPEED - 9] = LSB(length);
337 device_framework_high_speed[DEVICE_FRAMEWORK_LENGTH_HIGH_SPEED - 8] = MSB(length);
338
339 /* Modify class settings. */
340 class = &_ux_system_slave->ux_system_slave_class_array[0];
341 hid_class = (UX_SLAVE_CLASS_HID*)class->ux_slave_class_instance;
342
343 hid_class->ux_device_class_hid_report_address = descriptor;
344 hid_class->ux_device_class_hid_report_length = length;
345
346 #if UX_HOST_CLASS_HID_USAGES != 1024
347 hid_report_descriptor_generate(length);
348 #endif
349 }
350
351 /* Define what the initial system looks like. */
352
353 #ifdef CTEST
test_application_define(void * first_unused_memory)354 void test_application_define(void *first_unused_memory)
355 #else
356 void usbx_ux_host_class_hid_local_item_parse_test_application_define(void *first_unused_memory)
357 #endif
358 {
359
360 UINT status;
361 CHAR * stack_pointer;
362 CHAR * memory_pointer;
363 UINT descriptor_size = HID_REPORT_LENGTH;
364
365 /* Inform user. */
366 printf("Running ux_host_class_hid_local_item_parse Test..................... ");
367 stepinfo("\n");
368
369 /* Initialize the free memory pointer */
370 stack_pointer = (CHAR *) usbx_memory;
371 memory_pointer = stack_pointer + (UX_DEMO_STACK_SIZE * 2);
372
373 /* Initialize USBX. Memory */
374 status = ux_system_initialize(memory_pointer, UX_DEMO_MEMORY_SIZE, UX_NULL,0);
375
376 /* Check for error. */
377 if (status != UX_SUCCESS)
378 {
379
380 printf("Error on line %d\n", __LINE__);
381 test_control_return(1);
382 }
383
384 /* Register the error callback. */
385 _ux_utility_error_callback_register(error_callback);
386
387 /* The code below is required for installing the host portion of USBX */
388 status = ux_host_stack_initialize(UX_NULL);
389 if (status != UX_SUCCESS)
390 {
391
392 printf("Error on line %d\n", __LINE__);
393 test_control_return(1);
394 }
395
396 status = ux_host_stack_class_register(_ux_system_host_class_hid_name, ux_host_class_hid_entry);
397 if (status != UX_SUCCESS)
398 {
399
400 printf("Error on line %d\n", __LINE__);
401 test_control_return(1);
402 }
403
404 /* Register the HID client(s). */
405 status = ux_host_class_hid_client_register(_ux_system_host_class_hid_client_keyboard_name, ux_host_class_hid_keyboard_entry);
406 if (status != UX_SUCCESS)
407 {
408
409 printf("Error on line %d, error code: 0x%x\n", __LINE__, status);
410 test_control_return(1);
411 }
412
413 /* The code below is required for installing the device portion of USBX. No call back for
414 device status change in this example. */
415 status = ux_device_stack_initialize(device_framework_high_speed, DEVICE_FRAMEWORK_LENGTH_HIGH_SPEED,
416 device_framework_full_speed, DEVICE_FRAMEWORK_LENGTH_FULL_SPEED,
417 string_framework, STRING_FRAMEWORK_LENGTH,
418 language_id_framework, LANGUAGE_ID_FRAMEWORK_LENGTH,UX_NULL);
419 if(status!=UX_SUCCESS)
420 {
421
422 printf("Error on line %d\n", __LINE__);
423 test_control_return(1);
424 }
425
426 /* Initialize the hid class parameters. */
427 hid_parameter.ux_device_class_hid_parameter_report_address = hid_report_descriptor;
428 hid_parameter.ux_device_class_hid_parameter_report_length = HID_REPORT_LENGTH;
429 hid_parameter.ux_device_class_hid_parameter_callback = demo_thread_hid_callback;
430
431 /* Initilize the device hid class. The class is connected with interface 2 */
432 status = ux_device_stack_class_register(_ux_system_slave_class_hid_name, ux_device_class_hid_entry,
433 1,2, (VOID *)&hid_parameter);
434 if(status!=UX_SUCCESS)
435 {
436
437 printf("Error on line %d\n", __LINE__);
438 test_control_return(1);
439 }
440
441 /* Initialize the simulated device controller. */
442 status = _ux_dcd_sim_slave_initialize();
443
444 /* Check for error. */
445 if (status != UX_SUCCESS)
446 {
447
448 printf("Error on line %d\n", __LINE__);
449 test_control_return(1);
450 }
451
452 /* Register all the USB host controllers available in this system */
453 status = ux_host_stack_hcd_register(_ux_system_host_hcd_simulator_name, ux_hcd_sim_host_initialize,0,0);
454
455 /* Check for error. */
456 if (status != UX_SUCCESS)
457 {
458
459 printf("Error on line %d\n", __LINE__);
460 test_control_return(1);
461 }
462
463 /* Create the main host simulation thread. */
464 status = tx_thread_create(&tx_demo_thread_host_simulation, "tx demo host simulation", tx_demo_thread_host_simulation_entry, 0,
465 stack_pointer, UX_DEMO_STACK_SIZE,
466 20, 20, 1, TX_AUTO_START);
467
468 /* Check for error. */
469 if (status != TX_SUCCESS)
470 {
471
472 printf("Error on line %d\n", __LINE__);
473 test_control_return(1);
474 }
475 }
476
tx_demo_thread_host_simulation_entry(ULONG arg)477 static void tx_demo_thread_host_simulation_entry(ULONG arg)
478 {
479
480 UINT status;
481
482 stepinfo(">>>>>>>>>>> Test normal connect\n");
483
484 /* Find the HID class */
485 status = demo_class_hid_get();
486 if (status != UX_SUCCESS)
487 {
488
489 printf("Error on line %d, error code: 0x%x\n", __LINE__, status);
490 test_control_return(1);
491 }
492
493 stepinfo(">>>>>>>>>>> Test USAGE overflow\n");
494 ux_test_hcd_sim_host_disconnect();
495 set_hid_descriptor(hid_report_descriptor1, HID_REPORT_LENGTH1);
496 ux_test_hcd_sim_host_connect(UX_FULL_SPEED_DEVICE);
497 status = demo_class_hid_get();
498 if (status == UX_SUCCESS)
499 {
500
501 printf("Error on line %d, error code: 0x%x\n", __LINE__, status);
502 test_control_return(1);
503 }
504
505 stepinfo(">>>>>>>>>>> Test USAGE_MAXIMUM overflow\n");
506 ux_test_hcd_sim_host_disconnect();
507 set_hid_descriptor(hid_report_descriptor2, HID_REPORT_LENGTH2);
508 ux_test_hcd_sim_host_connect(UX_FULL_SPEED_DEVICE);
509 status = demo_class_hid_get();
510 if (status == UX_SUCCESS)
511 {
512
513 printf("Error on line %d, error code: 0x%x\n", __LINE__, status);
514 test_control_return(1);
515 }
516
517 /* Now disconnect the device. */
518 _ux_device_stack_disconnect();
519
520 /* And deinitialize the class. */
521 status = ux_device_stack_class_unregister(_ux_system_slave_class_hid_name, ux_device_class_hid_entry);
522
523 /* Deinitialize the device side of usbx. */
524 _ux_device_stack_uninitialize();
525
526 /* And finally the usbx system resources. */
527 _ux_system_uninitialize();
528
529 /* Successful test. */
530 printf("SUCCESS!\n");
531 test_control_return(0);
532 }
533
534
demo_thread_hid_callback(UX_SLAVE_CLASS_HID * class,UX_SLAVE_CLASS_HID_EVENT * event)535 static UINT demo_thread_hid_callback(UX_SLAVE_CLASS_HID *class, UX_SLAVE_CLASS_HID_EVENT *event)
536 {
537 return(UX_SUCCESS);
538 }