[PATCH] This patch adds support for a STM32H7 variation

Robin.Mueller robin.mueller.m at gmail.com
Wed Jan 6 16:05:30 UTC 2021


It was made so that  the default settings work out of the box for this board
This includes a new BSP configuration option and using different HSE value and console GPIO pins if that option is set.
---
 bsps/arm/stm32h7/console/console-usart3-cfg.c | 21 +++++++++++++++++++
 bsps/arm/stm32h7/include/stm32h7xx_hal_conf.h | 11 +++++++++-
 bsps/arm/stm32h7/include/stm32h7xx_hal_uart.h |  1 +
 bsps/arm/stm32h7/start/system_stm32h7xx.c     |  8 ++++++-
 spec/build/bsps/arm/stm32h7/bspstm32h7.yml    |  2 ++
 spec/build/bsps/arm/stm32h7/opth743nucleo.yml | 13 ++++++++++++
 6 files changed, 54 insertions(+), 2 deletions(-)
 create mode 100644 spec/build/bsps/arm/stm32h7/opth743nucleo.yml

diff --git a/bsps/arm/stm32h7/console/console-usart3-cfg.c b/bsps/arm/stm32h7/console/console-usart3-cfg.c
index b40f6da5aa..dc552610e1 100644
--- a/bsps/arm/stm32h7/console/console-usart3-cfg.c
+++ b/bsps/arm/stm32h7/console/console-usart3-cfg.c
@@ -25,12 +25,32 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifdef __rtems__
+#include <bspopts.h>
+#endif
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <stm32h7/hal.h>
 
+#if STM32H743ZI_NUCLEO == 1
+const stm32h7_uart_config stm32h7_usart3_config = {
+  .gpio = {
+    .regs = GPIOD,
+    .config = {
+      .Pin = GPIO_PIN_8 | GPIO_PIN_9,
+      .Mode = GPIO_MODE_AF_PP,
+      .Pull = GPIO_NOPULL,
+      .Speed = GPIO_SPEED_FREQ_LOW,
+      .Alternate = GPIO_AF7_USART3
+    }
+  },
+  .irq = USART3_IRQn,
+  .device_index = 2
+};
+#else
 const stm32h7_uart_config stm32h7_usart3_config = {
   .gpio = {
     .regs = GPIOB,
@@ -45,3 +65,4 @@ const stm32h7_uart_config stm32h7_usart3_config = {
   .irq = USART3_IRQn,
   .device_index = 2
 };
+#endif /*  STM32H743ZI_NUCLEO == 1 */
diff --git a/bsps/arm/stm32h7/include/stm32h7xx_hal_conf.h b/bsps/arm/stm32h7/include/stm32h7xx_hal_conf.h
index d423e4f782..b608188b4f 100644
--- a/bsps/arm/stm32h7/include/stm32h7xx_hal_conf.h
+++ b/bsps/arm/stm32h7/include/stm32h7xx_hal_conf.h
@@ -21,6 +21,9 @@
 #ifndef __STM32H7xx_HAL_CONF_H
 #define __STM32H7xx_HAL_CONF_H
 
+#ifdef __rtems__
+#include <bspopts.h>
+#endif /* __rtems__ */
 #ifdef __cplusplus
  extern "C" {
 #endif
@@ -103,7 +106,13 @@
   *        (when HSE is used as system clock source, directly or through the PLL).  
   */
 #if !defined  (HSE_VALUE) 
-#define HSE_VALUE    ((uint32_t)25000000) /*!< Value of the External oscillator in Hz : FPGA case fixed to 60MHZ */
+  #if STM32H743ZI_NUCLEO == 1
+    /*!< External oscillator clock for the STM32H743ZI Nucleo */
+    #define HSE_VALUE    ((uint32_t)8000000)
+  #else
+    /*!< Value of the External oscillator in Hz : FPGA case fixed to 60MHZ */
+    #define HSE_VALUE    ((uint32_t)25000000)
+  #endif /* STM32H743ZI_NUCLEO == 1 */
 #endif /* HSE_VALUE */
 
 #if !defined  (HSE_STARTUP_TIMEOUT)
diff --git a/bsps/arm/stm32h7/include/stm32h7xx_hal_uart.h b/bsps/arm/stm32h7/include/stm32h7xx_hal_uart.h
index e9fecc4aa0..b171f7dac7 100644
--- a/bsps/arm/stm32h7/include/stm32h7xx_hal_uart.h
+++ b/bsps/arm/stm32h7/include/stm32h7xx_hal_uart.h
@@ -27,6 +27,7 @@ extern "C" {
 
 /* Includes ------------------------------------------------------------------*/
 #include "stm32h7xx_hal_def.h"
+#include "stm32h7xx_hal_dma.h"
 
 /** @addtogroup STM32H7xx_HAL_Driver
   * @{
diff --git a/bsps/arm/stm32h7/start/system_stm32h7xx.c b/bsps/arm/stm32h7/start/system_stm32h7xx.c
index 092d853720..21b016d73b 100644
--- a/bsps/arm/stm32h7/start/system_stm32h7xx.c
+++ b/bsps/arm/stm32h7/start/system_stm32h7xx.c
@@ -48,10 +48,16 @@
 #include "stm32h7xx.h"
 #include <math.h>
 #ifdef __rtems__
+#include <bspopts.h>
 #include <bsp/linker-symbols.h>
 #endif /* __rtems__ */
+
 #if !defined  (HSE_VALUE)
-#define HSE_VALUE    ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */
+  #if STM32H743ZI_NUCLEO == 1
+    #define HSE_VALUE    ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
+  #else
+    #define HSE_VALUE    ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */
+  #endif /* STM32H743ZI_NUCLEO == 1 */
 #endif /* HSE_VALUE */
 
 #if !defined  (CSI_VALUE)
diff --git a/spec/build/bsps/arm/stm32h7/bspstm32h7.yml b/spec/build/bsps/arm/stm32h7/bspstm32h7.yml
index 1e54838c66..71a19cdbb9 100644
--- a/spec/build/bsps/arm/stm32h7/bspstm32h7.yml
+++ b/spec/build/bsps/arm/stm32h7/bspstm32h7.yml
@@ -244,6 +244,8 @@ links:
   uid: ../../optconsolebaud
 - role: build-dependency
   uid: ../../optconsoleirq
+- role: build-dependency
+  uid: opth743nucleo
 - role: build-dependency
   uid: ../grp
 - role: build-dependency
diff --git a/spec/build/bsps/arm/stm32h7/opth743nucleo.yml b/spec/build/bsps/arm/stm32h7/opth743nucleo.yml
new file mode 100644
index 0000000000..2c4176bf00
--- /dev/null
+++ b/spec/build/bsps/arm/stm32h7/opth743nucleo.yml
@@ -0,0 +1,13 @@
+actions:
+- get-boolean: null
+- define-condition: null
+build-type: option
+default: false
+default-by-variant: []
+enabled-by: true
+format: '{}'
+links: []
+name: STM32H743ZI_NUCLEO
+description: |
+  Nucleo board. Use 8 MHz HSE external clock and different pins for the UART console.
+type: build
-- 
2.25.1



More information about the devel mailing list