1 /* This test tests the case where there is an interface before the control interface. In this case, it's a storage class interface.
2    We do this because during activation, we need to link the the control interface into the class instance, so we need to find it. */
3 
4 #include "usbx_ux_test_cdc_ecm.h"
5 
6 static unsigned char interface_before_control_interface_framework[] = {
7 
8     /* Device Descriptor */
9     0x12, /* bLength */
10     0x01, /* bDescriptorType */
11     0x10, 0x01, /* bcdUSB */
12     0xef, /* bDeviceClass - Depends on bDeviceSubClass */
13     0x02, /* bDeviceSubClass - Depends on bDeviceProtocol */
14     0x01, /* bDeviceProtocol - There's an IAD */
15     0x40, /* bMaxPacketSize0 */
16     0x70, 0x07, /* idVendor */
17     0x42, 0x10, /* idProduct */
18     0x00, 0x01, /* bcdDevice */
19     0x01, /* iManufacturer */
20     0x02, /* iProduct */
21     0x03, /* iSerialNumber */
22     0x01, /* bNumConfigurations */
23 
24     /* Configuration Descriptor */
25     0x09, /* bLength */
26     0x02, /* bDescriptorType */
27     0x76, 0x00, /* wTotalLength */
28     0x02, /* bNumInterfaces */
29     0x01, /* bConfigurationValue */
30     0x00, /* iConfiguration */
31     0xc0, /* bmAttributes - Self-powered */
32     0x00, /* bMaxPower */
33 
34     /* Interface Descriptor */
35     0x09, /* bLength */
36     0x04, /* bDescriptorType */
37     0x00, /* bInterfaceNumber */
38     0x00, /* bAlternateSetting */
39     0x03, /* bNumEndpoints */
40     0x08, /* bInterfaceClass - Mass Storage */
41     0x06, /* bInterfaceSubClass */
42     0x50, /* bInterfaceProtocol */
43     0x00, /* iInterface */
44 
45     /* Endpoint Descriptor */
46     0x07, /* bLength */
47     0x05, /* bDescriptorType */
48     0x81, /* bEndpointAddress */
49     0x02, /* bmAttributes - Bulk */
50     0x40, 0x00, /* wMaxPacketSize */
51     0x00, /* bInterval */
52 
53     /* Endpoint Descriptor */
54     0x07, /* bLength */
55     0x05, /* bDescriptorType */
56     0x02, /* bEndpointAddress */
57     0x02, /* bmAttributes - Bulk */
58     0x40, 0x00, /* wMaxPacketSize */
59     0x00, /* bInterval */
60 
61     /* Endpoint Descriptor */
62     0x07, /* bLength */
63     0x05, /* bDescriptorType */
64     0x83, /* bEndpointAddress */
65     0x03, /* bmAttributes - Interrupt */
66     0x40, 0x00, /* wMaxPacketSize */
67     0x01, /* bInterval */
68 
69     /* Interface Association Descriptor */
70     0x08, /* bLength */
71     0x0b, /* bDescriptorType */
72     0x00, /* bFirstInterface */
73     0x02, /* bInterfaceCount */
74     0x02, /* bFunctionClass - CDC - Communication */
75     0x06, /* bFunctionSubClass - ECM */
76     0x00, /* bFunctionProtocol - No class specific protocol required */
77     0x00, /* iFunction */
78 
79     /* Interface Descriptor */
80     0x09, /* bLength */
81     0x04, /* bDescriptorType */
82     0x00, /* bInterfaceNumber */
83     0x00, /* bAlternateSetting */
84     0x01, /* bNumEndpoints */
85     0x02, /* bInterfaceClass - CDC - Communication */
86     0x06, /* bInterfaceSubClass - ECM */
87     0x00, /* bInterfaceProtocol - No class specific protocol required */
88     0x00, /* iInterface */
89 
90     /* CDC Header Functional Descriptor */
91     0x05, /* bLength */
92     0x24, /* bDescriptorType */
93     0x00, /* bDescriptorSubType */
94     0x10, 0x01, /* bcdCDC */
95 
96     /* CDC ECM Functional Descriptor */
97     0x0d, /* bLength */
98     0x24, /* bDescriptorType */
99     0x0f, /* bDescriptorSubType */
100     0x04, /* iMACAddress */
101     0x00, 0x00, 0x00, 0x00, /* bmEthernetStatistics */
102     0xea, 0x05, /* wMaxSegmentSize */
103     0x00, 0x00, /* wNumberMCFilters */
104     0x00, /* bNumberPowerFilters */
105 
106     /* CDC Union Functional Descriptor */
107     0x05, /* bLength */
108     0x24, /* bDescriptorType */
109     0x06, /* bDescriptorSubType */
110     0x00, /* bmMasterInterface */
111     0x01, /* bmSlaveInterface0 */
112 
113     /* Endpoint Descriptor */
114     0x07, /* bLength */
115     0x05, /* bDescriptorType */
116     0x84, /* bEndpointAddress */
117     0x03, /* bmAttributes - Interrupt */
118     0x08, 0x00, /* wMaxPacketSize */
119     0x08, /* bInterval */
120 
121     /* Interface Descriptor */
122     0x09, /* bLength */
123     0x04, /* bDescriptorType */
124     0x01, /* bInterfaceNumber */
125     0x00, /* bAlternateSetting */
126     0x00, /* bNumEndpoints */
127     0x0a, /* bInterfaceClass - CDC - Data */
128     0x00, /* bInterfaceSubClass - Should be 0x00 */
129     0x00, /* bInterfaceProtocol - No class specific protocol required */
130     0x00, /* iInterface */
131 
132     /* Interface Descriptor */
133     0x09, /* bLength */
134     0x04, /* bDescriptorType */
135     0x01, /* bInterfaceNumber */
136     0x01, /* bAlternateSetting */
137     0x02, /* bNumEndpoints */
138     0x0a, /* bInterfaceClass - CDC - Data */
139     0x00, /* bInterfaceSubClass - Should be 0x00 */
140     0x00, /* bInterfaceProtocol - No class specific protocol required */
141     0x00, /* iInterface */
142 
143     /* Endpoint Descriptor */
144     0x07, /* bLength */
145     0x05, /* bDescriptorType */
146     0x05, /* bEndpointAddress */
147     0x02, /* bmAttributes - Bulk */
148     0x40, 0x00, /* wMaxPacketSize */
149     0x00, /* bInterval */
150 
151     /* Endpoint Descriptor */
152     0x07, /* bLength */
153     0x05, /* bDescriptorType */
154     0x86, /* bEndpointAddress */
155     0x02, /* bmAttributes - Bulk */
156     0x40, 0x00, /* wMaxPacketSize */
157     0x00, /* bInterval */
158 
159 };
160 
161 static DEVICE_INIT_DATA device_init_data = { interface_before_control_interface_framework, sizeof(interface_before_control_interface_framework) };
162 
163 /* Define what the initial system looks like.  */
164 #ifdef CTEST
test_application_define(void * first_unused_memory)165 void test_application_define(void *first_unused_memory)
166 #else
167 void usbx_cdc_ecm_interface_before_control_interface_test_application_define(void *first_unused_memory)
168 #endif
169 {
170 
171     /* Inform user.  */
172     printf("Running cdc_ecm interface before control interface Test............. ");
173 
174     stepinfo("\n");
175 
176     ux_test_cdc_ecm_initialize_use_framework(first_unused_memory, &device_init_data);
177 }
178 
post_init_host()179 static void post_init_host()
180 {
181 
182     cdc_ecm_basic_test(BASIC_TEST_HOST, BASIC_TEST_TCP);
183 }
184 
post_init_device()185 static void post_init_device()
186 {
187 
188     cdc_ecm_basic_test(BASIC_TEST_DEVICE, BASIC_TEST_TCP);
189 }