diff --git a/TESTS/usb_device/basic/USBTester.cpp b/TESTS/usb_device/basic/USBTester.cpp index bf700d241d..8ca9b11c24 100644 --- a/TESTS/usb_device/basic/USBTester.cpp +++ b/TESTS/usb_device/basic/USBTester.cpp @@ -37,8 +37,8 @@ #define MIN_EP_SIZE 8 -USBTester::USBTester(uint16_t vendor_id, uint16_t product_id, uint16_t product_release, bool connect_blocking): - USBDevice(vendor_id, product_id, product_release), reset_count(0), suspend_count(0), +USBTester::USBTester(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint16_t product_release, bool connect_blocking): + USBDevice(phy, vendor_id, product_id, product_release), reset_count(0), suspend_count(0), resume_count(0), interface_set(NONE), configuration_set(NONE) { diff --git a/TESTS/usb_device/basic/USBTester.h b/TESTS/usb_device/basic/USBTester.h index 332507882e..d6c534ddc7 100644 --- a/TESTS/usb_device/basic/USBTester.h +++ b/TESTS/usb_device/basic/USBTester.h @@ -36,7 +36,7 @@ public: * @param product_release Your preoduct_release * @param connect_blocking define if the connection must be blocked if USB not plugged in */ - USBTester(uint16_t vendor_id, uint16_t product_id, uint16_t product_release, bool connect_blocking); + USBTester(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint16_t product_release, bool connect_blocking); ~USBTester(); diff --git a/TESTS/usb_device/basic/main.cpp b/TESTS/usb_device/basic/main.cpp index f18168013a..8ccd4c5e4e 100644 --- a/TESTS/usb_device/basic/main.cpp +++ b/TESTS/usb_device/basic/main.cpp @@ -22,6 +22,7 @@ #include "utest/utest.h" #include "USBTester.h" +#include "usb_phy_api.h" // If disconnect() + connect() occur too fast the reset event will be dropped. // At a minimum there should be a 200us delay between disconnect and connect. @@ -35,6 +36,11 @@ using namespace utest::v1; +static USBPhy *get_phy() +{ + return get_usb_phy(); +} + void control_basic_test() { uint16_t vendor_id = 0x0d28; @@ -45,7 +51,7 @@ void control_basic_test() char str[128] = {}; { - USBTester serial(vendor_id, product_id, product_release, true); + USBTester serial(get_phy(), vendor_id, product_id, product_release, true); sprintf (str, "%s %d %d", serial.get_serial_desc_string(), vendor_id, product_id); greentea_send_kv("control_basic_test", str); // Wait for host before terminating @@ -63,7 +69,7 @@ void control_stall_test() char _value[128] = {}; { - USBTester serial(vendor_id, product_id, product_release, true); + USBTester serial(get_phy(), vendor_id, product_id, product_release, true); greentea_send_kv("control_stall_test", serial.get_serial_desc_string()); // Wait for host before terminating greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); @@ -80,7 +86,7 @@ void control_sizes_test() char _value[128] = {}; { - USBTester serial(vendor_id, product_id, product_release, true); + USBTester serial(get_phy(), vendor_id, product_id, product_release, true); greentea_send_kv("control_sizes_test", serial.get_serial_desc_string()); // Wait for host before terminating greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); @@ -97,7 +103,7 @@ void control_stress_test() char _value[128] = {}; { - USBTester serial(vendor_id, product_id, product_release, true); + USBTester serial(get_phy(), vendor_id, product_id, product_release, true); greentea_send_kv("control_stress_test", serial.get_serial_desc_string()); // Wait for host before terminating greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); @@ -117,7 +123,7 @@ void device_reset_test() greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); if (strcmp(_value, "false") != 0) { - USBTester serial(vendor_id, product_id, product_release, true); + USBTester serial(get_phy(), vendor_id, product_id, product_release, true); serial.clear_reset_count(); greentea_send_kv("device_reset_test", serial.get_serial_desc_string()); while(serial.get_reset_count() == 0); @@ -163,7 +169,7 @@ void device_soft_reconnection_test() const uint32_t reconnect_try_count = 3; { - USBTester serial(vendor_id, product_id, product_release, true); + USBTester serial(get_phy(), vendor_id, product_id, product_release, true); greentea_send_kv("device_soft_reconnection_test", serial.get_serial_desc_string()); // Wait for host before terminating @@ -205,7 +211,7 @@ void device_suspend_resume_test() char _value[128] = {}; { - USBTester serial(vendor_id, product_id, product_release, true); + USBTester serial(get_phy(), vendor_id, product_id, product_release, true); greentea_send_kv("device_suspend_resume_test", serial.get_serial_desc_string()); printf("[1] suspend_count: %d resume_count: %d\n", serial.get_suspend_count(), serial.get_resume_count()); serial.clear_suspend_count(); @@ -228,25 +234,25 @@ void repeated_construction_destruction_test() char _value[128] = {}; { - USBTester serial(vendor_id, product_id, product_release, true); + USBTester serial(get_phy(), vendor_id, product_id, product_release, true); TEST_ASSERT_EQUAL(true, serial.configured()); } wait_us(MIN_DISCONNECT_TIME_US); { - USBTester serial(vendor_id, product_id, product_release, true); + USBTester serial(get_phy(), vendor_id, product_id, product_release, true); TEST_ASSERT_EQUAL(true, serial.configured()); } wait_us(MIN_DISCONNECT_TIME_US); { - USBTester serial(vendor_id, product_id, product_release, true); + USBTester serial(get_phy(), vendor_id, product_id, product_release, true); TEST_ASSERT_EQUAL(true, serial.configured()); } wait_us(MIN_DISCONNECT_TIME_US); { - USBTester serial(vendor_id, product_id, product_release, true); + USBTester serial(get_phy(), vendor_id, product_id, product_release, true); TEST_ASSERT_EQUAL(true, serial.configured()); greentea_send_kv("repeated_construction_destruction_test", serial.get_serial_desc_string()); // Wait for host before terminating @@ -256,7 +262,7 @@ void repeated_construction_destruction_test() wait_us(MIN_DISCONNECT_TIME_US); { - USBTester serial(vendor_id, product_id, product_release, true); + USBTester serial(get_phy(), vendor_id, product_id, product_release, true); TEST_ASSERT_EQUAL(true, serial.configured()); greentea_send_kv("repeated_construction_destruction_test", serial.get_serial_desc_string()); // Wait for host before terminating @@ -266,7 +272,7 @@ void repeated_construction_destruction_test() wait_us(MIN_DISCONNECT_TIME_US); { - USBTester serial(vendor_id, product_id, product_release, true); + USBTester serial(get_phy(), vendor_id, product_id, product_release, true); TEST_ASSERT_EQUAL(true, serial.configured()); greentea_send_kv("repeated_construction_destruction_test", serial.get_serial_desc_string()); // Wait for host before terminating