Description
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
to ENABLE
when USE_USB_HS
is defined, but to DISABLE
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?