summaryrefslogtreecommitdiff
path: root/ports/stm/supervisor
diff options
context:
space:
mode:
authorLucian Copeland <hierophect@gmail.com>2020-03-17 18:26:13 -0400
committerLucian Copeland <hierophect@gmail.com>2020-03-26 18:01:17 -0400
commitc4db8b87e2c57ca94b8f76e4b07ca02641df714e (patch)
tree8f17d3010e415f56914b81d0bd54ae86ff711e08 /ports/stm/supervisor
parentbb3ed3a827f70582f9a19ceb359b169d1b50262a (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')
-rw-r--r--ports/stm/supervisor/port.c43
-rw-r--r--ports/stm/supervisor/usb.c17
2 files changed, 40 insertions, 20 deletions
diff --git a/ports/stm/supervisor/port.c b/ports/stm/supervisor/port.c
index 948e9f2e4..fa377e74a 100644
--- a/ports/stm/supervisor/port.c
+++ b/ports/stm/supervisor/port.c
@@ -31,25 +31,29 @@
#include "tick.h"
#include "common-hal/microcontroller/Pin.h"
-#include "common-hal/busio/I2C.h"
-#include "common-hal/busio/SPI.h"
-#include "common-hal/busio/UART.h"
-#include "common-hal/pulseio/PWMOut.h"
-#include "common-hal/pulseio/PulseOut.h"
-#include "common-hal/pulseio/PulseIn.h"
-#include "stm32f4/clocks.h"
-#include "stm32f4/gpio.h"
+#if defined(STM32F4)
+ #include "common-hal/busio/I2C.h"
+ #include "common-hal/busio/SPI.h"
+ #include "common-hal/busio/UART.h"
+ #include "common-hal/pulseio/PWMOut.h"
+ #include "common-hal/pulseio/PulseOut.h"
+ #include "common-hal/pulseio/PulseIn.h"
+#endif
-#include "stm32f4xx_hal.h"
+#include "clocks.h"
+#include "gpio.h"
safe_mode_t port_init(void) {
HAL_Init();
__HAL_RCC_SYSCFG_CLK_ENABLE();
- __HAL_RCC_PWR_CLK_ENABLE();
+
+ #if defined(STM32F4)
+ __HAL_RCC_PWR_CLK_ENABLE();
+ #endif
- stm32f4_peripherals_clocks_init();
- stm32f4_peripherals_gpio_init();
+ stm32_peripherals_clocks_init();
+ stm32_peripherals_gpio_init();
tick_init();
@@ -58,12 +62,15 @@ safe_mode_t port_init(void) {
void reset_port(void) {
reset_all_pins();
- i2c_reset();
- spi_reset();
- uart_reset();
- pwmout_reset();
- pulseout_reset();
- pulsein_reset();
+
+ #if defined(STM32F4)
+ i2c_reset();
+ spi_reset();
+ uart_reset();
+ pwmout_reset();
+ pulseout_reset();
+ pulsein_reset();
+ #endif
}
void reset_to_bootloader(void) {
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();
}