1 /* This test is designed to test the ux_utility_descriptor_pack. */
2
3 #include <stdio.h>
4 #include "tx_api.h"
5 #include "ux_api.h"
6 #include "ux_system.h"
7 #include "ux_utility.h"
8
9 #include "ux_host_stack.h"
10 #include "ux_device_stack.h"
11
12 #include "ux_device_class_audio.h"
13 #include "ux_device_class_audio10.h"
14 #include "ux_device_class_audio20.h"
15
16 #include "ux_test.h"
17
18 /* Define USBX test constants. */
19
20 #define UX_TEST_STACK_SIZE 4096
21 #define UX_TEST_BUFFER_SIZE 2048
22 #define UX_TEST_MEMORY_SIZE (64*1024)
23
24
25 /* Define the counters used in the test application... */
26
27 static ULONG thread_0_counter;
28 static ULONG thread_1_counter;
29 static ULONG error_counter;
30
31 static UCHAR error_callback_ignore = UX_FALSE;
32 static ULONG error_callback_counter;
33
34 static UX_DEVICE_CLASS_AUDIO *slave_audio;
35 static UX_DEVICE_CLASS_AUDIO_PARAMETER slave_audio_parameter;
36 static UX_DEVICE_CLASS_AUDIO_STREAM_PARAMETER slave_audio_stream_parameter[2];
37
38 static UX_DEVICE_CLASS_AUDIO *slave_audio_tx;
39 static UX_DEVICE_CLASS_AUDIO_STREAM *slave_audio_tx_stream;
40 static UX_DEVICE_CLASS_AUDIO_PARAMETER slave_audio_tx_parameter;
41 static UX_DEVICE_CLASS_AUDIO_STREAM_PARAMETER slave_audio_tx_stream_parameter;
42
43 static UX_DEVICE_CLASS_AUDIO *slave_audio_rx;
44 static UX_DEVICE_CLASS_AUDIO_STREAM *slave_audio_rx_stream;
45 static UX_DEVICE_CLASS_AUDIO_PARAMETER slave_audio_rx_parameter;
46 static UX_DEVICE_CLASS_AUDIO_STREAM_PARAMETER slave_audio_rx_stream_parameter;
47 static UX_SLAVE_TRANSFER *slave_audio_rx_transfer;
48
49 /* Define USBX test global variables. */
50
51
52 /* Define prototypes for external Host Controller's (HCDs), classes and clients. */
53
54 static TX_THREAD ux_test_thread_simulation_0;
55 static TX_THREAD ux_test_thread_simulation_1;
56 static void ux_test_thread_simulation_0_entry(ULONG);
57 static void ux_test_thread_simulation_1_entry(ULONG);
58
59 /* Prototype for test control return. */
60
61 void test_control_return(UINT status);
62
63 #define D3(d) ((UCHAR)((d) >> 24))
64 #define D2(d) ((UCHAR)((d) >> 16))
65 #define D1(d) ((UCHAR)((d) >> 8))
66 #define D0(d) ((UCHAR)((d) >> 0))
67
68 static unsigned char device_framework_full_speed[] = {
69
70 /* --------------------------------------- Device Descriptor */
71 /* 0 bLength, bDescriptorType */ 18, 0x01,
72 /* 2 bcdUSB */ D0(0x200),D1(0x200),
73 /* 4 bDeviceClass, bDeviceSubClass, bDeviceProtocol */ 0x00, 0x00, 0x00,
74 /* 7 bMaxPacketSize0 */ 0x08,
75 /* 8 idVendor, idProduct */ 0x84, 0x84, 0x01, 0x00,
76 /* 12 bcdDevice */ D0(0x100),D1(0x100),
77 /* 14 iManufacturer, iProduct, iSerialNumber */ 0, 0, 0,
78 /* 17 bNumConfigurations */ 1,
79
80 /* -------------------------------- Configuration Descriptor *//* 9+8+88+52*2=209 */
81 /* 0 bLength, bDescriptorType */ 9, 0x02,
82 /* 2 wTotalLength */ D0(209),D1(209),
83 /* 4 bNumInterfaces, bConfigurationValue */ 3, 1,
84 /* 6 iConfiguration */ 0,
85 /* 7 bmAttributes, bMaxPower */ 0x80, 50,
86
87 /* ------------------------ Interface Association Descriptor */
88 /* 0 bLength, bDescriptorType */ 8, 0x0B,
89 /* 2 bFirstInterface, bInterfaceCount */ 0, 3,
90 /* 4 bFunctionClass, bFunctionSubClass, bFunctionProtocol */ 0x01, 0x01, 0x00,
91 /* 7 iFunction */ 0,
92
93 /* ------------------------------------ Interface Descriptor *//* 0 Control (9+72+7=88) */
94 /* 0 bLength, bDescriptorType */ 9, 0x04,
95 /* 2 bInterfaceNumber, bAlternateSetting */ 0, 0,
96 /* 4 bNumEndpoints */ 1,
97 /* 5 bInterfaceClass, bInterfaceSubClass, bInterfaceProtocol */ 0x01, 0x01, 0x00,
98 /* 8 iInterface */ 0,
99 /* ---------------- Audio 1.0 AC Interface Header Descriptor *//* (10+12*2+10*2+9*2=72) */
100 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 10, 0x24, 0x01,
101 /* 3 bcdADC */ 0x00, 0x01,
102 /* 5 wTotalLength, bInCollection */ D0(72),D1(72), 2,
103 /* 8 baInterfaceNr(1) ... baInterfaceNr(n) */ 1, 2,
104 /* ------------------- Audio 1.0 AC Input Terminal Descriptor */
105 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 12, 0x24, 0x02,
106 /* 3 bTerminalID, wTerminalType */ 0x01, D0(0x0201),D1(0x0201),
107 /* 6 bAssocTerminal, */ 0x00,
108 /* 7 bNrChannels, wChannelConfig */ 0x02, D0(0),D1(0),
109 /* 10 iChannelNames, iTerminal */ 0, 0,
110 /* --------------------- Audio 1.0 AC Feature Unit Descriptor */
111 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 10, 0x24, 0x06,
112 /* 3 bUnitID, bSourceID */ 0x02, 0x01,
113 /* 5 bControlSize */ 1,
114 /* 6 bmaControls(0) ... bmaControls(...) ... */ 0x00, 0x00, 0x00,
115 /* . iFeature */ 0,
116 /* ------------------ Audio 1.0 AC Output Terminal Descriptor */
117 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 9, 0x24, 0x03,
118 /* 3 bTerminalID, wTerminalType */ 0x03, D0(0x0101),D1(0x0101),
119 /* 6 bAssocTerminal, bSourceID */ 0x00, 0x02,
120 /* 8 iTerminal */ 0,
121 /* ------------------- Audio 1.0 AC Input Terminal Descriptor */
122 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 12, 0x24, 0x02,
123 /* 3 bTerminalID, wTerminalType */ 0x04, D0(0x0101),D1(0x0101),
124 /* 6 bAssocTerminal, */ 0x00,
125 /* 7 bNrChannels, wChannelConfig */ 0x02, D0(0),D1(0),
126 /* 10 iChannelNames, iTerminal */ 0, 0,
127 /* --------------------- Audio 1.0 AC Feature Unit Descriptor */
128 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 10, 0x24, 0x06,
129 /* 3 bUnitID, bSourceID */ 0x05, 0x04,
130 /* 5 bControlSize */ 1,
131 /* 6 bmaControls(0) ... bmaControls(...) ... */ 0x00, 0x00, 0x00,
132 /* . iFeature */ 0,
133 /* ------------------ Audio 1.0 AC Output Terminal Descriptor */
134 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 9, 0x24, 0x03,
135 /* 3 bTerminalID, wTerminalType */ 0x06, D0(0x0301),D1(0x0301),
136 /* 6 bAssocTerminal, bSourceID */ 0x00, 0x05,
137 /* 8 iTerminal */ 0,
138 /* --------------------- Audio 1.0 AC INT Endpoint Descriptor */
139 /* 0 bLength, bDescriptorType */ 7, 0x05,
140 /* 2 bEndpointAddress, bmAttributes */ 0x83, 0x03,
141 /* 4 wMaxPacketSize, bInterval */ D0(8),D1(8), 1,
142
143 /* ------------------------------------ Interface Descriptor *//* 1 Stream IN (9+9+7+11+9+7=52) */
144 /* 0 bLength, bDescriptorType */ 9, 0x04,
145 /* 2 bInterfaceNumber, bAlternateSetting */ 1, 0,
146 /* 4 bNumEndpoints */ 0,
147 /* 5 bInterfaceClass, bInterfaceSubClass, bInterfaceProtocol */ 0x01, 0x02, 0x00,
148 /* 8 iInterface */ 0,
149 /* ------------------------------------ Interface Descriptor */
150 /* 0 bLength, bDescriptorType */ 9, 0x04,
151 /* 2 bInterfaceNumber, bAlternateSetting */ 1, 1,
152 /* 4 bNumEndpoints */ 1,
153 /* 5 bInterfaceClass, bInterfaceSubClass, bInterfaceProtocol */ 0x01, 0x02, 0x00,
154 /* 8 iInterface */ 0,
155 /* ------------------------ Audio 1.0 AS Interface Descriptor */
156 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 7, 0x24, 0x01,
157 /* 3 bTerminalLink */ 0x03,
158 /* 4 bDelay, wFormatTag */ 0x00, D0(0x0001),D1(0x0001),
159 /* -------------------------- Audio AS Format Type Descriptor */
160 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 11, 0x24, 0x02,
161 /* 3 bFormatType, bNrChannels, bSubframeSize, bBitResolution */ 0x01, 0x02, 0x02, 16,
162 /* 7 bSamFreqType (n), tSamFreq[1] ... tSamFreq[n] */ 1, D0(48000),D1(48000),D2(48000),
163 /* --------------------- Audio 1.0 AS ISO Endpoint Descriptor */
164 /* 0 bLength, bDescriptorType */ 9, 0x05,
165 /* 2 bEndpointAddress, bmAttributes */ 0x81, 0x01,
166 /* 4 wMaxPacketSize, bInterval, bRefresh, bSynchAddress */ D0(256),D1(256), 1, 0, 0,
167 /* ---------- Audio 1.0 AS ISO Audio Data Endpoint Descriptor */
168 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 7, 0x25, 0x01,
169 /* 3 bmAttributes */ 0x00,
170 /* 5 bLockDelayUnits, wLockDelay */ 0x00, D0(0),D1(0),
171
172 /* ------------------------------------ Interface Descriptor *//* 2 Stream OUT (9+9+7+11+9+7=52) */
173 /* 0 bLength, bDescriptorType */ 9, 0x04,
174 /* 2 bInterfaceNumber, bAlternateSetting */ 2, 0,
175 /* 4 bNumEndpoints */ 0,
176 /* 5 bInterfaceClass, bInterfaceSubClass, bInterfaceProtocol */ 0x01, 0x02, 0x00,
177 /* 8 iInterface */ 0,
178 /* ------------------------------------ Interface Descriptor */
179 /* 0 bLength, bDescriptorType */ 9, 0x04,
180 /* 2 bInterfaceNumber, bAlternateSetting */ 2, 1,
181 /* 4 bNumEndpoints */ 1,
182 /* 5 bInterfaceClass, bInterfaceSubClass, bInterfaceProtocol */ 0x01, 0x02, 0x00,
183 /* 8 iInterface */ 0,
184 /* ------------------------ Audio 1.0 AS Interface Descriptor */
185 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 7, 0x24, 0x01,
186 /* 3 bTerminalLink */ 0x04,
187 /* 4 bDelay, wFormatTag */ 0x00, D0(0x0001),D1(0x0001),
188 /* -------------------------- Audio AS Format Type Descriptor */
189 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 11, 0x24, 0x02,
190 /* 3 bFormatType, bNrChannels, bSubframeSize, bBitResolution */ 0x01, 0x02, 0x02, 16,
191 /* 7 bSamFreqType (n), tSamFreq[1] ... tSamFreq[n] */ 1, D0(48000),D1(48000),D2(48000),
192 /* --------------------- Audio 1.0 AS ISO Endpoint Descriptor */
193 /* 0 bLength, bDescriptorType */ 9, 0x05,
194 /* 2 bEndpointAddress, bmAttributes */ 0x02, 0x01,
195 /* 4 wMaxPacketSize, bInterval, bRefresh, bSynchAddress */ D0(256),D1(256), 1, 0, 0,
196 /* ---------- Audio 1.0 AS ISO Audio Data Endpoint Descriptor */
197 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 7, 0x25, 0x01,
198 /* 3 bmAttributes */ 0x00,
199 /* 5 bLockDelayUnits, wLockDelay */ 0x00, D0(0),D1(0),
200 };
201 #define DEVICE_FRAMEWORK_LENGTH_FULL_SPEED sizeof(device_framework_full_speed)
202
203 static unsigned char device_framework_high_speed[] = {
204 /* --------------------------------------- Device Descriptor */
205 /* 0 bLength, bDescriptorType */ 18, 0x01,
206 /* 2 bcdUSB */ D0(0x200),D1(0x200),
207 /* 4 bDeviceClass, bDeviceSubClass, bDeviceProtocol */ 0x00, 0x00, 0x00,
208 /* 7 bMaxPacketSize0 */ 8,
209 /* 8 idVendor, idProduct */ 0x84, 0x84, 0x01, 0x00,
210 /* 12 bcdDevice */ D0(0x100),D1(0x100),
211 /* 14 iManufacturer, iProduct, iSerialNumber */ 0, 0, 0,
212 /* 17 bNumConfigurations */ 1,
213
214 /* ----------------------------- Device Qualifier Descriptor */
215 /* 0 bLength, bDescriptorType */ 10, 0x06,
216 /* 2 bcdUSB */ D0(0x200),D1(0x200),
217 /* 4 bDeviceClass, bDeviceSubClass, bDeviceProtocol */ 0x00, 0x00, 0x00,
218 /* 7 bMaxPacketSize0 */ 8,
219 /* 8 bNumConfigurations */ 1,
220 /* 9 bReserved */ 0,
221
222 /* -------------------------------- Configuration Descriptor *//* 9+8+88+52*2=209 */
223 /* 0 bLength, bDescriptorType */ 9, 0x02,
224 /* 2 wTotalLength */ D0(209),D1(209),
225 /* 4 bNumInterfaces, bConfigurationValue */ 3, 1,
226 /* 6 iConfiguration */ 0,
227 /* 7 bmAttributes, bMaxPower */ 0x80, 50,
228
229 /* ------------------------ Interface Association Descriptor */
230 /* 0 bLength, bDescriptorType */ 8, 0x0B,
231 /* 2 bFirstInterface, bInterfaceCount */ 0, 3,
232 /* 4 bFunctionClass, bFunctionSubClass, bFunctionProtocol */ 0x01, 0x01, 0x00,
233 /* 7 iFunction */ 0,
234
235 /* ------------------------------------ Interface Descriptor *//* 0 Control (9+72+7=88) */
236 /* 0 bLength, bDescriptorType */ 9, 0x04,
237 /* 2 bInterfaceNumber, bAlternateSetting */ 0, 0,
238 /* 4 bNumEndpoints */ 1,
239 /* 5 bInterfaceClass, bInterfaceSubClass, bInterfaceProtocol */ 0x01, 0x01, 0x00,
240 /* 8 iInterface */ 0,
241 /* ---------------- Audio 1.0 AC Interface Header Descriptor *//* (10+12*2+10*2+9*2=72) */
242 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 10, 0x24, 0x01,
243 /* 3 bcdADC */ 0x00, 0x01,
244 /* 5 wTotalLength, bInCollection */ D0(72),D1(72), 2,
245 /* 8 baInterfaceNr(1) ... baInterfaceNr(n) */ 1, 2,
246 /* ------------------- Audio 1.0 AC Input Terminal Descriptor */
247 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 12, 0x24, 0x02,
248 /* 3 bTerminalID, wTerminalType */ 0x01, D0(0x0201),D1(0x0201),
249 /* 6 bAssocTerminal, */ 0x00,
250 /* 7 bNrChannels, wChannelConfig */ 0x02, D0(0),D1(0),
251 /* 10 iChannelNames, iTerminal */ 0, 0,
252 /* --------------------- Audio 1.0 AC Feature Unit Descriptor */
253 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 10, 0x24, 0x06,
254 /* 3 bUnitID, bSourceID */ 0x02, 0x01,
255 /* 5 bControlSize */ 1,
256 /* 6 bmaControls(0) ... bmaControls(...) ... */ 0x00, 0x00, 0x00,
257 /* . iFeature */ 0,
258 /* ------------------ Audio 1.0 AC Output Terminal Descriptor */
259 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 9, 0x24, 0x03,
260 /* 3 bTerminalID, wTerminalType */ 0x03, D0(0x0101),D1(0x0101),
261 /* 6 bAssocTerminal, bSourceID */ 0x00, 0x02,
262 /* 8 iTerminal */ 0,
263 /* ------------------- Audio 1.0 AC Input Terminal Descriptor */
264 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 12, 0x24, 0x02,
265 /* 3 bTerminalID, wTerminalType */ 0x04, D0(0x0101),D1(0x0101),
266 /* 6 bAssocTerminal, */ 0x00,
267 /* 7 bNrChannels, wChannelConfig */ 0x02, D0(0),D1(0),
268 /* 10 iChannelNames, iTerminal */ 0, 0,
269 /* --------------------- Audio 1.0 AC Feature Unit Descriptor */
270 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 10, 0x24, 0x06,
271 /* 3 bUnitID, bSourceID */ 0x05, 0x04,
272 /* 5 bControlSize */ 1,
273 /* 6 bmaControls(0) ... bmaControls(...) ... */ 0x00, 0x00, 0x00,
274 /* . iFeature */ 0,
275 /* ------------------ Audio 1.0 AC Output Terminal Descriptor */
276 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 9, 0x24, 0x03,
277 /* 3 bTerminalID, wTerminalType */ 0x06, D0(0x0301),D1(0x0301),
278 /* 6 bAssocTerminal, bSourceID */ 0x00, 0x05,
279 /* 8 iTerminal */ 0,
280 /* --------------------- Audio 1.0 AC INT Endpoint Descriptor */
281 /* 0 bLength, bDescriptorType */ 7, 0x05,
282 /* 2 bEndpointAddress, bmAttributes */ 0x83, 0x03,
283 /* 4 wMaxPacketSize, bInterval */ D0(8),D1(8), 4,
284
285 /* ------------------------------------ Interface Descriptor *//* 1 Stream IN (9+9+7+11+9+7=52) */
286 /* 0 bLength, bDescriptorType */ 9, 0x04,
287 /* 2 bInterfaceNumber, bAlternateSetting */ 1, 0,
288 /* 4 bNumEndpoints */ 0,
289 /* 5 bInterfaceClass, bInterfaceSubClass, bInterfaceProtocol */ 0x01, 0x02, 0x00,
290 /* 8 iInterface */ 0,
291 /* ------------------------------------ Interface Descriptor */
292 /* 0 bLength, bDescriptorType */ 9, 0x04,
293 /* 2 bInterfaceNumber, bAlternateSetting */ 1, 1,
294 /* 4 bNumEndpoints */ 1,
295 /* 5 bInterfaceClass, bInterfaceSubClass, bInterfaceProtocol */ 0x01, 0x02, 0x00,
296 /* 8 iInterface */ 0,
297 /* ------------------------ Audio 1.0 AS Interface Descriptor */
298 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 7, 0x24, 0x01,
299 /* 3 bTerminalLink */ 0x03,
300 /* 4 bDelay, wFormatTag */ 0x00, D0(0x0001),D1(0x0001),
301 /* -------------------------- Audio AS Format Type Descriptor */
302 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 11, 0x24, 0x02,
303 /* 3 bFormatType, bNrChannels, bSubframeSize, bBitResolution */ 0x01, 0x02, 0x02, 16,
304 /* 7 bSamFreqType (n), tSamFreq[1] ... tSamFreq[n] */ 1, D0(48000),D1(48000),D2(48000),
305 /* --------------------- Audio 1.0 AS ISO Endpoint Descriptor */
306 /* 0 bLength, bDescriptorType */ 9, 0x05,
307 /* 2 bEndpointAddress, bmAttributes */ 0x81, 0x01,
308 /* 4 wMaxPacketSize, bInterval, bRefresh, bSynchAddress */ D0(256),D1(256), 4, 0, 0,
309 /* ---------- Audio 1.0 AS ISO Audio Data Endpoint Descriptor */
310 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 7, 0x25, 0x01,
311 /* 3 bmAttributes */ 0x00,
312 /* 5 bLockDelayUnits, wLockDelay */ 0x00, D0(0),D1(0),
313
314 /* ------------------------------------ Interface Descriptor *//* 2 Stream OUT (9+9+7+11+9+7=52) */
315 /* 0 bLength, bDescriptorType */ 9, 0x04,
316 /* 2 bInterfaceNumber, bAlternateSetting */ 2, 0,
317 /* 4 bNumEndpoints */ 0,
318 /* 5 bInterfaceClass, bInterfaceSubClass, bInterfaceProtocol */ 0x01, 0x02, 0x00,
319 /* 8 iInterface */ 0,
320 /* ------------------------------------ Interface Descriptor */
321 /* 0 bLength, bDescriptorType */ 9, 0x04,
322 /* 2 bInterfaceNumber, bAlternateSetting */ 2, 1,
323 /* 4 bNumEndpoints */ 1,
324 /* 5 bInterfaceClass, bInterfaceSubClass, bInterfaceProtocol */ 0x01, 0x02, 0x00,
325 /* 8 iInterface */ 0,
326 /* ------------------------ Audio 1.0 AS Interface Descriptor */
327 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 7, 0x24, 0x01,
328 /* 3 bTerminalLink */ 0x04,
329 /* 4 bDelay, wFormatTag */ 0x00, D0(0x0001),D1(0x0001),
330 /* -------------------------- Audio AS Format Type Descriptor */
331 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 11, 0x24, 0x02,
332 /* 3 bFormatType, bNrChannels, bSubframeSize, bBitResolution */ 0x01, 0x02, 0x02, 16,
333 /* 7 bSamFreqType (n), tSamFreq[1] ... tSamFreq[n] */ 1, D0(48000),D1(48000),D2(48000),
334 /* --------------------- Audio 1.0 AS ISO Endpoint Descriptor */
335 /* 0 bLength, bDescriptorType */ 9, 0x05,
336 /* 2 bEndpointAddress, bmAttributes */ 0x02, 0x01,
337 /* 4 wMaxPacketSize, bInterval, bRefresh, bSynchAddress */ D0(256),D1(256), 4, 0, 0,
338 /* ---------- Audio 1.0 AS ISO Audio Data Endpoint Descriptor */
339 /* 0 bLength, bDescriptorType, bDescriptorSubtype */ 7, 0x25, 0x01,
340 /* 3 bmAttributes */ 0x00,
341 /* 5 bLockDelayUnits, wLockDelay */ 0x00, D0(0),D1(0),
342 };
343 #define DEVICE_FRAMEWORK_LENGTH_HIGH_SPEED sizeof(device_framework_high_speed)
344
345 static unsigned char string_framework[] = {
346
347 /* Manufacturer string descriptor : Index 1 - "Express Logic" */
348 0x09, 0x04, 0x01, 0x0c,
349 0x45, 0x78, 0x70, 0x72,0x65, 0x73, 0x20, 0x4c,
350 0x6f, 0x67, 0x69, 0x63,
351
352 /* Product string descriptor : Index 2 - "EL Composite device" */
353 0x09, 0x04, 0x02, 0x13,
354 0x45, 0x4c, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x6f,
355 0x73, 0x69, 0x74, 0x65, 0x20, 0x64, 0x65, 0x76,
356 0x69, 0x63, 0x65,
357
358 /* Serial Number string descriptor : Index 3 - "0001" */
359 0x09, 0x04, 0x03, 0x04,
360 0x30, 0x30, 0x30, 0x31
361 };
362 #define STRING_FRAMEWORK_LENGTH sizeof(string_framework)
363
364
365 /* Multiple languages are supported on the device, to add
366 a language besides English, the Unicode language code must
367 be appended to the language_id_framework array and the length
368 adjusted accordingly. */
369 static unsigned char language_id_framework[] = {
370
371 /* English. */
372 0x09, 0x04
373 };
374 #define LANGUAGE_ID_FRAMEWORK_LENGTH sizeof(language_id_framework)
375
slave_audio_tx_activate(VOID * audio_instance)376 static VOID slave_audio_tx_activate(VOID *audio_instance){}
slave_audio_deactivate(VOID * audio_instance)377 static VOID slave_audio_deactivate(VOID *audio_instance){}
slave_audio_tx_stream_change(UX_DEVICE_CLASS_AUDIO_STREAM * audio,ULONG alt)378 static VOID slave_audio_tx_stream_change(UX_DEVICE_CLASS_AUDIO_STREAM *audio, ULONG alt){}
slave_audio_control_process(UX_DEVICE_CLASS_AUDIO * audio,UX_SLAVE_TRANSFER * transfer)379 static UINT slave_audio_control_process(UX_DEVICE_CLASS_AUDIO *audio, UX_SLAVE_TRANSFER *transfer)
380 {
381 return(UX_ERROR);
382 }
slave_audio_tx_done(UX_DEVICE_CLASS_AUDIO_STREAM * audio,ULONG length)383 static VOID slave_audio_tx_done(UX_DEVICE_CLASS_AUDIO_STREAM *audio, ULONG length){}
384
385 /* Define what the initial system looks like. */
386
387 #ifdef CTEST
test_application_define(void * first_unused_memory)388 void test_application_define(void *first_unused_memory)
389 #else
390 void usbx_uxe_device_audio_test_application_define(void *first_unused_memory)
391 #endif
392 {
393
394 UINT status;
395 CHAR *stack_pointer;
396 CHAR *memory_pointer;
397
398 /* Inform user. */
399 printf("Running uxe_device_audio APIs Test.................................. ");
400 #if !defined(UX_DEVICE_CLASS_AUDIO_ENABLE_ERROR_CHECKING)
401 #warning Tests skipped due to compile option!
402 printf("SKIP SUCCESS!\n");
403 test_control_return(0);
404 return;
405 #endif
406
407 /* Initialize the free memory pointer. */
408 stack_pointer = (CHAR *) first_unused_memory;
409 memory_pointer = stack_pointer + (UX_TEST_STACK_SIZE * 2);
410
411 /* Initialize USBX Memory. */
412 status = ux_system_initialize(memory_pointer, UX_TEST_MEMORY_SIZE, UX_NULL, 0);
413
414 /* Check for error. */
415 if (status != UX_SUCCESS)
416 {
417
418 printf("ERROR #%d\n", __LINE__);
419 test_control_return(1);
420 }
421
422 /* The code below is required for installing the device portion of USBX. No call back for
423 device status change in this example. */
424 status = ux_device_stack_initialize(device_framework_high_speed, DEVICE_FRAMEWORK_LENGTH_HIGH_SPEED,
425 device_framework_full_speed, DEVICE_FRAMEWORK_LENGTH_FULL_SPEED,
426 string_framework, STRING_FRAMEWORK_LENGTH,
427 language_id_framework, LANGUAGE_ID_FRAMEWORK_LENGTH,UX_NULL);
428 UX_TEST_CHECK_SUCCESS(status);
429
430 #if !defined(UX_DEVICE_STANDALONE)
431 slave_audio_tx_stream_parameter.ux_device_class_audio_stream_parameter_thread_entry = ux_device_class_audio_write_thread_entry;
432 #else
433 slave_audio_tx_stream_parameter.ux_device_class_audio_stream_parameter_task_function = _ux_device_class_audio_write_task_function;
434 #endif
435 slave_audio_tx_stream_parameter.ux_device_class_audio_stream_parameter_callbacks.ux_device_class_audio_stream_change = slave_audio_tx_stream_change;
436 slave_audio_tx_stream_parameter.ux_device_class_audio_stream_parameter_callbacks.ux_device_class_audio_stream_frame_done = slave_audio_tx_done;
437 slave_audio_tx_stream_parameter.ux_device_class_audio_stream_parameter_max_frame_buffer_size = 256;
438 slave_audio_tx_stream_parameter.ux_device_class_audio_stream_parameter_max_frame_buffer_nb = 8;
439 slave_audio_tx_parameter.ux_device_class_audio_parameter_streams = &slave_audio_tx_stream_parameter;
440 slave_audio_tx_parameter.ux_device_class_audio_parameter_streams_nb = 1;
441 slave_audio_tx_parameter.ux_device_class_audio_parameter_callbacks.ux_slave_class_audio_instance_activate = slave_audio_tx_activate;
442 slave_audio_tx_parameter.ux_device_class_audio_parameter_callbacks.ux_slave_class_audio_instance_deactivate = slave_audio_deactivate;
443 slave_audio_tx_parameter.ux_device_class_audio_parameter_callbacks.ux_device_class_audio_control_process = slave_audio_control_process;
444 slave_audio_tx_parameter.ux_device_class_audio_parameter_callbacks.ux_device_class_audio_arg = UX_NULL;
445
446 status = ux_device_stack_class_register(_ux_system_slave_class_audio_name, ux_device_class_audio_entry,
447 1, 1, NX_NULL);
448 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
449
450 slave_audio_tx_parameter.ux_device_class_audio_parameter_streams = NX_NULL;
451 status = ux_device_stack_class_register(_ux_system_slave_class_audio_name, ux_device_class_audio_entry,
452 1, 1, &slave_audio_tx_parameter);
453 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
454
455 slave_audio_tx_parameter.ux_device_class_audio_parameter_streams = &slave_audio_tx_stream_parameter;
456 slave_audio_tx_parameter.ux_device_class_audio_parameter_streams_nb = 0;
457 status = ux_device_stack_class_register(_ux_system_slave_class_audio_name, ux_device_class_audio_entry,
458 1, 1, &slave_audio_tx_parameter);
459 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
460
461 slave_audio_tx_parameter.ux_device_class_audio_parameter_streams = &slave_audio_tx_stream_parameter;
462 slave_audio_tx_parameter.ux_device_class_audio_parameter_streams_nb = 1;
463 slave_audio_tx_stream_parameter.ux_device_class_audio_stream_parameter_max_frame_buffer_nb = 0;
464 status = ux_device_stack_class_register(_ux_system_slave_class_audio_name, ux_device_class_audio_entry,
465 1, 1, &slave_audio_tx_parameter);
466 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
467
468 slave_audio_tx_parameter.ux_device_class_audio_parameter_streams = &slave_audio_tx_stream_parameter;
469 slave_audio_tx_parameter.ux_device_class_audio_parameter_streams_nb = 1;
470 slave_audio_tx_stream_parameter.ux_device_class_audio_stream_parameter_max_frame_buffer_nb = 1;
471 slave_audio_tx_stream_parameter.ux_device_class_audio_stream_parameter_max_frame_buffer_size = 0;
472 status = ux_device_stack_class_register(_ux_system_slave_class_audio_name, ux_device_class_audio_entry,
473 1, 1, &slave_audio_tx_parameter);
474 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
475
476 /* Create the simulation thread. */
477 status = tx_thread_create(&ux_test_thread_simulation_0, "test simulation", ux_test_thread_simulation_0_entry, 0,
478 stack_pointer, UX_TEST_STACK_SIZE,
479 20, 20, 1, TX_AUTO_START);
480
481 /* Check for error. */
482 if (status != TX_SUCCESS)
483 {
484
485 printf("ERROR #%d\n", __LINE__);
486 test_control_return(1);
487 }
488 }
489
490
ux_test_thread_simulation_0_entry(ULONG arg)491 static void ux_test_thread_simulation_0_entry(ULONG arg)
492 {
493 UINT status;
494 UX_DEVICE_CLASS_AUDIO dummy_audio_inst;
495 UX_DEVICE_CLASS_AUDIO *dummy_audio = &dummy_audio_inst;
496 UX_DEVICE_CLASS_AUDIO_STREAM dummy_stream_inst;
497 UX_DEVICE_CLASS_AUDIO_STREAM *dummy_stream = &dummy_stream_inst;
498 UCHAR *dummy_buffer;
499 ULONG dummy_dw;
500 UX_SLAVE_TRANSFER dummy_transfer;
501 UX_DEVICE_CLASS_AUDIO10_CONTROL_GROUP dummy_group10;
502 UX_DEVICE_CLASS_AUDIO20_CONTROL_GROUP dummy_group20;
503
504 /* ux_device_class_audio_stream_get() */
505 status = ux_device_class_audio_stream_get(UX_NULL, 0, &dummy_stream);
506 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
507 status = ux_device_class_audio_stream_get(dummy_audio, 0, UX_NULL);
508 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
509 dummy_stream = &dummy_stream_inst;
510
511 /* ux_device_class_audio_reception_start() */
512 status = ux_device_class_audio_reception_start(UX_NULL);
513 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
514
515 /* ux_device_class_audio_sample_read8() */
516 status = ux_device_class_audio_sample_read8(UX_NULL, (UCHAR *)&dummy_dw);
517 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
518
519 /* ux_device_class_audio_sample_read16() */
520 status = ux_device_class_audio_sample_read16(UX_NULL, (USHORT *)&dummy_dw);
521 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
522
523 /* ux_device_class_audio_sample_read24() */
524 status = ux_device_class_audio_sample_read24(UX_NULL, &dummy_dw);
525 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
526
527 /* ux_device_class_audio_sample_read32() */
528 status = ux_device_class_audio_sample_read32(UX_NULL, &dummy_dw);
529 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
530
531 /* ux_device_class_audio_read_frame_get() */
532 status = ux_device_class_audio_read_frame_get(UX_NULL, &dummy_buffer, &dummy_dw);
533 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
534 status = ux_device_class_audio_read_frame_get(dummy_stream, UX_NULL, &dummy_dw);
535 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
536 status = ux_device_class_audio_read_frame_get(dummy_stream, &dummy_buffer, UX_NULL);
537 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
538
539 /* ux_device_class_audio_read_frame_free() */
540 status = ux_device_class_audio_read_frame_free(UX_NULL);
541 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
542
543 /* ux_device_class_audio_transmission_start() */
544 status = ux_device_class_audio_transmission_start(UX_NULL);
545 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
546
547 /* ux_device_class_audio_frame_write() */
548 status = ux_device_class_audio_frame_write(UX_NULL, dummy_buffer, 4);
549 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
550 status = ux_device_class_audio_frame_write(dummy_stream, UX_NULL, 4);
551 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
552 status = ux_device_class_audio_frame_write(dummy_stream, dummy_buffer, 0);
553 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
554
555 /* ux_device_class_audio_write_frame_get() */
556 status = ux_device_class_audio_write_frame_get(UX_NULL, &dummy_buffer, &dummy_dw);
557 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
558 status = ux_device_class_audio_write_frame_get(dummy_stream, UX_NULL, &dummy_dw);
559 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
560 status = ux_device_class_audio_write_frame_get(dummy_stream, &dummy_buffer, UX_NULL);
561 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
562
563 /* ux_device_class_audio_write_frame_commit() */
564 status = ux_device_class_audio_write_frame_commit(UX_NULL, 1);
565 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
566 status = ux_device_class_audio_write_frame_commit(dummy_stream, 0);
567 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
568
569 /* ux_device_class_audio_ioctl() */
570 status = ux_device_class_audio_ioctl(UX_NULL, 0, &dummy_dw);
571 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
572
573 /* ux_device_class_audio_feedback_get() */
574 status = ux_device_class_audio_feedback_get(UX_NULL, (UCHAR *)&dummy_dw);
575 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
576 status = ux_device_class_audio_feedback_get(dummy_stream, UX_NULL);
577 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
578
579 /* ux_device_class_audio_feedback_set() */
580 status = ux_device_class_audio_feedback_set(UX_NULL, (UCHAR *)&dummy_dw);
581 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
582 status = ux_device_class_audio_feedback_set(dummy_stream, UX_NULL);
583 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
584
585 /* ux_device_class_audio_interrupt_send() */
586 status = ux_device_class_audio_interrupt_send(UX_NULL, (UCHAR *)&dummy_dw);
587 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
588 status = ux_device_class_audio_interrupt_send(dummy_audio, UX_NULL);
589 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
590
591 /* ux_device_class_audio10_control_process() */
592 status = ux_device_class_audio10_control_process(UX_NULL, &dummy_transfer, &dummy_group10);
593 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
594 status = ux_device_class_audio10_control_process(dummy_audio, UX_NULL, &dummy_group10);
595 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
596 status = ux_device_class_audio10_control_process(dummy_audio, &dummy_transfer, UX_NULL);
597 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
598
599 /* ux_device_class_audio20_control_process() */
600 status = ux_device_class_audio20_control_process(UX_NULL, &dummy_transfer, &dummy_group20);
601 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
602 status = ux_device_class_audio20_control_process(dummy_audio, UX_NULL, &dummy_group20);
603 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
604 status = ux_device_class_audio20_control_process(dummy_audio, &dummy_transfer, UX_NULL);
605 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
606
607 /* Sleep for a tick to make sure everything is complete. */
608 tx_thread_sleep(1);
609
610 /* Check for errors from other threads. */
611 if (error_counter)
612 {
613
614 /* Test error. */
615 printf("ERROR #%d: total %ld errors\n", __LINE__, error_counter);
616 test_control_return(1);
617 }
618 else
619 {
620
621 /* Successful test. */
622 printf("SUCCESS!\n");
623 test_control_return(0);
624 }
625 }
626