Skip to content

Commit 9e2423e

Browse files
JohnieBraafdpgeorge
authored andcommitted
stm32: Add support for H7A3(Q)/H7B3(Q), and STM32H73B3I_DK board defn.
This commit is based upon prior work of @dpgeorge and @koendv. MCU support for the STM32H7A3 and B3 families MCUs: - STM32H7A3xx - STM32H7A3xxQ (SMPS) - STM32H7B3xx - STM32H7B3xxQ (SMPS) Support has been added for the STM32H7B3I_DK board. Signed-off-by: Jan Staal <info@janstaal.com>
1 parent d9749f9 commit 9e2423e

21 files changed

+655
-12
lines changed

ports/stm32/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ CFLAGS_CORTEX_M = -mthumb
7777
# Select hardware floating-point support
7878
SUPPORTS_HARDWARE_FP_SINGLE = 0
7979
SUPPORTS_HARDWARE_FP_DOUBLE = 0
80-
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),STM32F765xx STM32F767xx STM32F769xx STM32H743xx STM32H750xx))
80+
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),STM32F765xx STM32F767xx STM32F769xx STM32H743xx STM32H750xx STM32H7A3xx STM32H7A3xxQ STM32H7B3xx STM32H7B3xxQ))
8181
CFLAGS_CORTEX_M += -mfpu=fpv5-d16 -mfloat-abi=hard
8282
SUPPORTS_HARDWARE_FP_SINGLE = 1
8383
SUPPORTS_HARDWARE_FP_DOUBLE = 1
@@ -424,7 +424,7 @@ HAL_SRC_C += $(addprefix $(HAL_DIR)/Src/stm32$(MCU_SERIES)xx_,\
424424
)
425425
endif
426426

427-
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),STM32H743xx STM32H750xx))
427+
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),STM32H743xx STM32H750xx STM32H7A3xx STM32H7A3xxQ STM32H7B3xx STM32H7B3xxQ))
428428
HAL_SRC_C += $(addprefix $(HAL_DIR)/Src/stm32$(MCU_SERIES)xx_, hal_fdcan.c)
429429
else
430430
ifeq ($(MCU_SERIES),$(filter $(MCU_SERIES),f0 f4 f7 h7 l4))

ports/stm32/adc.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@
5555
#define PIN_ADC_MASK PIN_ADC1
5656
#define pin_adc_table pin_adc1
5757

58-
#if defined(STM32H7)
58+
#if defined(STM32H7A3xx) || defined(STM32H7A3xxQ) || \
59+
defined(STM32H7B3xx) || defined(STM32H7B3xxQ)
60+
#define ADCALLx (ADC2)
61+
#define pin_adcall_table pin_adc2
62+
#elif defined(STM32H7)
5963
// On the H7 ADC3 is used for ADCAll to be able to read internal
6064
// channels. For all other GPIO channels, ADC12 is used instead.
6165
#define ADCALLx (ADC3)
@@ -137,6 +141,8 @@
137141
defined(STM32F767xx) || defined(STM32F769xx)
138142
#define VBAT_DIV (4)
139143
#elif defined(STM32H743xx) || defined(STM32H747xx) || \
144+
defined(STM32H7A3xx) || defined(STM32H7A3xxQ) || \
145+
defined(STM32H7B3xx) || defined(STM32H7B3xxQ) || \
140146
defined(STM32H750xx)
141147
#define VBAT_DIV (4)
142148
#elif defined(STM32L432xx) || \
@@ -227,6 +233,9 @@ STATIC void adc_wait_for_eoc_or_timeout(ADC_HandleTypeDef *adcHandle, int32_t ti
227233
STATIC void adcx_clock_enable(ADC_HandleTypeDef *adch) {
228234
#if defined(STM32F0) || defined(STM32F4) || defined(STM32F7)
229235
ADCx_CLK_ENABLE();
236+
#elif defined(STM32H7A3xx) || defined(STM32H7A3xxQ) || defined(STM32H7B3xx) || defined(STM32H7B3xxQ)
237+
__HAL_RCC_ADC12_CLK_ENABLE();
238+
__HAL_RCC_ADC_CONFIG(RCC_ADCCLKSOURCE_CLKP);
230239
#elif defined(STM32H7)
231240
if (adch->Instance == ADC3) {
232241
__HAL_RCC_ADC3_CLK_ENABLE();

ports/stm32/adc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ static inline void adc_deselect_vbat(ADC_TypeDef *adc, uint32_t channel) {
4848
adc_common = ADC_COMMON_REGISTER(0);
4949
#elif defined(STM32F7)
5050
adc_common = ADC123_COMMON;
51+
#elif defined(STM32H7A3xx) || defined(STM32H7A3xxQ) || defined(STM32H7B3xx) || defined(STM32H7B3xxQ)
52+
adc_common = ADC12_COMMON;
5153
#elif defined(STM32H7)
5254
adc_common = adc == ADC3 ? ADC3_COMMON : ADC12_COMMON;
5355
#endif
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#define MICROPY_HW_BOARD_NAME "STM32H7B3I-DK"
2+
#define MICROPY_HW_MCU_NAME "STM32H7B3LIH6Q"
3+
4+
#define MICROPY_HW_ENABLE_RTC (1)
5+
#define MICROPY_HW_ENABLE_RNG (1)
6+
#define MICROPY_HW_ENABLE_ADC (1)
7+
#define MICROPY_HW_ENABLE_DAC (1)
8+
#define MICROPY_HW_ENABLE_USB (1)
9+
#define MICROPY_HW_ENABLE_SDCARD (1)
10+
#define MICROPY_HW_HAS_SWITCH (1)
11+
#define MICROPY_HW_HAS_FLASH (0)
12+
13+
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
14+
15+
// The board has a 24MHz HSE, the following gives 280MHz CPU speed
16+
#define MICROPY_HW_CLK_PLLM (12)
17+
#define MICROPY_HW_CLK_PLLN (280)
18+
#define MICROPY_HW_CLK_PLLP (2)
19+
#define MICROPY_HW_CLK_PLLQ (2)
20+
#define MICROPY_HW_CLK_PLLR (2)
21+
22+
// The USB clock is set using PLL3 (48Mhz usb clock)
23+
#define MICROPY_HW_CLK_PLL3M (12)
24+
#define MICROPY_HW_CLK_PLL3N (192)
25+
#define MICROPY_HW_CLK_PLL3P (17)
26+
#define MICROPY_HW_CLK_PLL3Q (8)
27+
#define MICROPY_HW_CLK_PLL3R (2)
28+
29+
// 6 wait states when running at 280MHz (VOS0 range)
30+
#define MICROPY_HW_FLASH_LATENCY FLASH_LATENCY_6
31+
32+
#if 0
33+
// 512MBit external OSPI flash, used for either the filesystem or XIP memory mapped
34+
#define MICROPY_HW_OSPIFLASH_SIZE_BITS_LOG2 (29)
35+
#define MICROPY_HW_OSPIFLASH_CS (pin_G6)
36+
#define MICROPY_HW_OSPIFLASH_CLK (pin_B2)
37+
#define MICROPY_HW_OSPIFLASH_DQS (pin_C5)
38+
#define MICROPY_HW_OSPIFLASH_IO0 (pin_P8)
39+
#define MICROPY_HW_OSPIFLASH_IO1 (pin_F9)
40+
#define MICROPY_HW_OSPIFLASH_IO2 (pin_F7)
41+
#define MICROPY_HW_OSPIFLASH_IO3 (pin_F6)
42+
#define MICROPY_HW_OSPIFLASH_IO4 (pin_C1)
43+
#define MICROPY_HW_OSPIFLASH_IO5 (pin_H3)
44+
#define MICROPY_HW_OSPIFLASH_IO6 (pin_D6)
45+
#define MICROPY_HW_OSPIFLASH_IO7 (pin_G14)
46+
#endif
47+
48+
// UART buses
49+
#define MICROPY_HW_UART1_TX (pin_A9)
50+
#define MICROPY_HW_UART1_RX (pin_A10)
51+
#define MICROPY_HW_UART4_TX (pin_H13) // Arduino Connector CN11-Pin1
52+
#define MICROPY_HW_UART4_RX (pin_H14) // Arduino Connector CN11-Pin2
53+
#define MICROPY_HW_UART_REPL PYB_UART_1
54+
#define MICROPY_HW_UART_REPL_BAUD 115200
55+
56+
// USRSW is pulled low. Pressing the button makes the input go high.
57+
#define MICROPY_HW_USRSW_PIN (pin_C13)
58+
#define MICROPY_HW_USRSW_PULL (GPIO_NOPULL)
59+
#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_RISING)
60+
#define MICROPY_HW_USRSW_PRESSED (1)
61+
62+
// LEDs
63+
#define MICROPY_HW_LED1 (pin_G11) // red
64+
#define MICROPY_HW_LED2 (pin_G2) // blue
65+
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_low(pin))
66+
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_high(pin))
67+
68+
// USB config
69+
#define MICROPY_HW_USB_FS (0)
70+
#define MICROPY_HW_USB_HS (1)
71+
#define MICROPY_HW_USB_HS_IN_FS (1)
72+
#define MICROPY_HW_USB_MAIN_DEV (USB_PHY_HS_ID)
73+
#define MICROPY_HW_USB_CDC_NUM (2)
74+
#define MICROPY_HW_USB_MSC (0)
75+
76+
// SD card detect switch
77+
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_I8)
78+
#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
79+
#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET)
80+
81+
#define MICROPY_HW_SDMMC_D0 (pin_C8)
82+
#define MICROPY_HW_SDMMC_D1 (pin_C9)
83+
#define MICROPY_HW_SDMMC_D2 (pin_C10)
84+
#define MICROPY_HW_SDMMC_D3 (pin_C11)
85+
#define MICROPY_HW_SDMMC_CK (pin_C12)
86+
#define MICROPY_HW_SDMMC_CMD (pin_D2)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
USE_MBOOT ?= 0
2+
3+
# MCU settings
4+
MCU_SERIES = h7
5+
CMSIS_MCU = STM32H7B3xxQ
6+
MICROPY_FLOAT_IMPL = double
7+
AF_FILE = boards/stm32h7b3_af.csv
8+
9+
ifeq ($(USE_MBOOT),1)
10+
# When using Mboot all the text goes together after the filesystem
11+
LD_FILES = boards/stm32h743.ld boards/common_blifs.ld
12+
TEXT0_ADDR = 0x08040000
13+
else
14+
# When not using Mboot the ISR text goes first, then the rest after the filesystem
15+
LD_FILES = boards/stm32h7b3.ld boards/common_ifs.ld
16+
TEXT0_ADDR = 0x08000000
17+
TEXT1_ADDR = 0x08040000
18+
endif
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
,PA0
2+
,PA1
3+
,PA2
4+
,PA3
5+
,PA4
6+
,PA5
7+
,PA6
8+
,PA7
9+
,PA8
10+
,PA9
11+
,PA10
12+
,PA11
13+
,PA12
14+
,PA13
15+
,PA14
16+
,PA15
17+
,PB0
18+
,PB1
19+
,PB2
20+
,PB3
21+
,PB4
22+
,PB5
23+
,PB6
24+
,PB7
25+
,PB8
26+
,PB9
27+
,PB10
28+
,PB11
29+
,PB12
30+
,PB13
31+
,PB14
32+
,PB15
33+
,PC0
34+
,PC1
35+
,PC2
36+
,PC3
37+
,PC4
38+
,PC5
39+
,PC6
40+
,PC7
41+
,PC8
42+
,PC9
43+
,PC10
44+
,PC11
45+
,PC12
46+
,PC13
47+
,PC14
48+
,PC15
49+
,PD0
50+
,PD1
51+
,PD2
52+
,PD3
53+
,PD4
54+
,PD5
55+
,PD6
56+
,PD7
57+
,PD8
58+
,PD9
59+
,PD10
60+
,PD11
61+
,PD12
62+
,PD13
63+
,PD14
64+
,PD15
65+
,PE0
66+
,PE1
67+
,PE2
68+
,PE3
69+
,PE4
70+
,PE5
71+
,PE6
72+
,PE7
73+
,PE8
74+
,PE9
75+
,PE10
76+
,PE11
77+
,PE12
78+
,PE13
79+
,PE14
80+
,PE15
81+
,PF0
82+
,PF1
83+
,PF2
84+
,PF3
85+
,PF4
86+
,PF5
87+
,PF6
88+
,PF7
89+
,PF8
90+
,PF9
91+
,PF10
92+
,PF11
93+
,PF12
94+
,PF13
95+
,PF14
96+
,PF15
97+
,PG0
98+
,PG1
99+
,PG2
100+
,PG3
101+
,PG4
102+
,PG5
103+
,PG6
104+
,PG7
105+
,PG8
106+
,PG9
107+
,PG10
108+
,PG11
109+
,PG12
110+
,PG13
111+
,PG14
112+
,PG15
113+
,PH0
114+
,PH1
115+
,PH2
116+
,PH3
117+
,PH4
118+
,PH5
119+
,PH6
120+
,PH7
121+
,PH8
122+
,PH9
123+
,PH10
124+
,PH11
125+
,PH12
126+
,PH13
127+
,PH14
128+
,PH15
129+
,PI0
130+
,PI1
131+
,PI2
132+
,PI3
133+
,PI4
134+
,PI5
135+
,PI6
136+
,PI7
137+
,PI8
138+
,PI9
139+
,PI10
140+
,PI11
141+
,PI12
142+
,PI13
143+
,PI14
144+
,PI15
145+
DAC1,PA4
146+
DAC2,PA5
147+
LED1,G11
148+
LED2,G2
149+
SW,PC13
150+
I2C1_SDA,PB9
151+
I2C1_SCL,PB8
152+
I2C2_SDA,PF0
153+
I2C2_SCL,PF1
154+
I2C4_SCL,PF14
155+
I2C4_SDA,PF15
156+
SD_D0,PC8
157+
SD_D1,PC9
158+
SD_D2,PC10
159+
SD_D3,PC11
160+
SD_CMD,PD2
161+
SD_CK,PC12
162+
SD_SW,PG2
163+
OTG_FS_POWER,PG6
164+
OTG_FS_OVER_CURRENT,PG7
165+
USB_VBUS,PA9
166+
USB_ID,PA10
167+
USB_DM,PA11
168+
USB_DP,PA12
169+
UART2_TX,PD5
170+
UART2_RX,PD6
171+
UART2_RTS,PD4
172+
UART2_CTS,PD3
173+
UART3_TX,PD8
174+
UART3_RX,PD9
175+
UART5_TX,PB6
176+
UART5_RX,PB12
177+
UART6_TX,PC6
178+
UART6_RX,PC7
179+
UART7_TX,PF7
180+
UART7_RX,PF6
181+
UART8_TX,PE1
182+
UART8_RX,PE0
183+
ETH_MDC,PC1
184+
ETH_MDIO,PA2
185+
ETH_RMII_REF_CLK,PA1
186+
ETH_RMII_CRS_DV,PA7
187+
ETH_RMII_RXD0,PC4
188+
ETH_RMII_RXD1,PC5
189+
ETH_RMII_TX_EN,PG11
190+
ETH_RMII_TXD0,PG13
191+
ETH_RMII_TXD1,PB13
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* This file is part of the MicroPython project, http://micropython.org/
2+
* The MIT License (MIT)
3+
* Copyright (c) 2019 Damien P. George
4+
*/
5+
#ifndef MICROPY_INCLUDED_STM32H7XX_HAL_CONF_H
6+
#define MICROPY_INCLUDED_STM32H7XX_HAL_CONF_H
7+
8+
#include "boards/stm32h7xx_hal_conf_base.h"
9+
10+
// Oscillator values in Hz
11+
#define HSE_VALUE (24000000)
12+
#define LSE_VALUE (32768)
13+
#define EXTERNAL_CLOCK_VALUE (12288000)
14+
15+
// Oscillator timeouts in ms
16+
#define HSE_STARTUP_TIMEOUT (5000)
17+
#define LSE_STARTUP_TIMEOUT (5000)
18+
19+
#endif // MICROPY_INCLUDED_STM32H7XX_HAL_CONF_H

0 commit comments

Comments
 (0)