-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# name of your application | ||
APPLICATION = lpm_example | ||
|
||
# If no BOARD is found in the environment, use this default: | ||
BOARD ?= msbiot | ||
|
||
# This has to be the absolute path to the RIOT base directory: | ||
RIOTBASE ?= $(CURDIR)/../.. | ||
|
||
# Define default pin mappings for some boards: | ||
ifneq (,$(filter stm32f4discovery,$(BOARD))) | ||
export WKUP_GPIO ?= GPIO_0 | ||
endif | ||
ifneq (,$(filter msbiot,$(BOARD))) | ||
export WKUP_GPIO ?= GPIO_8 | ||
endif | ||
|
||
ifneq (,$(WKUP_GPIO)) | ||
CFLAGS += -DWKUP_GPIO=$(WKUP_GPIO) | ||
else | ||
# set random default | ||
CFLAGS += -DWKUP_GPIO=GPIO_0 | ||
endif | ||
|
||
# Comment this out to disable code in RIOT that does safety checking | ||
# which is not needed in a production environment but helps in the | ||
# development process: | ||
CFLAGS += -DDEVELHELP | ||
|
||
# Change this to 0 show compiler invocation lines by default: | ||
QUIET ?= 1 | ||
|
||
include $(RIOTBASE)/Makefile.include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (C) 2014 Freie Universität Berlin | ||
* | ||
* 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 examples | ||
* @{ | ||
* | ||
* @file | ||
* @brief LPM example application | ||
* | ||
* @author Fabian Nack <nack@inf.fu-berlin.de> | ||
* | ||
* @} | ||
*/ | ||
|
||
#ifndef WKUP_GPIO | ||
#error "WKUP_GPIO not defined" | ||
#endif | ||
|
||
#include <stdio.h> | ||
|
||
#include "cpu-conf.h" | ||
#include "periph/gpio.h" | ||
#include "arch/lpm_arch.h" | ||
|
||
static void button_handler(void *args) | ||
{ | ||
lpm_arch_awake(); | ||
} | ||
|
||
int main(void) | ||
{ | ||
puts("LPM example application"); | ||
|
||
gpio_init_int(WKUP_GPIO, GPIO_NOPULL, GPIO_RISING, &button_handler, 0); | ||
|
||
/* Check whether the device was reset from standby */ | ||
if (PWR->CSR & PWR_CSR_SBF) { | ||
puts("LPM tests successful"); | ||
PWR->CR |= PWR_CR_CSBF; | ||
return 0; | ||
} | ||
|
||
lpm_arch_init(); | ||
|
||
puts("Entering LPM_IDLE"); | ||
lpm_arch_set(LPM_IDLE); | ||
puts("Successfully awoke from LPM_IDLE"); | ||
|
||
puts("Entering LPM_SLEEP"); | ||
lpm_arch_set(LPM_SLEEP); | ||
puts("Successfully awoke from LPM_SLEEP"); | ||
|
||
puts("Entering LPM_POWERDOWN"); | ||
lpm_arch_set(LPM_POWERDOWN); | ||
|
||
/* Never reached */ | ||
return 0; | ||
} |