hal_aon_wdt.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file hal_aon_wdt.h
5 * @author BLE Driver Team
6 * @brief Header file containing functions prototypes of AON WDT 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_AON_WDT AON_WDT
47 * @brief WDT HAL module driver.
48 * @{
49 */
50
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef HAL_AON_WDT_H
53 #define HAL_AON_WDT_H
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 /* Includes ------------------------------------------------------------------*/
60 #include "ll_aon_wdt.h"
61 #include "hal_def.h"
62
63 /* Exported types ------------------------------------------------------------*/
64 /** @addtogroup HAL_AON_WDT_STRUCTURES Structures
65 * @{
66 */
67
68 /** @defgroup AON_WDT_Configuration AON_WDT Configuration
69 * @{
70 */
71
72 /**
73 * @brief AON_WDT_Configuration init structure definition
74 */
75 typedef struct _aon_wdt_init
76 {
77 uint32_t counter; /**< Specifies the AON_WDT free-running downcounter value. Unit (ms)
78 This parameter can be a number ranging between 0x0U ~ 0xFFFFFFFFU / (SystemSlowClock / 1000). */
79
80 uint32_t alarm_counter; /**< Specifies the AON_WDT downcounter alarm value before system reset.
81 When counter counts down to the alarm value, AON_WDT will generate
82 an interrupt. After counter counts down to 0, AON_WDT will then
83 request a SoC Reset. Unit (ms)
84 This parameter can be a number ranging between 0x0U ~ 0xFFFFU / (SystemSlowClock / 1000).
85 If alarm_counter > (0xFFFFU / (SystemSlowClock / 1000), the alarm register will be set the to the max value(0xFFFFU) */
86
87 } aon_wdt_init_t;
88
89 /** @} */
90
91 /** @defgroup AON_WDT_handle AON_WDT handle
92 * @{
93 */
94
95 /**
96 * @brief AON_WDT handle Structure definition
97 */
98 typedef struct _aon_wdt_handle
99 {
100 aon_wdt_init_t init; /**< AON_WDT required parameters */
101
102 uint32_t *SystemCoreLowClock; /**< AON_WDT Specifies the number of low-speed clocks. */
103 } aon_wdt_handle_t;
104
105 /** @} */
106
107 /** @} */
108
109 /** @addtogroup HAL_AON_WDT_CALLBACK_STRUCTURES Callback Structures
110 * @{
111 */
112
113 /** @defgroup HAL_AON_WDT_Callback Callback
114 * @{
115 */
116
117 /**
118 * @brief HAL_AON_WDT Callback function definition
119 */
120
121 typedef struct _hal_aon_wdt_callback
122 {
123 void (*aon_wdt_alarm_callback)(aon_wdt_handle_t *p_aon_wdt); /**< AON_WDT count complete callback */
124 } hal_aon_wdt_callback_t;
125
126 /** @} */
127
128 /** @} */
129
130 /* Exported functions --------------------------------------------------------*/
131 /** @addtogroup HAL_AON_WDT_DRIVER_FUNCTIONS Functions
132 * @{
133 */
134
135 /** @addtogroup AON_WDT_Exported_Functions_Group1 Initialization and de-initialization functions
136 * @brief Initialization and Configuration functions.
137 *
138 @verbatim
139 ==============================================================================
140 ##### Initialization and Configuration functions #####
141 ==============================================================================
142 [..]
143 This section provides functions allowing to:
144 (+) Initialize and start the AON_WDT according to the specified parameters
145 in the wdt_init_t of associated handle.
146 (+) Initialize the AON_WDT MSP.
147
148 @endverbatim
149 * @{
150 */
151
152 /**
153 ****************************************************************************************
154 * @brief Initialize the AON_WDT according to the specified parameters in the wdt_init_t
155 * of associated handle.
156 *
157 * @param[in] p_aon_wdt: Pointer to a AON_WDT handle which contains the configuration
158 * information for the specified AON_WDT module.
159 *
160 * @retval ::HAL_OK: Operation is OK.
161 * @retval ::HAL_ERROR: Parameter error or operation not supported.
162 * @retval ::HAL_BUSY: Driver is busy.
163 * @retval ::HAL_TIMEOUT: Timeout occurred.
164 ****************************************************************************************
165 */
166 hal_status_t hal_aon_wdt_init(aon_wdt_handle_t *p_aon_wdt);
167
168 /**
169 ****************************************************************************************
170 * @brief De-initialize the AON_WDT peripheral.
171 *
172 * @param[in] p_aon_wdt: AON_WDT handle.
173 *
174 * @retval ::HAL_OK: Operation is OK.
175 * @retval ::HAL_ERROR: Parameter error or operation not supported.
176 * @retval ::HAL_BUSY: Driver is busy.
177 * @retval ::HAL_TIMEOUT: Timeout occurred.
178 ****************************************************************************************
179 */
180 hal_status_t hal_aon_wdt_deinit(const aon_wdt_handle_t *p_aon_wdt);
181
182 /** @} */
183
184 /** @addtogroup AON_WDT_Exported_Functions_Group2 IO operation functions
185 * @brief IO operation functions
186 *
187 @verbatim
188 ==============================================================================
189 ##### IO operation functions #####
190 ==============================================================================
191 [..]
192 This section provides functions allowing to:
193 (+) Refresh the AON_WDT.
194 (+) Handle AON_WDT interrupt request and associated function callback.
195
196 @endverbatim
197 * @{
198 */
199
200 /**
201 ****************************************************************************************
202 * @brief Refresh the AON_WDT.
203 *
204 * @param[in] p_aon_wdt: Pointer to a AON_WDT handle which contains the configuration
205 * information for the specified AON_WDT module.
206 *
207 * @retval ::HAL_OK: Operation is OK.
208 * @retval ::HAL_ERROR: Parameter error or operation not supported.
209 * @retval ::HAL_BUSY: Driver is busy.
210 * @retval ::HAL_TIMEOUT: Timeout occurred.
211 ****************************************************************************************
212 */
213 hal_status_t hal_aon_wdt_refresh(const aon_wdt_handle_t *p_aon_wdt);
214
215 /** @} */
216
217
218 /** @addtogroup AON_WDT_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
219 * @brief IRQ Handler and Callbacks functions
220 * @{
221 */
222
223 /**
224 ****************************************************************************************
225 * @brief Handle AON_WDT interrupt request.
226 *
227 * @note The count completed can be used if specific safety operations
228 * or data logging must be performed before the actual reset is generated.
229 * When RESET Mode is enabled, AON_WDT will generate an interrupt on first timeout.
230 * If interrupt has not been cleared before the second timeout, AON_WDT will then
231 * request a SoC Reset.
232 *
233 * @param[in] p_aon_wdt: Pointer to a AON_WDT handle which contains the configuration
234 * information for the specified AON_WDT module.
235 ****************************************************************************************
236 */
237 void hal_aon_wdt_irq_handler(aon_wdt_handle_t *p_aon_wdt);
238
239 /**
240 ****************************************************************************************
241 * @brief AON_WDT count complete (counter reaches to 0) callback.
242 *
243 * @note This function should not be modified. When the callback is needed,
244 * the hal_wdt_count_cplt_callback can be implemented in the user file.
245 *
246 * @param[in] p_aon_wdt: Pointer to a AON_WDT handle which contains the configuration
247 * information for the specified AON_WDT module.
248 ****************************************************************************************
249 */
250 void hal_aon_wdt_alarm_callback(aon_wdt_handle_t *p_aon_wdt);
251
252 /**
253 ****************************************************************************************
254 * @brief Disable the AON_WDT.
255 *
256 * @retval ::HAL_OK: Operation is OK.
257 * @retval ::HAL_TIMEOUT: Timeout occurred.
258 ****************************************************************************************
259 */
260 hal_status_t hal_aon_wdt_disable(void);
261
262 /**
263 ****************************************************************************************
264 * @brief Enable the AON_WDT.
265 *
266 * @retval ::HAL_OK: Operation is OK.
267 * @retval ::HAL_TIMEOUT: Timeout occurred.
268 ****************************************************************************************
269 */
270 hal_status_t hal_aon_wdt_enable(void);
271
272 /** @} */
273
274 /** @} */
275
276 #ifdef __cplusplus
277 }
278 #endif
279
280 #endif /* HAL_AON_WDT_H */
281
282 /** @} */
283
284 /** @} */
285
286 /** @} */
_aon_wdt_init::alarm_counter
uint32_t alarm_counter
Definition: hal_aon_wdt.h:80
hal_aon_wdt_disable
hal_status_t hal_aon_wdt_disable(void)
Disable the AON_WDT.
_hal_aon_wdt_callback
HAL_AON_WDT Callback function definition.
Definition: hal_aon_wdt.h:122
_aon_wdt_handle::init
aon_wdt_init_t init
Definition: hal_aon_wdt.h:100
hal_aon_wdt_alarm_callback
void hal_aon_wdt_alarm_callback(aon_wdt_handle_t *p_aon_wdt)
AON_WDT count complete (counter reaches to 0) callback.
hal_aon_wdt_irq_handler
void hal_aon_wdt_irq_handler(aon_wdt_handle_t *p_aon_wdt)
Handle AON_WDT interrupt request.
aon_wdt_init_t
struct _aon_wdt_init aon_wdt_init_t
AON_WDT_Configuration init structure definition.
_hal_aon_wdt_callback::aon_wdt_alarm_callback
void(* aon_wdt_alarm_callback)(aon_wdt_handle_t *p_aon_wdt)
Definition: hal_aon_wdt.h:123
aon_wdt_handle_t
struct _aon_wdt_handle aon_wdt_handle_t
AON_WDT handle Structure definition.
ll_aon_wdt.h
Header file containing functions prototypes of AON WDT LL library.
hal_aon_wdt_enable
hal_status_t hal_aon_wdt_enable(void)
Enable the AON_WDT.
_aon_wdt_handle::SystemCoreLowClock
uint32_t * SystemCoreLowClock
Definition: hal_aon_wdt.h:102
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.
hal_aon_wdt_init
hal_status_t hal_aon_wdt_init(aon_wdt_handle_t *p_aon_wdt)
Initialize the AON_WDT according to the specified parameters in the wdt_init_t of associated handle.
hal_aon_wdt_deinit
hal_status_t hal_aon_wdt_deinit(const aon_wdt_handle_t *p_aon_wdt)
De-initialize the AON_WDT peripheral.
_aon_wdt_init::counter
uint32_t counter
Definition: hal_aon_wdt.h:77
_aon_wdt_handle
AON_WDT handle Structure definition.
Definition: hal_aon_wdt.h:99
_aon_wdt_init
AON_WDT_Configuration init structure definition.
Definition: hal_aon_wdt.h:76
hal_aon_wdt_refresh
hal_status_t hal_aon_wdt_refresh(const aon_wdt_handle_t *p_aon_wdt)
Refresh the AON_WDT.
hal_aon_wdt_callback_t
struct _hal_aon_wdt_callback hal_aon_wdt_callback_t
HAL_AON_WDT Callback function definition.