Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys/board_software_reset: add module for soft-reset button #19833

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions boards/common/e104-bt50xxa-tb/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -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
35 changes: 0 additions & 35 deletions boards/common/e104-bt50xxa-tb/board.c

This file was deleted.

3 changes: 3 additions & 0 deletions boards/common/e104-bt50xxa-tb/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions boards/nrf52840dk/Makefile.default
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DEFAULT_MODULE += board_software_reset
5 changes: 5 additions & 0 deletions boards/nrf52840dk/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions makefiles/pseudomodules.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions sys/board_software_reset/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(RIOTBASE)/Makefile.base
2 changes: 2 additions & 0 deletions sys/board_software_reset/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FEATURES_REQUIRED += periph_gpio_irq
FEATURES_REQUIRED += periph_pm
40 changes: 40 additions & 0 deletions sys/board_software_reset/init_reset_btn.c
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

@aabadie aabadie Sep 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @@defgroup module_board_software_reset board_software_reset
* @defgroup board_software_reset Board software reset
* @ingroup sys

Should fix the not showing up documentation

* @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 <benpicco@googlemail.com>
*/

#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);