Skip to content

Commit 2ba1cdd

Browse files
author
Cruz Monrreal
authored
Merge pull request #9539 from c1728p9/fix_travis
Remove inclusion of mbed.h from USB
2 parents e23e57d + f8864ae commit 2ba1cdd

21 files changed

+108
-91
lines changed

TESTS/usb_device/basic/USBEndpointTester.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717

1818
#include "stdint.h"
19+
#include "stdlib.h"
1920
#include "USBEndpointTester.h"
2021
#include "mbed_shared_queues.h"
2122
#include "EndpointResolver.h"
@@ -167,7 +168,7 @@ USBEndpointTester::USBEndpointTester(USBPhy *phy, uint16_t vendor_id, uint16_t p
167168
}
168169
MBED_ASSERT(resolver.valid());
169170

170-
queue = mbed_highprio_event_queue();
171+
queue = mbed::mbed_highprio_event_queue();
171172
configuration_desc(0);
172173
init();
173174
USBDevice::connect();

TESTS/usb_device/basic/USBEndpointTester.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class USBEndpointTester: public USBDevice {
7878
};
7979

8080
protected:
81-
EventQueue *queue;
81+
events::EventQueue *queue;
8282
rtos::EventFlags flags;
8383
uint8_t ctrl_buf[2048];
8484

TESTS/usb_device/basic/USBTester.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141

4242

4343
USBTester::USBTester(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint16_t product_release):
44-
USBDevice(phy, vendor_id, product_id, product_release), interface_0_alt_set(NONE),
45-
interface_1_alt_set(NONE), configuration_set(NONE), reset_count(0),
46-
suspend_count(0), resume_count(0)
44+
USBDevice(phy, vendor_id, product_id, product_release), interface_0_alt_set(NONE),
45+
interface_1_alt_set(NONE), configuration_set(NONE), reset_count(0),
46+
suspend_count(0), resume_count(0)
4747
{
4848

4949
EndpointResolver resolver(endpoint_table());
@@ -54,7 +54,7 @@ USBTester::USBTester(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint1
5454
int_in = resolver.endpoint_in(USB_EP_TYPE_INT, 64);
5555
int_out = resolver.endpoint_out(USB_EP_TYPE_INT, 64);
5656
MBED_ASSERT(resolver.valid());
57-
queue = mbed_highprio_event_queue();
57+
queue = mbed::mbed_highprio_event_queue();
5858

5959
configuration_desc(0);
6060

@@ -269,14 +269,14 @@ bool USBTester::set_configuration(uint16_t configuration)
269269
bulk_buf, sizeof(bulk_buf), &USBTester::epbulk_out_callback);
270270
// interface 1 alternate 0
271271
success &= setup_iterface(int_in, int_out, MAX_EP_SIZE, USB_EP_TYPE_INT,
272-
int_buf, sizeof(int_buf), &USBTester::epint_out_callback);
272+
int_buf, sizeof(int_buf), &USBTester::epint_out_callback);
273273
} else if (configuration == 2) {
274274
// interface 0 alternate 0
275275
success = setup_iterface(int_in, int_out, MIN_EP_SIZE, USB_EP_TYPE_INT,
276276
int_buf, sizeof(int_buf), &USBTester::epint_out_callback);
277277
// interface 1 alternate 0
278278
success &= setup_iterface(bulk_in, bulk_out, MIN_EP_SIZE, USB_EP_TYPE_BULK,
279-
bulk_buf, sizeof(bulk_buf), &USBTester::epbulk_out_callback);
279+
bulk_buf, sizeof(bulk_buf), &USBTester::epbulk_out_callback);
280280
}
281281
if (success) {
282282
configuration_set = configuration;

TESTS/usb_device/basic/USBTester.h

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,30 @@ class USBTester: public USBDevice {
4747
const char *get_serial_desc_string();
4848
const char *get_iproduct_desc_string();
4949
const char *get_iinterface_desc_string();
50-
uint32_t get_reset_count() const { return reset_count; }
51-
uint32_t get_suspend_count() const { return suspend_count; }
52-
uint32_t get_resume_count() const { return resume_count; }
53-
void clear_reset_count() { reset_count = 0; }
54-
void clear_suspend_count() { suspend_count = 0; }
55-
void clear_resume_count() { resume_count = 0; }
50+
uint32_t get_reset_count() const
51+
{
52+
return reset_count;
53+
}
54+
uint32_t get_suspend_count() const
55+
{
56+
return suspend_count;
57+
}
58+
uint32_t get_resume_count() const
59+
{
60+
return resume_count;
61+
}
62+
void clear_reset_count()
63+
{
64+
reset_count = 0;
65+
}
66+
void clear_suspend_count()
67+
{
68+
suspend_count = 0;
69+
}
70+
void clear_resume_count()
71+
{
72+
resume_count = 0;
73+
}
5674

5775
private:
5876

@@ -106,7 +124,7 @@ class USBTester: public USBDevice {
106124
uint8_t int_in;
107125
uint8_t int_out;
108126
uint8_t int_buf[64];
109-
EventQueue *queue;
127+
events::EventQueue *queue;
110128
rtos::EventFlags flags;
111129
volatile uint32_t reset_count;
112130
volatile uint32_t suspend_count;

usb/device/USBAudio/USBAudio.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ void USBAudio::_init(uint32_t frequency_rx, uint8_t channel_count_rx, uint32_t f
145145
_vol_max = 0x0100;
146146
_vol_res = 0x0004;
147147

148-
_update_vol = callback(stub_volume);
149-
_tx_done = callback(stub_handler);
150-
_rx_done = callback(stub_handler);
148+
_update_vol = mbed::callback(stub_volume);
149+
_tx_done = mbed::callback(stub_handler);
150+
_rx_done = mbed::callback(stub_handler);
151151

152152
_rx_overflow = 0;
153153
_tx_underflow = 0;
@@ -348,7 +348,7 @@ float USBAudio::get_volume()
348348
return ret;
349349
}
350350

351-
void USBAudio::attach(Callback<void()> &cb)
351+
void USBAudio::attach(mbed::Callback<void()> &cb)
352352
{
353353
lock();
354354

@@ -360,25 +360,25 @@ void USBAudio::attach(Callback<void()> &cb)
360360
unlock();
361361
}
362362

363-
void USBAudio::attach_tx(Callback<void(AudioEvent)> &cb)
363+
void USBAudio::attach_tx(mbed::Callback<void(AudioEvent)> &cb)
364364
{
365365
lock();
366366

367367
_tx_done = cb;
368368
if (!_tx_done) {
369-
_tx_done = callback(stub_handler);
369+
_tx_done = mbed::callback(stub_handler);
370370
}
371371

372372
unlock();
373373
}
374374

375-
void USBAudio::attach_rx(Callback<void(AudioEvent)> &cb)
375+
void USBAudio::attach_rx(mbed::Callback<void(AudioEvent)> &cb)
376376
{
377377
lock();
378378

379379
_rx_done = cb;
380380
if (!_rx_done) {
381-
_rx_done = callback(stub_handler);
381+
_rx_done = mbed::callback(stub_handler);
382382
}
383383

384384
unlock();
@@ -498,7 +498,7 @@ void USBAudio::callback_request_xfer_done(const setup_packet_t *setup, bool abor
498498
}
499499

500500
if ((setup->wLength == 1) || (setup->wLength == 2)) {
501-
uint16_t data = (_control_receive[0] << 0) | (_control_receive[1] << 8);
501+
uint16_t data = (_control_receive[0] << 0) | (_control_receive[1] << 8);
502502
data &= ((setup->wLength == 1) ? 0xFF : 0xFFFF);
503503
switch (setup->wValue >> 8) {
504504
case MUTE_CONTROL:
@@ -516,7 +516,7 @@ void USBAudio::callback_request_xfer_done(const setup_packet_t *setup, bool abor
516516
case REQUEST_SET_CUR:
517517
_vol_cur = data;
518518
_volume = (float)_vol_cur / (float)_vol_max;
519-
_update_vol.call();
519+
_update_vol.call();
520520
break;
521521
default:
522522
break;

usb/device/USBAudio/USBAudio.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class USBAudio: protected USBDevice {
8080
* @param product_id Your product_id
8181
* @param product_release Your product_release
8282
*/
83-
USBAudio(bool connect=true, uint32_t frequency_rx = 48000, uint8_t channel_count_rx = 1, uint32_t frequency_tx = 8000, uint8_t channel_count_tx = 1, uint32_t buffer_ms=10, uint16_t vendor_id = 0x7bb8, uint16_t product_id = 0x1111, uint16_t product_release = 0x0100);
83+
USBAudio(bool connect = true, uint32_t frequency_rx = 48000, uint8_t channel_count_rx = 1, uint32_t frequency_tx = 8000, uint8_t channel_count_tx = 1, uint32_t buffer_ms = 10, uint16_t vendor_id = 0x7bb8, uint16_t product_id = 0x1111, uint16_t product_release = 0x0100);
8484

8585
/**
8686
* Fully featured constructor
@@ -153,7 +153,7 @@ class USBAudio: protected USBDevice {
153153
* @param clear Reset the overflow count back to 0
154154
* @return Number of packets dropped due to overflow
155155
*/
156-
uint32_t read_overflows(bool clear=false);
156+
uint32_t read_overflows(bool clear = false);
157157

158158
/**
159159
* Check if the audio read channel is open
@@ -196,7 +196,7 @@ class USBAudio: protected USBDevice {
196196
* @return Number of packets that should have been
197197
* sent but weren't due to overflow
198198
*/
199-
uint32_t write_underflows(bool clear=false);
199+
uint32_t write_underflows(bool clear = false);
200200

201201
/**
202202
* Check if the audio write channel is open
@@ -222,21 +222,21 @@ class USBAudio: protected USBDevice {
222222
* @param cb Callback to attach
223223
*
224224
*/
225-
void attach(Callback<void()> &cb);
225+
void attach(mbed::Callback<void()> &cb);
226226

227227
/** attach a Callback to Tx Done
228228
*
229229
* @param cb Callback to attach
230230
*
231231
*/
232-
void attach_tx(Callback<void(AudioEvent)> &cb);
232+
void attach_tx(mbed::Callback<void(AudioEvent)> &cb);
233233

234234
/** attach a Callback to Rx Done
235235
*
236236
* @param cb Callback to attach
237237
*
238238
*/
239-
void attach_rx(Callback<void(AudioEvent)> &cb);
239+
void attach_rx(mbed::Callback<void(AudioEvent)> &cb);
240240

241241
protected:
242242

@@ -303,13 +303,13 @@ class USBAudio: protected USBDevice {
303303
uint16_t _vol_res;
304304

305305
// callback to update volume
306-
Callback<void()> _update_vol;
306+
mbed::Callback<void()> _update_vol;
307307

308308
// callback transmit Done
309-
Callback<void(AudioEvent)> _tx_done;
309+
mbed::Callback<void(AudioEvent)> _tx_done;
310310

311311
// callback receive Done
312-
Callback<void(AudioEvent)> _rx_done;
312+
mbed::Callback<void(AudioEvent)> _rx_done;
313313

314314
// Number of times data was dropped due to an overflow
315315
uint32_t _rx_overflow;

usb/device/USBDevice/EndpointResolver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
#include "mbed.h"
1817
#include "EndpointResolver.h"
1918

2019
static uint32_t logical_to_index(uint32_t logical, bool in_not_out)
@@ -74,7 +73,8 @@ bool EndpointResolver::valid()
7473
return _valid && (_cost <= _table->resources);
7574
}
7675

77-
void EndpointResolver::reset() {
76+
void EndpointResolver::reset()
77+
{
7878
_cost = 0;
7979
_used = 0;
8080
_valid = true;

usb/device/USBDevice/EndpointResolver.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
#ifndef ENDPOINT_RESOLVER_H
1818
#define ENDPOINT_RESOLVER_H
1919

20-
#include "mbed.h"
21-
2220
#include "USBPhy.h"
2321

2422
/**

usb/device/USBDevice/USBDevice.cpp

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
* limitations under the License.
1515
*/
1616

17-
#include "stdint.h"
17+
#include <stdint.h>
18+
#include <string.h>
1819

1920
#include "USBDevice.h"
2021
#include "USBDescriptor.h"
2122
#include "usb_phy_api.h"
23+
#include "mbed_assert.h"
2224

2325
//#define DEBUG
2426

@@ -62,8 +64,7 @@ bool USBDevice::_request_get_descriptor()
6264
printf("get descr: type: %d\r\n", DESCRIPTOR_TYPE(_transfer.setup.wValue));
6365
#endif
6466
switch (DESCRIPTOR_TYPE(_transfer.setup.wValue)) {
65-
case DEVICE_DESCRIPTOR:
66-
{
67+
case DEVICE_DESCRIPTOR: {
6768
if (device_desc() != NULL) {
6869
if ((device_desc()[0] == DEVICE_DESCRIPTOR_LENGTH) \
6970
&& (device_desc()[1] == DEVICE_DESCRIPTOR)) {
@@ -78,8 +79,7 @@ bool USBDevice::_request_get_descriptor()
7879
}
7980
break;
8081
}
81-
case CONFIGURATION_DESCRIPTOR:
82-
{
82+
case CONFIGURATION_DESCRIPTOR: {
8383
const uint8_t idx = DESCRIPTOR_INDEX(_transfer.setup.wValue);
8484
if (configuration_desc(idx) != NULL) {
8585
if ((configuration_desc(idx)[0] == CONFIGURATION_DESCRIPTOR_LENGTH) \
@@ -89,7 +89,7 @@ bool USBDevice::_request_get_descriptor()
8989
#endif
9090
/* Get wTotalLength */
9191
_transfer.remaining = configuration_desc(idx)[2] \
92-
| (configuration_desc(idx)[3] << 8);
92+
| (configuration_desc(idx)[3] << 8);
9393

9494
_transfer.ptr = (uint8_t *)configuration_desc(idx);
9595
_transfer.direction = Send;
@@ -98,8 +98,7 @@ bool USBDevice::_request_get_descriptor()
9898
}
9999
break;
100100
}
101-
case STRING_DESCRIPTOR:
102-
{
101+
case STRING_DESCRIPTOR: {
103102
#ifdef DEBUG
104103
printf("str descriptor\r\n");
105104
#endif
@@ -161,23 +160,20 @@ bool USBDevice::_request_get_descriptor()
161160
}
162161
break;
163162
}
164-
case INTERFACE_DESCRIPTOR:
165-
{
163+
case INTERFACE_DESCRIPTOR: {
166164
#ifdef DEBUG
167165
printf("interface descr\r\n");
168166
#endif
169167
break;
170168
}
171-
case ENDPOINT_DESCRIPTOR:
172-
{
169+
case ENDPOINT_DESCRIPTOR: {
173170
#ifdef DEBUG
174171
printf("endpoint descr\r\n");
175172
#endif
176173
/* TODO: Support is optional, not implemented here */
177174
break;
178175
}
179-
default:
180-
{
176+
default: {
181177
#ifdef DEBUG
182178
printf("ERROR\r\n");
183179
#endif
@@ -1152,7 +1148,7 @@ void USBDevice::endpoint_stall(usb_ep_t endpoint)
11521148
_phy->endpoint_stall(endpoint);
11531149

11541150
if (info->pending) {
1155-
endpoint_abort(endpoint);
1151+
endpoint_abort(endpoint);
11561152
}
11571153

11581154
unlock();
@@ -1587,7 +1583,8 @@ void USBDevice::assert_locked()
15871583
MBED_ASSERT(_locked > 0);
15881584
}
15891585

1590-
void USBDevice::_change_state(DeviceState new_state) {
1586+
void USBDevice::_change_state(DeviceState new_state)
1587+
{
15911588
assert_locked();
15921589

15931590
DeviceState old_state = _device.state;

usb/device/USBDevice/USBDevice.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#ifndef USBDEVICE_H
1818
#define USBDEVICE_H
1919

20-
#include "mbed.h"
2120
#include "USBDevice_Types.h"
2221
#include "USBPhy.h"
2322
#include "mbed_critical.h"
@@ -404,7 +403,7 @@ class USBDevice: public USBPhyEvents {
404403
* @param data Buffer to send or receive if the result is Send or Receive
405404
* @param size Size to transfer if the result is Send or Receive
406405
*/
407-
void complete_request(RequestResult result, uint8_t *data=NULL, uint32_t size=0);
406+
void complete_request(RequestResult result, uint8_t *data = NULL, uint32_t size = 0);
408407

409408
/**
410409
* Called by USBDevice on data stage completion

0 commit comments

Comments
 (0)