Skip to content

Update Tinyusb #2379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Dec 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#define FLASH_PAGE_SIZE (0x4000)

#define BOARD_OSC_DIV 25
#define BOARD_NO_VBUS

// On-board flash
// #define SPI_FLASH_MOSI_PIN (&pin_PA07)
Expand Down
29 changes: 28 additions & 1 deletion ports/stm32f4/supervisor/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,33 @@
#include "lib/mp-readline/readline.h"
#include "stm32f4xx_hal.h"

#include "py/mpconfig.h"

#include "common-hal/microcontroller/Pin.h"

STATIC void init_usb_vbus_sense(void) {

#ifdef BOARD_NO_VBUS
// Disable VBUS sensing
#ifdef USB_OTG_GCCFG_VBDEN
USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN;
#else
USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS;
USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN;
USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN;
#endif
#else
// Enable VBUS hardware sensing
#ifdef USB_OTG_GCCFG_VBDEN
USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBDEN;
#else
USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_NOVBUSSENS;
USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBUSBSEN; // B Device sense
#endif
#endif
}


void init_usb_hardware(void) {
//TODO: if future chips overload this with options, move to peripherals management.

Expand Down Expand Up @@ -79,7 +104,9 @@ void init_usb_hardware(void) {
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
never_reset_pin_number(0, 8);
#endif

/* Peripheral clock enable */
__HAL_RCC_USB_OTG_FS_CLK_ENABLE();

init_usb_vbus_sense();
}