22
22
#include " utest/utest.h"
23
23
24
24
#include " USBTester.h"
25
+ #include " usb_phy_api.h"
25
26
26
27
// If disconnect() + connect() occur too fast the reset event will be dropped.
27
28
// At a minimum there should be a 200us delay between disconnect and connect.
35
36
36
37
using namespace utest ::v1;
37
38
39
+ static USBPhy *get_phy ()
40
+ {
41
+ return get_usb_phy ();
42
+ }
43
+
38
44
void control_basic_test ()
39
45
{
40
46
uint16_t vendor_id = 0x0d28 ;
@@ -45,7 +51,7 @@ void control_basic_test()
45
51
char str[128 ] = {};
46
52
47
53
{
48
- USBTester serial (vendor_id, product_id, product_release, true );
54
+ USBTester serial (get_phy (), vendor_id, product_id, product_release, true );
49
55
sprintf (str, " %s %d %d" , serial.get_serial_desc_string (), vendor_id, product_id);
50
56
greentea_send_kv (" control_basic_test" , str);
51
57
// Wait for host before terminating
@@ -63,7 +69,7 @@ void control_stall_test()
63
69
char _value[128 ] = {};
64
70
65
71
{
66
- USBTester serial (vendor_id, product_id, product_release, true );
72
+ USBTester serial (get_phy (), vendor_id, product_id, product_release, true );
67
73
greentea_send_kv (" control_stall_test" , serial.get_serial_desc_string ());
68
74
// Wait for host before terminating
69
75
greentea_parse_kv (_key, _value, sizeof (_key), sizeof (_value));
@@ -80,7 +86,7 @@ void control_sizes_test()
80
86
char _value[128 ] = {};
81
87
82
88
{
83
- USBTester serial (vendor_id, product_id, product_release, true );
89
+ USBTester serial (get_phy (), vendor_id, product_id, product_release, true );
84
90
greentea_send_kv (" control_sizes_test" , serial.get_serial_desc_string ());
85
91
// Wait for host before terminating
86
92
greentea_parse_kv (_key, _value, sizeof (_key), sizeof (_value));
@@ -97,7 +103,7 @@ void control_stress_test()
97
103
char _value[128 ] = {};
98
104
99
105
{
100
- USBTester serial (vendor_id, product_id, product_release, true );
106
+ USBTester serial (get_phy (), vendor_id, product_id, product_release, true );
101
107
greentea_send_kv (" control_stress_test" , serial.get_serial_desc_string ());
102
108
// Wait for host before terminating
103
109
greentea_parse_kv (_key, _value, sizeof (_key), sizeof (_value));
@@ -117,7 +123,7 @@ void device_reset_test()
117
123
greentea_parse_kv (_key, _value, sizeof (_key), sizeof (_value));
118
124
if (strcmp (_value, " false" ) != 0 ) {
119
125
120
- USBTester serial (vendor_id, product_id, product_release, true );
126
+ USBTester serial (get_phy (), vendor_id, product_id, product_release, true );
121
127
serial.clear_reset_count ();
122
128
greentea_send_kv (" device_reset_test" , serial.get_serial_desc_string ());
123
129
while (serial.get_reset_count () == 0 );
@@ -163,7 +169,7 @@ void device_soft_reconnection_test()
163
169
const uint32_t reconnect_try_count = 3 ;
164
170
165
171
{
166
- USBTester serial (vendor_id, product_id, product_release, true );
172
+ USBTester serial (get_phy (), vendor_id, product_id, product_release, true );
167
173
168
174
greentea_send_kv (" device_soft_reconnection_test" , serial.get_serial_desc_string ());
169
175
// Wait for host before terminating
@@ -205,7 +211,7 @@ void device_suspend_resume_test()
205
211
char _value[128 ] = {};
206
212
207
213
{
208
- USBTester serial (vendor_id, product_id, product_release, true );
214
+ USBTester serial (get_phy (), vendor_id, product_id, product_release, true );
209
215
greentea_send_kv (" device_suspend_resume_test" , serial.get_serial_desc_string ());
210
216
printf (" [1] suspend_count: %d resume_count: %d\n " , serial.get_suspend_count (), serial.get_resume_count ());
211
217
serial.clear_suspend_count ();
@@ -228,25 +234,25 @@ void repeated_construction_destruction_test()
228
234
char _value[128 ] = {};
229
235
230
236
{
231
- USBTester serial (vendor_id, product_id, product_release, true );
237
+ USBTester serial (get_phy (), vendor_id, product_id, product_release, true );
232
238
TEST_ASSERT_EQUAL (true , serial.configured ());
233
239
}
234
240
235
241
wait_us (MIN_DISCONNECT_TIME_US);
236
242
{
237
- USBTester serial (vendor_id, product_id, product_release, true );
243
+ USBTester serial (get_phy (), vendor_id, product_id, product_release, true );
238
244
TEST_ASSERT_EQUAL (true , serial.configured ());
239
245
}
240
246
241
247
wait_us (MIN_DISCONNECT_TIME_US);
242
248
{
243
- USBTester serial (vendor_id, product_id, product_release, true );
249
+ USBTester serial (get_phy (), vendor_id, product_id, product_release, true );
244
250
TEST_ASSERT_EQUAL (true , serial.configured ());
245
251
}
246
252
247
253
wait_us (MIN_DISCONNECT_TIME_US);
248
254
{
249
- USBTester serial (vendor_id, product_id, product_release, true );
255
+ USBTester serial (get_phy (), vendor_id, product_id, product_release, true );
250
256
TEST_ASSERT_EQUAL (true , serial.configured ());
251
257
greentea_send_kv (" repeated_construction_destruction_test" , serial.get_serial_desc_string ());
252
258
// Wait for host before terminating
@@ -256,7 +262,7 @@ void repeated_construction_destruction_test()
256
262
257
263
wait_us (MIN_DISCONNECT_TIME_US);
258
264
{
259
- USBTester serial (vendor_id, product_id, product_release, true );
265
+ USBTester serial (get_phy (), vendor_id, product_id, product_release, true );
260
266
TEST_ASSERT_EQUAL (true , serial.configured ());
261
267
greentea_send_kv (" repeated_construction_destruction_test" , serial.get_serial_desc_string ());
262
268
// Wait for host before terminating
@@ -266,7 +272,7 @@ void repeated_construction_destruction_test()
266
272
267
273
wait_us (MIN_DISCONNECT_TIME_US);
268
274
{
269
- USBTester serial (vendor_id, product_id, product_release, true );
275
+ USBTester serial (get_phy (), vendor_id, product_id, product_release, true );
270
276
TEST_ASSERT_EQUAL (true , serial.configured ());
271
277
greentea_send_kv (" repeated_construction_destruction_test" , serial.get_serial_desc_string ());
272
278
// Wait for host before terminating
0 commit comments