mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #11607 from fkjagodzinski/fix-usb_device-basic_test
Tests: USB: Move control endpoint buffers to heappull/11645/head
commit
ef4fe9852f
|
@ -40,6 +40,8 @@
|
||||||
#define VENDOR_TEST_RW_RESTART 11
|
#define VENDOR_TEST_RW_RESTART 11
|
||||||
#define VENDOR_TEST_ABORT_BUFF_CHECK 12
|
#define VENDOR_TEST_ABORT_BUFF_CHECK 12
|
||||||
|
|
||||||
|
#define CTRL_BUF_SIZE (2048)
|
||||||
|
|
||||||
#define EVENT_READY (1 << 0)
|
#define EVENT_READY (1 << 0)
|
||||||
|
|
||||||
#define TEST_SIZE_EP_BULK_MAX (64)
|
#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();
|
queue = mbed::mbed_highprio_event_queue();
|
||||||
configuration_desc(0);
|
configuration_desc(0);
|
||||||
|
ctrl_buf = new uint8_t[CTRL_BUF_SIZE];
|
||||||
init();
|
init();
|
||||||
USBDevice::connect();
|
USBDevice::connect();
|
||||||
flags.wait_any(EVENT_READY, osWaitForever, false);
|
flags.wait_any(EVENT_READY, osWaitForever, false);
|
||||||
|
@ -183,6 +186,7 @@ USBEndpointTester::~USBEndpointTester()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deinit();
|
deinit();
|
||||||
|
delete[] ctrl_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *USBEndpointTester::get_desc_string(const uint8_t *desc)
|
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:
|
case VENDOR_TEST_CTRL_IN:
|
||||||
result = Send;
|
result = Send;
|
||||||
data = ctrl_buf;
|
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;
|
break;
|
||||||
case VENDOR_TEST_CTRL_OUT:
|
case VENDOR_TEST_CTRL_OUT:
|
||||||
result = Receive;
|
result = Receive;
|
||||||
|
|
|
@ -23,12 +23,13 @@
|
||||||
#include "USBDevice_Types.h"
|
#include "USBDevice_Types.h"
|
||||||
#include "EventQueue.h"
|
#include "EventQueue.h"
|
||||||
#include "EventFlags.h"
|
#include "EventFlags.h"
|
||||||
|
#include "platform/NonCopyable.h"
|
||||||
|
|
||||||
#include "USBDevice.h"
|
#include "USBDevice.h"
|
||||||
|
|
||||||
#define NUM_ENDPOINTS 6 // Not including CTRL OUT/IN
|
#define NUM_ENDPOINTS 6 // Not including CTRL OUT/IN
|
||||||
|
|
||||||
class USBEndpointTester: public USBDevice {
|
class USBEndpointTester: public USBDevice, private mbed::NonCopyable<USBEndpointTester> {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
USBEndpointTester(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint16_t product_release,
|
USBEndpointTester(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint16_t product_release,
|
||||||
|
@ -80,7 +81,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
events::EventQueue *queue;
|
events::EventQueue *queue;
|
||||||
rtos::EventFlags flags;
|
rtos::EventFlags flags;
|
||||||
uint8_t ctrl_buf[2048];
|
uint8_t *ctrl_buf;
|
||||||
|
|
||||||
bool _abort_transfer_test;
|
bool _abort_transfer_test;
|
||||||
usb_ep_t _endpoints[NUM_ENDPOINTS];
|
usb_ep_t _endpoints[NUM_ENDPOINTS];
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
#define MAX_EP_SIZE 64
|
#define MAX_EP_SIZE 64
|
||||||
#define MIN_EP_SIZE 8
|
#define MIN_EP_SIZE 8
|
||||||
|
|
||||||
|
#define CTRL_BUF_SIZE (2048)
|
||||||
|
|
||||||
#define EVENT_READY (1 << 0)
|
#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();
|
queue = mbed::mbed_highprio_event_queue();
|
||||||
|
|
||||||
configuration_desc(0);
|
configuration_desc(0);
|
||||||
|
ctrl_buf = new uint8_t[CTRL_BUF_SIZE];
|
||||||
init();
|
init();
|
||||||
USBDevice::connect();
|
USBDevice::connect();
|
||||||
flags.wait_any(EVENT_READY, osWaitForever, false);
|
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()
|
USBTester::~USBTester()
|
||||||
{
|
{
|
||||||
deinit();
|
deinit();
|
||||||
|
delete[] ctrl_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,7 +141,7 @@ void USBTester::callback_request(const setup_packet_t *setup)
|
||||||
case VENDOR_TEST_CTRL_IN:
|
case VENDOR_TEST_CTRL_IN:
|
||||||
result = Send;
|
result = Send;
|
||||||
data = ctrl_buf;
|
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;
|
break;
|
||||||
case VENDOR_TEST_CTRL_OUT:
|
case VENDOR_TEST_CTRL_OUT:
|
||||||
result = Receive;
|
result = Receive;
|
||||||
|
|
|
@ -23,10 +23,11 @@
|
||||||
#include "USBDevice_Types.h"
|
#include "USBDevice_Types.h"
|
||||||
#include "EventQueue.h"
|
#include "EventQueue.h"
|
||||||
#include "EventFlags.h"
|
#include "EventFlags.h"
|
||||||
|
#include "platform/NonCopyable.h"
|
||||||
|
|
||||||
#include "USBDevice.h"
|
#include "USBDevice.h"
|
||||||
|
|
||||||
class USBTester: public USBDevice {
|
class USBTester: public USBDevice, private mbed::NonCopyable<USBTester> {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -138,7 +139,7 @@ protected:
|
||||||
virtual void epbulk_out_callback();
|
virtual void epbulk_out_callback();
|
||||||
virtual void epint_out_callback();
|
virtual void epint_out_callback();
|
||||||
virtual void callback_reset();
|
virtual void callback_reset();
|
||||||
uint8_t ctrl_buf[2048];
|
uint8_t *ctrl_buf;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue