Skip to content

Tests: USB: Move control endpoint buffers to heap #11607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion TESTS/usb_device/basic/USBEndpointTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand All @@ -183,6 +186,7 @@ USBEndpointTester::~USBEndpointTester()
}
}
deinit();
delete[] ctrl_buf;
}

const char *USBEndpointTester::get_desc_string(const uint8_t *desc)
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions TESTS/usb_device/basic/USBEndpointTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -80,7 +81,7 @@ class USBEndpointTester: public USBDevice {
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];
Expand Down
7 changes: 5 additions & 2 deletions TESTS/usb_device/basic/USBTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#define MAX_EP_SIZE 64
#define MIN_EP_SIZE 8

#define CTRL_BUF_SIZE (2048)

#define EVENT_READY (1 << 0)


Expand All @@ -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);
Expand All @@ -67,6 +69,7 @@ USBTester::USBTester(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint1
USBTester::~USBTester()
{
deinit();
delete[] ctrl_buf;
}


Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions TESTS/usb_device/basic/USBTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:

/*
Expand Down Expand Up @@ -138,7 +139,7 @@ class USBTester: public USBDevice {
virtual void epbulk_out_callback();
virtual void epint_out_callback();
virtual void callback_reset();
uint8_t ctrl_buf[2048];
uint8_t *ctrl_buf;

};

Expand Down