gr55xx_ll_calendar.h
Go to the documentation of this file.
1
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55XX_LL_CALENDAR_H__
53 #define __GR55XX_LL_CALENDAR_H__
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx.h"
61
62 #if defined(AON)
63
68 /* Exported constants --------------------------------------------------------*/
76 #define LL_CALENDAR_DIV_NONE ((uint32_t)0x00U)
77 #define LL_CALENDAR_DIV_32 ((uint32_t)0x01U << AON_CALENDAR_TIMER_CTL_CLK_SEL_Pos)
78 #define LL_CALENDAR_DIV_64 ((uint32_t)0x02U << AON_CALENDAR_TIMER_CTL_CLK_SEL_Pos)
79 #define LL_CALENDAR_DIV_128 ((uint32_t)0x03U << AON_CALENDAR_TIMER_CTL_CLK_SEL_Pos)
80 #define LL_CALENDAR_DIV_256 ((uint32_t)0x04U << AON_CALENDAR_TIMER_CTL_CLK_SEL_Pos)
81 #define LL_CALENDAR_NO_CLOCK ((uint32_t)0x05U << AON_CALENDAR_TIMER_CTL_CLK_SEL_Pos)
87 /* Exported functions --------------------------------------------------------*/
88
105 __STATIC_INLINE void ll_calendar_enable(void)
106 {
107 SET_BITS(AON->CALENDAR_TIMER_CTL, AON_CALENDAR_TIMER_CTL_EN);
108 }
109
119 __STATIC_INLINE void ll_calendar_disable(void)
120 {
121 CLEAR_BITS(AON->CALENDAR_TIMER_CTL, AON_CALENDAR_TIMER_CTL_EN);
122 }
123
133 __STATIC_INLINE uint32_t ll_calendar_is_enabled(void)
134 {
135 return (READ_BITS(AON->CALENDAR_TIMER_CTL, AON_CALENDAR_TIMER_CTL_EN) == (AON_CALENDAR_TIMER_CTL_EN));
136 }
137
148 __STATIC_INLINE void ll_calendar_reload_counter(uint32_t counter)
149 {
150 WRITE_REG(AON->TIMER_VALUE, counter);
151 SET_BITS(AON->CALENDAR_TIMER_CTL, AON_CALENDAR_TIMER_CTL_VAL_LOAD);
152 }
153
164 __STATIC_INLINE void ll_calendar_reload_alarm(uint32_t alarm)
165 {
166 WRITE_REG(AON->TIMER_VALUE, alarm);
167 SET_BITS(AON->CALENDAR_TIMER_CTL, AON_CALENDAR_TIMER_CTL_ALARM_VAL_LOAD);
168 }
169
180 __STATIC_INLINE uint32_t ll_calendar_get_counter(void)
181 {
182 GLOBAL_EXCEPTION_DISABLE();
183 MODIFY_REG(AON->AON_PAD_CTL1, AON_PAD_CTL1_TIMER_READ_SEL, AON_PAD_CTL1_TIMER_READ_SEL_CAL_TIMER);
184 GLOBAL_EXCEPTION_ENABLE();
185 return (uint32_t)READ_REG(AON->TIMER_VAL);
186 }
187
198 __STATIC_INLINE uint32_t ll_calendar_get_alarm(void)
199 {
200 GLOBAL_EXCEPTION_DISABLE();
201 MODIFY_REG(AON->AON_PAD_CTL1, AON_PAD_CTL1_TIMER_READ_SEL, AON_PAD_CTL1_TIMER_READ_SEL_CAL_ALARM);
202 GLOBAL_EXCEPTION_ENABLE();
203 return (uint32_t)READ_REG(AON->TIMER_VAL);
204 }
205
216 __STATIC_INLINE uint32_t ll_calendar_get_wrapcnt(void)
217 {
218 return (uint32_t)(READ_BITS(AON->CALENDAR_TIMER_CTL, AON_CALENDAR_TIMER_CTL_WRAP_CNT) >> AON_CALENDAR_TIMER_CTL_WRAP_CNT_Pos);
219 }
220
237 __STATIC_INLINE void ll_calendar_set_clock_div(uint32_t div)
238 {
239 MODIFY_REG(AON->CALENDAR_TIMER_CTL, AON_CALENDAR_TIMER_CTL_CLK_SEL, div);
240 }
241
251 __STATIC_INLINE void ll_calendar_it_enable_alarm(void)
252 {
253 SET_BITS(AON->CALENDAR_TIMER_CTL, AON_CALENDAR_TIMER_CTL_ALARM_INT_EN);
254 }
255
265 __STATIC_INLINE void ll_calendar_it_disable_alarm(void)
266 {
267 CLEAR_BITS(AON->CALENDAR_TIMER_CTL, AON_CALENDAR_TIMER_CTL_ALARM_INT_EN);
268 }
269
279 __STATIC_INLINE uint32_t ll_calendar_it_is_enabled_alarm(void)
280 {
281 return (READ_BITS(AON->CALENDAR_TIMER_CTL, AON_CALENDAR_TIMER_CTL_ALARM_INT_EN) == (AON_CALENDAR_TIMER_CTL_ALARM_INT_EN));
282 }
283
293 __STATIC_INLINE void ll_calendar_it_enable_wrap(void)
294 {
295 SET_BITS(AON->CALENDAR_TIMER_CTL, AON_CALENDAR_TIMER_CTL_WRAP_INT_EN);
296 }
297
307 __STATIC_INLINE void ll_calendar_it_disable_wrap(void)
308 {
309 CLEAR_BITS(AON->CALENDAR_TIMER_CTL, AON_CALENDAR_TIMER_CTL_WRAP_INT_EN);
310 }
311
321 __STATIC_INLINE uint32_t ll_calendar_it_is_enabled_wrap(void)
322 {
323 return (READ_BITS(AON->CALENDAR_TIMER_CTL, AON_CALENDAR_TIMER_CTL_WRAP_INT_EN) == (AON_CALENDAR_TIMER_CTL_WRAP_INT_EN));
324 }
325
343 __STATIC_INLINE uint32_t ll_calendar_is_active_flag_alarm(void)
344 {
345 return (uint32_t)(READ_BITS(AON->SLP_EVENT, AON_SLP_EVENT_CALENDAR_TIMER_ALARM) == AON_SLP_EVENT_CALENDAR_TIMER_ALARM);
346 }
347
359 __STATIC_INLINE uint32_t ll_calendar_is_active_flag_wrap(void)
360 {
361 return (uint32_t)(READ_BITS(AON->SLP_EVENT, AON_SLP_EVENT_CALENDAR_TIMER_WRAP) == AON_SLP_EVENT_CALENDAR_TIMER_WRAP);
362 }
363
373 __STATIC_INLINE void ll_calendar_clear_flag_alarm(void)
374 {
375 GLOBAL_EXCEPTION_DISABLE();
376 WRITE_REG(AON->SLP_EVENT, ~AON_SLP_EVENT_CALENDAR_TIMER_ALARM);
377 GLOBAL_EXCEPTION_ENABLE();
378 }
379
389 __STATIC_INLINE void ll_calendar_clear_flag_wrap(void)
390 {
391 GLOBAL_EXCEPTION_DISABLE();
392 WRITE_REG(AON->SLP_EVENT, ~AON_SLP_EVENT_CALENDAR_TIMER_WRAP);
393 GLOBAL_EXCEPTION_ENABLE();
394 }
395
400 #endif /* CALENDAR */
401
402 #ifdef __cplusplus
403 }
404 #endif
405
406 #endif /* __GR55XX_LL_CALENDAR_H__ */
407
ll_calendar_is_enabled
__STATIC_INLINE uint32_t ll_calendar_is_enabled(void)
Check if the CALENDAR peripheral is enabled or disabled.
Definition: gr55xx_ll_calendar.h:133
ll_calendar_get_alarm
__STATIC_INLINE uint32_t ll_calendar_get_alarm(void)
Read the CALENDAR counter alarm value.
Definition: gr55xx_ll_calendar.h:198
ll_calendar_clear_flag_alarm
__STATIC_INLINE void ll_calendar_clear_flag_alarm(void)
Clear calendar alarm interrupt flag.
Definition: gr55xx_ll_calendar.h:373
ll_calendar_reload_counter
__STATIC_INLINE void ll_calendar_reload_counter(uint32_t counter)
Reloads CALENDAR counter.
Definition: gr55xx_ll_calendar.h:148
ll_calendar_is_active_flag_wrap
__STATIC_INLINE uint32_t ll_calendar_is_active_flag_wrap(void)
Indicate if the CALENDAR wrap event flag is set or not.
Definition: gr55xx_ll_calendar.h:359
ll_calendar_it_enable_alarm
__STATIC_INLINE void ll_calendar_it_enable_alarm(void)
Enable calendar alarm interrupt.
Definition: gr55xx_ll_calendar.h:251
ll_calendar_it_enable_wrap
__STATIC_INLINE void ll_calendar_it_enable_wrap(void)
Enable calendar wrap interrupt.
Definition: gr55xx_ll_calendar.h:293
ll_calendar_clear_flag_wrap
__STATIC_INLINE void ll_calendar_clear_flag_wrap(void)
Clear calendar wrap interrupt flag.
Definition: gr55xx_ll_calendar.h:389
ll_calendar_it_is_enabled_alarm
__STATIC_INLINE uint32_t ll_calendar_it_is_enabled_alarm(void)
Check if the CALENDAR alarm interrupt is enabled or disabled.
Definition: gr55xx_ll_calendar.h:279
ll_calendar_disable
__STATIC_INLINE void ll_calendar_disable(void)
Disable calendar counter.
Definition: gr55xx_ll_calendar.h:119
ll_calendar_enable
__STATIC_INLINE void ll_calendar_enable(void)
Enable calendar counter.
Definition: gr55xx_ll_calendar.h:105
ll_calendar_is_active_flag_alarm
__STATIC_INLINE uint32_t ll_calendar_is_active_flag_alarm(void)
Indicate if the CALENDAR alarm event flag is set or not.
Definition: gr55xx_ll_calendar.h:343
ll_calendar_set_clock_div
__STATIC_INLINE void ll_calendar_set_clock_div(uint32_t div)
Select the CALENDAR clock divider.
Definition: gr55xx_ll_calendar.h:237
ll_calendar_reload_alarm
__STATIC_INLINE void ll_calendar_reload_alarm(uint32_t alarm)
Reloads CALENDAR alarm.
Definition: gr55xx_ll_calendar.h:164
ll_calendar_get_wrapcnt
__STATIC_INLINE uint32_t ll_calendar_get_wrapcnt(void)
Get the CALENDAR wrap-around value.
Definition: gr55xx_ll_calendar.h:216
ll_calendar_it_disable_alarm
__STATIC_INLINE void ll_calendar_it_disable_alarm(void)
Disable calendar alarm interrupt.
Definition: gr55xx_ll_calendar.h:265
ll_calendar_it_disable_wrap
__STATIC_INLINE void ll_calendar_it_disable_wrap(void)
Disable calendar warp interrupt.
Definition: gr55xx_ll_calendar.h:307
ll_calendar_get_counter
__STATIC_INLINE uint32_t ll_calendar_get_counter(void)
Read the CALENDAR counter current value.
Definition: gr55xx_ll_calendar.h:180
ll_calendar_it_is_enabled_wrap
__STATIC_INLINE uint32_t ll_calendar_it_is_enabled_wrap(void)
Check if the CALENDAR wrap interrupt is enabled or disabled.
Definition: gr55xx_ll_calendar.h:321