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:
benpicco 2019-12-05 15:08:16 +01:00 committed by GitHub
commit bcacd8e4c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -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

View File

@ -23,6 +23,10 @@
#include <stdlib.h>
#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);