1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu/samd21/periph/pm.c

87 lines
2.2 KiB
C
Raw Normal View History

2017-01-09 18:13:04 +01:00
/*
* Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de>
* Copyright (C) 2014 Freie Universität Berlin
* Copyright (C) 2015 Saurabh Singh
*
* 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_samd21
* @ingroup drivers_periph_pm
2017-01-09 18:13:04 +01:00
* @{
*
* @file
* @brief Implementation of the kernels power management interface
*
* @author Thomas Eichinger <thomas.eichinger@fu-berlin.de>
* @author Saurabh Singh <saurabh@cezy.co>
* @author Kaspar Schleiser <kaspar@schleiser.de>
*
* @}
*/
#include "periph/pm.h"
2020-10-22 11:34:00 +02:00
#define ENABLE_DEBUG 0
2017-01-09 18:13:04 +01:00
#include "debug.h"
enum system_sleepmode {
/**
* Idle 0 mode.
* Potential Wake Up sources: Synchronous(APB, AHB), asynchronous.
*/
SYSTEM_SLEEPMODE_IDLE_0,
/**
* Idle 1 mode.
* Potential Wake Up sources: Synchronous (APB), asynchronous
*/
SYSTEM_SLEEPMODE_IDLE_1,
/**
* Idle 2 mode.
* Potential Wake Up sources: Asynchronous
*/
SYSTEM_SLEEPMODE_IDLE_2,
/**
* Standby mode.
* Potential Wake Up sources: Asynchronous
*/
SYSTEM_SLEEPMODE_STANDBY,
};
void pm_set(unsigned mode)
{
int deep = 0;
2017-01-09 18:13:04 +01:00
switch (mode) {
2019-03-18 13:43:16 +01:00
case SAMD21_PM_STANDBY:
2017-01-09 18:13:04 +01:00
/* Standby Mode
* Potential Wake Up sources: asynchronous
*/
deep = 1;
2017-01-09 18:13:04 +01:00
break;
2019-03-18 13:43:16 +01:00
case SAMD21_PM_IDLE_2:
2017-01-09 18:13:04 +01:00
/* Sleep mode Idle 2
* Potential Wake Up sources: asynchronous
*/
PM->SLEEP.reg = SYSTEM_SLEEPMODE_IDLE_2;
break;
2019-03-18 13:43:16 +01:00
case SAMD21_PM_IDLE_1:
2017-01-09 18:13:04 +01:00
/* Sleep mode Idle 1
* Potential Wake Up sources: Synchronous (APB), asynchronous
*/
PM->SLEEP.reg = SYSTEM_SLEEPMODE_IDLE_1;
break;
2019-03-18 13:43:16 +01:00
case SAMD21_PM_IDLE_0:
2017-01-09 18:13:04 +01:00
/* Sleep mode Idle 0
* Potential Wake Up sources: Synchronous (APB, AHB), asynchronous
*/
PM->SLEEP.reg = SYSTEM_SLEEPMODE_IDLE_0;
break;
}
2020-02-21 16:18:36 +01:00
sam0_cortexm_sleep(deep);
2017-01-09 18:13:04 +01:00
}