[PATCH v1 2/2] bsps/stm32h7: Configure UART clocks when enabled

Kinsey Moore kinsey.moore at oarcorp.com
Mon Jul 24 18:28:33 UTC 2023


This change allows configuration of all enabled UART clocks without
direct modificaton of the exiting BSP.
---
 .../stm/stm32h743i-eval/stm32h7-config-per.c  | 41 +++++++++++++++++--
 1 file changed, 38 insertions(+), 3 deletions(-)

diff --git a/bsps/arm/stm32h7/boards/stm/stm32h743i-eval/stm32h7-config-per.c b/bsps/arm/stm32h7/boards/stm/stm32h743i-eval/stm32h7-config-per.c
index 8ca665915f..dcce247a51 100644
--- a/bsps/arm/stm32h7/boards/stm/stm32h743i-eval/stm32h7-config-per.c
+++ b/bsps/arm/stm32h7/boards/stm/stm32h743i-eval/stm32h7-config-per.c
@@ -32,9 +32,34 @@
 #include <stm32h7/hal.h>
 
 const RCC_PeriphCLKInitTypeDef stm32h7_config_peripheral_clocks = {
-  .PeriphClockSelection = RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_USART3
-    | RCC_PERIPHCLK_FDCAN | RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_I2C1
-    | RCC_PERIPHCLK_USB | RCC_PERIPHCLK_FMC | RCC_PERIPHCLK_RNG,
+  .PeriphClockSelection = RCC_PERIPHCLK_RTC
+    | RCC_PERIPHCLK_FDCAN | RCC_PERIPHCLK_I2C1
+    | RCC_PERIPHCLK_USB | RCC_PERIPHCLK_FMC | RCC_PERIPHCLK_RNG
+#ifdef STM32H7_CONSOLE_ENABLE_USART1
+    | RCC_PERIPHCLK_USART1
+#endif
+#ifdef STM32H7_CONSOLE_ENABLE_USART2
+    | RCC_PERIPHCLK_USART2
+#endif
+#ifdef STM32H7_CONSOLE_ENABLE_USART3
+    | RCC_PERIPHCLK_USART3
+#endif
+#ifdef STM32H7_CONSOLE_ENABLE_UART4
+    | RCC_PERIPHCLK_UART4
+#endif
+#ifdef STM32H7_CONSOLE_ENABLE_UART5
+    | RCC_PERIPHCLK_UART5
+#endif
+#ifdef STM32H7_CONSOLE_ENABLE_USART6
+    | RCC_PERIPHCLK_USART6
+#endif
+#ifdef STM32H7_CONSOLE_ENABLE_UART7
+    | RCC_PERIPHCLK_UART7
+#endif
+#ifdef STM32H7_CONSOLE_ENABLE_UART8
+    | RCC_PERIPHCLK_UART8
+#endif
+  ,
   .PLL2.PLL2M = 3,
   .PLL2.PLL2N = 48,
   .PLL2.PLL2P = 1,
@@ -53,8 +78,18 @@ const RCC_PeriphCLKInitTypeDef stm32h7_config_peripheral_clocks = {
   .PLL3.PLL3FRACN = 0,
   .FmcClockSelection = RCC_FMCCLKSOURCE_PLL2,
   .FdcanClockSelection = RCC_FDCANCLKSOURCE_PLL,
+#if defined(STM32H7_CONSOLE_ENABLE_USART2) \
+  || defined(STM32H7_CONSOLE_ENABLE_USART3) \
+  || defined(STM32H7_CONSOLE_ENABLE_UART4) \
+  || defined(STM32H7_CONSOLE_ENABLE_UART5) \
+  || defined(STM32H7_CONSOLE_ENABLE_UART7) \
+  || defined(STM32H7_CONSOLE_ENABLE_UART8)
   .Usart234578ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1,
+#endif
+#if defined(STM32H7_CONSOLE_ENABLE_USART1) \
+  || defined(STM32H7_CONSOLE_ENABLE_USART6)
   .Usart16ClockSelection = RCC_USART16CLKSOURCE_D2PCLK2,
+#endif
   .I2c123ClockSelection = RCC_I2C123CLKSOURCE_D2PCLK1,
   .UsbClockSelection = RCC_USBCLKSOURCE_PLL3,
   .RTCClockSelection = RCC_RTCCLKSOURCE_LSE,
-- 
2.39.2



More information about the devel mailing list