Create VBUS disable interface in shared supervisor

This commit is contained in:
Hierophect 2019-12-06 15:55:00 -05:00
parent 6c8503b3c6
commit 252da17bc9
4 changed files with 18 additions and 1 deletions

View File

@ -33,6 +33,7 @@
#define FLASH_PAGE_SIZE (0x4000) #define FLASH_PAGE_SIZE (0x4000)
#define BOARD_OSC_DIV 25 #define BOARD_OSC_DIV 25
#define BOARD_NO_VBUS
// On-board flash // On-board flash
// #define SPI_FLASH_MOSI_PIN (&pin_PA07) // #define SPI_FLASH_MOSI_PIN (&pin_PA07)

View File

@ -43,6 +43,7 @@ void init_usb_hardware(void) {
PA11 ------> USB_OTG_FS_DM PA11 ------> USB_OTG_FS_DM
PA12 ------> USB_OTG_FS_DP PA12 ------> USB_OTG_FS_DP
*/ */
__HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE();
/* Configure DM DP Pins */ /* Configure DM DP Pins */
@ -83,3 +84,9 @@ void init_usb_hardware(void) {
/* Peripheral clock enable */ /* Peripheral clock enable */
__HAL_RCC_USB_OTG_FS_CLK_ENABLE(); __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
} }
void disable_usb_vbus(void) {
USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS;
USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN;
USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN;
}

View File

@ -33,6 +33,8 @@
#include "lib/utils/interrupt_char.h" #include "lib/utils/interrupt_char.h"
#include "lib/mp-readline/readline.h" #include "lib/mp-readline/readline.h"
#include "py/mpconfig.h"
#include "tusb.h" #include "tusb.h"
// Serial number as hex characters. This writes directly to the USB // Serial number as hex characters. This writes directly to the USB
@ -72,6 +74,11 @@ void usb_init(void) {
#if CIRCUITPY_USB_MIDI #if CIRCUITPY_USB_MIDI
usb_midi_init(); usb_midi_init();
#endif #endif
#ifdef BOARD_NO_VBUS
disable_usb_vbus();
#endif
} }
void usb_background(void) { void usb_background(void) {

View File

@ -37,6 +37,8 @@ void usb_background(void);
// TinyUSB. // TinyUSB.
void init_usb_hardware(void); void init_usb_hardware(void);
void disable_usb_vbus(void);
// Shared implementation. // Shared implementation.
bool usb_enabled(void); bool usb_enabled(void);
void usb_init(void); void usb_init(void);