diff --git a/hw/bsp/stm32f2/family.c b/hw/bsp/stm32f2/family.c index 8ea8ec5a5..f863a59f0 100644 --- a/hw/bsp/stm32f2/family.c +++ b/hw/bsp/stm32f2/family.c @@ -31,7 +31,6 @@ #include "stm32f2xx_hal.h" #include "bsp/board_api.h" #include "board.h" - //--------------------------------------------------------------------+ // Forward USB interrupt events to TinyUSB IRQ Handler //--------------------------------------------------------------------+ @@ -105,9 +104,14 @@ void board_init(void) { /* Enable USB FS Clocks */ __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); +#if CFG_TUD_ENABLED // Enable VBUS sense (B device) via pin PA9 - USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_NOVBUSSENS; - USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBUSBSEN; + tud_configure_dwc2_t cfg = { + .bm_double_buffered = 0, + .vbus_sensing = true + }; + tud_configure(0, TUD_CFGID_DWC2, &cfg); +#endif } //--------------------------------------------------------------------+