diff options
| author | Lucian Copeland <hierophect@gmail.com> | 2020-03-17 18:26:13 -0400 |
|---|---|---|
| committer | Lucian Copeland <hierophect@gmail.com> | 2020-03-26 18:01:17 -0400 |
| commit | c4db8b87e2c57ca94b8f76e4b07ca02641df714e (patch) | |
| tree | 8f17d3010e415f56914b81d0bd54ae86ff711e08 /ports/stm/supervisor/usb.c | |
| parent | bb3ed3a827f70582f9a19ceb359b169d1b50262a (diff) | |
Add F7 and H7 Support to the STM32 port
Restructures the STM port of Circuitpython to be more generic about the STM32 chip lines to support
the F7 and H7 series of chips. Adds the new Packages directory to organize different chip layouts
between lines. Makes general changes to the Makefile to condense board-level flags to the minimum
and support the new chip series. Adds the new chip line to the Peripherals directory, along with
new python tools used to generate peripheral text automatically in the tools/ directory.
Diffstat (limited to 'ports/stm/supervisor/usb.c')
| -rw-r--r-- | ports/stm/supervisor/usb.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/ports/stm/supervisor/usb.c b/ports/stm/supervisor/usb.c index 358c2de5b..a0c907a3d 100644 --- a/ports/stm/supervisor/usb.c +++ b/ports/stm/supervisor/usb.c @@ -30,7 +30,6 @@ #include "supervisor/usb.h" #include "lib/utils/interrupt_char.h" #include "lib/mp-readline/readline.h" -#include "stm32f4xx_hal.h" #include "py/mpconfig.h" @@ -74,7 +73,11 @@ void init_usb_hardware(void) { GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; + #if defined(STM32H7) + GPIO_InitStruct.Alternate = GPIO_AF10_OTG1_FS; + #else GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; + #endif HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); never_reset_pin_number(0, 11); never_reset_pin_number(0, 12); @@ -91,7 +94,11 @@ void init_usb_hardware(void) { GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; + #if defined(STM32H7) + GPIO_InitStruct.Alternate = GPIO_AF10_OTG1_FS; + #else GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; + #endif HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); never_reset_pin_number(0, 10); @@ -103,10 +110,16 @@ void init_usb_hardware(void) { HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); never_reset_pin_number(0, 8); #endif - + + +#if defined(STM32H7) + HAL_PWREx_EnableUSBVoltageDetector(); + __HAL_RCC_USB2_OTG_FS_CLK_ENABLE(); +#else /* Peripheral clock enable */ __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); +#endif init_usb_vbus_sense(); } |
