blob: a262f9cb67cea42c7bf4b2817ee2fd11b985963e (
plain)
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
/**
******************************************************************************
* @file stm32_lpm.h
* @author MCD Application Team
* @brief Header for stm32_lpm.c module
******************************************************************************
* @attention
*
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef STM32_TINY_LPM_H
#define STM32_TINY_LPM_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stdint.h"
/** @defgroup TINY_LPM TINY LPM
* @{
*/
/* Exported typedef ---------------------------------------------------------*/
/** @defgroup TINY_LPM_Exported_typedef TINY LPM exported typedef
* @{
*/
/**
* @brief type definition to represent the bit mask of an LPM mode
*/
typedef uint32_t UTIL_LPM_bm_t;
/**
* @brief type definition to represent value of an LPM mode
*/
typedef enum
{
UTIL_LPM_ENABLE=0,
UTIL_LPM_DISABLE,
} UTIL_LPM_State_t;
/**
* @brief type definition to represent the different type of LPM mode
*/
typedef enum
{
UTIL_LPM_SLEEPMODE,
UTIL_LPM_STOPMODE,
UTIL_LPM_OFFMODE,
} UTIL_LPM_Mode_t;
/**
* @}
*/
/** @defgroup TINY_LPM_Exported_struct TINY LPM exported struct
* @{
*/
/**
* @brief LPM driver definition
*/
struct UTIL_LPM_Driver_s
{
void (*EnterSleepMode) ( void ); /*!<function to enter the sleep mode */
void (*ExitSleepMode) ( void ); /*!<function to exit the sleep mode */
void (*EnterStopMode) ( void ); /*!<function to enter the stop mode */
void (*ExitStopMode) ( void ); /*!<function to exit the stop mode */
void (*EnterOffMode) ( void ); /*!<function to enter the off mode */
void (*ExitOffMode) ( void ); /*!<function to exit the off mode */
};
/**
* @}
*/
/* External variables --------------------------------------------------------*/
/** @defgroup TINY_LPM_Exported_struct TINY LPM exported struct
* @{
*/
/**
* @brief LPM driver
*
* @note This structure is defined and initialized in the specific platform
* power implementation
*/
extern const struct UTIL_LPM_Driver_s UTIL_PowerDriver;
/**
* @}
*/
/* Exported macros -----------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
/** @defgroup TINY_LPM_Exported_function TINY LPM exported functions
* @{
*/
/**
* @brief This API Initializes the LPM resources.
*/
void UTIL_LPM_Init( void );
/**
* @brief This API Un-Initializes the LPM resources.
*/
void UTIL_LPM_DeInit( void );
/**
* @brief This API returns the Low Power Mode selected that will be applied when the system will enter low power mode
* if there is no update between the time the mode is read with this API and the time the system enters
* low power mode.
* @retval the LPM mode based on @ref UTIL_LPM_Mode_t
*/
UTIL_LPM_Mode_t UTIL_LPM_GetMode( void );
/**
* @brief This API notifies the low power manager if the specified user allows the Stop mode or not.
* The default mode selection for all users is Stop Mode enabled
* @param lpm_id_bm: identifier of the user ( 1 bit per user )
* @param state: Specify whether StopMode is allowed or not by this user
*/
void UTIL_LPM_SetStopMode( UTIL_LPM_bm_t lpm_id_bm, UTIL_LPM_State_t state );
/**
* @brief This API notifies the low power manager if the specified user allows the Off mode or not.
* The default mode selection for all users is Off mode enabled
* @param lpm_id_bm: identifier of the user ( 1 bit per user )
* @param state: Specify whether OffMode is allowed or not by this user
*/
void UTIL_LPM_SetOffMode( UTIL_LPM_bm_t lpm_id_bm, UTIL_LPM_State_t state );
/**
* @brief This API is called by the low power manager in a critical section (PRIMASK bit set) to allow the
* application to implement dedicated code before entering Low Power Mode
*/
void UTIL_LPM_EnterLowPower( void );
/**
*@}
*/
/**
*@}
*/
#ifdef __cplusplus
}
#endif
#endif /* STM32_TINY_LPM_H */
|