This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 16cbe92937aea7ea398d3b24edee11ed0c0abe64 Author: raiden00pl <[email protected]> AuthorDate: Mon Oct 12 09:34:44 2026 +0200 boards/arm/common/stm32: add common board initialization Add stm32_common_initialize() for the initialization shared by STM32 boards that use the common board logic (CONFIG_ARCH_BOARD_COMMON). For now it registers the IWDG as /dev/watchdog0 and the WWDG as /dev/watchdog1 when they are enabled. Signed-off-by: raiden00pl <[email protected]> Assisted-by: Claude Code --- boards/arm/common/stm32/include/board_common.h | 46 ++++++++++++++++++ boards/arm/common/stm32/src/CMakeLists.txt | 2 +- boards/arm/common/stm32/src/Make.defs | 2 + boards/arm/common/stm32/src/board_common.c | 66 ++++++++++++++++++++++++++ 4 files changed, 115 insertions(+), 1 deletion(-) diff --git a/boards/arm/common/stm32/include/board_common.h b/boards/arm/common/stm32/include/board_common.h new file mode 100644 index 00000000000..34b54fe8da9 --- /dev/null +++ b/boards/arm/common/stm32/include/board_common.h @@ -0,0 +1,46 @@ +/**************************************************************************** + * boards/arm/common/stm32/include/board_common.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_COMMON_STM32_INCLUDE_BOARD_COMMON_H +#define __BOARDS_ARM_COMMON_STM32_INCLUDE_BOARD_COMMON_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: stm32_common_initialize + * + * Description: + * Initialize the board features that are common to all STM32 boards. + * + ****************************************************************************/ + +int stm32_common_initialize(void); + +#endif /* __BOARDS_ARM_COMMON_STM32_INCLUDE_BOARD_COMMON_H */ diff --git a/boards/arm/common/stm32/src/CMakeLists.txt b/boards/arm/common/stm32/src/CMakeLists.txt index 6175c5a0c30..635c011a731 100644 --- a/boards/arm/common/stm32/src/CMakeLists.txt +++ b/boards/arm/common/stm32/src/CMakeLists.txt @@ -20,7 +20,7 @@ # # ############################################################################## -set(SRCS) +set(SRCS board_common.c) if(CONFIG_SENSORS_BMP180) list(APPEND SRCS stm32_bmp180.c) diff --git a/boards/arm/common/stm32/src/Make.defs b/boards/arm/common/stm32/src/Make.defs index 3d92678a36b..9920ba1d515 100644 --- a/boards/arm/common/stm32/src/Make.defs +++ b/boards/arm/common/stm32/src/Make.defs @@ -24,6 +24,8 @@ ifeq ($(CONFIG_ARCH_BOARD_COMMON),y) STM32_BOARD_COMMON_DIR := $(TOPDIR)$(DELIM)boards$(DELIM)arm$(DELIM)common$(DELIM)stm32 +CSRCS += board_common.c + ifeq ($(CONFIG_SENSORS_BMP180),y) CSRCS += stm32_bmp180.c endif diff --git a/boards/arm/common/stm32/src/board_common.c b/boards/arm/common/stm32/src/board_common.c new file mode 100644 index 00000000000..e31706756a8 --- /dev/null +++ b/boards/arm/common/stm32/src/board_common.c @@ -0,0 +1,66 @@ +/**************************************************************************** + * boards/arm/common/stm32/src/board_common.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <sys/types.h> + +#include <arch/board/board.h> + +#if defined(CONFIG_STM32_IWDG) || defined(CONFIG_STM32_WWDG) +# include "stm32_wdg.h" +#endif + +#include "board_common.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: stm32_common_initialize + * + * Description: + * Initialize the board features that are common to all STM32 boards. + * + ****************************************************************************/ + +int stm32_common_initialize(void) +{ +#ifdef CONFIG_STM32_IWDG + /* Initialize the independent watchdog */ + + stm32_iwdginitialize("/dev/watchdog0", STM32_LSI_FREQUENCY); +#endif + +#ifdef CONFIG_STM32_WWDG + /* Initialize the window watchdog */ + + stm32_wwdginitialize("/dev/watchdog1"); +#endif + + return OK; +}
