1 parent 1244125 commit 885a141Copy full SHA for 885a141
1 file changed
ports/stm32f4/supervisor/usb.c
@@ -32,6 +32,8 @@
32
#include "lib/mp-readline/readline.h"
33
#include "stm32f4xx_hal.h"
34
35
+#include "py/mpconfig.h"
36
+
37
#include "common-hal/microcontroller/Pin.h"
38
39
void init_usb_hardware(void) {
@@ -79,7 +81,21 @@ void init_usb_hardware(void) {
79
81
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
80
82
never_reset_pin_number(0, 8);
83
#endif
84
85
+#ifdef BOARD_NO_VBUS
86
+ disable_usb_vbus();
87
+#endif
88
89
/* Peripheral clock enable */
90
__HAL_RCC_USB_OTG_FS_CLK_ENABLE();
91
}
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
101
+}
0 commit comments