From ece408a96ca6076a1117bce26cee6387d1369328 Mon Sep 17 00:00:00 2001 From: Frank Holtz Date: Sat, 9 May 2015 21:48:46 +0200 Subject: [PATCH] cpu/nrf51822/lpm_arch: add power modes --- cpu/nrf51822/lpm_arch.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/cpu/nrf51822/lpm_arch.c b/cpu/nrf51822/lpm_arch.c index 64821fc56a..c5c6955ed1 100644 --- a/cpu/nrf51822/lpm_arch.c +++ b/cpu/nrf51822/lpm_arch.c @@ -14,10 +14,12 @@ * @brief Implementation of the kernels power management interface * * @author Hauke Petersen + * @author Frank Holtz * * @} */ +#include "cpu.h" #include "arch/lpm_arch.h" void lpm_arch_init(void) @@ -27,8 +29,26 @@ void lpm_arch_init(void) enum lpm_mode lpm_arch_set(enum lpm_mode target) { - (void) target; - /* TODO: needs to be implemented */ + switch (target) { + /* wait for next interrupt */ + case LPM_IDLE: + case LPM_SLEEP: + case LPM_POWERDOWN: + __DSB(); + __WFI(); + break; + case LPM_OFF: + /* Switch of RAM and power off */ + NRF_POWER->RAMON = 0; + NRF_POWER->SYSTEMOFF = 1; + break; + + /* do nothing here */ + case LPM_UNKNOWN: + case LPM_ON: + default: + break; + } return 0; }