Merge pull request #11607 from fkjagodzinski/fix-usb_device-basic_test

Tests: USB: Move control endpoint buffers to heap
pull/11645/head
Anna Bridge 2019-10-07 16:53:50 +01:00 committed by GitHub
commit ef4fe9852f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 7 deletions

View File

@ -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;

View File

@ -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<USBEndpointTester> {
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];

View File

@ -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;

View File

@ -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<USBTester> {
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;
};