From 6e39f2cc1ed7d4e6a6b1d3132a1b5a73b198ef38 Mon Sep 17 00:00:00 2001 From: Chris Fiege Date: Tue, 14 Sep 2021 11:50:53 +0200 Subject: [PATCH] stm32/boards: Add OLIMEX H407 board definition. This change adds the OLIMEX H407 support to the STM32 port. The H407 (https://www.olimex.com/Products/ARM/ST/STM32-H407/) is simliar to the already existing E407 (https://www.olimex.com/Products/ARM/ST/STM32-E407) but does not support Ethernet and has a full-size USB-A port instead of a Mini-USB socket. Both boards use the STM32F407ZGT6 CPU. This port is basically a copy of the E407 but with changed pinmux: * Removed Ethernet pin definition * Removed UART1 (pins are used for other functions) * Removed UART3 flow control pins (pins are used for other functions) * Removed SD-Card detect pin (since it is not connected on the H407) A REPL on UART3 is connected to the U3BOOT-header, a 3-pin header with RX, TX and GND that is intended for the serial terminal. Tested: * Micro-SD Card is detected when inserted on RESET * REPL on UART3 works * Serial port on the mini USB socket Signed-off-by: Chris Fiege --- ports/stm32/boards/OLIMEX_H407/README.md | 18 ++++ .../stm32/boards/OLIMEX_H407/mpconfigboard.h | 81 +++++++++++++++++ .../stm32/boards/OLIMEX_H407/mpconfigboard.mk | 6 ++ ports/stm32/boards/OLIMEX_H407/pins.csv | 89 +++++++++++++++++++ .../boards/OLIMEX_H407/stm32f4xx_hal_conf.h | 19 ++++ 5 files changed, 213 insertions(+) create mode 100644 ports/stm32/boards/OLIMEX_H407/README.md create mode 100644 ports/stm32/boards/OLIMEX_H407/mpconfigboard.h create mode 100644 ports/stm32/boards/OLIMEX_H407/mpconfigboard.mk create mode 100644 ports/stm32/boards/OLIMEX_H407/pins.csv create mode 100644 ports/stm32/boards/OLIMEX_H407/stm32f4xx_hal_conf.h diff --git a/ports/stm32/boards/OLIMEX_H407/README.md b/ports/stm32/boards/OLIMEX_H407/README.md new file mode 100644 index 0000000000..458e288e7a --- /dev/null +++ b/ports/stm32/boards/OLIMEX_H407/README.md @@ -0,0 +1,18 @@ +OLIMEX H407 board +================= + +This board definition supports the OLIMEX H407 board: +https://www.olimex.com/Products/ARM/ST/STM32-H407/ + +A REPL is available at the U3BOOT connector with 115200 baud and on the +micro USB socket. + +What works +---------- + +* REPL +* UART +* SD-Card +* Timer +* GPIOs +* USB device on the mini USB socket diff --git a/ports/stm32/boards/OLIMEX_H407/mpconfigboard.h b/ports/stm32/boards/OLIMEX_H407/mpconfigboard.h new file mode 100644 index 0000000000..813fffeac3 --- /dev/null +++ b/ports/stm32/boards/OLIMEX_H407/mpconfigboard.h @@ -0,0 +1,81 @@ +#define MICROPY_HW_BOARD_NAME "OLIMEX STM32-H407" +#define MICROPY_HW_MCU_NAME "STM32F407" + +#define MICROPY_HW_HAS_SWITCH (1) +#define MICROPY_HW_HAS_FLASH (1) +#define MICROPY_HW_ENABLE_RNG (1) +#define MICROPY_HW_ENABLE_RTC (1) +#define MICROPY_HW_ENABLE_DAC (1) +#define MICROPY_HW_ENABLE_USB (1) +#define MICROPY_HW_ENABLE_SDCARD (1) + +// HSE is 12MHz +#define MICROPY_HW_CLK_PLLM (12) +#define MICROPY_HW_CLK_PLLN (336) +#define MICROPY_HW_CLK_PLLP (RCC_PLLP_DIV2) +#define MICROPY_HW_CLK_PLLQ (7) + +// UART config + +#define MICROPY_HW_UART2_TX (pin_A2) +#define MICROPY_HW_UART2_RX (pin_A3) + +#define MICROPY_HW_UART3_TX (pin_B10) +#define MICROPY_HW_UART3_RX (pin_B11) + +#define MICROPY_HW_UART3_RTS (pin_D12) +#define MICROPY_HW_UART3_CTS (pin_D11) + +#if MICROPY_HW_HAS_SWITCH == 0 +// NOTE: A0 also connects to the user switch. To use UART4 you should +// set MICROPY_HW_HAS_SWITCH to 0, and also remove SB20 (on the back +// of the board near the USER switch). +#define MICROPY_HW_UART4_TX (pin_A0) +#define MICROPY_HW_UART4_RX (pin_A1) +#endif + +#define MICROPY_HW_UART6_TX (pin_C6) +#define MICROPY_HW_UART6_RX (pin_C7) + +// REPL mapping +#define MICROPY_HW_UART_REPL PYB_UART_3 +#define MICROPY_HW_UART_REPL_BAUD 115200 + +// I2C buses +#define MICROPY_HW_I2C1_SCL (pin_B8) +#define MICROPY_HW_I2C1_SDA (pin_B9) +#define MICROPY_HW_I2C2_SCL (pin_B10) +#define MICROPY_HW_I2C2_SDA (pin_B11) + +// SPI buses +#define MICROPY_HW_SPI1_NSS (pin_A4) +#define MICROPY_HW_SPI1_SCK (pin_A5) +#define MICROPY_HW_SPI1_MISO (pin_A6) +#define MICROPY_HW_SPI1_MOSI (pin_A7) +#define MICROPY_HW_SPI2_NSS (pin_B12) +#define MICROPY_HW_SPI2_SCK (pin_B13) +#define MICROPY_HW_SPI2_MISO (pin_B14) +#define MICROPY_HW_SPI2_MOSI (pin_B15) + +// CAN buses +#define MICROPY_HW_CAN1_TX (pin_B9) +#define MICROPY_HW_CAN1_RX (pin_B8) +#define MICROPY_HW_CAN2_TX (pin_B13) +#define MICROPY_HW_CAN2_RX (pin_B12) + +// USRSW is pulled low. Pressing the button makes the input go high. +#define MICROPY_HW_USRSW_PIN (pin_A0) +#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_C13) +#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_HS (1) +#define MICROPY_HW_USB_HS_IN_FS (1) +#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_B13) +#define MICROPY_HW_USB_OTG_ID_PIN (pin_B12) diff --git a/ports/stm32/boards/OLIMEX_H407/mpconfigboard.mk b/ports/stm32/boards/OLIMEX_H407/mpconfigboard.mk new file mode 100644 index 0000000000..b154dcfbac --- /dev/null +++ b/ports/stm32/boards/OLIMEX_H407/mpconfigboard.mk @@ -0,0 +1,6 @@ +MCU_SERIES = f4 +CMSIS_MCU = STM32F407xx +AF_FILE = boards/stm32f405_af.csv +LD_FILES = boards/stm32f405.ld boards/common_ifs.ld +TEXT0_ADDR = 0x08000000 +TEXT1_ADDR = 0x08020000 diff --git a/ports/stm32/boards/OLIMEX_H407/pins.csv b/ports/stm32/boards/OLIMEX_H407/pins.csv new file mode 100644 index 0000000000..cb0a49916e --- /dev/null +++ b/ports/stm32/boards/OLIMEX_H407/pins.csv @@ -0,0 +1,89 @@ +PC0,PC0 +PC1,PC1 +PC2,PC2 +PC3,PC3 +PA0,PA0 +PA1,PA1 +PA2,PA2 +PA3,PA3 +PA4,PA4 +PA5,PA5 +PA6,PA6 +PA7,PA7 +PC4,PC4 +PC5,PC5 +PB0,PB0 +PB1,PB1 +PB2,PB2 +PE7,PE7 +PE8,PE8 +PE9,PE9 +PE10,PE10 +PE11,PE11 +PE12,PE12 +PE13,PE13 +PE14,PE14 +PE15,PE15 +PB10,PB10 +PB11,PB11 +PB12,PB12 +PB13,PB13 +PB14,PB14 +PB15,PB15 +PD8,PD8 +PD9,PD9 +PD10,PD10 +PD11,PD11 +PD12,PD12 +PD13,PD13 +PD14,PD14 +PD15,PD15 +PC6,PC6 +PC7,PC7 +PC8,PC8 +PC9,PC9 +PA8,PA8 +PA9,PA9 +PA10,PA10 +PA13,PA13 +PA14,PA14 +PA15,PA15 +PC10,PC10 +PC11,PC11 +PC12,PC12 +PD0,PD0 +PD1,PD1 +PD2,PD2 +PD3,PD3 +PD4,PD4 +PD5,PD5 +PD6,PD6 +PD7,PD7 +PB4,PB4 +PB5,PB5 +PB6,PB6 +PB7,PB7 +PB8,PB8 +PB9,PB9 +PE0,PE0 +PE1,PE1 +PE2,PE2 +PE3,PE3 +PE4,PE4 +PE5,PE5 +PE6,PE6 +LED_GREEN,PC13 +PC14,PC14 +PC15,PC15 +PH0,PH0 +PH1,PH1 +PD12,PD12 +PD13,PD13 +PD14,PD14 +PD15,PD15 +PA0,PA0 +USB_DM,PA11 +USB_DP,PA12 +PG11,PG11 +PG13,PG13 +PG14,PG14 diff --git a/ports/stm32/boards/OLIMEX_H407/stm32f4xx_hal_conf.h b/ports/stm32/boards/OLIMEX_H407/stm32f4xx_hal_conf.h new file mode 100644 index 0000000000..9719157e55 --- /dev/null +++ b/ports/stm32/boards/OLIMEX_H407/stm32f4xx_hal_conf.h @@ -0,0 +1,19 @@ +/* This file is part of the MicroPython project, http://micropython.org/ + * The MIT License (MIT) + * Copyright (c) 2019 Damien P. George + */ +#ifndef MICROPY_INCLUDED_STM32F4XX_HAL_CONF_H +#define MICROPY_INCLUDED_STM32F4XX_HAL_CONF_H + +#include "boards/stm32f4xx_hal_conf_base.h" + +// Oscillator values in Hz +#define HSE_VALUE (12000000) +#define LSE_VALUE (32768) +#define EXTERNAL_CLOCK_VALUE (12288000) + +// Oscillator timeouts in ms +#define HSE_STARTUP_TIMEOUT (100) +#define LSE_STARTUP_TIMEOUT (5000) + +#endif // MICROPY_INCLUDED_STM32F4XX_HAL_CONF_H