File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
boards/stm32f411ce_blackpill Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 33
33
#define FLASH_PAGE_SIZE (0x4000)
34
34
35
35
#define BOARD_OSC_DIV 25
36
+ #define BOARD_NO_VBUS
36
37
37
38
// On-board flash
38
39
// #define SPI_FLASH_MOSI_PIN (&pin_PA07)
Original file line number Diff line number Diff line change 32
32
#include "lib/mp-readline/readline.h"
33
33
#include "stm32f4xx_hal.h"
34
34
35
+ #include "py/mpconfig.h"
36
+
35
37
#include "common-hal/microcontroller/Pin.h"
36
38
39
+ STATIC void init_usb_vbus_sense (void ) {
40
+
41
+ #ifdef BOARD_NO_VBUS
42
+ // Disable VBUS sensing
43
+ #ifdef USB_OTG_GCCFG_VBDEN
44
+ USB_OTG_FS -> GCCFG &= ~USB_OTG_GCCFG_VBDEN ;
45
+ #else
46
+ USB_OTG_FS -> GCCFG |= USB_OTG_GCCFG_NOVBUSSENS ;
47
+ USB_OTG_FS -> GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN ;
48
+ USB_OTG_FS -> GCCFG &= ~USB_OTG_GCCFG_VBUSASEN ;
49
+ #endif
50
+ #else
51
+ // Enable VBUS hardware sensing
52
+ #ifdef USB_OTG_GCCFG_VBDEN
53
+ USB_OTG_FS -> GCCFG |= USB_OTG_GCCFG_VBDEN ;
54
+ #else
55
+ USB_OTG_FS -> GCCFG &= ~USB_OTG_GCCFG_NOVBUSSENS ;
56
+ USB_OTG_FS -> GCCFG |= USB_OTG_GCCFG_VBUSBSEN ; // B Device sense
57
+ #endif
58
+ #endif
59
+ }
60
+
61
+
37
62
void init_usb_hardware (void ) {
38
63
//TODO: if future chips overload this with options, move to peripherals management.
39
64
@@ -79,7 +104,9 @@ void init_usb_hardware(void) {
79
104
HAL_GPIO_Init (GPIOG , & GPIO_InitStruct );
80
105
never_reset_pin_number (0 , 8 );
81
106
#endif
82
-
107
+
83
108
/* Peripheral clock enable */
84
109
__HAL_RCC_USB_OTG_FS_CLK_ENABLE ();
110
+
111
+ init_usb_vbus_sense ();
85
112
}
You can’t perform that action at this time.
0 commit comments