gr55xx_hal_pwr.h
Go to the documentation of this file.
1
/**
2
****************************************************************************************
3
*
4
* @file gr55xx_hal_pwr.h
5
* @author BLE Driver Team
6
* @brief Header file containing functions prototypes of PWR HAL library.
7
*
8
****************************************************************************************
9
* @attention
10
#####Copyright (c) 2019 GOODIX
11
All rights reserved.
12
13
Redistribution and use in source and binary forms, with or without
14
modification, are permitted provided that the following conditions are met:
15
* Redistributions of source code must retain the above copyright
16
notice, this list of conditions and the following disclaimer.
17
* Redistributions in binary form must reproduce the above copyright
18
notice, this list of conditions and the following disclaimer in the
19
documentation and/or other materials provided with the distribution.
20
* Neither the name of GOODIX nor the names of its contributors may be used
21
to endorse or promote products derived from this software without
22
specific prior written permission.
23
24
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
POSSIBILITY OF SUCH DAMAGE.
35
****************************************************************************************
36
*/
37
38
/** @addtogroup PERIPHERAL Peripheral Driver
39
* @{
40
*/
41
42
/** @addtogroup HAL_DRIVER HAL Driver
43
* @{
44
*/
45
46
/** @defgroup HAL_PWR PWR
47
* @brief PWR HAL module driver.
48
* @{
49
*/
50
51
/* Define to prevent recursive inclusion -------------------------------------*/
52
#ifndef __GR55xx_HAL_PWR_H__
53
#define __GR55xx_HAL_PWR_H__
54
55
#ifdef __cplusplus
56
extern
"C"
{
57
#endif
58
59
/* Includes ------------------------------------------------------------------*/
60
#include "
gr55xx_ll_pwr.h
"
61
#include "
gr55xx_hal_def.h
"
62
63
64
/**
65
* @defgroup HAL_PWR_MACRO Defines
66
* @{
67
*/
68
69
/* Exported constants --------------------------------------------------------*/
70
/** @defgroup PWR_Exported_Constants PWR Exported Constants
71
* @{
72
*/
73
74
/** @defgroup PWR_WakeUp_Conditions PWR Wakeup Condition
75
* @{
76
*/
77
#define PWR_WKUP_COND_EXT LL_PWR_WKUP_COND_EXT
/**< External wakeup: AON_GPIO */
78
#define PWR_WKUP_COND_TIMER LL_PWR_WKUP_COND_TIMER
/**< AON Timer wakeup */
79
#define PWR_WKUP_COND_BLE LL_PWR_WKUP_COND_BLE
/**< BLE wakeup */
80
#define PWR_WKUP_COND_CLDR LL_PWR_WKUP_COND_CLDR
/**< Calendar wakeup */
81
82
#define PWR_WKUP_COND_BOD_FEDGE LL_PWR_WKUP_COND_BOD_FEDGE
/**< PMU Bod falling edge wakeup */
83
#define PWR_WKUP_COND_MSIO_COMP LL_PWR_WKUP_COND_COMP
/**< Msio comparator wakeup */
84
#define PWR_WKUP_COND_AUSB LL_PWR_WKUP_COND_AUSB
/**< USB attach wakeup event */
85
#define PWR_WKUP_COND_DUSB LL_PWR_WKUP_COND_DUSB
/**< USB detach wakeup event */
86
#define PWR_WKUP_COND_BLE_IRQ LL_PWR_WKUP_COND_BLE_IRQ
/**< BLE IRQ wakeup event */
87
#define PWR_WKUP_COND_CLDR_TICK LL_PWR_WKUP_COND_CLDR_TICK
/**< Calendar Tick wakeup event */
88
#define PWR_WKUP_COND_AON_WDT LL_PWR_WKUP_COND_AON_WDT
/**< AON WDT Alarm wakeup event */
89
#define PWR_WKUP_COND_ALL LL_PWR_WKUP_COND_ALL
/**< All wakeup sources mask */
90
91
/** @} */
92
93
/** @defgroup PWR_Timer_Type PWR Timer Type
94
* @note Only available on GR551xx_B2 and later versions.
95
* @{
96
*/
97
98
#define PWR_TIMER_TYPE_CAL_TIMER 0
/**< Calendar timer */
99
#define PWR_TIMER_TYPE_AON_WDT 1
/**< AON watchdog alarm timer */
100
#define PWR_TIMER_TYPE_SLP_TIMER 2
/**< Sleep timer */
101
#define PWR_TIMER_TYPE_CAL_ALARM 3
/**< Calendar alarm timer */
102
#define PWR_TIMER_TYPE_AON_WDT_TIMER 4
/**< AON watchdog timer timer(B0) */
103
104
/** @} */
105
106
107
/** @defgroup PWR_Memory_Power_State Memory Power State
108
* @{
109
*/
110
#define PWR_MEM_POWER_OFF LL_PWR_MEM_POWER_OFF
/**< Power off */
111
#define PWR_MEM_POWER_FULL LL_PWR_MEM_POWER_FULL
/**< Full power */
112
#define PWR_MEM_POWER_RETENTION LL_PWR_MEM_POWER_RETENTION
/**< Power retention, low valtage mode */
113
/** @} */
114
115
/** @defgroup PWR_Timeout_definition PWR Timeout definition
116
* @{
117
*/
118
#define HAL_PWR_TIMEOUT_DEFAULT_VALUE ((uint32_t)0x000FFFFF)
/**< 0xFFFFF counts */
119
/** @} */
120
121
/** @} */
122
123
/* Exported macro ------------------------------------------------------------*/
124
/* Private macros ------------------------------------------------------------*/
125
/** @defgroup PWR_Private_Macros PWR Private Macros
126
* @{
127
*/
128
129
/**
130
* @brief Check if PWR wakeup condition is valid.
131
* @param __COND__ PWR wakeup condition.
132
* @retval SET (__COND__ is valid) or RESET (__COND__ is invalid)
133
*/
134
#define IS_PWR_WAKEUP_CONDITION(__COND__) ((((__COND__) & PWR_WKUP_COND_ALL) != 0x00U) &&\
135
(((__COND__) & ~PWR_WKUP_COND_ALL) == 0x00U))
136
137
/**
138
* @brief Check if PWR memory block is valid.
139
* @param __BLOCK__ PWR memory block.
140
* @retval SET (__BLOCK__ is valid) or RESET (__BLOCK__ is invalid)
141
*/
142
#define IS_PWR_MEM_BLOCK(__BLOCK__) ((((__BLOCK__) & PWR_MEM_ALL) != 0x00U) &&\
143
(((__BLOCK__) & ~PWR_MEM_ALL) == 0x00U))
144
145
/**
146
* @brief Check if PWR memory power state is valid.
147
* @param __STATE__ PWR memory power state.
148
* @retval SET (__STATE__ is valid) or RESET (__STATE__ is invalid)
149
*/
150
#define IS_PWR_MEM_POWER_STAT(__STATE__) (((__STATE__) == PWR_MEM_POWER_OFF) || \
151
((__STATE__) == PWR_MEM_POWER_FULL) || \
152
((__STATE__) == PWR_MEM_POWER_RETENTION))
153
154
/**
155
* @brief Check if PWR sleep timer type is valid.
156
* @param __TYPE__ PWR sleep timer type.
157
* @retval SET (__TYPE__ is valid) or RESET (__TYPE__ is invalid)
158
*/
159
#define IS_PWR_PWR_TIMER_TYPE(__TYPE__) (((__TYPE__) == PWR_TIMER_TYPE_CAL_TIMER) || \
160
((__TYPE__) == PWR_TIMER_TYPE_AON_WDT) || \
161
((__TYPE__) == PWR_TIMER_TYPE_SLP_TIMER) || \
162
((__TYPE__) == PWR_TIMER_TYPE_CAL_ALARM))
163
164
/** @} */
165
166
/** @} */
167
168
/* Exported functions --------------------------------------------------------*/
169
/** @addtogroup HAL_PWR_DRIVER_FUNCTIONS Functions
170
* @{
171
*/
172
173
/** @addtogroup PWR_Exported_Functions_Group1 Low Power mode configuration functions
174
* @{
175
*/
176
177
/**
178
****************************************************************************************
179
* @brief Enters DeepSleep mode.
180
* @note In DeepSleep mode, all I/O pins keep the same state as in Run mode.
181
****************************************************************************************
182
*/
183
void
hal_pwr_enter_chip_deepsleep
(
void
);
184
185
/** @} */
186
187
/** @addtogroup PWR_Exported_Functions_Group2 BLE Communication timer and core configuration function
188
* @{
189
*/
190
191
/**
192
****************************************************************************************
193
* @brief Get the current value of specified timer.
194
* @note Only available on GR551xx_B2 and later versions.
195
* @param[in] timer_type: This parameter can be one of the following values:
196
* @arg @ref PWR_TIMER_TYPE_CAL_TIMER
197
* @arg @ref PWR_TIMER_TYPE_AON_WDT
198
* @arg @ref PWR_TIMER_TYPE_SLP_TIMER
199
* @arg @ref PWR_TIMER_TYPE_CAL_ALARM
200
* @param[out] p_value: Pointer to an integer storing current value
201
* @retval ::HAL_OK: Operation is OK.
202
* @retval ::HAL_ERROR: Parameter error or operation not supported.
203
* @retval ::HAL_BUSY: Driver is busy.
204
* @retval ::HAL_TIMEOUT: Timeout occurred.
205
****************************************************************************************
206
*/
207
hal_status_t
hal_pwr_get_timer_current_value
(uint32_t timer_type, uint32_t *p_value);
208
209
/** @} */
210
/** @} */
211
212
#ifdef __cplusplus
213
}
214
#endif
215
216
217
#endif
/* __GR55xx_HAL_PWR_H__ */
218
219
/** @} */
220
221
/** @} */
222
223
/** @} */
hal_pwr_get_timer_current_value
hal_status_t hal_pwr_get_timer_current_value(uint32_t timer_type, uint32_t *p_value)
Get the current value of specified timer.
hal_pwr_enter_chip_deepsleep
void hal_pwr_enter_chip_deepsleep(void)
Enters DeepSleep mode.
hal_status_t
hal_status_t
HAL Status structures definition.
Definition:
gr55xx_hal_def.h:70
gr55xx_ll_pwr.h
Header file containing functions prototypes of PWR LL library.
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.