1
10
11
12
13
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
134
135
136
137
138
139
140
141
142
143
149
150
151
152
153
154
161
162
163
164
165
166
167
168
169
175
176
177
178
179
180
181
182
183
184
185
186
190
191
194
195
196
197
198
199
200
207
213
217
218
219
220
221
222
...
...
#define UX_SOURCE_CODE
#include "ux_api.h"
#include "ux_device_class_hid.h"
#include "ux_device_stack.h"
...
...
UINT _ux_device_class_hid_control_request(UX_SLAVE_CLASS_COMMAND *command)
{
UX_SLAVE_TRANSFER *transfer_request;
UX_SLAVE_DEVICE *device;
UX_SLAVE_CLASS *class;
ULONG request;
ULONG request_value;
ULONG request_index;
ULONG request_length;
ULONG descriptor_type;
UCHAR duration;
UX_SLAVE_CLASS_HID *hid;
device = &_ux_system_slave -> ux_system_slave_device;
transfer_request = &device -> ux_slave_device_control_endpoint.ux_slave_endpoint_transfer_request;
request = *(transfer_request -> ux_slave_transfer_request_setup + UX_SETUP_REQUEST);
request_value = _ux_utility_short_get(transfer_request -> ux_slave_transfer_request_setup + UX_SETUP_VALUE);
request_index = _ux_utility_short_get(transfer_request -> ux_slave_transfer_request_setup + UX_SETUP_INDEX);
request_length = _ux_utility_short_get(transfer_request -> ux_slave_transfer_request_setup + UX_SETUP_LENGTH);
duration = *(transfer_request -> ux_slave_transfer_request_setup + UX_SETUP_VALUE + 1);
class = command -> ux_slave_class_command_class_ptr;
hid = (UX_SLAVE_CLASS_HID *) class -> ux_slave_class_instance;
switch (request)
{
case UX_DEVICE_CLASS_HID_COMMAND_GET_REPORT:
_ux_device_class_hid_report_get(hid, request_value, request_index, request_length);
break;
case UX_DEVICE_CLASS_HID_COMMAND_GET_REPORT:
case UX_DEVICE_CLASS_HID_COMMAND_SET_REPORT:
descriptor_type = (request_value & 0xff00) >> 8;
_ux_device_class_hid_report_set(hid, descriptor_type, request_index, request_length);
break;
case UX_DEVICE_CLASS_HID_COMMAND_SET_REPORT:
case UX_GET_DESCRIPTOR:
_ux_device_class_hid_descriptor_send(hid, request_value, request_index, request_length);
break;
case UX_GET_DESCRIPTOR:
case UX_DEVICE_CLASS_HID_COMMAND_GET_IDLE:
case UX_DEVICE_CLASS_HID_COMMAND_SET_IDLE:
if (request == UX_DEVICE_CLASS_HID_COMMAND_GET_IDLE)
{
*transfer_request -> ux_slave_transfer_request_data_pointer = (UCHAR)hid -> ux_device_class_hid_event_idle_rate;
_ux_device_stack_transfer_request(transfer_request, 1, request_length);
}if (request == UX_DEVICE_CLASS_HID_COMMAND_GET_IDLE) { ... }
else
{
if ((UCHAR)hid -> ux_device_class_hid_event_idle_rate != duration)
{
hid -> ux_device_class_hid_event_idle_rate = duration;
if (duration == 0)
{
hid -> ux_device_class_hid_event_wait_timeout = UX_WAIT_FOREVER;
}if (duration == 0) { ... }
else
{
hid -> ux_device_class_hid_event_wait_timeout = (ULONG)UX_MS_TO_TICK((ULONG)duration << 2u);
if (hid -> ux_device_class_hid_event_wait_timeout == 0)
hid -> ux_device_class_hid_event_wait_timeout ++;
#if defined(UX_DEVICE_STANDALONE)
if (hid -> ux_device_class_hid_event_state != UX_STATE_WAIT)
hid -> ux_device_class_hid_event_state = UX_STATE_RESET;/* ... */
#else
_ux_utility_event_flags_set(&hid -> ux_device_class_hid_event_flags_group, UX_DEVICE_CLASS_HID_NEW_IDLE_RATE, UX_OR);/* ... */
#endif
}else { ... }
}if ((UCHAR)hid -> ux_device_class_hid_event_idle_rate != duration) { ... }
}else { ... }
break;
case UX_DEVICE_CLASS_HID_COMMAND_SET_IDLE:
case UX_DEVICE_CLASS_HID_COMMAND_GET_PROTOCOL:
*transfer_request -> ux_slave_transfer_request_data_pointer = (UCHAR)hid -> ux_device_class_hid_protocol;
_ux_device_stack_transfer_request(transfer_request, 1, request_length);
break;
case UX_DEVICE_CLASS_HID_COMMAND_GET_PROTOCOL:
case UX_DEVICE_CLASS_HID_COMMAND_SET_PROTOCOL:
hid -> ux_device_class_hid_protocol = request_value;
break;
case UX_DEVICE_CLASS_HID_COMMAND_SET_PROTOCOL:
default:
return(UX_ERROR);default
}switch (request) { ... }
return(UX_SUCCESS);
}{ ... }