summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--ports/stm32/boards/STM32H573I_DK/bdev.c45
-rw-r--r--ports/stm32/boards/STM32H573I_DK/mpconfigboard.h113
-rw-r--r--ports/stm32/boards/STM32H573I_DK/mpconfigboard.mk15
-rw-r--r--ports/stm32/boards/STM32H573I_DK/pins.csv149
-rw-r--r--ports/stm32/boards/STM32H573I_DK/stm32h5xx_hal_conf.h19
5 files changed, 341 insertions, 0 deletions
diff --git a/ports/stm32/boards/STM32H573I_DK/bdev.c b/ports/stm32/boards/STM32H573I_DK/bdev.c
new file mode 100644
index 0000000000..b304734237
--- /dev/null
+++ b/ports/stm32/boards/STM32H573I_DK/bdev.c
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2023 Damien P. George
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "storage.h"
+#include "octospi.h"
+
+#if MICROPY_HW_SPIFLASH_ENABLE_CACHE
+static mp_spiflash_cache_t spi_bdev_cache;
+#endif
+
+// External SPI flash uses hardware OCTOSPI interface (in 1-line mode).
+
+const mp_spiflash_config_t spiflash_config = {
+ .bus_kind = MP_SPIFLASH_BUS_QSPI, // spiflash driver doesn't yet support OSPI
+ .bus.u_qspi.data = NULL,
+ .bus.u_qspi.proto = &octospi_proto,
+ #if MICROPY_HW_SPIFLASH_ENABLE_CACHE
+ .cache = &spi_bdev_cache,
+ #endif
+};
+
+spi_bdev_t spi_bdev;
diff --git a/ports/stm32/boards/STM32H573I_DK/mpconfigboard.h b/ports/stm32/boards/STM32H573I_DK/mpconfigboard.h
new file mode 100644
index 0000000000..01064325da
--- /dev/null
+++ b/ports/stm32/boards/STM32H573I_DK/mpconfigboard.h
@@ -0,0 +1,113 @@
+#define MICROPY_HW_BOARD_NAME "STM32H573I-DK"
+#define MICROPY_HW_MCU_NAME "STM32H573IIK3Q"
+
+#define MICROPY_PY_PYB_LEGACY (0)
+#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
+#define MICROPY_HW_ENABLE_RTC (1)
+#define MICROPY_HW_ENABLE_RNG (1)
+#define MICROPY_HW_ENABLE_ADC (1)
+#define MICROPY_HW_ENABLE_DAC (0) // requires DMA
+#define MICROPY_HW_ENABLE_USB (1)
+#define MICROPY_HW_HAS_SWITCH (1)
+#define MICROPY_HW_HAS_FLASH (1)
+
+#if 1
+// The board has a 25MHz oscillator, the following gives 250MHz CPU speed
+#define MICROPY_HW_CLK_USE_BYPASS (1)
+#define MICROPY_HW_CLK_PLLM (5)
+#define MICROPY_HW_CLK_PLLN (100)
+#define MICROPY_HW_CLK_PLLP (2)
+#define MICROPY_HW_CLK_PLLQ (2)
+#define MICROPY_HW_CLK_PLLR (2)
+#define MICROPY_HW_CLK_PLLVCI_LL (LL_RCC_PLLINPUTRANGE_4_8)
+#define MICROPY_HW_CLK_PLLVCO_LL (LL_RCC_PLLVCORANGE_WIDE)
+#define MICROPY_HW_CLK_PLLFRAC (0)
+#define MICROPY_HW_FLASH_LATENCY FLASH_LATENCY_5
+#else
+// Use 64MHz HSI to clock the CPU at 200MHz
+#define MICROPY_HW_CLK_USE_HSI (1) // 64MHz
+#define MICROPY_HW_CLK_PLLM (16)
+#define MICROPY_HW_CLK_PLLN (100)
+#define MICROPY_HW_CLK_PLLP (2)
+#define MICROPY_HW_CLK_PLLQ (2)
+#define MICROPY_HW_CLK_PLLR (2)
+#define MICROPY_HW_CLK_PLLVCI_LL (LL_RCC_PLLINPUTRANGE_4_8)
+#define MICROPY_HW_CLK_PLLVCO_LL (LL_RCC_PLLVCORANGE_WIDE)
+#define MICROPY_HW_CLK_PLLFRAC (0)
+#define MICROPY_HW_FLASH_LATENCY FLASH_LATENCY_4 // VOS0, 168-210MHz
+#endif
+
+// PLL3 with Q output at 48MHz for USB
+#define MICROPY_HW_CLK_PLL3M (25)
+#define MICROPY_HW_CLK_PLL3N (192)
+#define MICROPY_HW_CLK_PLL3P (2)
+#define MICROPY_HW_CLK_PLL3Q (4)
+#define MICROPY_HW_CLK_PLL3R (2)
+#define MICROPY_HW_CLK_PLL3FRAC (0)
+#define MICROPY_HW_CLK_PLL3VCI_LL (LL_RCC_PLLINPUTRANGE_1_2)
+#define MICROPY_HW_CLK_PLL3VCO_LL (LL_RCC_PLLVCORANGE_MEDIUM)
+
+// There is an external 32kHz oscillator
+#define MICROPY_HW_RTC_USE_LSE (1)
+
+// 512MBit
+#if !MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
+#define MICROPY_HW_OSPIFLASH_SIZE_BITS_LOG2 (29)
+#define MICROPY_HW_OSPIFLASH_CS (pin_G6)
+#define MICROPY_HW_OSPIFLASH_SCK (pin_F10)
+#define MICROPY_HW_OSPIFLASH_IO0 (pin_B1)
+#define MICROPY_HW_OSPIFLASH_IO1 (pin_D12)
+#define MICROPY_HW_OSPIFLASH_IO2 (pin_C2)
+#define MICROPY_HW_OSPIFLASH_IO3 (pin_D13)
+#define MICROPY_HW_OSPIFLASH_IO4 (pin_H2)
+#define MICROPY_HW_OSPIFLASH_IO5 (pin_H3)
+#define MICROPY_HW_OSPIFLASH_IO6 (pin_G9)
+#define MICROPY_HW_OSPIFLASH_IO7 (pin_C0)
+#define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1)
+#define MICROPY_HW_BDEV_SPIFLASH (&spi_bdev)
+#define MICROPY_HW_BDEV_SPIFLASH_CONFIG (&spiflash_config)
+#define MICROPY_HW_BDEV_SPIFLASH_SIZE_BYTES ((1 << MICROPY_HW_OSPIFLASH_SIZE_BITS_LOG2) / 8)
+#define MICROPY_HW_BDEV_SPIFLASH_EXTENDED (&spi_bdev) // for extended block protocol
+#endif
+
+// UART buses
+#define MICROPY_HW_UART1_TX (pin_A9)
+#define MICROPY_HW_UART1_RX (pin_A10)
+#define MICROPY_HW_UART3_TX (pin_B10) // Arduino Connector CN15-Pin2 (D1)
+#define MICROPY_HW_UART3_RX (pin_B11) // Arduino Connector CN15-Pin1 (D0)
+#define MICROPY_HW_UART_REPL PYB_UART_1
+#define MICROPY_HW_UART_REPL_BAUD 115200
+
+// I2C buses
+#define MICROPY_HW_I2C1_SCL (pin_B6) // Arduino Connector CN13-Pin10 (D15)
+#define MICROPY_HW_I2C1_SDA (pin_B7) // Arduino Connector CN13-Pin9 (D14)
+
+// SPI buses
+#define MICROPY_HW_SPI2_NSS (pin_A3) // Arduino Connector CN13-Pin3 (D10)
+#define MICROPY_HW_SPI2_SCK (pin_I1) // Arduino Connector CN13-Pin6 (D13)
+#define MICROPY_HW_SPI2_MISO (pin_I2) // Arduino Connector CN13-Pin5 (D12)
+#define MICROPY_HW_SPI2_MOSI (pin_B15) // Arduino Connector CN13-Pin4 (D11)
+
+// USRSW is pulled low. Pressing the button makes the input go high.
+#define MICROPY_HW_USRSW_PIN (pin_C13)
+#define MICROPY_HW_USRSW_PULL (GPIO_NOPULL)
+#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_RISING)
+#define MICROPY_HW_USRSW_PRESSED (1)
+
+// LEDs
+#define MICROPY_HW_LED1 (pin_I9) // green
+#define MICROPY_HW_LED2 (pin_I8) // orange
+#define MICROPY_HW_LED3 (pin_F1) // red
+#define MICROPY_HW_LED4 (pin_F4) // blue
+#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_low(pin))
+#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_high(pin))
+
+// USB config
+#define MICROPY_HW_USB_FS (1)
+#define MICROPY_HW_USB_MAIN_DEV (USB_PHY_FS_ID)
+
+/******************************************************************************/
+// Variable and function declarations
+
+extern const struct _mp_spiflash_config_t spiflash_config;
+extern struct _spi_bdev_t spi_bdev;
diff --git a/ports/stm32/boards/STM32H573I_DK/mpconfigboard.mk b/ports/stm32/boards/STM32H573I_DK/mpconfigboard.mk
new file mode 100644
index 0000000000..99d3923f20
--- /dev/null
+++ b/ports/stm32/boards/STM32H573I_DK/mpconfigboard.mk
@@ -0,0 +1,15 @@
+USE_MBOOT ?= 0
+
+# MCU settings
+MCU_SERIES = h5
+CMSIS_MCU = STM32H573xx
+MICROPY_FLOAT_IMPL = single
+AF_FILE = boards/stm32h573_af.csv
+
+ifeq ($(USE_MBOOT),1)
+LD_FILES = boards/stm32h573xi.ld boards/common_bl.ld
+TEXT0_ADDR = 0x08008000
+else
+LD_FILES = boards/stm32h573xi.ld boards/common_basic.ld
+TEXT0_ADDR = 0x08000000
+endif
diff --git a/ports/stm32/boards/STM32H573I_DK/pins.csv b/ports/stm32/boards/STM32H573I_DK/pins.csv
new file mode 100644
index 0000000000..5672bc4922
--- /dev/null
+++ b/ports/stm32/boards/STM32H573I_DK/pins.csv
@@ -0,0 +1,149 @@
+,PA0
+,PA1
+,PA2
+,PA3
+,PA4
+,PA5
+,PA6
+,PA7
+,PA8
+,PA9
+,PA10
+,PA11
+,PA12
+,PA13
+,PA14
+,PA15
+,PB0
+,PB1
+,PB2
+,PB3
+,PB4
+,PB5
+,PB6
+,PB7
+,PB8
+,PB9
+,PB10
+,PB11
+,PB12
+,PB13
+,PB14
+,PB15
+,PC0
+,PC1
+,PC2
+,PC3
+,PC4
+,PC5
+,PC6
+,PC7
+,PC8
+,PC9
+,PC10
+,PC11
+,PC12
+,PC13
+,PC14
+,PC15
+,PD0
+,PD1
+,PD2
+,PD3
+,PD4
+,PD5
+,PD6
+,PD7
+,PD8
+,PD9
+,PD10
+,PD11
+,PD12
+,PD13
+,PD14
+,PD15
+,PE0
+,PE1
+,PE2
+,PE3
+,PE4
+,PE5
+,PE6
+,PE7
+,PE8
+,PE9
+,PE10
+,PE11
+,PE12
+,PE13
+,PE14
+,PE15
+,PF0
+,PF1
+,PF2
+,PF3
+,PF4
+,PF5
+,PF6
+,PF7
+,PF8
+,PF9
+,PF10
+,PF11
+,PF12
+,PF13
+,PF14
+,PF15
+,PG0
+,PG1
+,PG2
+,PG3
+,PG4
+,PG5
+,PG6
+,PG7
+,PG8
+,PG9
+,PG10
+,PG11
+,PG12
+,PG13
+,PG14
+,PG15
+,PH0
+,PH1
+,PH2
+,PH3
+,PH4
+,PH5
+,PH6
+,PH7
+,PH8
+,PH9
+,PH10
+,PH11
+,PH12
+,PH13
+,PH14
+,PH15
+,PI0
+,PI1
+,PI2
+,PI3
+,PI4
+,PI5
+,PI6
+,PI7
+,PI8
+,PI9
+,PI10
+,PI11
+,PI12
+,PI13
+,PI14
+,PI15
+LED1,G11
+LED2,G2
+SW,PC13
+UART3_TX,PB10
+UART3_RX,PB11
diff --git a/ports/stm32/boards/STM32H573I_DK/stm32h5xx_hal_conf.h b/ports/stm32/boards/STM32H573I_DK/stm32h5xx_hal_conf.h
new file mode 100644
index 0000000000..6b32ffb185
--- /dev/null
+++ b/ports/stm32/boards/STM32H573I_DK/stm32h5xx_hal_conf.h
@@ -0,0 +1,19 @@
+/* This file is part of the MicroPython project, http://micropython.org/
+ * The MIT License (MIT)
+ * Copyright (c) 2023 Damien P. George
+ */
+#ifndef MICROPY_INCLUDED_STM32H5XX_HAL_CONF_H
+#define MICROPY_INCLUDED_STM32H5XX_HAL_CONF_H
+
+// Oscillator values in Hz
+#define HSE_VALUE (25000000)
+#define LSE_VALUE (32768)
+#define EXTERNAL_CLOCK_VALUE (12288000)
+
+#include "boards/stm32h5xx_hal_conf_base.h"
+
+// Oscillator timeouts in ms
+#define HSE_STARTUP_TIMEOUT (100)
+#define LSE_STARTUP_TIMEOUT (5000)
+
+#endif // MICROPY_INCLUDED_STM32H5XX_HAL_CONF_H