diff --git a/tests/periph_pm/Makefile b/tests/periph_pm/Makefile index 78d9538197..16bb20073b 100644 --- a/tests/periph_pm/Makefile +++ b/tests/periph_pm/Makefile @@ -5,6 +5,7 @@ include ../Makefile.tests_common BOARD_BLACKLIST := chronos msb-430h msb-430 telosb wsn430-v1_3b wsn430-v1_4 z1 FEATURES_OPTIONAL += periph_rtc +FEATURES_OPTIONAL += periph_gpio_irq USEMODULE += shell diff --git a/tests/periph_pm/main.c b/tests/periph_pm/main.c index 4fe74b3bfa..71f72b8abb 100644 --- a/tests/periph_pm/main.c +++ b/tests/periph_pm/main.c @@ -23,6 +23,10 @@ #include #include "periph/pm.h" +#ifdef MODULE_PERIPH_GPIO +#include "board.h" +#include "periph/gpio.h" +#endif #ifdef MODULE_PM_LAYERED #ifdef MODULE_PERIPH_RTC #include "periph/rtc.h" @@ -204,6 +208,15 @@ static int cmd_unblock_rtc(int argc, char **argv) #endif /* MODULE_PERIPH_RTC */ #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. */ @@ -241,6 +254,11 @@ int main(void) "needed."); #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 */ shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);