Skip to content

USB device cleanup #8125

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

Closed
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
2 changes: 2 additions & 0 deletions TESTS/events/queue/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#endif

using namespace utest::v1;
using events::EventQueue;
using events::Event;

// Assume that tolerance is 5% of measured time.
#define DELTA(ms) (ms / 20)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "nsapi_dns.h"

using namespace utest::v1;
using events::EventQueue;

namespace {
int result_ok;
Expand All @@ -34,7 +35,7 @@ int result_exp_timeout;
const int EXTERNAL_THREAD_SIZE = 2048;
const int EVENT_QUEUE_SIZE = 10;

events::EventQueue *event_queue;
EventQueue *event_queue;
}

static nsapi_error_t event_queue_call(int delay, mbed::Callback<void()> func)
Expand Down
3 changes: 2 additions & 1 deletion TESTS/netsocket/dns/asynchronous_dns_timeouts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "nsapi_dns.h"

using namespace utest::v1;
using events::EventQueue;

namespace {
int result_ok;
Expand All @@ -34,7 +35,7 @@ int result_exp_timeout;
const int EXTERNAL_THREAD_SIZE = 2048;
const int EVENT_QUEUE_SIZE = 10;

events::EventQueue *event_queue;
EventQueue *event_queue;
}

static nsapi_error_t event_queue_call(int delay, mbed::Callback<void()> func)
Expand Down
1 change: 0 additions & 1 deletion TESTS/netsocket/dns/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "unity.h"
#include "utest.h"
#include "nsapi_dns.h"
#include "EventQueue.h"
#include "dns_tests.h"

using namespace utest::v1;
Expand Down
2 changes: 1 addition & 1 deletion TESTS/usb_device/basic/USBEndpointTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ USBEndpointTester::USBEndpointTester(USBPhy *phy, uint16_t vendor_id, uint16_t p
}
MBED_ASSERT(resolver.valid());

queue = mbed_highprio_event_queue();
queue = mbed::mbed_highprio_event_queue();
configuration_desc(0);
init();
USBDevice::connect();
Expand Down
2 changes: 1 addition & 1 deletion TESTS/usb_device/basic/USBEndpointTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class USBEndpointTester: public USBDevice {
};

protected:
EventQueue *queue;
events::EventQueue *queue;
rtos::EventFlags flags;
uint8_t ctrl_buf[2048];

Expand Down
2 changes: 1 addition & 1 deletion TESTS/usb_device/basic/USBTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ USBTester::USBTester(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint1
int_in = resolver.endpoint_in(USB_EP_TYPE_INT, 64);
int_out = resolver.endpoint_out(USB_EP_TYPE_INT, 64);
MBED_ASSERT(resolver.valid());
queue = mbed_highprio_event_queue();
queue = mbed::mbed_highprio_event_queue();

configuration_desc(0);

Expand Down
2 changes: 1 addition & 1 deletion TESTS/usb_device/basic/USBTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class USBTester: public USBDevice {
uint8_t int_in;
uint8_t int_out;
uint8_t int_buf[64];
EventQueue *queue;
events::EventQueue *queue;
rtos::EventFlags flags;
volatile uint32_t reset_count;
volatile uint32_t suspend_count;
Expand Down
4 changes: 3 additions & 1 deletion usb/device/USBAudio/USBAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
* limitations under the License.
*/

#include "stdint.h"
#include "USBAudio.h"
#include "USBAudio_Types.h"
#include "EndpointResolver.h"
#include "usb_phy_api.h"

using mbed::Callback;
using mbed::callback;

#define SAMPLE_SIZE 2
#define XFER_FREQUENCY_HZ 1000
#define WRITE_READY_UNBLOCK (1 << 0)
Expand Down
12 changes: 6 additions & 6 deletions usb/device/USBAudio/USBAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,21 @@ class USBAudio: protected USBDevice {
* @param cb Callback to attach
*
*/
void attach(Callback<void()> &cb);
void attach(mbed::Callback<void()> &cb);

/** attach a Callback to Tx Done
*
* @param cb Callback to attach
*
*/
void attach_tx(Callback<void(AudioEvent)> &cb);
void attach_tx(mbed::Callback<void(AudioEvent)> &cb);

/** attach a Callback to Rx Done
*
* @param cb Callback to attach
*
*/
void attach_rx(Callback<void(AudioEvent)> &cb);
void attach_rx(mbed::Callback<void(AudioEvent)> &cb);

protected:

Expand Down Expand Up @@ -303,13 +303,13 @@ class USBAudio: protected USBDevice {
uint16_t _vol_res;

// callback to update volume
Callback<void()> _update_vol;
mbed::Callback<void()> _update_vol;

// callback transmit Done
Callback<void(AudioEvent)> _tx_done;
mbed::Callback<void(AudioEvent)> _tx_done;

// callback receive Done
Callback<void(AudioEvent)> _rx_done;
mbed::Callback<void(AudioEvent)> _rx_done;

// Number of times data was dropped due to an overflow
uint32_t _rx_overflow;
Expand Down
1 change: 0 additions & 1 deletion usb/device/USBDevice/EndpointResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

#include "mbed.h"
#include "EndpointResolver.h"

static uint32_t logical_to_index(uint32_t logical, bool in_not_out)
Expand Down
2 changes: 0 additions & 2 deletions usb/device/USBDevice/EndpointResolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#ifndef ENDPOINT_RESOLVER_H
#define ENDPOINT_RESOLVER_H

#include "mbed.h"

#include "USBPhy.h"

/**
Expand Down
5 changes: 3 additions & 2 deletions usb/device/USBDevice/USBDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
* limitations under the License.
*/

#include "stdint.h"

#include "USBDevice.h"
#include "USBDescriptor.h"
#include "usb_phy_api.h"
#include "mbed_critical.h"
#include "mbed_assert.h"
#include <string.h> // memset

//#define DEBUG

Expand Down
3 changes: 1 addition & 2 deletions usb/device/USBDevice/USBDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
#ifndef USBDEVICE_H
#define USBDEVICE_H

#include "mbed.h"
#include "USBDevice_Types.h"
#include "USBPhy.h"
#include "mbed_critical.h"
#include <stdlib.h> // NULL

/**
* \defgroup usb_device USB Device
Expand Down
1 change: 0 additions & 1 deletion usb/device/USBHID/USBHID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

#include "stdint.h"
#include "USBHID.h"
#include "EndpointResolver.h"
#include "usb_phy_api.h"
Expand Down
2 changes: 0 additions & 2 deletions usb/device/USBHID/USBKeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

#include "stdint.h"

#include "USBKeyboard.h"
#include "usb_phy_api.h"

Expand Down
2 changes: 1 addition & 1 deletion usb/device/USBHID/USBKeyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ enum FUNCTION_KEY {
*
* @note Synchronization level: Thread safe
*/
class USBKeyboard: public USBHID, public Stream {
class USBKeyboard: public USBHID, public mbed::Stream {
public:

/**
Expand Down
8 changes: 4 additions & 4 deletions usb/device/USBHID/USBMouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* limitations under the License.
*/

#include "stdint.h"
#include "USBMouse.h"
#include "PlatformMutex.h"
#include "usb_phy_api.h"
#include "PlatformMutex.h"
#include "mbed_wait_api.h"


USBMouse::USBMouse(bool connect_blocking, MOUSE_TYPE mouse_type, uint16_t vendor_id, uint16_t product_id, uint16_t product_release):
Expand Down Expand Up @@ -155,7 +155,7 @@ bool USBMouse::double_click()
_mutex.unlock();
return false;
}
wait(0.1);
wait_ms(100);
bool ret = click(MOUSE_LEFT);

_mutex.unlock();
Expand All @@ -170,7 +170,7 @@ bool USBMouse::click(uint8_t button)
_mutex.unlock();
return false;
}
wait(0.01);
wait_ms(10);
bool ret = update(0, 0, 0, 0);

_mutex.unlock();
Expand Down
6 changes: 3 additions & 3 deletions usb/device/USBHID/USBMouseKeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

#include "stdint.h"
#include "USBMouseKeyboard.h"
#include "usb_phy_api.h"
#include "mbed_wait_api.h"

typedef struct {
unsigned char usage;
Expand Down Expand Up @@ -707,7 +707,7 @@ bool USBMouseKeyboard::doubleClick()
_mutex.unlock();
return false;
}
wait(0.1);
wait_ms(100);
bool ret = click(MOUSE_LEFT);

_mutex.unlock();
Expand All @@ -722,7 +722,7 @@ bool USBMouseKeyboard::click(uint8_t button)
_mutex.unlock();
return false;
}
wait(0.01);
wait_ms(10);
bool ret = update(0, 0, 0, 0);

_mutex.unlock();
Expand Down
2 changes: 1 addition & 1 deletion usb/device/USBHID/USBMouseKeyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
*
* @note Synchronization level: Thread safe
*/
class USBMouseKeyboard: public USBHID, public Stream
class USBMouseKeyboard: public USBHID, public mbed::Stream
{
public:

Expand Down
1 change: 0 additions & 1 deletion usb/device/USBMIDI/USBMIDI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

#include "stdint.h"
#include "USBMIDI.h"
#include "EndpointResolver.h"
#include "usb_phy_api.h"
Expand Down
5 changes: 4 additions & 1 deletion usb/device/USBMSD/USBMSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
* limitations under the License.
*/

#include "stdint.h"
#include "USBMSD.h"
#include "EndpointResolver.h"
#include "usb_phy_api.h"
#include "BlockDevice.h"
#include <stdlib.h>

#define DISK_OK 0x00
#define NO_INIT 0x01
Expand Down Expand Up @@ -86,6 +87,8 @@ void USBMSD::_init()
{
_bd->init();

using mbed::callback;

_in_task = callback(this, &USBMSD::_in);
_out_task = callback(this, &USBMSD::_out);
_reset_task = callback(this, &USBMSD::_reset);
Expand Down
15 changes: 8 additions & 7 deletions usb/device/USBMSD/USBMSD.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
#include "platform/Callback.h"
#include "events/PolledQueue.h"
#include "events/Task.h"
#include "BlockDevice.h"
#include "Mutex.h"

#include "USBDevice.h"

class BlockDevice;

/**
* USBMSD class: generic class in order to use all kinds of blocks storage chip
*
Expand Down Expand Up @@ -237,12 +238,12 @@ class USBMSD: public USBDevice {
uint32_t _bulk_out_size;

// Interrupt to thread deferral
PolledQueue _queue;
Task<void()> _in_task;
Task<void()> _out_task;
Task<void()> _reset_task;
Task<void(const setup_packet_t *)> _control_task;
Task<void()> _configure_task;
events::PolledQueue _queue;
events::Task<void()> _in_task;
events::Task<void()> _out_task;
events::Task<void()> _reset_task;
events::Task<void(const setup_packet_t *)> _control_task;
events::Task<void()> _configure_task;

BlockDevice *_bd;
rtos::Mutex _mutex_init;
Expand Down
1 change: 0 additions & 1 deletion usb/device/USBSerial/USBCDC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

#include "stdint.h"
#include "USBCDC.h"
#include "EndpointResolver.h"
#include "AsyncOp.h"
Expand Down
2 changes: 1 addition & 1 deletion usb/device/USBSerial/USBCDC.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class USBCDC: public USBDevice {

protected:
/*
* Get device descriptor. Warning: this method has to store the length of the report descriptor in reportLength.
* Get device descriptor
*
* @returns pointer to the device descriptor
*/
Expand Down
1 change: 0 additions & 1 deletion usb/device/USBSerial/USBSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

#include "stdint.h"
#include "USBSerial.h"
#include "usb_phy_api.h"

Expand Down
Loading