stm32: Add support for STM32H723 MCUs.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George 2022-12-20 17:00:59 +11:00
parent 3187e4c7e7
commit 13fcd8440e
7 changed files with 47 additions and 14 deletions

View File

@ -437,14 +437,10 @@ HAL_SRC_C += $(addprefix $(STM32LIB_HAL_BASE)/Src/stm32$(MCU_SERIES)xx_,\
)
endif
ifeq ($(MCU_SERIES),$(filter $(MCU_SERIES),g0 g4))
HAL_SRC_C += $(addprefix $(STM32LIB_HAL_BASE)/Src/stm32$(MCU_SERIES)xx_, hal_fdcan.c)
endif
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),STM32H743xx STM32H747xx STM32H750xx STM32H7A3xx STM32H7A3xxQ STM32H7B3xx STM32H7B3xxQ))
HAL_SRC_C += $(addprefix $(STM32LIB_HAL_BASE)/Src/stm32$(MCU_SERIES)xx_, hal_fdcan.c)
else ifeq ($(MCU_SERIES),$(filter $(MCU_SERIES),f0 f4 f7 h7))
ifeq ($(MCU_SERIES),$(filter $(MCU_SERIES),f0 f4 f7))
HAL_SRC_C += $(addprefix $(STM32LIB_HAL_BASE)/Src/stm32$(MCU_SERIES)xx_, hal_can.c)
else ifeq ($(MCU_SERIES),$(filter $(MCU_SERIES),g0 g4 h7))
HAL_SRC_C += $(addprefix $(STM32LIB_HAL_BASE)/Src/stm32$(MCU_SERIES)xx_, hal_fdcan.c)
else ifeq ($(MCU_SERIES),$(filter $(MCU_SERIES),l4))
HAL_SRC_C += $(addprefix $(STM32LIB_HAL_BASE)/Src/Legacy/stm32$(MCU_SERIES)xx_, hal_can.c)
$(BUILD)/$(STM32LIB_HAL_BASE)/Src/Legacy/stm32$(MCU_SERIES)xx_hal_can.o: CFLAGS += -Wno-error=cpp

View File

@ -160,7 +160,8 @@
#define VBAT_DIV (4)
#elif defined(STM32G0) || defined(STM32G4)
#define VBAT_DIV (3)
#elif defined(STM32H743xx) || defined(STM32H747xx) || \
#elif defined(STM32H723xx) || defined(STM32H733xx) || \
defined(STM32H743xx) || defined(STM32H747xx) || \
defined(STM32H7A3xx) || defined(STM32H7A3xxQ) || \
defined(STM32H7B3xx) || defined(STM32H7B3xxQ) || \
defined(STM32H750xx)

View File

@ -133,7 +133,14 @@ static const flash_layout_t flash_layout[] = {
#error Unsupported processor
#endif
#if (defined(STM32L4) && defined(SYSCFG_MEMRMP_FB_MODE)) || defined(STM32H7)
#if defined(STM32H723xx)
// get the bank of a given flash address
static uint32_t get_bank(uint32_t addr) {
return FLASH_BANK_1;
}
#elif (defined(STM32L4) && defined(SYSCFG_MEMRMP_FB_MODE)) || defined(STM32H7)
// get the bank of a given flash address
static uint32_t get_bank(uint32_t addr) {

View File

@ -315,7 +315,13 @@ STATIC void adc_config_channel(ADC_TypeDef *adc, uint32_t channel, uint32_t samp
#if defined(STM32H7A3xx) || defined(STM32H7A3xxQ) || defined(STM32H7B3xx) || defined(STM32H7B3xxQ)
ADC_Common_TypeDef *adc_common = ADC12_COMMON;
#elif defined(STM32H7)
#if defined(ADC_VER_V5_V90)
if (adc != ADC3) {
adc->PCSEL_RES0 |= 1 << channel;
}
#else
adc->PCSEL |= 1 << channel;
#endif
ADC_Common_TypeDef *adc_common = adc == ADC3 ? ADC3_COMMON : ADC12_COMMON;
#elif defined(STM32L4)
ADC_Common_TypeDef *adc_common = ADCx_COMMON;

View File

@ -379,8 +379,10 @@ void stm32_main(uint32_t reset_mode) {
// Enable D2 SRAM1/2/3 clocks.
__HAL_RCC_D2SRAM1_CLK_ENABLE();
__HAL_RCC_D2SRAM2_CLK_ENABLE();
#if defined(__HAL_RCC_D2SRAM3_CLK_ENABLE)
__HAL_RCC_D2SRAM3_CLK_ENABLE();
#endif
#endif
MICROPY_BOARD_EARLY_INIT();

View File

@ -33,11 +33,9 @@
#if defined(STM32H7)
#define RCC_SR RSR
#if defined(STM32H743xx) || defined(STM32H750xx)
#define RCC_SR_SFTRSTF RCC_RSR_SFTRSTF
#elif defined(STM32H747xx)
#if defined(STM32H747xx)
#define RCC_SR_SFTRSTF RCC_RSR_SFT2RSTF
#elif defined(STM32H7A3xx) || defined(STM32H7A3xxQ) || defined(STM32H7B3xx) || defined(STM32H7B3xxQ)
#else
#define RCC_SR_SFTRSTF RCC_RSR_SFTRSTF
#endif
#define RCC_SR_RMVF RCC_RSR_RMVF
@ -48,6 +46,8 @@
defined(STM32H7B3xx) || defined(STM32H7B3xxQ)
// TODO
#define POWERCTRL_GET_VOLTAGE_SCALING() PWR_REGULATOR_VOLTAGE_SCALE0
#elif defined(STM32H723xx)
#define POWERCTRL_GET_VOLTAGE_SCALING() LL_PWR_GetRegulVoltageScaling()
#else
#define POWERCTRL_GET_VOLTAGE_SCALING() \
(((PWR->CSR1 & PWR_CSR1_ACTVOS) && (SYSCFG->PWRCR & SYSCFG_PWRCR_ODEN)) ? \

View File

@ -135,6 +135,26 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd) {
if (hpcd->Instance == USB_OTG_HS) {
#if MICROPY_HW_USB_HS_IN_FS
// Configure USB GPIO's.
#if defined(STM32H723xx)
// These MCUs don't have an alternate function for USB but rather require
// the pins to be disconnected from all peripherals, ie put in analog mode.
#if defined(MICROPY_HW_USB_OTG_ID_PIN)
const uint32_t otg_alt = GPIO_AF10_OTG1_FS;
#endif
mp_hal_pin_config(pin_A11, MP_HAL_PIN_MODE_ANALOG, MP_HAL_PIN_PULL_NONE, 0);
mp_hal_pin_config_speed(pin_A11, GPIO_SPEED_FREQ_VERY_HIGH);
mp_hal_pin_config(pin_A12, MP_HAL_PIN_MODE_ANALOG, MP_HAL_PIN_PULL_NONE, 0);
mp_hal_pin_config_speed(pin_A12, GPIO_SPEED_FREQ_VERY_HIGH);
#else
// Other MCUs have an alternate function for GPIO's to be in USB mode.
#if defined(STM32H7A3xx) || defined(STM32H7A3xxQ) || defined(STM32H7B3xx) || defined(STM32H7B3xxQ)
const uint32_t otg_alt = GPIO_AF10_OTG1_FS;
#elif defined(STM32H7)
@ -143,12 +163,13 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd) {
const uint32_t otg_alt = GPIO_AF12_OTG_HS_FS;
#endif
// Configure USB FS GPIOs
mp_hal_pin_config(pin_B14, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_NONE, otg_alt);
mp_hal_pin_config_speed(pin_B14, GPIO_SPEED_FREQ_VERY_HIGH);
mp_hal_pin_config(pin_B15, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_NONE, otg_alt);
mp_hal_pin_config_speed(pin_B15, GPIO_SPEED_FREQ_VERY_HIGH);
#endif
#if defined(MICROPY_HW_USB_VBUS_DETECT_PIN)
// Configure VBUS Pin
mp_hal_pin_config(MICROPY_HW_USB_VBUS_DETECT_PIN, MP_HAL_PIN_MODE_INPUT, MP_HAL_PIN_PULL_NONE, 0);