1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu/lpc2387/periph/pm.c
Benjamin Valentin a9d1825e2e cpu/lpc2387: implement periph/pm
Enable IDLE and Deep Powerdown mode.

IDLE is pretty straightforward - insteady of busy waiting, the CPU will
enter an idle state from which it will resume on any event.

Deep Power Down shuts off the entite system except for the battery backup
power domain.
That means the CPU will reset on resume and can be woken by e.g. RTC.

SLEEP and POWERDOWN disable the PLL and the PLL and Flash respectively.
This requires some proper wake-up handling.

Since this turned out to be a major time sink and those modes are never
currently never used in RIOT outside of tests, I left this as an exercise
for a future reader.
2019-11-22 09:11:39 +01:00

57 lines
1.5 KiB
C

/*
* Copyright (C) 2019 Beuth Hochschule für Technik 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_lpc2387
* @ingroup drivers_periph_pm
* @{
*
* @file
* @brief Implementation of the kernels power management interface
*
* @note Handling of wake-up from POWERDOWN & SLEEP is not implemented
* yet, so those states are disabled.
*
* @author Benjamin Valentin <benpicco@beuth-hochschule.de>
*
* @}
*/
#include "periph/pm.h"
#define ENABLE_DEBUG (0)
#include "debug.h"
void pm_set(unsigned mode)
{
switch (mode) {
case 0:
/* Everything except battery backup is powered down */
DEBUG_PUTS("pm_set(): setting Deep Power Down mode.");
PCON |= PM_DEEP_POWERDOWN;
break;
case 1:
/* PLL & Flash are powered down */
DEBUG_PUTS("pm_set(): setting Power Down mode.");
/* PCON |= PM_POWERDOWN; */
PCON |= PM_IDLE; /* fixme */
break;
case 2:
/* PLL is powered down */
DEBUG_PUTS("pm_set(): setting Sleep mode.");
/* PCON |= PM_SLEEP; */
PCON |= PM_IDLE; /* fixme */
break;
default: /* Falls through */
case 3:
DEBUG_PUTS("pm_set(): setting Idle mode.");
PCON |= PM_IDLE;
break;
}
}