lpm_arch.h
2.36 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* 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 */
/** @} */