hal_pwr.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file 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 ___HAL_PWR_H__
53 #define ___HAL_PWR_H__
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 /* Includes ------------------------------------------------------------------*/
60 #include "ll_pwr.h"
61 #include "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_MSIO_COMP LL_PWR_WKUP_COND_COMP /**< Msio comparator wakeup */
83 #define PWR_WKUP_COND_AUSB LL_PWR_WKUP_COND_AUSB /**< USB attach wakeup event */
84 #define PWR_WKUP_COND_DUSB LL_PWR_WKUP_COND_DUSB /**< USB detach wakeup event */
85 #define PWR_WKUP_COND_CLDR_TICK LL_PWR_WKUP_COND_CLDR_TICK /**< Calendar Tick wakeup event */
86 #define PWR_WKUP_COND_AON_WDT LL_PWR_WKUP_COND_AON_WDT /**< AON WDT Alarm wakeup event */
87 #define PWR_WKUP_COND_ALL LL_PWR_WKUP_COND_ALL /**< All wakeup sources mask */
88 
89 /** @} */
90 
91 /** @defgroup PWR_Timer_Type PWR Timer Type
92  * @note Only available on GR551xx_B2 and later versions.
93  * @{
94  */
95 
96 #define PWR_TIMER_TYPE_CAL_TIMER 0 /**< Calendar timer */
97 #define PWR_TIMER_TYPE_AON_WDT 1 /**< AON watchdog alarm timer */
98 #define PWR_TIMER_TYPE_SLP_TIMER 2 /**< Sleep timer */
99 #define PWR_TIMER_TYPE_CAL_ALARM 3 /**< Calendar alarm timer */
100 #define PWR_TIMER_TYPE_AON_WDT_TIMER 4 /**< AON watchdog timer timer(B0) */
101 
102 /** @} */
103 
104 
105 /** @defgroup PWR_Memory_Power_State Memory Power State
106  * @{
107  */
108 #define PWR_MEM_POWER_OFF LL_PWR_MEM_POWER_OFF /**< Power off */
109 #define PWR_MEM_POWER_FULL LL_PWR_MEM_POWER_FULL /**< Full power */
110 #define PWR_MEM_POWER_RETENTION LL_PWR_MEM_POWER_RETENTION /**< Power retention, low valtage mode */
111 /** @} */
112 
113 /** @defgroup PWR_Timeout_definition PWR Timeout definition
114  * @{
115  */
116 #define HAL_PWR_TIMEOUT_DEFAULT_VALUE ((uint32_t)0x000FFFFF) /**< 0xFFFFF counts */
117 /** @} */
118 
119 /** @} */
120 
121 /* Exported macro ------------------------------------------------------------*/
122 /* Private macros ------------------------------------------------------------*/
123 /** @addtogroup PWR_Private_Macros PWR Private Macros
124  * @{
125  */
126 
127 /**
128  * @brief Check if PWR wakeup condition is valid.
129  * @param __COND__ PWR wakeup condition.
130  * @retval SET (__COND__ is valid) or RESET (__COND__ is invalid)
131  */
132 #define IS_PWR_WAKEUP_CONDITION(__COND__) ((((__COND__) & PWR_WKUP_COND_ALL) != 0x00U) &&\
133  (((__COND__) & ~PWR_WKUP_COND_ALL) == 0x00U))
134 
135 /**
136  * @brief Check if PWR memory block is valid.
137  * @param __BLOCK__ PWR memory block.
138  * @retval SET (__BLOCK__ is valid) or RESET (__BLOCK__ is invalid)
139  */
140 #define IS_PWR_MEM_BLOCK(__BLOCK__) ((((__BLOCK__) & PWR_MEM_ALL) != 0x00U) &&\
141  (((__BLOCK__) & ~PWR_MEM_ALL) == 0x00U))
142 
143 /**
144  * @brief Check if PWR memory power state is valid.
145  * @param __STATE__ PWR memory power state.
146  * @retval SET (__STATE__ is valid) or RESET (__STATE__ is invalid)
147  */
148 #define IS_PWR_MEM_POWER_STAT(__STATE__) (((__STATE__) == PWR_MEM_POWER_OFF) || \
149  ((__STATE__) == PWR_MEM_POWER_FULL) || \
150  ((__STATE__) == PWR_MEM_POWER_RETENTION))
151 
152 /**
153  * @brief Check if PWR sleep timer type is valid.
154  * @param __TYPE__ PWR sleep timer type.
155  * @retval SET (__TYPE__ is valid) or RESET (__TYPE__ is invalid)
156  */
157 #define IS_PWR_PWR_TIMER_TYPE(__TYPE__) (((__TYPE__) == PWR_TIMER_TYPE_CAL_TIMER) || \
158  ((__TYPE__) == PWR_TIMER_TYPE_AON_WDT) || \
159  ((__TYPE__) == PWR_TIMER_TYPE_SLP_TIMER) || \
160  ((__TYPE__) == PWR_TIMER_TYPE_CAL_ALARM))
161 
162 /** @} */
163 
164 /** @} */
165 
166 /* Exported functions --------------------------------------------------------*/
167 /** @addtogroup HAL_PWR_DRIVER_FUNCTIONS Functions
168  * @{
169  */
170 
171 /** @addtogroup PWR_Exported_Functions_Group1 Low Power mode configuration functions
172  * @{
173  */
174 
175 /**
176  ****************************************************************************************
177  * @brief Enters DeepSleep mode.
178  * @note In DeepSleep mode, all I/O pins keep the same state as in Run mode.
179  ****************************************************************************************
180 */
182 
183 /** @} */
184 
185 /** @addtogroup PWR_Exported_Functions_Group2 BLE Communication timer and core configuration function
186  * @{
187  */
188 
189 /**
190  ****************************************************************************************
191  * @brief Get the current value of specified timer.
192  * @note Only available on GR551xx_B2 and later versions.
193  * @param[in] timer_type: This parameter can be one of the following values:
194  * @arg @ref PWR_TIMER_TYPE_CAL_TIMER
195  * @arg @ref PWR_TIMER_TYPE_AON_WDT
196  * @arg @ref PWR_TIMER_TYPE_SLP_TIMER
197  * @arg @ref PWR_TIMER_TYPE_CAL_ALARM
198  * @param[out] p_value: Pointer to an integer storing current value
199  * @retval ::HAL_OK: Operation is OK.
200  * @retval ::HAL_ERROR: Parameter error or operation not supported.
201  * @retval ::HAL_BUSY: Driver is busy.
202  * @retval ::HAL_TIMEOUT: Timeout occurred.
203  ****************************************************************************************
204  */
205 hal_status_t hal_pwr_get_timer_current_value(uint32_t timer_type, uint32_t *p_value);
206 
207 /** @} */
208 /** @} */
209 
210 #ifdef __cplusplus
211 }
212 #endif
213 
214 
215 #endif /* ___HAL_PWR_H__ */
216 
217 /** @} */
218 
219 /** @} */
220 
221 /** @} */
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: gr_common.h:140
hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
ll_pwr.h
Header file containing functions prototypes of PWR LL library.