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 3333#define FLASH_PAGE_SIZE (0x4000)
3434
3535#define BOARD_OSC_DIV 25
36+ #define BOARD_NO_VBUS
3637
3738// On-board flash
3839// #define SPI_FLASH_MOSI_PIN (&pin_PA07)
Original file line number Diff line number Diff line change 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
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+
3762void init_usb_hardware (void ) {
3863 //TODO: if future chips overload this with options, move to peripherals management.
3964
@@ -79,7 +104,9 @@ void init_usb_hardware(void) {
79104 HAL_GPIO_Init (GPIOG , & GPIO_InitStruct );
80105 never_reset_pin_number (0 , 8 );
81106#endif
82-
107+
83108 /* Peripheral clock enable */
84109 __HAL_RCC_USB_OTG_FS_CLK_ENABLE ();
110+
111+ init_usb_vbus_sense ();
85112}
You can’t perform that action at this time.
0 commit comments