Merge pull request #12710 from benpicco/tests/periph_pm-button
tests/periph_pm: use button as a wake-up source
This commit is contained in:
commit
bcacd8e4c3
@ -5,6 +5,7 @@ include ../Makefile.tests_common
|
|||||||
BOARD_BLACKLIST := chronos msb-430h msb-430 telosb wsn430-v1_3b wsn430-v1_4 z1
|
BOARD_BLACKLIST := chronos msb-430h msb-430 telosb wsn430-v1_3b wsn430-v1_4 z1
|
||||||
|
|
||||||
FEATURES_OPTIONAL += periph_rtc
|
FEATURES_OPTIONAL += periph_rtc
|
||||||
|
FEATURES_OPTIONAL += periph_gpio_irq
|
||||||
|
|
||||||
USEMODULE += shell
|
USEMODULE += shell
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "periph/pm.h"
|
#include "periph/pm.h"
|
||||||
|
#ifdef MODULE_PERIPH_GPIO
|
||||||
|
#include "board.h"
|
||||||
|
#include "periph/gpio.h"
|
||||||
|
#endif
|
||||||
#ifdef MODULE_PM_LAYERED
|
#ifdef MODULE_PM_LAYERED
|
||||||
#ifdef MODULE_PERIPH_RTC
|
#ifdef MODULE_PERIPH_RTC
|
||||||
#include "periph/rtc.h"
|
#include "periph/rtc.h"
|
||||||
@ -204,6 +208,15 @@ static int cmd_unblock_rtc(int argc, char **argv)
|
|||||||
#endif /* MODULE_PERIPH_RTC */
|
#endif /* MODULE_PERIPH_RTC */
|
||||||
#endif /* MODULE_PM_LAYERED */
|
#endif /* MODULE_PM_LAYERED */
|
||||||
|
|
||||||
|
#if defined(MODULE_PERIPH_GPIO_IRQ) && defined(BTN0_PIN)
|
||||||
|
static void btn_cb(void *ctx)
|
||||||
|
{
|
||||||
|
(void) ctx;
|
||||||
|
puts("BTN0 pressed.");
|
||||||
|
}
|
||||||
|
#endif /* MODULE_PERIPH_GPIO_IRQ */
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief List of shell commands for this example.
|
* @brief List of shell commands for this example.
|
||||||
*/
|
*/
|
||||||
@ -241,6 +254,11 @@ int main(void)
|
|||||||
"needed.");
|
"needed.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODULE_PERIPH_GPIO_IRQ) && defined(BTN0_PIN)
|
||||||
|
puts("using BTN0 as wake-up source");
|
||||||
|
gpio_init_int(BTN0_PIN, BTN0_MODE, GPIO_RISING, btn_cb, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* run the shell and wait for the user to enter a mode */
|
/* run the shell and wait for the user to enter a mode */
|
||||||
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
|
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user