-
Notifications
You must be signed in to change notification settings - Fork 985
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
dcd_da146xx: Add VBUS handling #1094
Conversation
DA146xx are Bluetooth devices that may be battery powered and when not connected to USB host there is no need for USB peripheral to be running. This change allows to enable USB peripheral when VBUS is present otherwise USB is down reducing power consumption. tud_vsub_changed() function must be called whenever VBUS change was detected. For bus-powered devices this function should be called at startup since VBUS must be present while device is working.
Two BSPs with DA146xx MCUs are now adopted to VBUS handling changed introduced to dcd_da146xx driver. da14695_dk_usb as bus-powered devices informs driver that VBUS is present at startup. da1469x-dk-pro has VBUS change interrupt handler that informs driver about VBUS changes.
Thank you for your PR. I agree that we need an unified API for managing vbus/power. The nrf implementation is a good candidate with an |
I prefer to merge and you can take more time to rethink it. It will not be a problem if API will slightly change later on. I can also implement dcd_edpt_close_all() for Dialog in spare time. Do you have any scenario that this function can be tested? |
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.
The code looks great, I haven't tested it on the hardware, last time I have some difficulties with flashing bin to external flash or something (kind of forgot). Will do a overall test later on.
Yeah, I prefer to merge this as well. Since I can be late on the API revising --> merged
The close_all() is quite similar to bus_reset(), except it does not reset control endpoints. It is used when host switching from active configuration to non-active to another configuration https://github.com/hathach/tinyusb/blob/master/src/device/usbd.c#L701 To be honest, I don't know any host driver would do that, but it is required for USB Compliance Verification (USBCV) test suite, please check out #1059 for more USBCV details . There are 2 test suite that use it:
When all the compliant test is passed, it is good indicate that most of dcd work well. I have been fixing quite some corner bug with every DCD lately to get them passed the USBCV. If you have time and want to get it passed the USBCV as well, I will be more than happy to help since I am pretty familiar with most of the test suite. |
Describe the PR
DA146xx are Bluetooth devices that may be battery
powered and when not connected to USB host there
is no need for USB peripheral to be running.
This change allows to enable USB peripheral when
VBUS is present otherwise USB is down reducing
power consumption.
tud_vsub_changed()
function must be calledwhenever VBUS change was detected.
For bus-powered devices this function should be called
at startup since VBUS must be present while device
is working.
Two BSP were updated to reflect driver change.
Most of the driver code that touches registers is unchanged just
moved from
dcd_init()
todcd_connect()
Additional context
This is fallow up of #1019
Now that NRF and DA146xx have VBUS/power handling it could
be considered to make some sort of API for this.
Both NRF and DA146xx notification functions are not even
present in header files which makes usage awkward.