1
10
13
14
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
121
122
123
124
125
126
127
129
136
137
139
140
141
142
143
144
145
146
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
212
215
216
217
218
219
220
221
222
223
224
225
226
227
228
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
258
263
268
269
270
271
272
273
274
275
276
277
282
287
292
297
302
308
313
317
318
319
320
321
322
323
324
325
326
327
328
...
...
...
#define UX_SOURCE_CODE
#include "ux_api.h"
#include "ux_device_stack.h"
...
...
UINT _ux_device_stack_control_request_process(UX_SLAVE_TRANSFER *transfer_request)
{
UX_SLAVE_DCD *dcd;
UX_SLAVE_DEVICE *device;
UX_SLAVE_CLASS *class;
UX_SLAVE_CLASS_COMMAND class_command;
ULONG request_type;
ULONG request;
ULONG request_value;
ULONG request_index;
ULONG request_length;
ULONG class_index;
UINT status = UX_ERROR;
UX_SLAVE_ENDPOINT *endpoint;
ULONG application_data_length;
dcd = &_ux_system_slave -> ux_system_slave_dcd;
device = &_ux_system_slave -> ux_system_slave_device;
if (transfer_request -> ux_slave_transfer_request_completion_code == UX_SUCCESS)
{
/* ... */
request_type = *transfer_request -> ux_slave_transfer_request_setup;
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);
/* ... */
if ((request == UX_GET_DESCRIPTOR || request == UX_SET_DESCRIPTOR) && (((request_value >> 8) & UX_REQUEST_TYPE) != UX_REQUEST_TYPE_STANDARD))
{
request_type &= (UINT)~UX_REQUEST_TYPE;
request_type |= UX_REQUEST_TYPE_CLASS;
}if ((request == UX_GET_DESCRIPTOR || request == UX_SET_DESCRIPTOR) && (((request_value >> 8) & UX_REQUEST_TYPE) != UX_REQUEST_TYPE_STANDARD)) { ... }
/* ... */
if ((request_type & UX_REQUEST_TYPE) == UX_REQUEST_TYPE_VENDOR)
{
if (request == _ux_system_slave -> ux_system_slave_device_vendor_request)
{
/* ... */
application_data_length = UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH;
status = _ux_system_slave -> ux_system_slave_device_vendor_request_function(request, request_value,
request_index, request_length,
transfer_request -> ux_slave_transfer_request_data_pointer,
&application_data_length);
if (status == UX_SUCCESS)
{
endpoint = &device -> ux_slave_device_control_endpoint;
transfer_request = &endpoint -> ux_slave_endpoint_transfer_request;
transfer_request -> ux_slave_transfer_request_phase = UX_TRANSFER_PHASE_DATA_OUT;
_ux_device_stack_transfer_request(transfer_request, application_data_length, request_length);
return(UX_SUCCESS);
}if (status == UX_SUCCESS) { ... }
else
{
_ux_device_stack_endpoint_stall(&device -> ux_slave_device_control_endpoint);
return(UX_SUCCESS);
}else { ... }
}if (request == _ux_system_slave -> ux_system_slave_device_vendor_request) { ... }
}if ((request_type & UX_REQUEST_TYPE) == UX_REQUEST_TYPE_VENDOR) { ... }
/* ... */
if (((request_type & UX_REQUEST_TYPE) == UX_REQUEST_TYPE_CLASS) ||
((request_type & UX_REQUEST_TYPE) == UX_REQUEST_TYPE_VENDOR))
{
class_command.ux_slave_class_command_request = UX_SLAVE_CLASS_COMMAND_REQUEST;
for (class_index = 0; class_index < UX_MAX_SLAVE_INTERFACES; class_index ++)
{
class = _ux_system_slave -> ux_system_slave_interface_class_array[class_index];
if (class == UX_NULL)
continue;
if ((request_type & UX_REQUEST_TARGET) == UX_REQUEST_TARGET_INTERFACE)
{
/* ... */
/* ... */
if (((request_index & 0xFF) != class_index) ||
((class -> ux_slave_class_interface -> ux_slave_interface_descriptor.bInterfaceClass == 0x07) &&
(request == 0x00) &&
*(transfer_request -> ux_slave_transfer_request_setup + UX_SETUP_INDEX + 1) != class_index))
continue;
}if ((request_type & UX_REQUEST_TARGET) == UX_REQUEST_TARGET_INTERFACE) { ... }
class_command.ux_slave_class_command_class_ptr = class;
status = class -> ux_slave_class_entry_function(&class_command);
/* ... */
if (status == UX_SUCCESS)
break;
}for (class_index = 0; class_index < UX_MAX_SLAVE_INTERFACES; class_index ++) { ... }
if (status != UX_SUCCESS)
_ux_device_stack_endpoint_stall(&device -> ux_slave_device_control_endpoint);
return(status);
}if (((request_type & UX_REQUEST_TYPE) == UX_REQUEST_TYPE_CLASS) || ((request_type & UX_REQUEST_TYPE) == UX_REQUEST_TYPE_VENDOR)) { ... }
switch (request)
{
case UX_GET_STATUS:
status = _ux_device_stack_get_status(request_type, request_index, request_length);
break;
case UX_GET_STATUS:
case UX_CLEAR_FEATURE:
status = _ux_device_stack_clear_feature(request_type, request_value, request_index);
break;
case UX_CLEAR_FEATURE:
case UX_SET_FEATURE:
status = _ux_device_stack_set_feature(request_type, request_value, request_index);
break;
case UX_SET_FEATURE:
case UX_SET_ADDRESS:
dcd -> ux_slave_dcd_device_address = request_value;
status = dcd -> ux_slave_dcd_function(dcd, UX_DCD_SET_DEVICE_ADDRESS, (VOID *) (ALIGN_TYPE) request_value);
break;
case UX_SET_ADDRESS:
case UX_GET_DESCRIPTOR:
status = _ux_device_stack_descriptor_send(request_value, request_index, request_length);
break;
case UX_GET_DESCRIPTOR:
case UX_SET_DESCRIPTOR:
status = UX_FUNCTION_NOT_SUPPORTED;
break;
case UX_SET_DESCRIPTOR:
case UX_GET_CONFIGURATION:
status = _ux_device_stack_configuration_get();
break;
case UX_GET_CONFIGURATION:
case UX_SET_CONFIGURATION:
status = _ux_device_stack_configuration_set(request_value);
break;
case UX_SET_CONFIGURATION:
case UX_GET_INTERFACE:
status = _ux_device_stack_alternate_setting_get(request_index);
break;
case UX_GET_INTERFACE:
case UX_SET_INTERFACE:
status = _ux_device_stack_alternate_setting_set(request_index,request_value);
break;
case UX_SET_INTERFACE:
case UX_SYNCH_FRAME:
status = UX_SUCCESS;
break;
case UX_SYNCH_FRAME:
default :
status = UX_FUNCTION_NOT_SUPPORTED;
break;default
}switch (request) { ... }
if (status != UX_SUCCESS)
_ux_device_stack_endpoint_stall(&device -> ux_slave_device_control_endpoint);
}if (transfer_request -> ux_slave_transfer_request_completion_code == UX_SUCCESS) { ... }
return(status);
}{ ... }