gr55xx_ll_wdt.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file gr55xx_ll_wdt.h
5 * @author BLE Driver Team
6 * @brief Header file containing functions prototypes of WDT 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 LL_DRIVER LL Driver
43 * @{
44 */
45
46 /** @defgroup LL_WDT WDT
47 * @brief WDT LL module driver.
48 * @{
49 */
50
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55XX_LL_WDT_H__
53 #define __GR55XX_LL_WDT_H__
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx.h"
61
62 #if defined (WDT)
63
64 /**
65 * @defgroup WDT_LL_MACRO Defines
66 * @{
67 */
68
69 /* Private constants ---------------------------------------------------------*/
70 /** @defgroup WDT_LL_Private_Constants WDT Private Constants
71 * @{
72 */
73
74 /** @defgroup WDT_LL_PC_WR_ACCESS Write Access Defines
75 * @{
76 */
77 #define LL_WDT_LOCK_WR_ACCESS_ENABLE 0x1ACCE551 /**< WDT LOCK Write Access Enable */
78 #define LL_WDT_LOCK_WR_ACCESS_DISABLE (~0x1ACCE551) /**< WDT LOCK Write Access Disable */
79 /** @} */
80
81 /** @} */
82
83 /* Exported macro ------------------------------------------------------------*/
84 /** @defgroup WDT_LL_Exported_Macros WDT Exported Macros
85 * @{
86 */
87
88 /** @defgroup WDT_LL_EM_WRITE_READ Common Write and read registers Macros
89 * @{
90 */
91
92 /**
93 * @brief Write a value in WDT register
94 * @param __instance__ WDT instance
95 * @param __REG__ Register to be written
96 * @param __VALUE__ Value to be written in the register
97 * @retval None
98 */
99 #define LL_WDT_WriteReg(__instance__, __REG__, __VALUE__) WRITE_REG(__instance__->__REG__, (__VALUE__))
100
101 /**
102 * @brief Read a value in WDT register
103 * @param __instance__ WDT instance
104 * @param __REG__ Register to be read
105 * @retval Register value
106 */
107 #define LL_WDT_ReadReg(__instance__, __REG__) READ_REG(__instance__->__REG__)
108 /** @} */
109
110 /** @} */
111
112 /** @} */
113
114 /* Exported functions --------------------------------------------------------*/
115 /** @defgroup WDT_LL_DRIVER_FUNCTIONS Functions
116 * @{
117 */
118
119 /** @defgroup WDT_LL_EF_Configuration Configuration functions
120 * @{
121 */
122
123 /**
124 * @brief Enable write access to WDT_LOAD, WDT_CTRL and WDT_INTCLR registers.
125 *
126 * Register|BitsName
127 * --------|--------
128 * LOCK | ENRW
129 *
130 * @param WDTx WDT instance
131 * @retval None
132 */
133 __STATIC_INLINE void ll_wdt_enable_write_access(wdt_regs_t *WDTx)
134 {
135 WRITE_REG(WDTx->LOCK, LL_WDT_LOCK_WR_ACCESS_ENABLE);
136 }
137
138 /**
139 * @brief Disable write access to WDT_LOAD, WDT_CTRL and WDT_INTCLR registers.
140 *
141 * Register|BitsName
142 * --------|--------
143 * LOCK | ENRW
144 *
145 * @param WDTx WDT instance
146 * @retval None
147 */
148 __STATIC_INLINE void ll_wdt_disable_write_access(wdt_regs_t *WDTx)
149 {
150 WRITE_REG(WDTx->LOCK, LL_WDT_LOCK_WR_ACCESS_DISABLE);
151 }
152
153 /**
154 * @brief Enable watchdog counter and interrupt event.
155 *
156 * Register|BitsName
157 * --------|--------
158 * CTRL | INTEN
159 *
160 * @param WDTx WDT instance.
161 * @retval None
162 */
163 __STATIC_INLINE void ll_wdt_enable(wdt_regs_t *WDTx)
164 {
165 SET_BITS(WDTx->CTRL, WDT_CTRL_INTEN);
166 }
167
168 /**
169 * @brief Disable watchdog counter and interrupt event.
170 *
171 * Register|BitsName
172 * --------|--------
173 * CTRL | INTEN
174 *
175 * @param WDTx WDT instance.
176 * @retval None
177 */
178 __STATIC_INLINE void ll_wdt_disable(wdt_regs_t *WDTx)
179 {
180 CLEAR_BITS(WDTx->CTRL, WDT_CTRL_INTEN);
181 }
182
183 /**
184 * @brief Check if the WDT peripheral is enabled or disabled.
185 *
186 * Register|BitsName
187 * --------|--------
188 * CTRL | INTEN
189 *
190 * @param WDTx WDT instance.
191 * @retval State of bit (1 or 0).
192 */
193 __STATIC_INLINE uint32_t ll_wdt_is_enabled(wdt_regs_t *WDTx)
194 {
195 return (READ_BITS(WDTx->CTRL, WDT_CTRL_INTEN) == (WDT_CTRL_INTEN));
196 }
197
198 /**
199 * @brief Enable reset output.
200 * @note RSTEN acts as a mask for the reset output.
201 *
202 * Register|BitsName
203 * --------|--------
204 * CTRL | RSTEN
205 *
206 * @param WDTx WDT instance.
207 * @retval None
208 */
209 __STATIC_INLINE void ll_wdt_enable_reset(wdt_regs_t *WDTx)
210 {
211 SET_BITS(WDTx->CTRL, WDT_CTRL_RSTEN);
212 }
213
214 /**
215 * @brief Disable reset output.
216 *
217 * Register|BitsName
218 * --------|--------
219 * CTRL | RSTEN
220 *
221 * @param WDTx WDT instance.
222 * @retval None
223 */
224 __STATIC_INLINE void ll_wdt_disable_reset(wdt_regs_t *WDTx)
225 {
226 CLEAR_BITS(WDTx->CTRL, WDT_CTRL_RSTEN);
227 }
228
229 /**
230 * @brief Check if the WDT reset is enabled or disabled.
231 *
232 * Register|BitsName
233 * --------|--------
234 * CTRL | RSTEN
235 *
236 * @param WDTx WDT instance.
237 * @retval State of bit (1 or 0).
238 */
239 __STATIC_INLINE uint32_t ll_wdt_is_enabled_reset(wdt_regs_t *WDTx)
240 {
241 return (READ_BITS(WDTx->CTRL, WDT_CTRL_RSTEN) == (WDT_CTRL_RSTEN));
242 }
243
244 /**
245 * @brief Specify the WDT down-counter reload value.
246 *
247 * Register|BitsName
248 * --------|--------
249 * LOAD | LOAD
250 *
251 * @param WDTx WDT instance
252 * @param counter Value range between Min_Data=0 and Max_Data=0xFFFFFFFF
253 * @retval None
254 */
255 __STATIC_INLINE void ll_wdt_set_counter_load(wdt_regs_t *WDTx, uint32_t counter)
256 {
257 WRITE_REG(WDTx->LOAD, counter);
258 }
259
260 /**
261 * @brief Get the specified WDT down-counter reload value.
262 *
263 * Register|BitsName
264 * --------|--------
265 * LOAD | LOAD
266 *
267 * @param WDTx WDT instance
268 * @retval Value range between Min_Data=0 and Max_Data=0x0FFF
269 */
270 __STATIC_INLINE uint32_t ll_wdt_get_counter_load(wdt_regs_t *WDTx)
271 {
272 return (uint32_t)(READ_REG(WDTx->LOAD));
273 }
274
275 /**
276 * @brief Get current value of the specified WDT decrementing down-counter.
277 *
278 * Register|BitsName
279 * --------|--------
280 * VALUE | VALUE
281 *
282 * @param WDTx WDT instance
283 * @retval Value range between Min_Data=0 and Max_Data=0x0FFF
284 */
285 __STATIC_INLINE uint32_t ll_wdt_get_counter_value(wdt_regs_t *WDTx)
286 {
287 return (uint32_t)(READ_REG(WDTx->VALUE));
288 }
289
290 /**
291 * @brief Reloads WDT counter with value defined in the reload register
292 *
293 * Register|BitsName
294 * --------|--------
295 * INTCLR | INTCLR
296 *
297 * @param WDTx WDT instance
298 * @retval None
299 */
300 __STATIC_INLINE void ll_wdt_reload_counter(wdt_regs_t *WDTx)
301 {
302 WRITE_REG(WDTx->INTCLR, WDT_INTCLR);
303 }
304
305 /** @} */
306
307 /** @defgroup WDT_LL_EF_FLAG_Management FLAG_Management
308 * @{
309 */
310
311 /**
312 * @brief Indicate if the WDT Interrupt Flag is set or not.
313 * @note This bit is set by hardware when the counter has reached 0. It can
314 * be cleared by software by writing any value to the INTCLR Register.
315 *
316 * Register|BitsName
317 * --------|--------
318 * MIS | INTSTAT
319 *
320 * @param WDTx WDT instance.
321 * @retval State of bit (1 or 0).
322 */
323 __STATIC_INLINE uint32_t ll_wdt_is_active_flag_it(wdt_regs_t *WDTx)
324 {
325 return (READ_BITS(WDTx->MIS, WDT_MIS_INTSTAT) == (WDT_MIS_INTSTAT));
326 }
327
328 /**
329 * @brief Clear Interrupt Status flag.
330 *
331 * Register|BitsName
332 * --------|--------
333 * INTCLR| INTCLR
334 *
335 * @param WDTx WDT instance.
336 * @retval None
337 */
338 __STATIC_INLINE void ll_wdt_clear_flag_it(wdt_regs_t *WDTx)
339 {
340 WRITE_REG(WDTx->INTCLR, WDT_INTCLR);
341 }
342
343 /** @} */
344
345 /** @} */
346
347 #endif /* WDT */
348
349 #ifdef __cplusplus
350 }
351 #endif
352
353 #endif /* __GR55XX_LL_WDT_H__ */
354
355 /** @} */
356
357 /** @} */
358
359 /** @} */
ll_wdt_set_counter_load
__STATIC_INLINE void ll_wdt_set_counter_load(wdt_regs_t *WDTx, uint32_t counter)
Specify the WDT down-counter reload value.
Definition: gr55xx_ll_wdt.h:255
ll_wdt_enable_reset
__STATIC_INLINE void ll_wdt_enable_reset(wdt_regs_t *WDTx)
Enable reset output.
Definition: gr55xx_ll_wdt.h:209
ll_wdt_enable
__STATIC_INLINE void ll_wdt_enable(wdt_regs_t *WDTx)
Enable watchdog counter and interrupt event.
Definition: gr55xx_ll_wdt.h:163
ll_wdt_is_enabled
__STATIC_INLINE uint32_t ll_wdt_is_enabled(wdt_regs_t *WDTx)
Check if the WDT peripheral is enabled or disabled.
Definition: gr55xx_ll_wdt.h:193
ll_wdt_disable_reset
__STATIC_INLINE void ll_wdt_disable_reset(wdt_regs_t *WDTx)
Disable reset output.
Definition: gr55xx_ll_wdt.h:224
ll_wdt_get_counter_value
__STATIC_INLINE uint32_t ll_wdt_get_counter_value(wdt_regs_t *WDTx)
Get current value of the specified WDT decrementing down-counter.
Definition: gr55xx_ll_wdt.h:285
ll_wdt_disable_write_access
__STATIC_INLINE void ll_wdt_disable_write_access(wdt_regs_t *WDTx)
Disable write access to WDT_LOAD, WDT_CTRL and WDT_INTCLR registers.
Definition: gr55xx_ll_wdt.h:148
ll_wdt_is_active_flag_it
__STATIC_INLINE uint32_t ll_wdt_is_active_flag_it(wdt_regs_t *WDTx)
Indicate if the WDT Interrupt Flag is set or not.
Definition: gr55xx_ll_wdt.h:323
ll_wdt_clear_flag_it
__STATIC_INLINE void ll_wdt_clear_flag_it(wdt_regs_t *WDTx)
Clear Interrupt Status flag.
Definition: gr55xx_ll_wdt.h:338
ll_wdt_get_counter_load
__STATIC_INLINE uint32_t ll_wdt_get_counter_load(wdt_regs_t *WDTx)
Get the specified WDT down-counter reload value.
Definition: gr55xx_ll_wdt.h:270
ll_wdt_is_enabled_reset
__STATIC_INLINE uint32_t ll_wdt_is_enabled_reset(wdt_regs_t *WDTx)
Check if the WDT reset is enabled or disabled.
Definition: gr55xx_ll_wdt.h:239
ll_wdt_disable
__STATIC_INLINE void ll_wdt_disable(wdt_regs_t *WDTx)
Disable watchdog counter and interrupt event.
Definition: gr55xx_ll_wdt.h:178
LL_WDT_LOCK_WR_ACCESS_ENABLE
#define LL_WDT_LOCK_WR_ACCESS_ENABLE
WDT LOCK Write Access Enable
Definition: gr55xx_ll_wdt.h:77
ll_wdt_enable_write_access
__STATIC_INLINE void ll_wdt_enable_write_access(wdt_regs_t *WDTx)
Enable write access to WDT_LOAD, WDT_CTRL and WDT_INTCLR registers.
Definition: gr55xx_ll_wdt.h:133
ll_wdt_reload_counter
__STATIC_INLINE void ll_wdt_reload_counter(wdt_regs_t *WDTx)
Reloads WDT counter with value defined in the reload register.
Definition: gr55xx_ll_wdt.h:300
LL_WDT_LOCK_WR_ACCESS_DISABLE
#define LL_WDT_LOCK_WR_ACCESS_DISABLE
WDT LOCK Write Access Disable.
Definition: gr55xx_ll_wdt.h:78