diff --git a/TESTS/usb_device/basic/USBEndpointTester.cpp b/TESTS/usb_device/basic/USBEndpointTester.cpp index 476e407acb..0b95dff212 100644 --- a/TESTS/usb_device/basic/USBEndpointTester.cpp +++ b/TESTS/usb_device/basic/USBEndpointTester.cpp @@ -40,6 +40,8 @@ #define VENDOR_TEST_RW_RESTART 11 #define VENDOR_TEST_ABORT_BUFF_CHECK 12 +#define CTRL_BUF_SIZE (2048) + #define EVENT_READY (1 << 0) #define TEST_SIZE_EP_BULK_MAX (64) @@ -170,6 +172,7 @@ USBEndpointTester::USBEndpointTester(USBPhy *phy, uint16_t vendor_id, uint16_t p queue = mbed::mbed_highprio_event_queue(); configuration_desc(0); + ctrl_buf = new uint8_t[CTRL_BUF_SIZE]; init(); USBDevice::connect(); flags.wait_any(EVENT_READY, osWaitForever, false); @@ -183,6 +186,7 @@ USBEndpointTester::~USBEndpointTester() } } deinit(); + delete[] ctrl_buf; } const char *USBEndpointTester::get_desc_string(const uint8_t *desc) @@ -225,7 +229,7 @@ void USBEndpointTester::callback_request(const setup_packet_t *setup) case VENDOR_TEST_CTRL_IN: result = Send; data = ctrl_buf; - size = setup->wValue < sizeof(ctrl_buf) ? setup->wValue : sizeof(ctrl_buf); + size = setup->wValue < CTRL_BUF_SIZE ? setup->wValue : CTRL_BUF_SIZE; break; case VENDOR_TEST_CTRL_OUT: result = Receive; diff --git a/TESTS/usb_device/basic/USBEndpointTester.h b/TESTS/usb_device/basic/USBEndpointTester.h index be099c1484..b6037f60a7 100644 --- a/TESTS/usb_device/basic/USBEndpointTester.h +++ b/TESTS/usb_device/basic/USBEndpointTester.h @@ -23,12 +23,13 @@ #include "USBDevice_Types.h" #include "EventQueue.h" #include "EventFlags.h" +#include "platform/NonCopyable.h" #include "USBDevice.h" #define NUM_ENDPOINTS 6 // Not including CTRL OUT/IN -class USBEndpointTester: public USBDevice { +class USBEndpointTester: public USBDevice, private mbed::NonCopyable { public: USBEndpointTester(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint16_t product_release, @@ -80,7 +81,7 @@ public: protected: events::EventQueue *queue; rtos::EventFlags flags; - uint8_t ctrl_buf[2048]; + uint8_t *ctrl_buf; bool _abort_transfer_test; usb_ep_t _endpoints[NUM_ENDPOINTS]; diff --git a/TESTS/usb_device/basic/USBTester.cpp b/TESTS/usb_device/basic/USBTester.cpp index eba6d79714..6907a859c1 100644 --- a/TESTS/usb_device/basic/USBTester.cpp +++ b/TESTS/usb_device/basic/USBTester.cpp @@ -37,6 +37,8 @@ #define MAX_EP_SIZE 64 #define MIN_EP_SIZE 8 +#define CTRL_BUF_SIZE (2048) + #define EVENT_READY (1 << 0) @@ -57,7 +59,7 @@ USBTester::USBTester(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint1 queue = mbed::mbed_highprio_event_queue(); configuration_desc(0); - + ctrl_buf = new uint8_t[CTRL_BUF_SIZE]; init(); USBDevice::connect(); flags.wait_any(EVENT_READY, osWaitForever, false); @@ -67,6 +69,7 @@ USBTester::USBTester(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint1 USBTester::~USBTester() { deinit(); + delete[] ctrl_buf; } @@ -138,7 +141,7 @@ void USBTester::callback_request(const setup_packet_t *setup) case VENDOR_TEST_CTRL_IN: result = Send; data = ctrl_buf; - size = setup->wValue < sizeof(ctrl_buf) ? setup->wValue : sizeof(ctrl_buf); + size = setup->wValue < CTRL_BUF_SIZE ? setup->wValue : CTRL_BUF_SIZE; break; case VENDOR_TEST_CTRL_OUT: result = Receive; diff --git a/TESTS/usb_device/basic/USBTester.h b/TESTS/usb_device/basic/USBTester.h index 01045501e7..76258004d9 100644 --- a/TESTS/usb_device/basic/USBTester.h +++ b/TESTS/usb_device/basic/USBTester.h @@ -23,10 +23,11 @@ #include "USBDevice_Types.h" #include "EventQueue.h" #include "EventFlags.h" +#include "platform/NonCopyable.h" #include "USBDevice.h" -class USBTester: public USBDevice { +class USBTester: public USBDevice, private mbed::NonCopyable { public: /* @@ -138,7 +139,7 @@ protected: virtual void epbulk_out_callback(); virtual void epint_out_callback(); virtual void callback_reset(); - uint8_t ctrl_buf[2048]; + uint8_t *ctrl_buf; };