lpm_arch.c
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* 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 */
}