mirror of https://github.com/ARMmbed/mbed-os.git
Update usb test to connect and block itself
Update the basic usb test so it does blocking itself since blocking connect was removed from USBDevice.pull/9768/head
parent
3d429cf43f
commit
bcfe96b83c
|
@ -37,8 +37,10 @@
|
|||
#define MAX_EP_SIZE 64
|
||||
#define MIN_EP_SIZE 8
|
||||
|
||||
#define EVENT_READY (1 << 0)
|
||||
|
||||
USBTester::USBTester(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint16_t product_release, bool connect_blocking):
|
||||
|
||||
USBTester::USBTester(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint16_t product_release):
|
||||
USBDevice(phy, vendor_id, product_id, product_release), reset_count(0), suspend_count(0),
|
||||
resume_count(0), interface_0_alt_set(NONE), interface_1_alt_set(NONE), configuration_set(NONE)
|
||||
{
|
||||
|
@ -56,7 +58,8 @@ USBTester::USBTester(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint1
|
|||
configuration_desc(0);
|
||||
|
||||
init();
|
||||
USBDevice::connect(connect_blocking);
|
||||
USBDevice::connect();
|
||||
flags.wait_any(EVENT_READY, osWaitForever, false);
|
||||
|
||||
}
|
||||
|
||||
|
@ -105,7 +108,10 @@ const char *USBTester::get_iproduct_desc_string()
|
|||
|
||||
void USBTester::callback_state_change(DeviceState new_state)
|
||||
{
|
||||
if (new_state != Configured) {
|
||||
if (new_state == Configured) {
|
||||
flags.set(EVENT_READY);
|
||||
} else {
|
||||
flags.clear(EVENT_READY);
|
||||
configuration_set = NONE;
|
||||
interface_0_alt_set = NONE;
|
||||
interface_1_alt_set = NONE;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "USBDescriptor.h"
|
||||
#include "USBDevice_Types.h"
|
||||
#include "EventQueue.h"
|
||||
#include "EventFlags.h"
|
||||
|
||||
#include "USBDevice.h"
|
||||
|
||||
|
@ -34,9 +35,8 @@ public:
|
|||
* @param vendor_id Your vendor_id
|
||||
* @param product_id Your product_id
|
||||
* @param product_release Your product_release
|
||||
* @param connect_blocking define if the connection must be blocked if USB not plugged in
|
||||
*/
|
||||
USBTester(USBPhy *phy, 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);
|
||||
|
||||
~USBTester();
|
||||
|
||||
|
@ -107,6 +107,7 @@ protected:
|
|||
uint8_t int_out;
|
||||
uint8_t int_buf[64];
|
||||
EventQueue *queue;
|
||||
rtos::EventFlags flags;
|
||||
volatile uint32_t reset_count;
|
||||
volatile uint32_t suspend_count;
|
||||
volatile uint32_t resume_count;
|
||||
|
|
|
@ -51,7 +51,7 @@ void control_basic_test()
|
|||
char str[128] = {};
|
||||
|
||||
{
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release, true);
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release);
|
||||
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
|
||||
|
@ -69,7 +69,7 @@ void control_stall_test()
|
|||
char _value[128] = {};
|
||||
|
||||
{
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release, true);
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release);
|
||||
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));
|
||||
|
@ -86,7 +86,7 @@ void control_sizes_test()
|
|||
char _value[128] = {};
|
||||
|
||||
{
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release, true);
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release);
|
||||
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));
|
||||
|
@ -103,7 +103,7 @@ void control_stress_test()
|
|||
char _value[128] = {};
|
||||
|
||||
{
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release, true);
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release);
|
||||
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));
|
||||
|
@ -123,7 +123,7 @@ void device_reset_test()
|
|||
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
|
||||
if (strcmp(_value, "false") != 0) {
|
||||
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release, true);
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release);
|
||||
serial.clear_reset_count();
|
||||
greentea_send_kv("device_reset_test", serial.get_serial_desc_string());
|
||||
while(serial.get_reset_count() == 0);
|
||||
|
@ -169,7 +169,7 @@ void device_soft_reconnection_test()
|
|||
const uint32_t reconnect_try_count = 3;
|
||||
|
||||
{
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release, true);
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release);
|
||||
|
||||
greentea_send_kv("device_soft_reconnection_test", serial.get_serial_desc_string());
|
||||
// Wait for host before terminating
|
||||
|
@ -211,7 +211,7 @@ void device_suspend_resume_test()
|
|||
char _value[128] = {};
|
||||
|
||||
{
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release, true);
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release);
|
||||
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();
|
||||
|
@ -234,25 +234,25 @@ void repeated_construction_destruction_test()
|
|||
char _value[128] = {};
|
||||
|
||||
{
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release, true);
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release);
|
||||
TEST_ASSERT_EQUAL(true, serial.configured());
|
||||
}
|
||||
|
||||
wait_us(MIN_DISCONNECT_TIME_US);
|
||||
{
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release, true);
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release);
|
||||
TEST_ASSERT_EQUAL(true, serial.configured());
|
||||
}
|
||||
|
||||
wait_us(MIN_DISCONNECT_TIME_US);
|
||||
{
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release, true);
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release);
|
||||
TEST_ASSERT_EQUAL(true, serial.configured());
|
||||
}
|
||||
|
||||
wait_us(MIN_DISCONNECT_TIME_US);
|
||||
{
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release, true);
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release);
|
||||
TEST_ASSERT_EQUAL(true, serial.configured());
|
||||
greentea_send_kv("repeated_construction_destruction_test", serial.get_serial_desc_string());
|
||||
// Wait for host before terminating
|
||||
|
@ -262,7 +262,7 @@ void repeated_construction_destruction_test()
|
|||
|
||||
wait_us(MIN_DISCONNECT_TIME_US);
|
||||
{
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release, true);
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release);
|
||||
TEST_ASSERT_EQUAL(true, serial.configured());
|
||||
greentea_send_kv("repeated_construction_destruction_test", serial.get_serial_desc_string());
|
||||
// Wait for host before terminating
|
||||
|
@ -272,7 +272,7 @@ void repeated_construction_destruction_test()
|
|||
|
||||
wait_us(MIN_DISCONNECT_TIME_US);
|
||||
{
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release, true);
|
||||
USBTester serial(get_phy(), vendor_id, product_id, product_release);
|
||||
TEST_ASSERT_EQUAL(true, serial.configured());
|
||||
greentea_send_kv("repeated_construction_destruction_test", serial.get_serial_desc_string());
|
||||
// Wait for host before terminating
|
||||
|
|
Loading…
Reference in New Issue