Skip to content

Commit 885a141

Browse files
committed
Update stm32 usb.c
1 parent 1244125 commit 885a141

File tree

1 file changed

+16
-0
lines changed
  • ports/stm32f4/supervisor

1 file changed

+16
-0
lines changed

ports/stm32f4/supervisor/usb.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include "lib/mp-readline/readline.h"
3333
#include "stm32f4xx_hal.h"
3434

35+
#include "py/mpconfig.h"
36+
3537
#include "common-hal/microcontroller/Pin.h"
3638

3739
void init_usb_hardware(void) {
@@ -79,7 +81,21 @@ void init_usb_hardware(void) {
7981
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
8082
never_reset_pin_number(0, 8);
8183
#endif
84+
85+
#ifdef BOARD_NO_VBUS
86+
disable_usb_vbus();
87+
#endif
8288

8389
/* Peripheral clock enable */
8490
__HAL_RCC_USB_OTG_FS_CLK_ENABLE();
8591
}
92+
93+
STATIC void disable_usb_vbus(void) {
94+
#ifdef USB_OTG_GCCFG_VBDEN
95+
USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN;
96+
#else
97+
USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS;
98+
USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN;
99+
USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN;
100+
#endif
101+
}

0 commit comments

Comments
 (0)