From 9eef0f566dd33a6c672cc2e222090db6d13a7f82 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 14 Jul 2023 15:27:02 +0200 Subject: [PATCH 1/4] boards/nrf52840dk: define reset button --- boards/nrf52840dk/include/board.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/boards/nrf52840dk/include/board.h b/boards/nrf52840dk/include/board.h index 0874aff0abb4..7c404790d876 100644 --- a/boards/nrf52840dk/include/board.h +++ b/boards/nrf52840dk/include/board.h @@ -94,6 +94,11 @@ extern mtd_dev_t *mtd0; #define BTN2_MODE GPIO_IN_PU #define BTN3_PIN GPIO_PIN(0, 25) #define BTN3_MODE GPIO_IN_PU +#define BTN4_PIN GPIO_PIN(0, 18) +#define BTN4_MODE GPIO_IN_PU + +#define BTN_RST_PIN BTN4_PIN /**< reset button */ +#define BTN_RST_MODE BTN4_MODE /**< reset button mode */ /** @} */ #ifdef __cplusplus From a4db4db957a9dd42af8acebf91aed46d8425506c Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 14 Jul 2023 15:34:59 +0200 Subject: [PATCH 2/4] boards/e104-bt50xxa-tb: define reset button --- boards/common/e104-bt50xxa-tb/include/board.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/boards/common/e104-bt50xxa-tb/include/board.h b/boards/common/e104-bt50xxa-tb/include/board.h index 058aadd64399..476f41012ad4 100644 --- a/boards/common/e104-bt50xxa-tb/include/board.h +++ b/boards/common/e104-bt50xxa-tb/include/board.h @@ -54,6 +54,9 @@ extern "C" { #define BTN0_MODE GPIO_IN_PU #define BTN1_PIN GPIO_PIN(0, 29) #define BTN1_MODE GPIO_IN_PU + +#define BTN_RST_PIN BTN0_PIN /**< reset button */ +#define BTN_RST_MODE BTN0_MODE /**< reset button mode */ /** @} */ #ifdef __cplusplus From c7c31f2993ff7e5c6ca8e96158d8f4500945a1d9 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 14 Jul 2023 15:32:02 +0200 Subject: [PATCH 3/4] sys/board_software_reset: add module for soft-reset button --- boards/common/e104-bt50xxa-tb/Makefile.dep | 6 ---- boards/common/e104-bt50xxa-tb/board.c | 35 ------------------- makefiles/pseudomodules.inc.mk | 10 ------ sys/board_software_reset/Makefile | 1 + sys/board_software_reset/Makefile.dep | 2 ++ sys/board_software_reset/init_reset_btn.c | 40 ++++++++++++++++++++++ 6 files changed, 43 insertions(+), 51 deletions(-) delete mode 100644 boards/common/e104-bt50xxa-tb/board.c create mode 100644 sys/board_software_reset/Makefile create mode 100644 sys/board_software_reset/Makefile.dep create mode 100644 sys/board_software_reset/init_reset_btn.c diff --git a/boards/common/e104-bt50xxa-tb/Makefile.dep b/boards/common/e104-bt50xxa-tb/Makefile.dep index 6d8bd098b2dc..7317b22d44d8 100644 --- a/boards/common/e104-bt50xxa-tb/Makefile.dep +++ b/boards/common/e104-bt50xxa-tb/Makefile.dep @@ -2,10 +2,4 @@ ifneq (,$(filter saul_default,$(USEMODULE))) USEMODULE += saul_gpio endif -# used for software reset -ifneq (,$(filter board_software_reset,$(USEMODULE))) - FEATURES_REQUIRED += periph_gpio_irq - FEATURES_REQUIRED += periph_pm -endif - include $(RIOTBOARD)/common/nrf52/Makefile.dep diff --git a/boards/common/e104-bt50xxa-tb/board.c b/boards/common/e104-bt50xxa-tb/board.c deleted file mode 100644 index f77f6e4c7b61..000000000000 --- a/boards/common/e104-bt50xxa-tb/board.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2020 Benjamin Valentin - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @ingroup boards_common_e104-bt50xxa-tb - * @{ - * - * @file - * @brief Board initialization for the E104-BT50xxA Test Board - * - * @author Benjamin Valentin - * - * @} - */ - -#include "cpu.h" -#include "board.h" -#include "periph/gpio.h" - -extern void pm_reboot(void*); - -void board_init(void) -{ - /* configure software RST button */ -#ifdef MODULE_BOARD_SOFTWARE_RESET - gpio_init_int(BTN0_PIN, BTN0_MODE, GPIO_FALLING, - pm_reboot, NULL); -#endif - -} diff --git a/makefiles/pseudomodules.inc.mk b/makefiles/pseudomodules.inc.mk index 602281a02eed..1dc78fa6b133 100644 --- a/makefiles/pseudomodules.inc.mk +++ b/makefiles/pseudomodules.inc.mk @@ -23,16 +23,6 @@ PSEUDOMODULES += atomic_utils PSEUDOMODULES += base64url -## @defgroup pseudomodule_board_software_reset board_software_reset -## @brief Use any software-only reset button on the board to reboot -## -## Some boards have reset buttons that are not wired to the MCU's reset line, -## but merely are configured to cause a reset by convention. -## -## If this module is active, the button will be configured thusly (and then not -## be advertised in any other capacity, e.g. through @ref sys_auto_init_saul). -PSEUDOMODULES += board_software_reset - PSEUDOMODULES += arduino_pwm PSEUDOMODULES += arduino_serial_stdio PSEUDOMODULES += can_mbox diff --git a/sys/board_software_reset/Makefile b/sys/board_software_reset/Makefile new file mode 100644 index 000000000000..48422e909a47 --- /dev/null +++ b/sys/board_software_reset/Makefile @@ -0,0 +1 @@ +include $(RIOTBASE)/Makefile.base diff --git a/sys/board_software_reset/Makefile.dep b/sys/board_software_reset/Makefile.dep new file mode 100644 index 000000000000..df93e1867bb0 --- /dev/null +++ b/sys/board_software_reset/Makefile.dep @@ -0,0 +1,2 @@ +FEATURES_REQUIRED += periph_gpio_irq +FEATURES_REQUIRED += periph_pm diff --git a/sys/board_software_reset/init_reset_btn.c b/sys/board_software_reset/init_reset_btn.c new file mode 100644 index 000000000000..63513f377bc4 --- /dev/null +++ b/sys/board_software_reset/init_reset_btn.c @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2020 Benjamin Valentin + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @@defgroup module_board_software_reset board_software_reset + * @brief Use any software-only reset button on the board to reboot + * + * Some boards have reset buttons that are not wired to the MCU's reset line, + * but merely are configured to cause a reset by convention. + * + * If this module is active, the button will be configured thusly (and then not + * be advertised in any other capacity, e.g. through @ref sys_auto_init_saul). + * + * @author Benjamin Valentin + */ + +#include "auto_init.h" +#include "auto_init_utils.h" +#include "board.h" +#include "periph/gpio.h" + +#ifndef BTN_RST_INT_FLANK +#define BTN_RST_INT_FLANK GPIO_FALLING +#endif + +extern void pm_reboot(void*); + +static void init_reset_btn(void) +{ + /* configure software RST button */ + gpio_init_int(BTN_RST_PIN, BTN_RST_MODE, BTN_RST_INT_FLANK, + pm_reboot, NULL); +} + +AUTO_INIT(init_reset_btn, 0); From c8630a7126c500a7950690f9c7b9555040f8117a Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 14 Jul 2023 15:36:53 +0200 Subject: [PATCH 4/4] boards/nrf52840dk: enable soft-reset by default --- boards/nrf52840dk/Makefile.default | 1 + 1 file changed, 1 insertion(+) create mode 100644 boards/nrf52840dk/Makefile.default diff --git a/boards/nrf52840dk/Makefile.default b/boards/nrf52840dk/Makefile.default new file mode 100644 index 000000000000..059ee4901720 --- /dev/null +++ b/boards/nrf52840dk/Makefile.default @@ -0,0 +1 @@ +DEFAULT_MODULE += board_software_reset