Browse Source

remove obsolete lpm code

pr/spi.typo
Kaspar Schleiser 6 years ago
parent
commit
0194091673
  1. 7
      boards/avsextrem/drivers/avsextrem-smb380.c
  2. 1
      boards/avsextrem/drivers/avsextrem-ssp0.c
  3. 53
      boards/qemu-i386/x86_board_lpm.c
  4. 100
      core/include/arch/lpm_arch.h
  5. 77
      core/include/lpm.h
  6. 14
      core/kernel_init.c
  7. 1
      core/panic.c
  8. 6
      cpu/arm7_common/panic.c
  9. 54
      cpu/atmega1281/lpm_arch.c
  10. 54
      cpu/atmega2560/lpm_arch.c
  11. 54
      cpu/atmega328p/lpm_arch.c
  12. 5
      cpu/atmega_common/panic.c
  13. 48
      cpu/cc2538/lpm_arch.c
  14. 45
      cpu/cc26x0/lpm_arch.c
  15. 9
      cpu/cortexm_common/panic.c
  16. 53
      cpu/ezr32wg/lpm_arch.c
  17. 81
      cpu/k60/lpm_arch.c
  18. 53
      cpu/k64f/lpm_arch.c
  19. 53
      cpu/kw2x/lpm_arch.c
  20. 53
      cpu/lm4f120/lpm_arch.c
  21. 54
      cpu/lpc11u34/lpm_arch.c
  22. 54
      cpu/lpc1768/lpm_arch.c
  23. 118
      cpu/lpc2387/lpc2387-lpm.c
  24. 4
      cpu/lpc2387/periph/rtc.c
  25. 128
      cpu/msp430-common/lpm_cpu.c
  26. 1
      cpu/msp430-common/msp430-main.c
  27. 6
      cpu/msp430-common/panic.c
  28. 4
      cpu/native/irq_cpu.c
  29. 123
      cpu/native/lpm_cpu.c
  30. 74
      cpu/nrf51/lpm_arch.c
  31. 72
      cpu/nrf52/lpm_arch.c
  32. 54
      cpu/sam3/lpm_arch.c
  33. 126
      cpu/samd21/lpm_arch.c
  34. 4
      cpu/saml21/cpu.c
  35. 95
      cpu/saml21/lpm_arch.c
  36. 54
      cpu/stm32f0/lpm_arch.c
  37. 98
      cpu/stm32f1/lpm_arch.c
  38. 98
      cpu/stm32f2/lpm_arch.c
  39. 53
      cpu/stm32f3/lpm_arch.c
  40. 98
      cpu/stm32f4/lpm_arch.c
  41. 53
      cpu/stm32l1/lpm_arch.c
  42. 5
      cpu/x86/panic.c
  43. 3
      tests/thread_flood/main.c
  44. 1
      tests/unittests/main.c

7
boards/avsextrem/drivers/avsextrem-smb380.c

@ -29,7 +29,6 @@
#include "lpc23xx.h" /* LPC23XX/24xx Peripheral Registers */
#include "cpu.h"
#include "lpm.h"
#include "VIC.h"
#include "ssp0-board.h"
#include "smb380-board.h"
@ -142,8 +141,6 @@ uint8_t SMB380_HystereseFunctionSample(int16_t *value)
static void SMB380_simple_interrupthandler(void)
{
lpm_awake();
SMB380_getAcceleration(SMB380_X_AXIS, NULL, &simple_buffer[0]);
SMB380_getAcceleration(SMB380_Y_AXIS, NULL, &simple_buffer[1]);
SMB380_getAcceleration(SMB380_Z_AXIS, NULL, &simple_buffer[2]);
@ -249,8 +246,6 @@ static void SMB380_extIntHandler(void)
{
int16_t accInt[4];
lpm_awake(); //initializes clock
SMB380_getAcceleration(SMB380_X_AXIS, NULL, &accInt[0]);
SMB380_getAcceleration(SMB380_Y_AXIS, NULL, &accInt[1]);
SMB380_getAcceleration(SMB380_Z_AXIS, NULL, &accInt[2]);
@ -1021,7 +1016,6 @@ void SMB380_enableNewDataInt(void)
* prevent deep sleep, reason: 400 µs wake-up time is to long for 3kHz
* interrupts
*/
SETBIT(lpm_prevent_sleep, LPM_PREVENT_SLEEP_ACCSENSOR);
SMB380_Prepare();
SMB380_ssp_write(SMB380_CONTROL4, 0, SMB380_READ_REGISTER);
uReg = SMB380_ssp_read();
@ -1050,7 +1044,6 @@ void SMB380_disableNewDataInt(void)
* enable deep sleep, reason: 400 µs wake-up time was to long for 3kHz
* interrupts
*/
CLRBIT(lpm_prevent_sleep, LPM_PREVENT_SLEEP_ACCSENSOR);
irq_restore(cpsr);
}

1
boards/avsextrem/drivers/avsextrem-ssp0.c

@ -29,7 +29,6 @@
//#include "mma7455l-board.h"
#include "gpioint.h"
#include <stdio.h>
#include "lpm.h"
//uint16_t sampleRateMMA7455L;
//uint16_t interruptTicksMMA7455L;

53
boards/qemu-i386/x86_board_lpm.c

@ -1,53 +0,0 @@
/*
* Copyright (C) 2014 René Kijewski <rene.kijewski@fu-berlin.de>
*
* 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 boards_qemu-i386
* @{
*
* @file
* @brief Low-power mode emulation for qemu-i386.
*
* @author René Kijewski <rene.kijewski@fu-berlin.de>
*
* @}
*/
#include "lpm.h"
#include "x86_reboot.h"
void lpm_init(void)
{
/* void */
}
enum lpm_mode lpm_set(enum lpm_mode target)
{
if (target != LPM_ON) {
if (target == LPM_POWERDOWN) {
x86_shutdown();
}
__asm__ volatile ("hlt");
}
return LPM_UNKNOWN;
}
void lpm_awake(void)
{
/* void */
}
void lpm_begin_awake(void)
{
/* void */
}
void lpm_end_awake(void)
{
/* void */
}

100
core/include/arch/lpm_arch.h

@ -1,100 +0,0 @@
/*
* 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 core_arch
* @{
*
* @file
* @brief Architecture dependent interface for power mode management
*
* This file acts as a wrapper between the kernels power management interface and the architecture
* dependent implementation of power management.
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*/
#ifndef LPM_ARCH_H
#define LPM_ARCH_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Define the mapping between the architecture independent interfaces
and the kernel internal interfaces
*
* This mapping is done for compatibility of existing platforms,
* new platforms should always use the *_arch_* interfaces.
* @{
*/
#ifdef COREIF_NG
#define lpm_init lpm_arch_init
#define lpm_set lpm_arch_set
#define lpm_get lpm_arch_get
#define lpm_awake lpm_arch_awake
#define lpm_begin_awake lpm_arch_begin_awake
#define lpm_end_awake lpm_arch_end_awake
#endif
/** @} */
/**
* @name Available power modes
*/
enum lpm_mode {
LPM_ON, /**< MCU is active */
LPM_IDLE, /**< MCU is idle */
LPM_SLEEP, /**< MCU in sleep mode */
LPM_POWERDOWN, /**< MCU is powered down */
LPM_OFF, /**< MCU is off */
LPM_UNKNOWN = -1 /**< status unknown/unavailable */
};
/**
* @brief Initialize the controller power management
*/
void lpm_arch_init(void);
/**
* @brief Try to set the controller to a given power mode
*
* @param[in] target the desired power mode
*
* @return the power mode that was actually set
*/
enum lpm_mode lpm_arch_set(enum lpm_mode target);
/**
* @brief Get the controller's current power mode
*
* @return the power mode the controller is currently in
*/
enum lpm_mode lpm_arch_get(void);
/**
* @brief Wakeup the controller from a low-power sleep mode
*/
void lpm_arch_awake(void);
/**
* @brief This hook is called on the beginning of a wake-up phase
*/
void lpm_arch_begin_awake(void);
/**
* @brief This hook is called on the end of a wake-up phase
*/
void lpm_arch_end_awake(void);
#ifdef __cplusplus
}
#endif
#endif /* LPM_ARCH_H */
/** @} */

77
core/include/lpm.h

@ -1,77 +0,0 @@
/*
* Copyright (C) 2013 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.
*/
/**
* @defgroup core_lpm Power Management
* @ingroup core
* @brief The kernels power management interface
* @{
*
* @file
* @brief Power management interface
*
* This interface needs to be implemented for each platform.
*
* @author Freie Universität Berlin, Computer Systems & Telematics
*/
#ifndef LPM_H_
#define LPM_H_
#include "arch/lpm_arch.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialization of power management (including clock setup)
*
* This function is invoked once during boot.
*/
void lpm_init(void);
/**
* @brief Switches the MCU to a new power mode
* @param[in] target Target power mode
* @return The previous power mode
*/
enum lpm_mode lpm_set(enum lpm_mode target);
/**
* @brief Switches the MCU to active power mode LPM_ON
*/
void lpm_awake(void);
/**
* @brief Begin to switch MCU to active power mode.
*/
void lpm_begin_awake(void);
/**
* @brief Finish to switch MCU to active power mode.
*/
void lpm_end_awake(void);
/**
* @brief Returns the current power mode
* @return Current power mode
*/
enum lpm_mode lpm_get(void);
/**
* @brief LPM-internal variable
*/
extern volatile int lpm_prevent_sleep;
#ifdef __cplusplus
}
#endif
#endif /* __LPM_H_ */
/** @} */

14
core/kernel_init.c

@ -1,5 +1,6 @@
/*
* Copyright (C) 2013 Freie Universität Berlin
* Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de>
* 2013 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
@ -24,7 +25,6 @@
#include "kernel_init.h"
#include "sched.h"
#include "thread.h"
#include "lpm.h"
#include "irq.h"
#include "log.h"
@ -39,8 +39,6 @@
#include <auto_init.h>
#endif
volatile int lpm_prevent_sleep = 0;
extern int main(void);
static void *main_trampoline(void *arg)
{
@ -66,14 +64,6 @@ static void *idle_thread(void *arg)
(void) arg;
while (1) {
if (lpm_prevent_sleep) {
lpm_set(LPM_IDLE);
}
else {
lpm_set(LPM_IDLE);
/* lpm_set(LPM_SLEEP); */
/* lpm_set(LPM_POWERDOWN); */
}
}
return NULL;

1
core/panic.c

@ -28,7 +28,6 @@
#include "kernel_defines.h"
#include "cpu.h"
#include "irq.h"
#include "lpm.h"
#include "panic.h"
#include "arch/panic_arch.h"
#include "reboot.h"

6
cpu/arm7_common/panic.c

@ -17,14 +17,10 @@
* @author Oliver Hahm <oliver.hahm@inria.fr>
*/
#include "lpm.h"
void panic_arch(void)
{
#ifdef DEVELHELP
/* enter infinite loop, into deepest possible sleep mode */
while (1) {
lpm_set(LPM_OFF);
}
// TODO
#endif
}

54
cpu/atmega1281/lpm_arch.c

@ -1,54 +0,0 @@
/*
* Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen
*
* 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 cpu_atmega1281
* @{
*
* @file
* @brief Implementation of the kernels power management interface
*
* @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
*
* @}
*/
#include "arch/lpm_arch.h"
void lpm_arch_init(void)
{
/* TODO */
}
enum lpm_mode lpm_arch_set(enum lpm_mode target)
{
(void) target;
/* TODO */
return 0;
}
enum lpm_mode lpm_arch_get(void)
{
/* TODO */
return 0;
}
void lpm_arch_awake(void)
{
/* TODO */
}
void lpm_arch_begin_awake(void)
{
/* TODO */
}
void lpm_arch_end_awake(void)
{
/* TODO */
}

54
cpu/atmega2560/lpm_arch.c

@ -1,54 +0,0 @@
/*
* Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen
*
* 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 cpu_atmega2560
* @{
*
* @file
* @brief Implementation of the kernels power management interface
*
* @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
*
* @}
*/
#include "arch/lpm_arch.h"
void lpm_arch_init(void)
{
/* TODO */
}
enum lpm_mode lpm_arch_set(enum lpm_mode target)
{
(void) target;
/* TODO */
return 0;
}
enum lpm_mode lpm_arch_get(void)
{
/* TODO */
return 0;
}
void lpm_arch_awake(void)
{
/* TODO */
}
void lpm_arch_begin_awake(void)
{
/* TODO */
}
void lpm_arch_end_awake(void)
{
/* TODO */
}

54
cpu/atmega328p/lpm_arch.c

@ -1,54 +0,0 @@
/*
* Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen
*
* 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 cpu_atmega328p
* @{
*
* @file
* @brief Implementation of the kernels power management interface
*
* @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
*
* @}
*/
#include "arch/lpm_arch.h"
void lpm_arch_init(void)
{
/* TODO */
}
enum lpm_mode lpm_arch_set(enum lpm_mode target)
{
(void) target;
/* TODO */
return 0;
}
enum lpm_mode lpm_arch_get(void)
{
/* TODO */
return 0;
}
void lpm_arch_awake(void)
{
/* TODO */
}
void lpm_arch_begin_awake(void)
{
/* TODO */
}
void lpm_arch_end_awake(void)
{
/* TODO */
}

5
cpu/atmega_common/panic.c

@ -17,16 +17,13 @@
*/
#include <avr/wdt.h>
#include "lpm.h"
void panic_arch(void)
{
wdt_disable();
#ifdef DEVELHELP
/* enter infinite loop, into deepest possible sleep mode */
while (1) {
lpm_set(LPM_OFF);
}
// TODO
#endif
}

48
cpu/cc2538/lpm_arch.c

@ -1,48 +0,0 @@
/*
* Copyright (C) 2014 Loci Controls Inc.
*
* 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 cpu_cc2538
* @{
*
* @file
* @brief Implementation of the kernels power management interface
*
* @author Ian Martin <ian@locicontrols.com>
*
* @}
*/
#include "arch/lpm_arch.h"
void lpm_arch_init(void)
{
}
enum lpm_mode lpm_arch_set(enum lpm_mode target)
{
(void) target;
return 0;
}
enum lpm_mode lpm_arch_get(void)
{
return 0;
}
void lpm_arch_awake(void)
{
}
void lpm_arch_begin_awake(void)
{
}
void lpm_arch_end_awake(void)
{
}

45
cpu/cc26x0/lpm_arch.c

@ -1,45 +0,0 @@
/*
* Copyright (C) 2016 Leon George
*
* 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 cpu_cc26x0
* @{
*
* @file
* @brief implementation of the kernels power management interface
*
* @}
*/
#include "arch/lpm_arch.h"
void lpm_arch_init(void)
{
}
enum lpm_mode lpm_arch_set(enum lpm_mode target)
{
return 0;
}
enum lpm_mode lpm_arch_get(void)
{
return 0;
}
void lpm_arch_awake(void)
{
}
void lpm_arch_begin_awake(void)
{
}
void lpm_arch_end_awake(void)
{
}

9
cpu/cortexm_common/panic.c

@ -21,7 +21,6 @@
*/
#include "cpu.h"
#include "lpm.h"
#include "log.h"
#ifdef DEVELHELP
@ -42,9 +41,9 @@ void panic_arch(void)
print_ipsr();
/* The bkpt instruction will signal to the debugger to break here. */
__asm__("bkpt #0");
/* enter infinite loop, into deepest possible sleep mode */
while (1) {
lpm_set(LPM_OFF);
}
#endif
/* turn off device if possible */
// TODO
while (1) { }
}

53
cpu/ezr32wg/lpm_arch.c

@ -1,53 +0,0 @@
/*
* Copyright (C) 2015 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 cpu_ezr32wg
* @{
*
* @file
* @brief Implementation of the kernels power management interface
*
* @author Hauke Petersen <hauke.peterse@fu-berlin.de>
*
* @}
*/
#include "arch/lpm_arch.h"
void lpm_arch_init(void)
{
/* TODO */
}
enum lpm_mode lpm_arch_set(enum lpm_mode target)
{
/* TODO */
return 0;
}
enum lpm_mode lpm_arch_get(void)
{
/* TODO */
return 0;
}
void lpm_arch_awake(void)
{
/* TODO */
}
void lpm_arch_begin_awake(void)
{
/* TODO */
}
void lpm_arch_end_awake(void)
{
/* TODO */
}

81
cpu/k60/lpm_arch.c

@ -1,81 +0,0 @@
/*
* Copyright (C) 2014 Eistec AB
*
* 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 cpu_k60
* @{
*
* @file
* @brief Implementation of the kernel's power management interface
*
* @author Joakim Nohlgård <joakim.nohlgard@eistec.se>
*
* @}
*/
#include "cpu.h"
#include "arch/lpm_arch.h"
static inline void wait(void)
{
/* Clear the SLEEPDEEP bit to make sure we go into WAIT (sleep) mode instead
* of deep sleep.
*/
SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk;
/* WFI instruction will start entry into WAIT mode */
__WFI();
}
void lpm_arch_init(void)
{
/* Stub waiting for https://github.com/RIOT-OS/RIOT/pull/2605 */
}
enum lpm_mode lpm_arch_set(enum lpm_mode target)
{
switch (target) {
case LPM_ON:
/* MCU is active, do not go to low power */
break;
case LPM_IDLE:
case LPM_SLEEP:
case LPM_POWERDOWN:
case LPM_OFF:
wait();
break;
case LPM_UNKNOWN:
default:
break;
}
return 0;
}
enum lpm_mode lpm_arch_get(void)
{
/* TODO */
return LPM_ON;
}
void lpm_arch_awake(void)
{
/* TODO */
}
void lpm_arch_begin_awake(void)
{
/* TODO */
}
void lpm_arch_end_awake(void)
{
/* TODO */
}

53
cpu/k64f/lpm_arch.c

@ -1,53 +0,0 @@
/*
* 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 cpu_k64f
* @{
*
* @file
* @brief Implementation of the kernels power management interface
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*
* @}
*/
#include "arch/lpm_arch.h"
void lpm_arch_init(void)
{
/* TODO */
}
enum lpm_mode lpm_arch_set(enum lpm_mode target)
{
/* TODO */
return 0;
}
enum lpm_mode lpm_arch_get(void)
{
/* TODO */
return 0;
}
void lpm_arch_awake(void)
{
/* TODO */
}
void lpm_arch_begin_awake(void)
{
/* TODO */
}
void lpm_arch_end_awake(void)
{
/* TODO */
}

53
cpu/kw2x/lpm_arch.c

@ -1,53 +0,0 @@
/*
* 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 cpu_kw2x
* @{
*
* @file
* @brief Implementation of the kernels power management interface
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*
* @}
*/
#include "arch/lpm_arch.h"
void lpm_arch_init(void)
{
/* TODO */
}
enum lpm_mode lpm_arch_set(enum lpm_mode target)
{
/* TODO */
return 0;
}
enum lpm_mode lpm_arch_get(void)
{
/* TODO */
return 0;
}
void lpm_arch_awake(void)
{
/* TODO */
}
void lpm_arch_begin_awake(void)
{
/* TODO */
}
void lpm_arch_end_awake(void)
{
/* TODO */
}

53
cpu/lm4f120/lpm_arch.c

@ -1,53 +0,0 @@
/*
* Copyright (C) 2015 Rakendra Thapa <rakendrathapa@gmail.com
*
* 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 cpu_lm4f120
* @{
*
* @file lpm_arch.c
* @brief Implementation of the kernels power management interface
*
* @author Rakendra Thapa <rakendrathapa@gmail.com>
*/
#include "cpu.h"
#include "arch/lpm_arch.h"
void lpm_arch_init(void)
{
/* TODO */
}
enum lpm_mode lpm_arch_set(enum lpm_mode target)
{
/* TODO */
return 0;
}
enum lpm_mode lpm_arch_get(void)
{
/* TODO */
return 0;
}
void lpm_arch_awake(void)
{
/* TODO*/
}
void lpm_arch_begin_awake(void)
{
/* TODO */
}
void lpm_arch_end_awake(void)
{
/* TODO */
}
/** @} */

54
cpu/lpc11u34/lpm_arch.c

@ -1,54 +0,0 @@
/*
* Copyright (C) 2015 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 cpu_lpc11u34
* @{
*
* @file
* @brief Implementation of the kernels power management interface
*
* @author Paul RATHGEB <paul.rathgeb@skynet.be>
*
* @}
*/
#include "cpu.h"
#include "arch/lpm_arch.h"
void lpm_arch_init(void)
{
/* TODO */
}
enum lpm_mode lpm_arch_set(enum lpm_mode target)
{
/* TODO */
return 0;
}
enum lpm_mode lpm_arch_get(void)
{
/* TODO */
return 0;
}
void lpm_arch_awake(void)
{
/* TODO*/
}
void lpm_arch_begin_awake(void)
{
/* TODO */
}
void lpm_arch_end_awake(void)
{
/* TODO */
}

54
cpu/lpc1768/lpm_arch.c

@ -1,54 +0,0 @@
/*
* 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 cpu_lpc1768
* @{
*
* @file
* @brief Implementation of the kernels power management interface
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*
* @}
*/
#include "cpu.h"
#include "arch/lpm_arch.h"
void lpm_arch_init(void)
{
/* TODO */
}
enum lpm_mode lpm_arch_set(enum lpm_mode target)
{
/* TODO */
return 0;
}
enum lpm_mode lpm_arch_get(void)
{
/* TODO */
return 0;
}
void lpm_arch_awake(void)
{
/* TODO*/
}
void lpm_arch_begin_awake(void)
{
/* TODO */
}
void lpm_arch_end_awake(void)
{
/* TODO */
}

118
cpu/lpc2387/lpc2387-lpm.c

@ -1,118 +0,0 @@
/*
* Copyright (C) 2013, Freie Universitaet Berlin (FUB). All rights reserved.
*
* 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 lpc2387
* @ingroup lpm
* @{
*/
/**
* @file
* @brief LPC2387 Low-Power management
* @ingroup lpc2387
*
* @author Heiko Will
* @version $Revision$
*
* @note $Id$
*/
#include <stdio.h>
#include <stdint.h>
#include "lpc23xx.h"
#include "lpc2387.h"
#include "lpm.h"
/* lpm is accessed before memory init and initialized separately through code */
__attribute__((section(".noinit")))
static enum lpm_mode lpm;
extern void init_clks1(void);
extern void init_clks2(void);
#define ENABLE_DEBUG (0)
#include "debug.h"
void lpm_init(void)
{
lpm = LPM_ON;
}
#define LPM_DEBUG (1)
void lpm_begin_awake(void)
{
if (lpm >= LPM_SLEEP) { // wake up from deep sleep
init_clks1();
}
}
void lpm_end_awake(void)
{
if (lpm >= LPM_SLEEP) { // wake up from deep sleep
init_clks2();
}
lpm = LPM_ON;
}
void lpm_awake(void)
{
#if LPM_DEBUG
unsigned long usec = RTC_CTC;
#endif
if (lpm >= LPM_SLEEP) { // wake up from deep sleep
/* benchmark */
init_clks1();
init_clks2();
/* Debug tests */
#if LPM_DEBUG
usec = RTC_CTC - usec;
DEBUG("Wakeup in %lu usecs\n", usec * 31);
#endif
}
lpm = LPM_ON;
}
enum lpm_mode lpm_set(enum lpm_mode target)
{
unsigned target_flags;
enum lpm_mode last_lpm = lpm;
/* calculate target mcu power mode */
if (target == LPM_IDLE) {
target_flags = PM_IDLE;
}
else if (target == LPM_SLEEP) {
target_flags = PM_SLEEP;
}
else if (target == LPM_POWERDOWN) {
target_flags = PM_POWERDOWN;
}
else {
target_flags = 0;
}
lpm = target;
DEBUG("# LPM power down %u -> %u\n", lpm, target);
PCON |= target_flags; // set target power mode
return last_lpm;
}
/*---------------------------------------------------------------------------*/
enum lpm_mode
lpm_get(void)
{
return lpm;
}
/*---------------------------------------------------------------------------*/
/** @} */

4
cpu/lpc2387/periph/rtc.c

@ -17,7 +17,6 @@
#include "periph/rtc.h"
#include "VIC.h"
#include "lpc2387.h"
#include "lpm.h"
#define ENABLE_DEBUG (0)
#include "debug.h"
@ -164,8 +163,6 @@ void rtc_poweroff(void)
void RTC_IRQHandler(void)
{
lpm_begin_awake();
if (RTC_ILR & ILR_RTSSF) {
/* sub second interrupt (does not need flag-clearing) */
}
@ -179,7 +176,6 @@ void RTC_IRQHandler(void)
_cb(_cb_arg);
}
DEBUG("Ring\n");
lpm_end_awake();
}
VICVectAddr = 0; /* Acknowledge Interrupt */

128
cpu/msp430-common/lpm_cpu.c

@ -1,128 +0,0 @@
/*
* 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 cpu
* @{
*
* @file
* @brief low-power mode implementation for MSP430 MCUs
*
* @author Kévin Roussel <Kevin.Roussel@inria.fr>
* @author Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
* @author Thomas Eichinger <thomas.eichinger@fu-berlin.de>
*
* @}
*/
#include <assert.h>
#include <stdio.h>
#if (__GNUC__ >= 4) && (__GNUC_MINOR__ > 5)
#include <intrinsics.h> // MSP430-gcc compiler instrinsics
#endif
#include "board.h"
#include <msp430.h>
#include "lpm.h"
/* Initialise the MSP430 power-saving mechanisms. */
void lpm_init(void)
{
/* nothing to initialize on MSP430s: everything is done by fiddling
with 4 bits of the status register (SR). */
/* just ensure MCU is fully up and running at start */
lpm_awake();
}
/* Change the current power-saving mode. */
enum lpm_mode lpm_set(enum lpm_mode target)
{
enum lpm_mode last_mode = lpm_get();
/* ensure that interrupts are enabled before going to sleep,
or we're bound to hang our MCU! */
assert((target == LPM_ON) || (__read_status_register() & GIE));
switch (target) {
case LPM_ON:
/* fully running MCU */
__bic_status_register(CPUOFF | OSCOFF | SCG0 | SCG1);
break;
case LPM_IDLE:
/* lightest mode => LPM0 mode of MSP430 */
__bic_status_register(OSCOFF | SCG0 | SCG1);
/* only stops CPU block */
__bis_status_register(CPUOFF);
break;
case LPM_SLEEP:
/* mid-level mode => LPM1 mode of MSP430 */
__bic_status_register(OSCOFF | SCG1);
/* stops CPU and master clock blocks */
__bis_status_register(CPUOFF | SCG0);
break;
case LPM_POWERDOWN:
/* deep-level mode => LPM3 mode of MSP430 */
__bic_status_register(OSCOFF);
/* stops all blocks except auxiliary clock (timers) */
__bis_status_register(CPUOFF | SCG0 | SCG1);
break;
case LPM_OFF:
/* MCU totally down (LPM4), only RESET or NMI can resume execution */
__bis_status_register(CPUOFF | OSCOFF | SCG0 | SCG1);
/* all blocks off */
break;
default:
assert(0); /* abort if NDEBUG is not defined */
break;
}
return last_mode;
}
#define LPM_MASK_SR (CPUOFF | OSCOFF | SCG0 | SCG1)
/* Return the current LPM mode of the MSP430 MCU. */
enum lpm_mode lpm_get(void)
{
enum lpm_mode current_mode = LPM_UNKNOWN;
unsigned int current_sr = __read_status_register();
switch (current_sr & LPM_MASK_SR) {
case CPUOFF + OSCOFF + SCG0 + SCG1: /* MSP430's LPM4 */
current_mode = LPM_OFF;
break;
case CPUOFF + SCG0 + SCG1: /* MSP430's LPM3 */
case CPUOFF + SCG1: /* MSP430's LPM2 */
current_mode = LPM_POWERDOWN;
break;
case CPUOFF + SCG0: /* MSP430's LPM1 */
current_mode = LPM_SLEEP;
break;
case CPUOFF: /* MSP430's LPM1 */
current_mode = LPM_IDLE;
break;
case 0: /* MSP430 active */
current_mode = LPM_ON;
break;
}
return current_mode;
}
/* resume the MSP430 MCU */
inline void lpm_awake(void)
{
/* disable all power savings mechanisms */
__bic_status_register(CPUOFF | OSCOFF | SCG0 | SCG1);
}
/* the following two functions have no actual role to play MSP430s */
inline void lpm_begin_awake(void) { }
inline void lpm_end_awake(void) { }

1
cpu/msp430-common/msp430-main.c

@ -112,7 +112,6 @@ void msp430_cpu_init(void)
{
irq_disable();
init_ports();
// lpm_init();
irq_enable();
if ((uintptr_t)cur_break & 1) { /* Workaround for msp430-ld bug!*/

6
cpu/msp430-common/panic.c

@ -18,7 +18,6 @@
*/
#include "cpu.h"
#include "lpm.h"
void panic_arch(void)
{
@ -26,9 +25,6 @@ void panic_arch(void)
WDTCTL = WDTPW | WDTHOLD;
#ifdef DEVELHELP
/* enter infinite loop, into deepest possible sleep mode */
while (1) {
lpm_set(LPM_OFF);
}
// TODO
#endif
}

4
cpu/native/irq_cpu.c

@ -38,8 +38,6 @@
#include "irq.h"
#include "cpu.h"
#include "lpm.h"
#include "native_internal.h"
#define ENABLE_DEBUG (0)
@ -448,7 +446,7 @@ static void native_shutdown(int sig, siginfo_t *info, void *context)
(void)info;
(void)context;
lpm_set(LPM_OFF);
// TODO: poweroff
}
/**

123
cpu/native/lpm_cpu.c

@ -1,123 +0,0 @@
/**
* Native CPU lpm.h implementation
*
* Uses system calls to emulate CPU power modes.
*
* Copyright (C) 2013 Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
*
* 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 lpm
* @ingroup native_cpu