-
Notifications
You must be signed in to change notification settings - Fork 3k
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
USBDevice: Avoid forcing end device to be derived from USBDevice class #11136
USBDevice: Avoid forcing end device to be derived from USBDevice class #11136
Conversation
@facchinm, thank you for your changes. |
I can see there are lot of conflicts, please review |
a0c6d9c
to
811098f
Compare
Rebased upon master, thanks. |
@maciejbocianski please review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good,
tests-usb_device-basic needs adaptation to your changes, you can use my code maciejbocianski@092b26b
@fkjagodzinski @c1728p9 what do you think
drivers/internal/USBDevice.h
Outdated
@@ -141,21 +142,6 @@ class USBDevice: public USBPhyEvents { | |||
*/ | |||
bool endpoint_add(usb_ep_t endpoint, uint32_t max_packet, usb_ep_type_t type, ep_cb_t callback = NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're changing to Callback
, could you please avoid giving it NULL
- change to nullptr
. Will avoid issues with some optimisation work I'm doing on Callback
. Will save me touching this again later.
(That does make it a 5.14 change - we're not putting any C++11-isms into 5.13 patches. But this doesn't look like a patch anyway).
Yeah, I think this patch OK but can't really comment on performance aspect.
@c1728p9 could you comment on that, please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR seems reasonable to me. Does the use of callback increase or decrease RAM used? Also, you'll need a few more changes if you want to make USBDevice usable without inheriting from it:
- Protected functions need to be made public so they can be called
- Callback completion handlers such as complete_request
- Synchronization functions
Those changes could be made in a separate PR though as this change look good on its own merits.
CI started |
@facchinm Is this breaking change or functionality change? If yes, |
@0xc0170 the only breaking change is the removal of |
Test run: FAILEDSummary: 3 of 4 test jobs failed Failed test jobs:
|
Please review build logs, there are failures |
CI restarted |
By fixing the tests I came up with another implementation, much cleaner and, more important, without breaking changes. |
In this way we can use the USBDevice infrastructure without deriving directly from USBDevice.
You can force push |
f433881
to
84e228a
Compare
Once you do force push , please update PR with the current status to notify us - what has changed. |
Sorry, I updated the description on the top but probably this didn't trigger any notification. |
Ci restarted @maciejbocianski Please review |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
FYI, this patch increased the size of the |
@donatieng, @ARMmbed/mbed-os-hal, this information ^^^ might be useful for future reference. I think there's room for improvement if needed. |
Description
By replacing the existing callbacks with proper
mbed::callback
we can use the USBDevice infrastructure without deriving directly from USBDevice.The patch could bring a (tiny, big ?) performance hit due to the indirection, but would make the USBDevice class usable as a singleton.
A usage example can be found here https://github.com/arduino/ArduinoCore-nRF528x-mbedos/tree/master/cores/arduino/USB and https://github.com/bcmi-labs/ArduinoCore-nRF528x-mbedos/tree/master/libraries/USBHID
PluggableUSBDevice implements USBDevice and calls phy init() just once; all device drivers (derived from mbed ones) plug on it to create a composite device but they don't derive from USBDevice.
Pull request type
Reviewers
Release Notes