Merge pull request #2379 from hierophect/update-tusb

Update Tinyusb
This commit is contained in:
Ha Thach 2019-12-23 17:58:26 +07:00 committed by GitHub
commit 21cbd5ce96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 1 deletions

View File

@ -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)

View File

@ -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.
@ -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();
}