gr55xx_hal_sleep_timer.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file gr55xx_hal_sleep_timer.h
5 * @author BLE Driver Team
6 * @brief Header file containing functions prototypes of sleep timer LL 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_SLP_TIM SLP_TIM
47 * @brief SLEEP TIMER HAL module driver.
48 * @{
49 */
50
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55xx_HAL_SLEEP_TIMER_H__
53 #define __GR55xx_HAL_SLEEP_TIMER_H__
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx_ll_sleep_timer.h"
61 #include "gr55xx_hal_def.h"
62
63 /* Exported types ------------------------------------------------------------*/
64
65 /** @addtogroup HAL_PWR_CALLBACK_STRUCTURES Callback Structures
66 * @{
67 */
68 /** @defgroup HAL_PWR_SLEEP_ELAPSED_HANDLER HAL PWR sleep elapsed handler define
69 * @{
70 */
71
72 /**
73 * @brief PWR Sleep Timer Elapsed callback
74 */
75 typedef void (*pwr_slp_elapsed_handler_t)(void);
76
77 /** @} */
78
79
80 /** @defgroup HAL_PWR_CALLBACK_HANDLER PWR callback handle
81 * @{
82 */
83 /**
84 * @brief PWR callback handle Structure definition
85 */
86 typedef struct _pwr_handler
87 {
88 pwr_slp_elapsed_handler_t pwr_slp_elapsed_hander; /**< PWR sleep timer elapsed callback */
89 } pwr_handler_t;
90
91 /** @} */
92 /** @} */
93
94 /**
95 * @defgroup HAL_PWR_MACRO Defines
96 * @{
97 */
98
99 /* Exported constants --------------------------------------------------------*/
100 /** @defgroup PWR_Exported_Constants PWR Exported Constants
101 * @{
102 */
103
104 /** @defgroup PWR_Sleep_Timer_Mode PWR Sleep Timer Mode
105 * @{
106 */
107 #define PWR_SLP_TIMER_MODE_NORMAL LL_SLEEP_TIMER_SINGLE_MODE_0 /**< Start counting after sleeping and disabled when waked up */
108 #define PWR_SLP_TIMER_MODE_SINGLE LL_SLEEP_TIMER_SINGLE_MODE_1 /**< Single mode(keep counting until finished) */
109 #define PWR_SLP_TIMER_MODE_RELOAD LL_SLEEP_TIMER_AUTO_MODE /**< Auto reload */
110 /** @} */
111
112 /** @defgroup SLEEP_TIMER_CLK_SEL Sleep Timer Clock Source
113 * @{
114 */
115 #define SLEEP_TIMER_CLK_SEL_RNG_OSC LL_SLEEP_TIMER_CLK_SEL_RNG_OSC /**< Set Sleep Timer Clock Source as RNG. */
116 #define SLEEP_TIMER_CLK_SEL_XO LL_SLEEP_TIMER_CLK_SEL_XO /**< Set Sleep Timer Clock Source as XO. */
117 #define SLEEP_TIMER_CLK_SEL_RNG2_OSC LL_SLEEP_TIMER_CLK_SEL_RNG2_OSC /**< Set Sleep Timer Clock Source as RNG2. */
118 #define SLEEP_TIMER_CLK_SEL_RTC_OSC LL_SLEEP_TIMER_CLK_SEL_RTC_OSC /**< Set Sleep Timer Clock Source as RTC. */
119 /** @} */
120
121 /** @defgroup PWR_Timeout_definition PWR Timeout definition
122 * @{
123 */
124 #define HAL_PWR_TIMEOUT_DEFAULT_VALUE ((uint32_t)0x000FFFFF) /**< 0xFFFFF counts */
125 /** @} */
126
127 /** @defgroup Sleep_Timer_Overflow Overflow value definition
128 * @{
129 */
130 #define HAL_SLP_TIMER_OVERFLOW_VALUE (0xFFFFFFFFU) /**< After counting to 0, the count value rolls over to 0xFFFFFFFF */
131 /** @} */
132
133 /** @} */
134 /** @} */
135
136 /* Exported functions --------------------------------------------------------*/
137 /** @addtogroup HAL_PWR_DRIVER_FUNCTIONS Functions
138 * @{
139 */
140
141 /** @addtogroup PWR_Exported_Functions_Group1 Low Power mode configuration functions
142 * @{
143 */
144
145 /**
146 ****************************************************************************************
147 * @brief Configure the AON Sleep Timer mode, count and start used to wakeup MCU.
148 * @param[in] mode: Specifies the sleep timer mode.
149 * This parameter can be a combination of the following values:
150 * @arg @ref PWR_SLP_TIMER_MODE_NORMAL
151 * @arg @ref PWR_SLP_TIMER_MODE_SINGLE
152 * @arg @ref PWR_SLP_TIMER_MODE_RELOAD
153 * @param[in] value: Count value of the AON Sleep Timer.
154 * @retval ::HAL_OK: Operation is OK.
155 * @retval ::HAL_BUSY: Driver is busy.
156 * @note The sleep clock of AON Timer is 32 KHz.
157 ****************************************************************************************
158 */
159 hal_status_t hal_sleep_timer_config_and_start(uint8_t mode, uint32_t value);
160
161 /**
162 ****************************************************************************************
163 * @brief stop Sleep Timer
164 ****************************************************************************************
165 */
166 void hal_sleep_timer_stop(void);
167
168 /**
169 ****************************************************************************************
170 * @brief Get the reload value of sleep timer
171 * @retval the reload value of sleep timer
172 ****************************************************************************************
173 */
174 uint32_t hal_sleep_timer_get_reload_value(void);
175
176 /**
177 ****************************************************************************************
178 * @brief Get the current value of sleep timer
179 * @retval the current value of sleep timer
180 ****************************************************************************************
181 */
182 uint32_t hal_sleep_timer_get_current_value(void);
183
184 /**
185 ****************************************************************************************
186 * @brief Get clock frequency of sleep timer
187 * @retval clock frequency of sleep timer
188 ****************************************************************************************
189 */
190 uint32_t hal_sleep_timer_get_clock_freq(void);
191
192 /**
193 ****************************************************************************************
194 * @brief Set the clock source of sleep timer
195 * @param[in] clock_src: value This parameter can be a one of the following values:
196 * @arg @ref SLEEP_TIMER_CLK_SEL_RNG_OSC
197 * @arg @ref SLEEP_TIMER_CLK_SEL_XO
198 * @arg @ref SLEEP_TIMER_CLK_SEL_RNG2_OSC
199 * @arg @ref SLEEP_TIMER_CLK_SEL_RTC_OSC
200 ****************************************************************************************
201 */
202 void hal_sleep_timer_clock_set(uint32_t clock_src);
203
204 /**
205 ****************************************************************************************
206 * @brief get sleep timer is running or not
207 * @retval runing state of sleep timer (1 or 0).
208 ****************************************************************************************
209 */
210 uint8_t hal_sleep_timer_status_get(void);
211 /** @} */
212
213 /** @addtogroup PWR_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
214 * @brief IRQ Handler and Callbacks functions
215 * @{
216 */
217 /**
218 ****************************************************************************************
219 * @brief Handle PWR Sleep Timer interrupt request.
220 * @note Only available on GR551xx_B2 and later versions.
221 ****************************************************************************************
222 */
223 void hal_pwr_sleep_timer_irq_handler(void);
224
225 /**
226 ****************************************************************************************
227 * @brief PWR Sleep Timer Elapsed callback.
228 * @note Only available on GR551xx_B2 and later versions.
229 * This function should not be modified. When the callback is needed,
230 * the hal_pwr_sleep_timer_elapsed_callback can be implemented in the user file.
231 ****************************************************************************************
232 */
233 void hal_pwr_sleep_timer_elapsed_callback(void);
234
235 /** @} */
236 /** @} */
237
238 #ifdef __cplusplus
239 }
240 #endif
241
242 #endif /* __GR55xx_HAL_SLEEP_TIMER_H__ */
243
244 /** @} */
245
246 /** @} */
247
248 /** @} */
hal_sleep_timer_config_and_start
hal_status_t hal_sleep_timer_config_and_start(uint8_t mode, uint32_t value)
Configure the AON Sleep Timer mode, count and start used to wakeup MCU.
hal_pwr_sleep_timer_elapsed_callback
void hal_pwr_sleep_timer_elapsed_callback(void)
PWR Sleep Timer Elapsed callback.
hal_sleep_timer_get_current_value
uint32_t hal_sleep_timer_get_current_value(void)
Get the current value of sleep timer.
pwr_handler_t
struct _pwr_handler pwr_handler_t
PWR callback handle Structure definition.
hal_pwr_sleep_timer_irq_handler
void hal_pwr_sleep_timer_irq_handler(void)
Handle PWR Sleep Timer interrupt request.
hal_sleep_timer_get_reload_value
uint32_t hal_sleep_timer_get_reload_value(void)
Get the reload value of sleep timer.
pwr_slp_elapsed_handler_t
void(* pwr_slp_elapsed_handler_t)(void)
PWR Sleep Timer Elapsed callback.
Definition: gr55xx_hal_sleep_timer.h:75
_pwr_handler
PWR callback handle Structure definition.
Definition: gr55xx_hal_sleep_timer.h:87
gr55xx_ll_sleep_timer.h
Header file containing functions prototypes of sleep timer LL library.
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr55xx_hal_def.h:70
hal_sleep_timer_get_clock_freq
uint32_t hal_sleep_timer_get_clock_freq(void)
Get clock frequency of sleep timer.
hal_sleep_timer_stop
void hal_sleep_timer_stop(void)
stop Sleep Timer
hal_sleep_timer_status_get
uint8_t hal_sleep_timer_status_get(void)
get sleep timer is running or not
_pwr_handler::pwr_slp_elapsed_hander
pwr_slp_elapsed_handler_t pwr_slp_elapsed_hander
Definition: gr55xx_hal_sleep_timer.h:88
hal_sleep_timer_clock_set
void hal_sleep_timer_clock_set(uint32_t clock_src)
Set the clock source of sleep timer.
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.