summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojciech Klimek <[email protected]>2024-04-01 14:51:46 +0200
committerWojciech Klimek <[email protected]>2024-04-01 14:51:46 +0200
commit057278c0c6c159880e11f9b16de5735d8fc821ce (patch)
tree0c81b6f6f32f891b1d5279549e6f8ceb4831fe4f
parent943a2a6db335d98843b73246fcce9aead0d38886 (diff)
Support for STM32H503 MCU - review changes
Implemented changes suggested in the review: - restored original name of SystemClock_Config() function - some GPIO clocks are only enabled if macros are defined - moved GPIO clocks init back to family.c
-rw-r--r--hw/bsp/stm32h5/boards/stm32h503nucleo/board.h15
-rw-r--r--hw/bsp/stm32h5/boards/stm32h563nucleo/board.h12
-rw-r--r--hw/bsp/stm32h5/boards/stm32h573i_dk/board.h12
-rw-r--r--hw/bsp/stm32h5/family.c19
-rw-r--r--src/portable/st/stm32_fsdev/dcd_stm32_fsdev.h2
5 files changed, 25 insertions, 35 deletions
diff --git a/hw/bsp/stm32h5/boards/stm32h503nucleo/board.h b/hw/bsp/stm32h5/boards/stm32h503nucleo/board.h
index 96c126ab8..0651b2694 100644
--- a/hw/bsp/stm32h5/boards/stm32h503nucleo/board.h
+++ b/hw/bsp/stm32h5/boards/stm32h503nucleo/board.h
@@ -51,21 +51,14 @@ extern "C" {
#define UART_TX_PIN GPIO_PIN_3
#define UART_RX_PIN GPIO_PIN_4
-// //--------------------------------------------------------------------+
-// // RCC Clock
-// //--------------------------------------------------------------------+
-static inline void board_clock_init(void)
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
- // Enable All GPIOs clocks
- __HAL_RCC_GPIOA_CLK_ENABLE();
- __HAL_RCC_GPIOB_CLK_ENABLE();
- __HAL_RCC_GPIOC_CLK_ENABLE();
- __HAL_RCC_GPIOD_CLK_ENABLE();
- __HAL_RCC_GPIOH_CLK_ENABLE();
-
/** Configure the main internal regulator output voltage
*/
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0);
diff --git a/hw/bsp/stm32h5/boards/stm32h563nucleo/board.h b/hw/bsp/stm32h5/boards/stm32h563nucleo/board.h
index ccbcbd8e2..df249242a 100644
--- a/hw/bsp/stm32h5/boards/stm32h563nucleo/board.h
+++ b/hw/bsp/stm32h5/boards/stm32h563nucleo/board.h
@@ -54,21 +54,11 @@ extern "C" {
//--------------------------------------------------------------------+
// RCC Clock
//--------------------------------------------------------------------+
-static inline void board_clock_init(void)
+static inline void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
- // Enable All GPIOs clocks
- __HAL_RCC_GPIOA_CLK_ENABLE();
- __HAL_RCC_GPIOB_CLK_ENABLE();
- __HAL_RCC_GPIOC_CLK_ENABLE();
- __HAL_RCC_GPIOD_CLK_ENABLE();
- __HAL_RCC_GPIOE_CLK_ENABLE();
- __HAL_RCC_GPIOG_CLK_ENABLE();
- __HAL_RCC_GPIOH_CLK_ENABLE();
- __HAL_RCC_GPIOI_CLK_ENABLE();
-
/** Configure the main internal regulator output voltage
*/
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0);
diff --git a/hw/bsp/stm32h5/boards/stm32h573i_dk/board.h b/hw/bsp/stm32h5/boards/stm32h573i_dk/board.h
index 87bf2ac1a..c58de13ee 100644
--- a/hw/bsp/stm32h5/boards/stm32h573i_dk/board.h
+++ b/hw/bsp/stm32h5/boards/stm32h573i_dk/board.h
@@ -54,20 +54,10 @@ extern "C" {
//--------------------------------------------------------------------+
// RCC Clock
//--------------------------------------------------------------------+
-static inline void board_clock_init(void) {
+static inline void SystemClock_Config(void) {
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
- // Enable All GPIOs clocks
- __HAL_RCC_GPIOA_CLK_ENABLE();
- __HAL_RCC_GPIOB_CLK_ENABLE();
- __HAL_RCC_GPIOC_CLK_ENABLE();
- __HAL_RCC_GPIOD_CLK_ENABLE();
- __HAL_RCC_GPIOE_CLK_ENABLE();
- __HAL_RCC_GPIOG_CLK_ENABLE();
- __HAL_RCC_GPIOH_CLK_ENABLE();
- __HAL_RCC_GPIOI_CLK_ENABLE();
-
/** Configure the main internal regulator output voltage */
HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);
diff --git a/hw/bsp/stm32h5/family.c b/hw/bsp/stm32h5/family.c
index 0ff09a259..e4a9666b7 100644
--- a/hw/bsp/stm32h5/family.c
+++ b/hw/bsp/stm32h5/family.c
@@ -59,9 +59,26 @@ UART_HandleTypeDef UartHandle;
void board_init(void) {
HAL_Init(); // required for HAL_RCC_Osc TODO check with freeRTOS
- board_clock_init(); // implemented in board.h
+ SystemClock_Config(); // implemented in board.h
SystemCoreClockUpdate();
+ // Enable All GPIOs clocks
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ __HAL_RCC_GPIOD_CLK_ENABLE();
+ __HAL_RCC_GPIOH_CLK_ENABLE();
+
+ #ifdef __HAL_RCC_GPIOE_CLK_ENABLE
+ __HAL_RCC_GPIOE_CLK_ENABLE();
+ #endif
+ #ifdef __HAL_RCC_GPIOG_CLK_ENABLE
+ __HAL_RCC_GPIOE_CLK_ENABLE();
+ #endif
+ #ifdef __HAL_RCC_GPIOI_CLK_ENABLE
+ __HAL_RCC_GPIOE_CLK_ENABLE();
+ #endif
+
UART_CLK_EN();
#if CFG_TUSB_OS == OPT_OS_NONE
diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.h b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.h
index 8cedee5d1..946ad2c7c 100644
--- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.h
+++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.h
@@ -116,7 +116,7 @@
#include "stm32h5xx.h"
#define FSDEV_BUS_32BIT
- #ifdef STM32H503xx
+ #if !defined(USB_DRD_BASE) && defined(USB_DRD_FS_BASE)
#define USB_DRD_BASE USB_DRD_FS_BASE
#endif