-
Notifications
You must be signed in to change notification settings - Fork 1k
Handling of VBUS sensing #886
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
Comments
Previously, this was enabled only for OTG_HS, for some reason. This probably needs to be more configurable by board, but this is enough to for the specific board we are working with now. See stm32duino#886
@matthijskooijman |
Hi @matthijskooijman,
Taking all those remarks into consideration, it looks very complex to distinguish FS/HS/HS_IN_FS, impossible to detect Jumper configuration... |
Thanks for the detailed analysis. I had not realized that there could be different pins in use, which indeed complicates things. Regardless, it really depends on the board whether VBUS was connected and thus whether VBUS sensing should be enabled or not, so your proposal makes complete sense to me. The idea now is that different boards can set Or do all currently supported boards have the FS VBUS detection connected but not HS (or vice versa)? That does makes me wonder: Should a board (variant) be able to separately enable VBUS detection for FS/HS? That might better reflect the hardware setup. OTOH, I guess a variant could also check things like |
The idea was to do nothing else. Let user activate it only when he required it. |
Agreed, thanks! |
Ideally there would be a drop down asking if device is self powered or USB bus powered and then select the correct option for Activate_VBUS. |
Do not hesitate to provide a PR then we could discuss / review your solution. |
While, reading the code, I was a bit confused by this bit:
Arduino_Core_STM32/cores/arduino/stm32/usb/usbd_conf.c
Lines 472 to 496 in 0ff0a2a
In particular, IIUC, it sets
g_hpcd.Init.vbus_sensing_enable
toENABLE
whenUSE_USB_HS
is defined, but toDISABLE
when using the OTG_FS peripheral.Why is this difference there?
It seems it has been there from the start, when HS support was introduced in 861cd07, FS had no VBUS sensing and HS was added with VBUS sensing.
Ultimately, I think think this is something that should be board-specific? If the VBUS line is connected to the VBUS pin, then VBUS sensing should be enabled? If not (which is, I think, recommended only for bus-powered devices where VBUS is always present when the MCU is running).
Maybe it would be useful to enable VBUS sensing by default and have a "USB_ENABLE_VBUS_DETECTION" macro in
variant.h
for boards that need it?The text was updated successfully, but these errors were encountered: