From 4fa4ff6524e221b63fb022ebcb3312049cfe8c72 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Wed, 10 Aug 2022 18:50:05 +0200 Subject: [PATCH] bootloader: Add support for early bootloader pin config. * For pins such as OSC or ULPI enable. --- src/bootloader/src/stm32fxxx_hal_msp.c | 39 ++++++++++++++++++++------ 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/src/bootloader/src/stm32fxxx_hal_msp.c b/src/bootloader/src/stm32fxxx_hal_msp.c index 2d292db09..2cae128ab 100644 --- a/src/bootloader/src/stm32fxxx_hal_msp.c +++ b/src/bootloader/src/stm32fxxx_hal_msp.c @@ -15,6 +15,18 @@ extern void SystemClock_Config(); void HAL_MspInit() { + GPIO_InitTypeDef GPIO_InitStructure; + GPIO_InitStructure.Pull = GPIO_PULLUP; + GPIO_InitStructure.Speed = GPIO_SPEED_LOW; + GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; + + #if defined(OMV_BOOTLDR_OSCEN_PIN) + OMV_BOOTLDR_OSCEN_CLK_ENABLE(); + GPIO_InitStructure.Pin = OMV_BOOTLDR_OSCEN_PIN; + HAL_GPIO_Init(OMV_BOOTLDR_OSCEN_PORT, &GPIO_InitStructure); + HAL_GPIO_WritePin(OMV_BOOTLDR_OSCEN_PORT, OMV_BOOTLDR_OSCEN_PIN, GPIO_PIN_SET); + #endif + // Set the system clock SystemClock_Config(); @@ -27,24 +39,35 @@ void HAL_MspInit() __GPIOC_CLK_ENABLE(); __GPIOD_CLK_ENABLE(); __GPIOE_CLK_ENABLE(); - -#if defined (STM32F769xx) + #ifdef OMV_ENABLE_GPIO_BANK_F __GPIOF_CLK_ENABLE(); + #endif + #ifdef OMV_ENABLE_GPIO_BANK_G __GPIOG_CLK_ENABLE(); + #endif + #ifdef OMV_ENABLE_GPIO_BANK_H __GPIOH_CLK_ENABLE(); + #endif + #ifdef OMV_ENABLE_GPIO_BANK_I __GPIOI_CLK_ENABLE(); + #endif + #ifdef OMV_ENABLE_GPIO_BANK_J __GPIOJ_CLK_ENABLE(); + #endif + #ifdef OMV_ENABLE_GPIO_BANK_K __GPIOK_CLK_ENABLE(); -#endif - - GPIO_InitTypeDef GPIO_InitStructure; - GPIO_InitStructure.Pull = GPIO_PULLUP; - GPIO_InitStructure.Speed = GPIO_SPEED_LOW; - GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; + #endif GPIO_InitStructure.Pin = OMV_BOOTLDR_LED_PIN; HAL_GPIO_Init(OMV_BOOTLDR_LED_PORT, &GPIO_InitStructure); HAL_GPIO_WritePin(OMV_BOOTLDR_LED_PORT, OMV_BOOTLDR_LED_PIN, GPIO_PIN_SET); + + #if defined(OMV_BOOTLDR_USBEN_PIN) + OMV_BOOTLDR_USBEN_CLK_ENABLE(); + GPIO_InitStructure.Pin = OMV_BOOTLDR_USBEN_PIN; + HAL_GPIO_Init(OMV_BOOTLDR_USBEN_PORT, &GPIO_InitStructure); + HAL_GPIO_WritePin(OMV_BOOTLDR_USBEN_PORT, OMV_BOOTLDR_USBEN_PIN, GPIO_PIN_SET); + #endif } #if defined(OMV_QSPIF_LAYOUT)