From 5867e99bc94b2947e3c3248087a3fee5c1d1f91d Mon Sep 17 00:00:00 2001 From: Russ Butler Date: Tue, 29 Jan 2019 15:16:27 -0600 Subject: [PATCH 1/2] Remove inclusion of mbed.h from USB Remove mbed.h from USB files and fix the build errors this causes. This is required to pass CI. --- TESTS/usb_device/basic/USBEndpointTester.cpp | 3 ++- TESTS/usb_device/basic/USBEndpointTester.h | 2 +- TESTS/usb_device/basic/USBTester.cpp | 2 +- TESTS/usb_device/basic/USBTester.h | 2 +- usb/device/USBAudio/USBAudio.cpp | 16 ++++++++-------- usb/device/USBAudio/USBAudio.h | 12 ++++++------ usb/device/USBDevice/EndpointResolver.cpp | 1 - usb/device/USBDevice/EndpointResolver.h | 2 -- usb/device/USBDevice/USBDevice.cpp | 4 +++- usb/device/USBDevice/USBDevice.h | 1 - usb/device/USBHID/USBKeyboard.h | 2 +- usb/device/USBHID/USBMouse.cpp | 1 + usb/device/USBHID/USBMouseKeyboard.cpp | 1 + usb/device/USBHID/USBMouseKeyboard.h | 2 +- usb/device/USBMIDI/MIDIMessage.h | 2 +- usb/device/USBMIDI/USBMIDI.cpp | 2 +- usb/device/USBMIDI/USBMIDI.h | 4 ++-- usb/device/USBMSD/USBMSD.cpp | 13 +++++++------ usb/device/USBMSD/USBMSD.h | 12 ++++++------ usb/device/USBSerial/USBSerial.h | 10 +++++----- usb/device/utilities/events/TaskBase.cpp | 2 +- 21 files changed, 49 insertions(+), 47 deletions(-) diff --git a/TESTS/usb_device/basic/USBEndpointTester.cpp b/TESTS/usb_device/basic/USBEndpointTester.cpp index e8bbda66a2..476e407acb 100644 --- a/TESTS/usb_device/basic/USBEndpointTester.cpp +++ b/TESTS/usb_device/basic/USBEndpointTester.cpp @@ -16,6 +16,7 @@ */ #include "stdint.h" +#include "stdlib.h" #include "USBEndpointTester.h" #include "mbed_shared_queues.h" #include "EndpointResolver.h" @@ -167,7 +168,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(); diff --git a/TESTS/usb_device/basic/USBEndpointTester.h b/TESTS/usb_device/basic/USBEndpointTester.h index c20fc45bf5..be099c1484 100644 --- a/TESTS/usb_device/basic/USBEndpointTester.h +++ b/TESTS/usb_device/basic/USBEndpointTester.h @@ -78,7 +78,7 @@ public: }; protected: - EventQueue *queue; + events::EventQueue *queue; rtos::EventFlags flags; uint8_t ctrl_buf[2048]; diff --git a/TESTS/usb_device/basic/USBTester.cpp b/TESTS/usb_device/basic/USBTester.cpp index 36b01d9eeb..93cc892ffb 100644 --- a/TESTS/usb_device/basic/USBTester.cpp +++ b/TESTS/usb_device/basic/USBTester.cpp @@ -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); diff --git a/TESTS/usb_device/basic/USBTester.h b/TESTS/usb_device/basic/USBTester.h index f94f771f37..ac3554e837 100644 --- a/TESTS/usb_device/basic/USBTester.h +++ b/TESTS/usb_device/basic/USBTester.h @@ -106,7 +106,7 @@ protected: 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; diff --git a/usb/device/USBAudio/USBAudio.cpp b/usb/device/USBAudio/USBAudio.cpp index 71d392e999..ad6800a72e 100644 --- a/usb/device/USBAudio/USBAudio.cpp +++ b/usb/device/USBAudio/USBAudio.cpp @@ -145,9 +145,9 @@ void USBAudio::_init(uint32_t frequency_rx, uint8_t channel_count_rx, uint32_t f _vol_max = 0x0100; _vol_res = 0x0004; - _update_vol = callback(stub_volume); - _tx_done = callback(stub_handler); - _rx_done = callback(stub_handler); + _update_vol = mbed::callback(stub_volume); + _tx_done = mbed::callback(stub_handler); + _rx_done = mbed::callback(stub_handler); _rx_overflow = 0; _tx_underflow = 0; @@ -348,7 +348,7 @@ float USBAudio::get_volume() return ret; } -void USBAudio::attach(Callback &cb) +void USBAudio::attach(mbed::Callback &cb) { lock(); @@ -360,25 +360,25 @@ void USBAudio::attach(Callback &cb) unlock(); } -void USBAudio::attach_tx(Callback &cb) +void USBAudio::attach_tx(mbed::Callback &cb) { lock(); _tx_done = cb; if (!_tx_done) { - _tx_done = callback(stub_handler); + _tx_done = mbed::callback(stub_handler); } unlock(); } -void USBAudio::attach_rx(Callback &cb) +void USBAudio::attach_rx(mbed::Callback &cb) { lock(); _rx_done = cb; if (!_rx_done) { - _rx_done = callback(stub_handler); + _rx_done = mbed::callback(stub_handler); } unlock(); diff --git a/usb/device/USBAudio/USBAudio.h b/usb/device/USBAudio/USBAudio.h index d2ed6aea68..90b7cd00c2 100644 --- a/usb/device/USBAudio/USBAudio.h +++ b/usb/device/USBAudio/USBAudio.h @@ -222,21 +222,21 @@ public: * @param cb Callback to attach * */ - void attach(Callback &cb); + void attach(mbed::Callback &cb); /** attach a Callback to Tx Done * * @param cb Callback to attach * */ - void attach_tx(Callback &cb); + void attach_tx(mbed::Callback &cb); /** attach a Callback to Rx Done * * @param cb Callback to attach * */ - void attach_rx(Callback &cb); + void attach_rx(mbed::Callback &cb); protected: @@ -303,13 +303,13 @@ private: uint16_t _vol_res; // callback to update volume - Callback _update_vol; + mbed::Callback _update_vol; // callback transmit Done - Callback _tx_done; + mbed::Callback _tx_done; // callback receive Done - Callback _rx_done; + mbed::Callback _rx_done; // Number of times data was dropped due to an overflow uint32_t _rx_overflow; diff --git a/usb/device/USBDevice/EndpointResolver.cpp b/usb/device/USBDevice/EndpointResolver.cpp index 05ced02866..d9ae07af70 100644 --- a/usb/device/USBDevice/EndpointResolver.cpp +++ b/usb/device/USBDevice/EndpointResolver.cpp @@ -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) diff --git a/usb/device/USBDevice/EndpointResolver.h b/usb/device/USBDevice/EndpointResolver.h index a0a9a93e8f..7c0eb4a4fd 100644 --- a/usb/device/USBDevice/EndpointResolver.h +++ b/usb/device/USBDevice/EndpointResolver.h @@ -17,8 +17,6 @@ #ifndef ENDPOINT_RESOLVER_H #define ENDPOINT_RESOLVER_H -#include "mbed.h" - #include "USBPhy.h" /** diff --git a/usb/device/USBDevice/USBDevice.cpp b/usb/device/USBDevice/USBDevice.cpp index d2327ba5b1..2ec6b3ed8b 100644 --- a/usb/device/USBDevice/USBDevice.cpp +++ b/usb/device/USBDevice/USBDevice.cpp @@ -14,11 +14,13 @@ * limitations under the License. */ -#include "stdint.h" +#include +#include #include "USBDevice.h" #include "USBDescriptor.h" #include "usb_phy_api.h" +#include "mbed_assert.h" //#define DEBUG diff --git a/usb/device/USBDevice/USBDevice.h b/usb/device/USBDevice/USBDevice.h index 5831df48b7..e8b7f5c691 100644 --- a/usb/device/USBDevice/USBDevice.h +++ b/usb/device/USBDevice/USBDevice.h @@ -17,7 +17,6 @@ #ifndef USBDEVICE_H #define USBDEVICE_H -#include "mbed.h" #include "USBDevice_Types.h" #include "USBPhy.h" #include "mbed_critical.h" diff --git a/usb/device/USBHID/USBKeyboard.h b/usb/device/USBHID/USBKeyboard.h index d2f8a765a8..a78b1438f8 100644 --- a/usb/device/USBHID/USBKeyboard.h +++ b/usb/device/USBHID/USBKeyboard.h @@ -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: /** diff --git a/usb/device/USBHID/USBMouse.cpp b/usb/device/USBHID/USBMouse.cpp index 902e9e72f7..d54531acb4 100644 --- a/usb/device/USBHID/USBMouse.cpp +++ b/usb/device/USBHID/USBMouse.cpp @@ -18,6 +18,7 @@ #include "USBMouse.h" #include "PlatformMutex.h" #include "usb_phy_api.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): diff --git a/usb/device/USBHID/USBMouseKeyboard.cpp b/usb/device/USBHID/USBMouseKeyboard.cpp index 4d9e4b990d..8cb24a5fba 100644 --- a/usb/device/USBHID/USBMouseKeyboard.cpp +++ b/usb/device/USBHID/USBMouseKeyboard.cpp @@ -17,6 +17,7 @@ #include "stdint.h" #include "USBMouseKeyboard.h" #include "usb_phy_api.h" +#include "mbed_wait_api.h" typedef struct { unsigned char usage; diff --git a/usb/device/USBHID/USBMouseKeyboard.h b/usb/device/USBHID/USBMouseKeyboard.h index 75595e231b..d8b9d39c51 100644 --- a/usb/device/USBHID/USBMouseKeyboard.h +++ b/usb/device/USBHID/USBMouseKeyboard.h @@ -68,7 +68,7 @@ * * @note Synchronization level: Thread safe */ -class USBMouseKeyboard: public USBHID, public Stream +class USBMouseKeyboard: public USBHID, public mbed::Stream { public: diff --git a/usb/device/USBMIDI/MIDIMessage.h b/usb/device/USBMIDI/MIDIMessage.h index ff16226a9d..7a30d4a5e9 100644 --- a/usb/device/USBMIDI/MIDIMessage.h +++ b/usb/device/USBMIDI/MIDIMessage.h @@ -17,7 +17,7 @@ #ifndef MIDIMESSAGE_H #define MIDIMESSAGE_H -#include "mbed.h" +#include #define MAX_MIDI_MESSAGE_SIZE 256 // Max message size. SysEx can be up to 65536 but 256 should be fine for most usage diff --git a/usb/device/USBMIDI/USBMIDI.cpp b/usb/device/USBMIDI/USBMIDI.cpp index 24cceff1f4..328973c726 100644 --- a/usb/device/USBMIDI/USBMIDI.cpp +++ b/usb/device/USBMIDI/USBMIDI.cpp @@ -172,7 +172,7 @@ bool USBMIDI::read(MIDIMessage *m) return true; } -void USBMIDI::attach(Callback callback) +void USBMIDI::attach(mbed::Callback callback) { lock(); diff --git a/usb/device/USBMIDI/USBMIDI.h b/usb/device/USBMIDI/USBMIDI.h index 04adfe7ad0..6ddf6aef90 100644 --- a/usb/device/USBMIDI/USBMIDI.h +++ b/usb/device/USBMIDI/USBMIDI.h @@ -134,7 +134,7 @@ public: * * @param callback code to call when a packet is received */ - void attach(Callback callback); + void attach(mbed::Callback callback); protected: @@ -173,7 +173,7 @@ private: usb_ep_t _bulk_out; uint8_t _config_descriptor[0x65]; - Callback _callback; + mbed::Callback _callback; void _init(); void _in_callback(); diff --git a/usb/device/USBMSD/USBMSD.cpp b/usb/device/USBMSD/USBMSD.cpp index 79020201c0..6961c8e0c4 100644 --- a/usb/device/USBMSD/USBMSD.cpp +++ b/usb/device/USBMSD/USBMSD.cpp @@ -14,7 +14,8 @@ * limitations under the License. */ -#include "stdint.h" +#include +#include #include "USBMSD.h" #include "EndpointResolver.h" #include "usb_phy_api.h" @@ -86,11 +87,11 @@ void USBMSD::_init() { _bd->init(); - _in_task = callback(this, &USBMSD::_in); - _out_task = callback(this, &USBMSD::_out); - _reset_task = callback(this, &USBMSD::_reset); - _control_task = callback(this, &USBMSD::_control); - _configure_task = callback(this, &USBMSD::_configure); + _in_task = mbed::callback(this, &USBMSD::_in); + _out_task = mbed::callback(this, &USBMSD::_out); + _reset_task = mbed::callback(this, &USBMSD::_reset); + _control_task = mbed::callback(this, &USBMSD::_control); + _configure_task = mbed::callback(this, &USBMSD::_configure); EndpointResolver resolver(endpoint_table()); diff --git a/usb/device/USBMSD/USBMSD.h b/usb/device/USBMSD/USBMSD.h index d0584156fd..db733698d3 100644 --- a/usb/device/USBMSD/USBMSD.h +++ b/usb/device/USBMSD/USBMSD.h @@ -237,12 +237,12 @@ private: uint32_t _bulk_out_size; // Interrupt to thread deferral - PolledQueue _queue; - Task _in_task; - Task _out_task; - Task _reset_task; - Task _control_task; - Task _configure_task; + events::PolledQueue _queue; + events::Task _in_task; + events::Task _out_task; + events::Task _reset_task; + events::Task _control_task; + events::Task _configure_task; BlockDevice *_bd; rtos::Mutex _mutex_init; diff --git a/usb/device/USBSerial/USBSerial.h b/usb/device/USBSerial/USBSerial.h index f06eb2e817..d393a297ca 100644 --- a/usb/device/USBSerial/USBSerial.h +++ b/usb/device/USBSerial/USBSerial.h @@ -41,7 +41,7 @@ * } * @endcode */ -class USBSerial: public USBCDC, public Stream { +class USBSerial: public USBCDC, public mbed::Stream { public: /** @@ -149,7 +149,7 @@ public: USBCDC::lock(); if ((mptr != NULL) && (tptr != NULL)) { - rx = Callback(mptr, tptr); + rx = mbed::Callback(mptr, tptr); } USBCDC::unlock(); @@ -165,7 +165,7 @@ public: USBCDC::lock(); if (fptr != NULL) { - rx = Callback(fptr); + rx = mbed::Callback(fptr); } USBCDC::unlock(); @@ -176,7 +176,7 @@ public: * * @param cb Callback to attach */ - void attach(Callback &cb) + void attach(mbed::Callback &cb) { USBCDC::lock(); @@ -211,7 +211,7 @@ protected: } private: - Callback rx; + mbed::Callback rx; void (*_settings_changed_callback)(int baud, int bits, int parity, int stop); }; diff --git a/usb/device/utilities/events/TaskBase.cpp b/usb/device/utilities/events/TaskBase.cpp index ce974f529f..ddbbac173d 100644 --- a/usb/device/utilities/events/TaskBase.cpp +++ b/usb/device/utilities/events/TaskBase.cpp @@ -18,7 +18,7 @@ #include "events/TaskQueue.h" #include "events/mbed_events.h" #include "rtos/Semaphore.h" -#include "mbed.h" +#include "platform/mbed_critical.h" TaskBase::TaskBase(TaskQueue *q) : _queue(q), _posted(false), _start_count(0), _flush_sem(NULL) From f8864ae307e8d019bab8f06c39dff6a6e45087c6 Mon Sep 17 00:00:00 2001 From: Russ Butler Date: Tue, 29 Jan 2019 15:45:18 -0600 Subject: [PATCH 2/2] Applied suggested astyle fixes --- TESTS/usb_device/basic/USBTester.cpp | 10 ++++---- TESTS/usb_device/basic/USBTester.h | 30 ++++++++++++++++++----- usb/device/USBAudio/USBAudio.cpp | 4 +-- usb/device/USBAudio/USBAudio.h | 6 ++--- usb/device/USBDevice/EndpointResolver.cpp | 3 ++- usb/device/USBDevice/USBDevice.cpp | 25 ++++++++----------- usb/device/USBDevice/USBDevice.h | 2 +- usb/device/USBHID/USBMouseKeyboard.h | 9 +++---- usb/device/USBMSD/USBMSD.cpp | 6 ++--- usb/device/USBMSD/USBMSD.h | 6 +++-- usb/device/USBSerial/USBSerial.h | 4 +-- 11 files changed, 60 insertions(+), 45 deletions(-) diff --git a/TESTS/usb_device/basic/USBTester.cpp b/TESTS/usb_device/basic/USBTester.cpp index 93cc892ffb..eba6d79714 100644 --- a/TESTS/usb_device/basic/USBTester.cpp +++ b/TESTS/usb_device/basic/USBTester.cpp @@ -41,9 +41,9 @@ USBTester::USBTester(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint16_t product_release): - USBDevice(phy, vendor_id, product_id, product_release), interface_0_alt_set(NONE), - interface_1_alt_set(NONE), configuration_set(NONE), reset_count(0), - suspend_count(0), resume_count(0) + USBDevice(phy, vendor_id, product_id, product_release), interface_0_alt_set(NONE), + interface_1_alt_set(NONE), configuration_set(NONE), reset_count(0), + suspend_count(0), resume_count(0) { EndpointResolver resolver(endpoint_table()); @@ -269,14 +269,14 @@ bool USBTester::set_configuration(uint16_t configuration) bulk_buf, sizeof(bulk_buf), &USBTester::epbulk_out_callback); // interface 1 alternate 0 success &= setup_iterface(int_in, int_out, MAX_EP_SIZE, USB_EP_TYPE_INT, - int_buf, sizeof(int_buf), &USBTester::epint_out_callback); + int_buf, sizeof(int_buf), &USBTester::epint_out_callback); } else if (configuration == 2) { // interface 0 alternate 0 success = setup_iterface(int_in, int_out, MIN_EP_SIZE, USB_EP_TYPE_INT, int_buf, sizeof(int_buf), &USBTester::epint_out_callback); // interface 1 alternate 0 success &= setup_iterface(bulk_in, bulk_out, MIN_EP_SIZE, USB_EP_TYPE_BULK, - bulk_buf, sizeof(bulk_buf), &USBTester::epbulk_out_callback); + bulk_buf, sizeof(bulk_buf), &USBTester::epbulk_out_callback); } if (success) { configuration_set = configuration; diff --git a/TESTS/usb_device/basic/USBTester.h b/TESTS/usb_device/basic/USBTester.h index ac3554e837..01045501e7 100644 --- a/TESTS/usb_device/basic/USBTester.h +++ b/TESTS/usb_device/basic/USBTester.h @@ -47,12 +47,30 @@ public: const char *get_serial_desc_string(); const char *get_iproduct_desc_string(); const char *get_iinterface_desc_string(); - uint32_t get_reset_count() const { return reset_count; } - uint32_t get_suspend_count() const { return suspend_count; } - uint32_t get_resume_count() const { return resume_count; } - void clear_reset_count() { reset_count = 0; } - void clear_suspend_count() { suspend_count = 0; } - void clear_resume_count() { resume_count = 0; } + uint32_t get_reset_count() const + { + return reset_count; + } + uint32_t get_suspend_count() const + { + return suspend_count; + } + uint32_t get_resume_count() const + { + return resume_count; + } + void clear_reset_count() + { + reset_count = 0; + } + void clear_suspend_count() + { + suspend_count = 0; + } + void clear_resume_count() + { + resume_count = 0; + } private: diff --git a/usb/device/USBAudio/USBAudio.cpp b/usb/device/USBAudio/USBAudio.cpp index ad6800a72e..1b323ece05 100644 --- a/usb/device/USBAudio/USBAudio.cpp +++ b/usb/device/USBAudio/USBAudio.cpp @@ -498,7 +498,7 @@ void USBAudio::callback_request_xfer_done(const setup_packet_t *setup, bool abor } if ((setup->wLength == 1) || (setup->wLength == 2)) { - uint16_t data = (_control_receive[0] << 0) | (_control_receive[1] << 8); + uint16_t data = (_control_receive[0] << 0) | (_control_receive[1] << 8); data &= ((setup->wLength == 1) ? 0xFF : 0xFFFF); switch (setup->wValue >> 8) { case MUTE_CONTROL: @@ -516,7 +516,7 @@ void USBAudio::callback_request_xfer_done(const setup_packet_t *setup, bool abor case REQUEST_SET_CUR: _vol_cur = data; _volume = (float)_vol_cur / (float)_vol_max; - _update_vol.call(); + _update_vol.call(); break; default: break; diff --git a/usb/device/USBAudio/USBAudio.h b/usb/device/USBAudio/USBAudio.h index 90b7cd00c2..28e230a65f 100644 --- a/usb/device/USBAudio/USBAudio.h +++ b/usb/device/USBAudio/USBAudio.h @@ -80,7 +80,7 @@ public: * @param product_id Your product_id * @param product_release Your product_release */ - 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); + 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); /** * Fully featured constructor @@ -153,7 +153,7 @@ public: * @param clear Reset the overflow count back to 0 * @return Number of packets dropped due to overflow */ - uint32_t read_overflows(bool clear=false); + uint32_t read_overflows(bool clear = false); /** * Check if the audio read channel is open @@ -196,7 +196,7 @@ public: * @return Number of packets that should have been * sent but weren't due to overflow */ - uint32_t write_underflows(bool clear=false); + uint32_t write_underflows(bool clear = false); /** * Check if the audio write channel is open diff --git a/usb/device/USBDevice/EndpointResolver.cpp b/usb/device/USBDevice/EndpointResolver.cpp index d9ae07af70..1492d7ec03 100644 --- a/usb/device/USBDevice/EndpointResolver.cpp +++ b/usb/device/USBDevice/EndpointResolver.cpp @@ -73,7 +73,8 @@ bool EndpointResolver::valid() return _valid && (_cost <= _table->resources); } -void EndpointResolver::reset() { +void EndpointResolver::reset() +{ _cost = 0; _used = 0; _valid = true; diff --git a/usb/device/USBDevice/USBDevice.cpp b/usb/device/USBDevice/USBDevice.cpp index 2ec6b3ed8b..19a0fcd3c8 100644 --- a/usb/device/USBDevice/USBDevice.cpp +++ b/usb/device/USBDevice/USBDevice.cpp @@ -64,8 +64,7 @@ bool USBDevice::_request_get_descriptor() printf("get descr: type: %d\r\n", DESCRIPTOR_TYPE(_transfer.setup.wValue)); #endif switch (DESCRIPTOR_TYPE(_transfer.setup.wValue)) { - case DEVICE_DESCRIPTOR: - { + case DEVICE_DESCRIPTOR: { if (device_desc() != NULL) { if ((device_desc()[0] == DEVICE_DESCRIPTOR_LENGTH) \ && (device_desc()[1] == DEVICE_DESCRIPTOR)) { @@ -80,8 +79,7 @@ bool USBDevice::_request_get_descriptor() } break; } - case CONFIGURATION_DESCRIPTOR: - { + case CONFIGURATION_DESCRIPTOR: { const uint8_t idx = DESCRIPTOR_INDEX(_transfer.setup.wValue); if (configuration_desc(idx) != NULL) { if ((configuration_desc(idx)[0] == CONFIGURATION_DESCRIPTOR_LENGTH) \ @@ -91,7 +89,7 @@ bool USBDevice::_request_get_descriptor() #endif /* Get wTotalLength */ _transfer.remaining = configuration_desc(idx)[2] \ - | (configuration_desc(idx)[3] << 8); + | (configuration_desc(idx)[3] << 8); _transfer.ptr = (uint8_t *)configuration_desc(idx); _transfer.direction = Send; @@ -100,8 +98,7 @@ bool USBDevice::_request_get_descriptor() } break; } - case STRING_DESCRIPTOR: - { + case STRING_DESCRIPTOR: { #ifdef DEBUG printf("str descriptor\r\n"); #endif @@ -163,23 +160,20 @@ bool USBDevice::_request_get_descriptor() } break; } - case INTERFACE_DESCRIPTOR: - { + case INTERFACE_DESCRIPTOR: { #ifdef DEBUG printf("interface descr\r\n"); #endif break; } - case ENDPOINT_DESCRIPTOR: - { + case ENDPOINT_DESCRIPTOR: { #ifdef DEBUG printf("endpoint descr\r\n"); #endif /* TODO: Support is optional, not implemented here */ break; } - default: - { + default: { #ifdef DEBUG printf("ERROR\r\n"); #endif @@ -1154,7 +1148,7 @@ void USBDevice::endpoint_stall(usb_ep_t endpoint) _phy->endpoint_stall(endpoint); if (info->pending) { - endpoint_abort(endpoint); + endpoint_abort(endpoint); } unlock(); @@ -1589,7 +1583,8 @@ void USBDevice::assert_locked() MBED_ASSERT(_locked > 0); } -void USBDevice::_change_state(DeviceState new_state) { +void USBDevice::_change_state(DeviceState new_state) +{ assert_locked(); DeviceState old_state = _device.state; diff --git a/usb/device/USBDevice/USBDevice.h b/usb/device/USBDevice/USBDevice.h index e8b7f5c691..0cd438f316 100644 --- a/usb/device/USBDevice/USBDevice.h +++ b/usb/device/USBDevice/USBDevice.h @@ -403,7 +403,7 @@ protected: * @param data Buffer to send or receive if the result is Send or Receive * @param size Size to transfer if the result is Send or Receive */ - void complete_request(RequestResult result, uint8_t *data=NULL, uint32_t size=0); + void complete_request(RequestResult result, uint8_t *data = NULL, uint32_t size = 0); /** * Called by USBDevice on data stage completion diff --git a/usb/device/USBHID/USBMouseKeyboard.h b/usb/device/USBHID/USBMouseKeyboard.h index d8b9d39c51..84ce5673f4 100644 --- a/usb/device/USBHID/USBMouseKeyboard.h +++ b/usb/device/USBHID/USBMouseKeyboard.h @@ -68,8 +68,7 @@ * * @note Synchronization level: Thread safe */ -class USBMouseKeyboard: public USBHID, public mbed::Stream -{ +class USBMouseKeyboard: public USBHID, public mbed::Stream { public: /** @@ -86,7 +85,7 @@ public: * @param product_release Your preoduct_release (default: 0x0001) * */ - USBMouseKeyboard(bool connect_blocking=true, MOUSE_TYPE mouse_type=REL_MOUSE, uint16_t vendor_id=0x0021, uint16_t product_id=0x0011, uint16_t product_release=0x0001); + USBMouseKeyboard(bool connect_blocking = true, MOUSE_TYPE mouse_type = REL_MOUSE, uint16_t vendor_id = 0x0021, uint16_t product_id = 0x0011, uint16_t product_release = 0x0001); /** * Fully featured constructor @@ -106,7 +105,7 @@ public: * @param product_release Your preoduct_release (default: 0x0001) * */ - USBMouseKeyboard(USBPhy *phy, MOUSE_TYPE mouse_type=REL_MOUSE, uint16_t vendor_id=0x0021, uint16_t product_id=0x0011, uint16_t product_release=0x0001); + USBMouseKeyboard(USBPhy *phy, MOUSE_TYPE mouse_type = REL_MOUSE, uint16_t vendor_id = 0x0021, uint16_t product_id = 0x0011, uint16_t product_release = 0x0001); /** * Destroy this object @@ -221,7 +220,7 @@ public: * * @returns pointer to the report descriptor */ - virtual const uint8_t * report_desc(); + virtual const uint8_t *report_desc(); /* * Called when a data is received on the OUT endpoint. Useful to switch on LED of LOCK keys diff --git a/usb/device/USBMSD/USBMSD.cpp b/usb/device/USBMSD/USBMSD.cpp index 6961c8e0c4..750cadf8ae 100644 --- a/usb/device/USBMSD/USBMSD.cpp +++ b/usb/device/USBMSD/USBMSD.cpp @@ -212,14 +212,14 @@ void USBMSD::attach(mbed::Callback cb) unlock(); } -int USBMSD::disk_read(uint8_t* data, uint64_t block, uint8_t count) +int USBMSD::disk_read(uint8_t *data, uint64_t block, uint8_t count) { bd_addr_t addr = block * _bd->get_erase_size(); bd_size_t size = count * _bd->get_erase_size(); return _bd->read(data, addr, size); } -int USBMSD::disk_write(const uint8_t* data, uint64_t block, uint8_t count) +int USBMSD::disk_write(const uint8_t *data, uint64_t block, uint8_t count) { bd_addr_t addr = block * _bd->get_erase_size(); bd_size_t size = count * _bd->get_erase_size(); @@ -434,7 +434,7 @@ void USBMSD::_control(const setup_packet_t *setup) break; case MSC_REQUEST_GET_MAX_LUN: result = Send; - data = (uint8_t*)maxLUN; + data = (uint8_t *)maxLUN; size = 1; break; default: diff --git a/usb/device/USBMSD/USBMSD.h b/usb/device/USBMSD/USBMSD.h index db733698d3..5e96f31e3c 100644 --- a/usb/device/USBMSD/USBMSD.h +++ b/usb/device/USBMSD/USBMSD.h @@ -181,7 +181,8 @@ private: }; // Bulk-only CBW - typedef MBED_PACKED(struct) { + typedef MBED_PACKED(struct) + { uint32_t Signature; uint32_t Tag; uint32_t DataLength; @@ -192,7 +193,8 @@ private: } CBW; // Bulk-only CSW - typedef MBED_PACKED(struct) { + typedef MBED_PACKED(struct) + { uint32_t Signature; uint32_t Tag; uint32_t DataResidue; diff --git a/usb/device/USBSerial/USBSerial.h b/usb/device/USBSerial/USBSerial.h index d393a297ca..d7dbfb4a72 100644 --- a/usb/device/USBSerial/USBSerial.h +++ b/usb/device/USBSerial/USBSerial.h @@ -57,7 +57,7 @@ public: * @param product_release Your product_release (default: 0x0001) * */ - USBSerial(bool connect_blocking=true, uint16_t vendor_id=0x1f00, uint16_t product_id=0x2012, uint16_t product_release=0x0001); + USBSerial(bool connect_blocking = true, uint16_t vendor_id = 0x1f00, uint16_t product_id = 0x2012, uint16_t product_release = 0x0001); /** * Fully featured constructor @@ -76,7 +76,7 @@ public: * @param product_release Your product_release (default: 0x0001) * */ - USBSerial(USBPhy *phy, uint16_t vendor_id=0x1f00, uint16_t product_id=0x2012, uint16_t product_release=0x0001); + USBSerial(USBPhy *phy, uint16_t vendor_id = 0x1f00, uint16_t product_id = 0x2012, uint16_t product_release = 0x0001); /** * Destroy this object