From 0cc100be2c08f6b4e53a208dea8ef7953dc29cea Mon Sep 17 00:00:00 2001 From: Rene Straub Date: Sun, 6 Aug 2023 11:18:53 +0200 Subject: [PATCH] stm32/boards/NUCLEO_H563ZI: Add new NUCLEO-H563ZI board definition. Configuration: - Clock is HSE, CPU runs at 250MHz. - REPL on USB and UART connected to the ST-Link interface. - Storage is configured for internal flash memory. - Three LEDs and one user button. - Ethernet is enabled. Signed-off-by: Rene Straub --- ports/stm32/boards/NUCLEO_H563ZI/board.json | 15 ++ .../boards/NUCLEO_H563ZI/mpconfigboard.h | 91 ++++++++++++ .../boards/NUCLEO_H563ZI/mpconfigboard.mk | 23 ++++ ports/stm32/boards/NUCLEO_H563ZI/pins.csv | 130 ++++++++++++++++++ .../boards/NUCLEO_H563ZI/stm32h5xx_hal_conf.h | 19 +++ 5 files changed, 278 insertions(+) create mode 100644 ports/stm32/boards/NUCLEO_H563ZI/board.json create mode 100644 ports/stm32/boards/NUCLEO_H563ZI/mpconfigboard.h create mode 100644 ports/stm32/boards/NUCLEO_H563ZI/mpconfigboard.mk create mode 100644 ports/stm32/boards/NUCLEO_H563ZI/pins.csv create mode 100644 ports/stm32/boards/NUCLEO_H563ZI/stm32h5xx_hal_conf.h diff --git a/ports/stm32/boards/NUCLEO_H563ZI/board.json b/ports/stm32/boards/NUCLEO_H563ZI/board.json new file mode 100644 index 0000000000..b9c4e41b3e --- /dev/null +++ b/ports/stm32/boards/NUCLEO_H563ZI/board.json @@ -0,0 +1,15 @@ +{ + "deploy": [ + "../deploy.md" + ], + "docs": "", + "features": [], + "images": [ + "nucleo_h563zi.jpg" + ], + "mcu": "stm32h5", + "product": "Nucleo H563ZI", + "thumbnail": "", + "url": "", + "vendor": "ST Microelectronics" +} diff --git a/ports/stm32/boards/NUCLEO_H563ZI/mpconfigboard.h b/ports/stm32/boards/NUCLEO_H563ZI/mpconfigboard.h new file mode 100644 index 0000000000..1e802eda5b --- /dev/null +++ b/ports/stm32/boards/NUCLEO_H563ZI/mpconfigboard.h @@ -0,0 +1,91 @@ +#define MICROPY_HW_BOARD_NAME "NUCLEO_H563ZI" +#define MICROPY_HW_MCU_NAME "STM32H563ZI" + +#define MICROPY_PY_PYB_LEGACY (0) +#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (1) +#define MICROPY_HW_ENABLE_RTC (1) +#define MICROPY_HW_ENABLE_RNG (1) +#define MICROPY_HW_ENABLE_ADC (1) +#define MICROPY_HW_ENABLE_DAC (1) +#define MICROPY_HW_ENABLE_USB (1) +#define MICROPY_HW_HAS_SWITCH (1) +#define MICROPY_HW_HAS_FLASH (1) + +// The board has a 8MHz oscillator, the following gives 250MHz CPU speed +#define MICROPY_HW_CLK_USE_BYPASS (1) +#define MICROPY_HW_CLK_PLLM (2) +#define MICROPY_HW_CLK_PLLN (125) +#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) + +// PLL3 with Q output at 48MHz for USB +// #define MICROPY_HW_CLK_USE_PLL3_FOR_USB +#define MICROPY_HW_CLK_PLL3M (8) +#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) + +// 5 wait states, according to Table 37, Reference Manual (RM0481 Rev 1) +#define MICROPY_HW_FLASH_LATENCY FLASH_LATENCY_5 + +// There is an external 32kHz oscillator +#define MICROPY_HW_RTC_USE_LSE (1) + +// UART config +#define MICROPY_HW_UART1_TX (pin_B6) // SB14: Arduino Connector CN10-Pin14 (D1) +#define MICROPY_HW_UART1_RX (pin_B7) // SB63: Arduino Connector CN10-Pin16 (D0) +#define MICROPY_HW_UART3_TX (pin_D8) // SB23: ST-Link +#define MICROPY_HW_UART3_RX (pin_D9) // SB18: ST-Link + +// Connect REPL to UART3 which is provided on ST-Link USB interface +#define MICROPY_HW_UART_REPL PYB_UART_3 +#define MICROPY_HW_UART_REPL_BAUD 115200 + +// I2C buses +#define MICROPY_HW_I2C1_SCL (pin_B8) // Arduino Connector CN7-Pin2 (D15) +#define MICROPY_HW_I2C1_SDA (pin_B9) // Arduino Connector CN7-Pin4 (D14) +#define MICROPY_HW_I2C2_SCL (pin_F1) // Connector CN9-Pin19 +#define MICROPY_HW_I2C2_SDA (pin_F0) // Connector CN9-Pin21 + +// SPI buses +// PD14 according to datasheet not working as SPI1_NSS, have to use as GPIO, not as AF +#define MICROPY_HW_SPI1_NSS (pin_D14) // Arduino Connector CN7-Pin16 (D10) +#define MICROPY_HW_SPI1_SCK (pin_A5) // Arduino Connector CN7-Pin10 (D13) +#define MICROPY_HW_SPI1_MISO (pin_G9) // Arduino Connector CN7-Pin12 (D12) +#define MICROPY_HW_SPI1_MOSI (pin_B5) // Arduino Connector CN7-Pin14 (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_B0) // Green +#define MICROPY_HW_LED2 (pin_F4) // Orange +#define MICROPY_HW_LED3 (pin_G4) // Red +#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin)) +#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin)) + +// USB config +#define MICROPY_HW_USB_FS (1) +#define MICROPY_HW_USB_MAIN_DEV (USB_PHY_FS_ID) + +// Ethernet via RMII +#define MICROPY_HW_ETH_MDC (pin_C1) +#define MICROPY_HW_ETH_MDIO (pin_A2) +#define MICROPY_HW_ETH_RMII_REF_CLK (pin_A1) +#define MICROPY_HW_ETH_RMII_CRS_DV (pin_A7) +#define MICROPY_HW_ETH_RMII_RXD0 (pin_C4) +#define MICROPY_HW_ETH_RMII_RXD1 (pin_C5) +#define MICROPY_HW_ETH_RMII_TX_EN (pin_G11) +#define MICROPY_HW_ETH_RMII_TXD0 (pin_G13) +#define MICROPY_HW_ETH_RMII_TXD1 (pin_B15) diff --git a/ports/stm32/boards/NUCLEO_H563ZI/mpconfigboard.mk b/ports/stm32/boards/NUCLEO_H563ZI/mpconfigboard.mk new file mode 100644 index 0000000000..a55a54d1c7 --- /dev/null +++ b/ports/stm32/boards/NUCLEO_H563ZI/mpconfigboard.mk @@ -0,0 +1,23 @@ +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) +# When using Mboot everything goes after the bootloader +# TODO: not tested +LD_FILES = boards/stm32h573xi.ld boards/common_bl.ld +TEXT0_ADDR = 0x08008000 +else +# When not using Mboot everything goes at the start of flash +LD_FILES = boards/stm32h573xi.ld boards/common_basic.ld +TEXT0_ADDR = 0x08000000 +endif + +# MicroPython settings +MICROPY_PY_LWIP = 1 +MICROPY_PY_SSL = 1 +MICROPY_SSL_MBEDTLS = 1 diff --git a/ports/stm32/boards/NUCLEO_H563ZI/pins.csv b/ports/stm32/boards/NUCLEO_H563ZI/pins.csv new file mode 100644 index 0000000000..1f83e8a505 --- /dev/null +++ b/ports/stm32/boards/NUCLEO_H563ZI/pins.csv @@ -0,0 +1,130 @@ +,PA0 +,PA1 +,PA2 +,PA3 +,PA4 +,PA5 +,PA7 +,PA8 +,PA9 +,PA10 +,PA11 +,PA12 +,PA13 +,PA14 +,PA15 +,PB0 +,PB2 +,PB3 +,PB4 +,PB5 +,PB6 +,PB7 +,PB8 +,PB9 +,PB10 +,PB11 +,PB12 +,PB13 +,PB14 +,PB15 +,PC1 +,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 +,PE0 +,PE1 +,PE2 +,PE3 +,PE4 +,PE5 +,PE6 +,PE7 +,PE8 +,PE10 +,PE12 +,PE15 +,PF0 +,PF1 +,PF2 +,PF4 +,PF5 +,PF6 +,PF7 +,PF8 +,PF9 +,PF10 +,PF12 +,PF13 +,PF14 +,PF15 +,PG0 +,PG1 +,PG2 +,PG3 +,PG4 +,PG5 +,PG6 +,PG7 +,PG8 +,PG9 +,PG10 +,PG11 +,PG13 +,PG15 +A0,PA6 +A1,PC0 +A2,PC3 +A3,PB1 +A4,PC2 +A5,PF11 +D2,PG14 +D3,PE13 +D4,PE14 +D5,PE11 +D6,PE9 +D7,PG12 +D8,PF3 +D9,PD15 +UART1_TX,PB6 +UART1_RX,PB7 +UART3_TX,PD8 +UART3_RX,PD9 +LED_GREEN,PB0 +LED_ORANGE,PF4 +LED_RED,PG4 +SW,PC13 +I2C1_SDA,PB9 +I2C1_SCL,PB8 +I2C2_SDA,PF1 +I2C2_SCL,PF0 +USB_DM,PA11 +USB_DP,PA12 +SPI_A_CS,PD14 +SPI_A_SCK,PA5 +SPI_A_MOSI,PB5 +SPI_A_MISO,PG9 diff --git a/ports/stm32/boards/NUCLEO_H563ZI/stm32h5xx_hal_conf.h b/ports/stm32/boards/NUCLEO_H563ZI/stm32h5xx_hal_conf.h new file mode 100644 index 0000000000..f86c9300e3 --- /dev/null +++ b/ports/stm32/boards/NUCLEO_H563ZI/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 (8000000) +#define LSE_VALUE (32768) +#define EXTERNAL_CLOCK_VALUE (12288000) + +// Oscillator timeouts in ms +#define HSE_STARTUP_TIMEOUT (100) +#define LSE_STARTUP_TIMEOUT (5000) + +#include "boards/stm32h5xx_hal_conf_base.h" + +#endif // MICROPY_INCLUDED_STM32H5XX_HAL_CONF_H