gr55xx_ll_calendar.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file gr55xx_ll_calendar.h
5  * @author BLE Driver Team
6  * @brief Header file containing functions prototypes of CALENDAR 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_CALENDAR CALENDAR
47  * @brief CALENDAR LL module driver.
48  * @{
49  */
50 
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 /**
63  * @defgroup CALENDAR_LL_MACRO Defines
64  * @{
65  */
66 /* Exported constants --------------------------------------------------------*/
67 /** @defgroup CALENDAR_LL_Exported_Constants CALENDAR Exported Constants
68  * @{
69  */
70 /** @defgroup CALENDAR_LL_EC_CLOCK_DIV Clock divider
71  * @{
72  */
73 #define LL_CALENDAR_DIV_NONE ((uint32_t)0x00U) /**< Select SLP_CLK */
74 #define LL_CALENDAR_DIV_2 ((uint32_t)0x01U << RTC_CFG1_DIV_Pos) /**< Select 1/32 divider */
75 #define LL_CALENDAR_DIV_4 ((uint32_t)0x02U << RTC_CFG1_DIV_Pos) /**< Select 1/32 divider */
76 #define LL_CALENDAR_DIV_8 ((uint32_t)0x03U << RTC_CFG1_DIV_Pos) /**< Select 1/32 divider */
77 #define LL_CALENDAR_DIV_16 ((uint32_t)0x04U << RTC_CFG1_DIV_Pos) /**< Select 1/32 divider */
78 #define LL_CALENDAR_DIV_32 ((uint32_t)0x05U << RTC_CFG1_DIV_Pos) /**< Select 1/64 divider */
79 #define LL_CALENDAR_DIV_64 ((uint32_t)0x06U << RTC_CFG1_DIV_Pos) /**< Select 1/128 divider */
80 #define LL_CALENDAR_DIV_128 ((uint32_t)0x07U << RTC_CFG1_DIV_Pos) /**< Select 1/256 divider */
81 /** @} */
82 
83 /** @defgroup AON_CTL_CLDR_TIMER_CLK_SEL Calendar Timer clock select defines
84  * @{
85  */
86 #define LL_CLDR_TIMER_CLK_SEL_RNG (0x0U << RTC_CLK_SEL_Pos) /**< Select RNG clcok source */
87 #define LL_CLDR_TIMER_CLK_SEL_XO (0x1U << RTC_CLK_SEL_Pos) /**< Select XO clcok source */
88 #define LL_CLDR_TIMER_CLK_SEL_RNG2 (0x2U << RTC_CLK_SEL_Pos) /**< Select RNG2 clcok source */
89 #define LL_CLDR_TIMER_CLK_SEL_RTC (0x3U << RTC_CLK_SEL_Pos) /**< Select RTC clcok source */
90 /** @} */
91 
92 /** @} */
93 
94 /** @defgroup AON_CTL_CLDR_TIMER_PERIODIC_SEL Calendar Periodic timer select defines
95  * @{
96  */
97 #define LL_CLDR_TIMER_TICK (0x0U) /**< Select periodic alarm */
98 
99 /** @} */
100 
101 /** @defgroup AON_CTL_CLDR_TIMER_PERIODIC_SEL Calendar Periodic timer select defines
102  * @{
103  */
104 #define LL_CLDR_TIMER_TICK_TYPE_SINGLE (0x0U) /**< Select periodic alarm one-time */
105 #define LL_CLDR_TIMER_TICK_TYPE_AUTO (0x1U) /**< Select periodic alarm auto-reload */
106 
107 /** @} */
108 /**
109  * @brief Calendar Register Read.
110  */
111 #define CLDR_REG_READ (READ_BITS(CALENDAR->CFG0, RTC_CFG0_EN | \
112  RTC_CFG0_ALARM_EN | \
113  RTC_CFG0_TICK_EN | \
114  RTC_CFG0_TICK_MDOE))
115 /** @} */
116 
117 
118 /* Exported functions --------------------------------------------------------*/
119 /** @defgroup CALENDAR_LL_DRIVER_FUNCTIONS Functions
120  * @{
121  */
122 
123 /** @defgroup CALENDAR_LL_EF_Configuration Configuration functions
124  * @{
125  */
126 /**
127  * @brief Set the Calendar Timer clock
128  *
129  * Register|BitsName
130  * --------|--------
131  * CLDR_CLK | cldr_timer_clk_sel
132 
133  * @param value: This parameter can be a one of the following values:
134  * @arg @ref LL_CLDR_TIMER_CLK_SEL_RNG
135  * @arg @ref LL_CLDR_TIMER_CLK_SEL_XO
136  * @arg @ref LL_CLDR_TIMER_CLK_SEL_RNG2
137  * @arg @ref LL_CLDR_TIMER_CLK_SEL_RTC
138  * @retval None
139  */
140 __STATIC_INLINE void ll_calendar_timer_set_clk(uint32_t value)
141 {
142  MODIFY_REG(CALENDAR->CLK, RTC_CLK_SEL, value);
143 }
144 
145 /**
146  * @brief Get the Calendar Timer clock
147  *
148  * Register|BitsName
149  * --------|--------
150  * CLDR_CLK | cldr_timer_clk_sel
151  *
152  * @retval Calendar Timer clock source,the value can be the one of the following:
153  * @arg @ref LL_CLDR_TIMER_CLK_SEL_RNG
154  * @arg @ref LL_CLDR_TIMER_CLK_SEL_XO
155  * @arg @ref LL_CLDR_TIMER_CLK_SEL_RNG2
156  * @arg @ref LL_CLDR_TIMER_CLK_SEL_RTC
157  */
158 __STATIC_INLINE uint32_t ll_calendar_timer_get_clk(void)
159 {
160  return (READ_BITS(CALENDAR->CLK, RTC_CLK_SEL));
161 }
162 
163 /**
164  * @brief Enable calendar counter.
165  *
166  * Register|BitsName
167  * --------|--------
168  * CLDR_CFG0 | EN
169  *
170  * @retval None
171  */
172 __STATIC_INLINE void ll_calendar_enable(void)
173 {
174  WRITE_REG(CALENDAR->CFG0, RTC_CFG0_CFG | RTC_CFG0_EN | CLDR_REG_READ);
175 }
176 
177 /**
178  * @brief Disable calendar counter.
179  *
180  * Register|BitsName
181  * --------|--------
182  * CLDR_CFG0 | EN
183  *
184  * @retval None
185  */
186 __STATIC_INLINE void ll_calendar_disable(void)
187 {
188  MODIFY_REG(CALENDAR->CFG0, 0xFFFFFFFF, RTC_CFG0_CFG);
189 }
190 
191 /**
192  * @brief Check if the CALENDAR peripheral is enabled or disabled.
193  *
194  * Register|BitsName
195  * --------|--------
196  * CLDR_CFG0 | EN
197  *
198  * @retval State of bit (1 or 0).
199  */
200 __STATIC_INLINE uint32_t ll_calendar_is_enabled(void)
201 {
202  return (READ_BITS(CALENDAR->CFG0, RTC_CFG0_EN) == RTC_CFG0_EN);
203 }
204 
205 /**
206  * @brief Reloads CALENDAR counter.
207  *
208  * Register|BitsName
209  * --------|--------
210  * CLDR_TIMER_W | TIMER_VALUE
211  *
212  * @retval None
213  */
214 __STATIC_INLINE void ll_calendar_reload_counter(uint32_t counter)
215 {
216  WRITE_REG(CALENDAR->TIMER_W, counter);
217 }
218 
219 /**
220  * @brief Reloads CALENDAR counter and request.
221  *
222  * Register|BitsName
223  * --------|--------
224  * CLDR_TIMER_W | TIMER_VALUE
225  * CLDR_CFG0 | VAL_LOAD
226  *
227  * @retval None
228  */
229 __STATIC_INLINE void ll_calendar_reload_counter_and_request(uint32_t counter)
230 {
231  WRITE_REG(CALENDAR->TIMER_W, counter);
232  WRITE_REG(CALENDAR->CFG0, RTC_CFG0_CFG | RTC_CFG0_TIMER_SET | CLDR_REG_READ);
233 }
234 
235 /**
236  * @brief Reloads CALENDAR alarm.
237  *
238  * Register|BitsName
239  * --------|--------
240  * CLDR_TIMER_W | ALARM_VAL_LOAD
241  *
242  * @retval None
243  */
244 __STATIC_INLINE void ll_calendar_reload_alarm(uint32_t alarm)
245 {
246  WRITE_REG(CALENDAR->ALARM_W, alarm);
247 }
248 
249 /**
250  * @brief Reloads CALENDAR alarm and request.
251  *
252  * Register|BitsName
253  * --------|--------
254  * CLDR_ALARM_W | ALARM_VAL_LOAD
255  * CLDR_CFG0 | ALARM_VALUE
256  *
257  * @retval None
258  */
259 __STATIC_INLINE void ll_calendar_reload_alarm_and_request(uint32_t alarm)
260 {
261  WRITE_REG(CALENDAR->ALARM_W, alarm);
262  WRITE_REG(CALENDAR->CFG0, RTC_CFG0_CFG | RTC_CFG0_ALARM_SET | CLDR_REG_READ);
263 }
264 
265 /**
266  * @brief Read the CALENDAR counter config value.
267  *
268  * Register|BitsName
269  * --------|--------
270  * CLDR_TIMER_W | TIMER_VAL_READ
271  *
272  * @retval Value for current counter which should ranging between 0 ~ 0xFFFF_FFFF
273  */
274 __STATIC_INLINE uint32_t ll_calendar_get_counter(void)
275 {
276  return (uint32_t)READ_REG(CALENDAR->TIMER_W);
277 }
278 
279 /**
280  * @brief Read the CALENDAR counter current value.
281  *
282  * Register|BitsName
283  * --------|--------
284  * CLDR_TIMER_R | TIMER_VAL_READ
285  *
286  * @retval Value for current counter which should ranging between 0 ~ 0xFFFF_FFFF
287  */
288 __STATIC_INLINE uint32_t ll_calendar_get_read_counter(void)
289 {
290  return (uint32_t)READ_REG(CALENDAR->TIMER_R);
291 }
292 
293 /**
294  * @brief Read the CALENDAR counter config alarm value.
295  *
296  * Register|BitsName
297  * --------|--------
298  * CLDR_ALARM_W | CAL_ALARM
299  *
300  * @retval Value for current alarm which should ranging between 0 ~ 0xFFFF_FFFF
301  */
302 __STATIC_INLINE uint32_t ll_calendar_get_alarm(void)
303 {
304  return (uint32_t)READ_REG(CALENDAR->ALARM_W);
305 }
306 
307 /**
308  * @brief Read the CALENDAR counter current alarm value.
309  *
310  * Register|BitsName
311  * --------|--------
312  * CLDR_ALARM_R | CAL_ALARM
313  *
314  * @retval Value for current alarm which should ranging between 0 ~ 0xFFFF_FFFF
315  */
316 __STATIC_INLINE uint32_t ll_calendar_get_read_alarm(void)
317 {
318  return (uint32_t)READ_REG(CALENDAR->ALARM_R);
319 }
320 
321 /**
322  * @brief Get the CALENDAR wrap-around value.
323  * @note The value should be read multiple times until get the same value in at least two reads.
324  *
325  * Register|BitsName
326  * --------|--------
327  * CLDR_STAT | WRAP_CNT
328  *
329  * @retval Value between Min_Data=0 and Max_Data=0xF
330  */
331 __STATIC_INLINE uint32_t ll_calendar_get_wrapcnt(void)
332 {
333  return (uint32_t)(READ_BITS(CALENDAR->STAT, RTC_STAT_WRAP_CNT) >> RTC_STAT_WRAP_CNT_Pos);
334 }
335 
336 /**
337  * @brief The CALENDAR is busy.
338  *
339  * Register|BitsName
340  * --------|--------
341  * CLDR_STAT | BUSY
342  *
343  * @retval Value between Min_Data=0 and Max_Data=0xF
344  */
345 __STATIC_INLINE uint32_t ll_calendar_is_busy(void)
346 {
347  return (uint32_t)(READ_BITS(CALENDAR->STAT, RTC_STAT_BUSY) == RTC_STAT_BUSY);
348 }
349 
350 /**
351  * @brief The CALENDAR is running.
352  *
353  * Register|BitsName
354  * --------|--------
355  * CLDR_STAT | RUNNING
356  *
357  * @retval Value between Min_Data=0 and Max_Data=0xF
358  */
359 __STATIC_INLINE uint32_t ll_calendar_is_running(void)
360 {
361  return (uint32_t)(READ_BITS(CALENDAR->STAT, RTC_STAT_STAT) == RTC_STAT_STAT);
362 }
363 
364 /**
365  * @brief CLear calendar wrap.
366  *
367  * Register|BitsName
368  * --------|--------
369  * CLDR_CFG0 | Wrap counter clear
370  *
371  * @retval None
372  */
373 
374 __STATIC_INLINE void ll_calendar_clear_wrap(void)
375 {
376  WRITE_REG(CALENDAR->CFG0, RTC_CFG0_CFG | RTC_CFG0_WRAP_CLR | CLDR_REG_READ);
377 }
378 
379 /**
380  * @brief Select the CALENDAR clock divider.
381  *
382  * Register|BitsName
383  * --------|--------
384  * CLDR_CFG1 | CLK_SEL
385  *
386  * @param div This parameter can be one of the following values:
387  * @arg @ref LL_CALENDAR_DIV_NONE
388  * @arg @ref LL_CALENDAR_DIV_2
389  * @arg @ref LL_CALENDAR_DIV_4
390  * @arg @ref LL_CALENDAR_DIV_8
391  * @arg @ref LL_CALENDAR_DIV_16
392  * @arg @ref LL_CALENDAR_DIV_32
393  * @arg @ref LL_CALENDAR_DIV_64
394  * @arg @ref LL_CALENDAR_DIV_128
395  * @retval None
396  */
397 __STATIC_INLINE void ll_calendar_set_clock_div(uint32_t div)
398 {
399  MODIFY_REG(CALENDAR->CFG1, RTC_CFG1_DIV, div);
400 }
401 
402 /**
403  * @brief Enable calendar alarm.
404  *
405  * Register|BitsName
406  * --------|--------
407  * CALENDAR_TIMER_CTL | ALARM_EN
408  *
409  * @retval None
410  */
411 __STATIC_INLINE void ll_calendar_enable_alarm(void)
412 {
413  WRITE_REG(CALENDAR->CFG0, RTC_CFG0_CFG | RTC_CFG0_ALARM_EN | CLDR_REG_READ);
414 }
415 
416 /**
417  * @brief Enable calendar alarm interrupt.
418  *
419  * Register|BitsName
420  * --------|--------
421  * CALENDAR_TIMER_CTL | ALARM_INT_EN
422  *
423  * @retval None
424  */
425 __STATIC_INLINE void ll_calendar_it_enable_alarm(void)
426 {
427  SET_BITS(CALENDAR->INT_EN, RTC_INT_EN_ALARM);
428 }
429 
430 /**
431  * @brief Disable calendar alarm.
432  *
433  * Register|BitsName
434  * --------|--------
435  * CALENDAR_TIMER_CTL | ALARM_DISBALE
436  *
437  * @retval None
438  */
439 __STATIC_INLINE void ll_calendar_disable_alarm(void)
440 {
441  WRITE_REG(CALENDAR->CFG0, (CLDR_REG_READ & (~RTC_CFG0_ALARM_EN)) | RTC_CFG0_CFG);
442 }
443 
444 /**
445  * @brief Disable calendar alarm interrupt.
446  *
447  * Register|BitsName
448  * --------|--------
449  * CLDR_INT_EN | ALARM_INT_EN
450  *
451  * @retval None
452  */
453 __STATIC_INLINE void ll_calendar_it_disable_alarm(void)
454 {
455  CLEAR_BITS(CALENDAR->INT_EN, RTC_INT_EN_ALARM);
456 }
457 
458 /**
459  * @brief Check if the CALENDAR alarm interrupt is enabled or disabled.
460  *
461  * Register|BitsName
462  * --------|--------
463  * CALENDAR_TIMER_CTL | ALARM_INT_EN
464  *
465  * @retval State of bit (1 or 0).
466  */
467 __STATIC_INLINE uint32_t ll_calendar_it_is_enabled_alarm(void)
468 {
469  return (uint32_t)((READ_BITS(CALENDAR->CFG0, RTC_CFG0_ALARM_EN) == RTC_CFG0_ALARM_EN) &&
470  (READ_BITS(CALENDAR->INT_EN, RTC_INT_EN_ALARM) == RTC_INT_EN_ALARM));
471 }
472 
473 /**
474  * @brief Set calendar tick mode.
475  *
476  * Register|BitsName
477  * --------|--------
478  * CALENDAR_TIMER_CTL | TICK_EN
479  * @param tick_number: This parameter can be a one of the following values:
480  * @arg @ref LL_CLDR_TIMER_TICK
481  * @arg @ref LL_CLDR_TIMER_TICK
482  * @param tick_mode: This parameter can be a one of the following values:
483  * @arg @ref LL_CLDR_TIMER_TICK_TYPE_SINGLE
484  * @arg @ref LL_CLDR_TIMER_TICK_TYPE_AUTO
485  * @retval None
486 */
487 __STATIC_INLINE void ll_calendar_enable_tick(uint32_t tick_number, uint32_t tick_mode)
488 {
489  UNUSED(tick_number);
490  WRITE_REG(CALENDAR->CFG0, (RTC_CFG0_CFG | RTC_CFG0_TICK_EN | (tick_mode << RTC_CFG0_TICK_MDOE_Pos) | (CLDR_REG_READ & (~(1 << RTC_CFG0_TICK_MDOE_Pos)))));
491 }
492 
493 /**
494  * @brief Enable calendar tick interrupt.
495  *
496  * Register|BitsName
497  * --------|--------
498  * CLDR_INT_EN | TICK_INT_EN
499  * @param tick_number This parameter can be a one of the following values:
500  * @arg @ref LL_CLDR_TIMER_TICK
501  * @arg @ref LL_CLDR_TIMER_TICK
502  * @retval None
503  */
504 __STATIC_INLINE void ll_calendar_it_enable_tick(uint32_t tick_number)
505 {
506  UNUSED(tick_number);
507  SET_BITS(CALENDAR->INT_EN, RTC_INT_EN_TICK);
508 }
509 
510 /**
511  * @brief Disable calendar tick.
512  *
513  * Register|BitsName
514  * --------|--------
515  * CALENDAR_TIMER_CTL | TICK_EN
516  * @param tick_number This parameter can be a one of the following values:
517  * @arg @ref LL_CLDR_TIMER_TICK
518  * @arg @ref LL_CLDR_TIMER_TICK
519  * @retval None
520  */
521 __STATIC_INLINE void ll_calendar_disable_tick(uint32_t tick_number)
522 {
523  UNUSED(tick_number);
524  WRITE_REG(CALENDAR->CFG0, (CLDR_REG_READ & (~RTC_CFG0_TICK_EN)) | RTC_CFG0_CFG);
525 }
526 
527 /**
528  * @brief Disable calendar tick interrupt.
529  *
530  * Register|BitsName
531  * --------|--------
532  * CLDR_INT_EN | TICK0_INT_EN
533  * @param tick_number This parameter can be a one of the following values:
534  * @arg @ref LL_CLDR_TIMER_TICK
535  * @arg @ref LL_CLDR_TIMER_TICK
536  * @retval None
537  */
538 __STATIC_INLINE void ll_calendar_it_disable_tick(uint32_t tick_number)
539 {
540  UNUSED(tick_number);
541  CLEAR_BITS(CALENDAR->INT_EN, RTC_INT_EN_TICK);
542 }
543 
544 /**
545  * @brief Check if the CALENDAR alarm interrupt is enabled or disabled.
546  *
547  * Register|BitsName
548  * --------|--------
549  * CALENDAR_TIMER_CTL | TICK_EN
550  * CLDR_INT_EN | TICK_INT_EN
551  * @param tick_number This parameter can be a one of the following values:
552  * @arg @ref LL_CLDR_TIMER_TICK
553  * @arg @ref LL_CLDR_TIMER_TICK
554  * @retval State of bit (1 or 0).
555  */
556 __STATIC_INLINE uint32_t ll_calendar_it_is_enabled_tick(uint32_t tick_number)
557 {
558  UNUSED(tick_number);
559  return (uint32_t)((READ_BITS(CALENDAR->CFG0, RTC_CFG0_TICK_EN) == RTC_CFG0_TICK_EN) &&
560  (READ_BITS(CALENDAR->INT_EN, RTC_INT_EN_TICK) == RTC_INT_EN_TICK));
561 }
562 
563 /**
564  * @brief Reloads CALENDAR tick counter and request.
565  *
566  * Register|BitsName
567  * --------|--------
568  * CLDR_TIMER_W | TIMER_VALUE
569  * CLDR_CFG0 | VAL_LOAD
570  * @param tick_number: This parameter can be a one of the following values:
571  * @arg @ref LL_CLDR_TIMER_TICK;
572  * @arg @ref LL_CLDR_TIMER_TICK.
573  * @param counter: Calendar tick counter.
574  * @retval None
575  */
576 __STATIC_INLINE void ll_calendar_reload_tick_and_request(uint32_t tick_number , uint32_t counter)
577 {
578  UNUSED(tick_number);
579  WRITE_REG(CALENDAR->TICK_W, counter);
580  WRITE_REG(CALENDAR->CFG0, RTC_CFG0_CFG | RTC_CFG0_TICK_SET | CLDR_REG_READ);
581 }
582 
583 /**
584  * @brief Enable calendar wrap interrupt.
585  *
586  * Register|BitsName
587  * --------|--------
588  * CALENDAR_TIMER_CTL | WRAP_INT_EN
589  *
590  * @retval None
591  */
592 __STATIC_INLINE void ll_calendar_it_enable_wrap(void)
593 {
594  SET_BITS(CALENDAR->INT_EN, RTC_INT_EN_WRAP);
595 }
596 
597 /**
598  * @brief Disable calendar warp interrupt.
599  *
600  * Register|BitsName
601  * --------|--------
602  * CALENDAR_TIMER_CTL | WRAP_INT_EN
603  *
604  * @retval None
605  */
606 __STATIC_INLINE void ll_calendar_it_disable_wrap(void)
607 {
608  CLEAR_BITS(CALENDAR->INT_EN, RTC_INT_EN_WRAP);
609 }
610 
611 /**
612  * @brief Check if the CALENDAR wrap interrupt is enabled or disabled.
613  *
614  * Register|BitsName
615  * --------|--------
616  * CALENDAR_TIMER_CTL | WRAP_INT_EN
617  *
618  * @retval State of bit (1 or 0).
619  */
620 __STATIC_INLINE uint32_t ll_calendar_it_is_enabled_wrap(void)
621 {
622  return (uint32_t)(READ_BITS(CALENDAR->INT_EN, RTC_INT_EN_WRAP) == RTC_INT_EN_WRAP);
623 }
624 
625 /** @} */
626 
627 /** @defgroup CALENDAR_LL_EF_FLAG_Management FLAG_Management
628  * @{
629  */
630 
631 /**
632  * @brief Indicate if the CALENDAR alarm event flag is set or not.
633  * @note This bit is set by hardware when the counter has reached alarm value.
634  * It can be cleared by writing 0 to this bit.
635  *
636  * Register|BitsName
637  * --------|--------
638  * SLP_EVENT | CALENDAR_TIMER_ALARM
639  *
640  * @retval State of bit (1 or 0).
641  */
642 __STATIC_INLINE uint32_t ll_calendar_is_active_flag_alarm(void)
643 {
644  return (uint32_t)(READ_BITS(CALENDAR->INT_STAT, RTC_INT_STAT_ALARM) == RTC_INT_STAT_ALARM);
645 }
646 
647 /**
648  * @brief Indicate if the CALENDAR wrap event flag is set or not.
649  * @note This bit is set by hardware when the counter has overflow.
650  * It can be cleared by writing 0 to this bit.
651  *
652  * Register|BitsName
653  * --------|--------
654  * SLP_EVENT | CALENDAR_TIMER_WRAP
655  *
656  * @retval State of bit (1 or 0).
657  */
658 __STATIC_INLINE uint32_t ll_calendar_is_active_flag_wrap(void)
659 {
660  return (uint32_t)(READ_BITS(CALENDAR->INT_STAT, RTC_INT_STAT_WRAP) == RTC_INT_STAT_WRAP);
661 }
662 
663 /**
664  * @brief Indicate if the CALENDAR tick event flag is set or not.
665  * @note This bit is set by hardware when the counter has reached to 0.
666  * It can be cleared by writing 1 to this bit.
667  *
668  * Register|BitsName
669  * --------|--------
670  * CLDR_INT_STAT | TICK_INT_STAT
671  *
672  * @param tick_number: This parameter can be a one of the following values:
673  * @arg @ref LL_CLDR_TIMER_TICK
674  * @arg @ref LL_CLDR_TIMER_TICK
675  * @retval State of bit (1 or 0).
676  */
677 __STATIC_INLINE uint32_t ll_calendar_is_active_flag_tick(uint32_t tick_number)
678 {
679  UNUSED(tick_number);
680  return (uint32_t)(READ_BITS(CALENDAR->INT_STAT, RTC_INT_STAT_TICK) == RTC_INT_STAT_TICK);
681 }
682 
683 /**
684  * @brief Clear calendar alarm interrupt flag.
685  *
686  * Register|BitsName
687  * --------|--------
688  * SLP_EVENT| CALENDAR_TIMER_ALARM
689  *
690  * @retval None
691  */
692 __STATIC_INLINE void ll_calendar_clear_flag_alarm(void)
693 {
694  WRITE_REG(CALENDAR->INT_STAT, RTC_INT_STAT_ALARM);
695 }
696 
697 /**
698  * @brief Clear calendar wrap interrupt flag.
699  *
700  * Register|BitsName
701  * --------|--------
702  * CLDR_INT_STAT| CALENDAR_TICK
703  *
704  * @retval None
705  */
706 __STATIC_INLINE void ll_calendar_clear_flag_wrap(void)
707 {
708  WRITE_REG(CALENDAR->INT_STAT, RTC_INT_STAT_WRAP);
709 }
710 
711 /**
712  * @brief Clear calendar tick interrupt flag.
713  *
714  * Register|BitsName
715  * --------|--------
716  * SLP_EVENT| CALENDAR_TIMER_WRAP
717  *
718  * @param tick_number: This parameter can be a one of the following values:
719  * @arg @ref LL_CLDR_TIMER_TICK;
720  * @arg @ref LL_CLDR_TIMER_TICK.
721  * @retval None
722  */
723 __STATIC_INLINE void ll_calendar_clear_flag_tick(uint32_t tick_number)
724 {
725  UNUSED(tick_number);
726  WRITE_REG(CALENDAR->INT_STAT, RTC_INT_STAT_TICK);
727 }
728 
729 /**
730  * @brief Clear calendar interrupt event.
731  *
732  * @retval None
733  */
734 __STATIC_INLINE void ll_calendar_clear_it_event(void)
735 {
736  WRITE_REG(AON_CTL->AON_SLP_EVENT, ~AON_CTL_SLP_EVENT_RTC0);
737 }
738 /** @} */
739 
740 /** @} */
741 
742 
743 #ifdef __cplusplus
744 }
745 #endif
746 
747 #endif /* __GR55XX_LL_CALENDAR_H__ */
748 
749 /** @} */
750 
751 /** @} */
752 
753 /** @} */
ll_calendar_it_disable_tick
__STATIC_INLINE void ll_calendar_it_disable_tick(uint32_t tick_number)
Disable calendar tick interrupt.
Definition: gr55xx_ll_calendar.h:538
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:200
ll_calendar_get_alarm
__STATIC_INLINE uint32_t ll_calendar_get_alarm(void)
Read the CALENDAR counter config alarm value.
Definition: gr55xx_ll_calendar.h:302
ll_calendar_disable_alarm
__STATIC_INLINE void ll_calendar_disable_alarm(void)
Disable calendar alarm.
Definition: gr55xx_ll_calendar.h:439
ll_calendar_is_active_flag_tick
__STATIC_INLINE uint32_t ll_calendar_is_active_flag_tick(uint32_t tick_number)
Indicate if the CALENDAR tick event flag is set or not.
Definition: gr55xx_ll_calendar.h:677
ll_calendar_clear_wrap
__STATIC_INLINE void ll_calendar_clear_wrap(void)
CLear calendar wrap.
Definition: gr55xx_ll_calendar.h:374
ll_calendar_clear_flag_alarm
__STATIC_INLINE void ll_calendar_clear_flag_alarm(void)
Clear calendar alarm interrupt flag.
Definition: gr55xx_ll_calendar.h:692
ll_calendar_timer_set_clk
__STATIC_INLINE void ll_calendar_timer_set_clk(uint32_t value)
Set the Calendar Timer clock.
Definition: gr55xx_ll_calendar.h:140
ll_calendar_reload_counter
__STATIC_INLINE void ll_calendar_reload_counter(uint32_t counter)
Reloads CALENDAR counter.
Definition: gr55xx_ll_calendar.h:214
ll_calendar_reload_counter_and_request
__STATIC_INLINE void ll_calendar_reload_counter_and_request(uint32_t counter)
Reloads CALENDAR counter and request.
Definition: gr55xx_ll_calendar.h:229
ll_calendar_get_read_alarm
__STATIC_INLINE uint32_t ll_calendar_get_read_alarm(void)
Read the CALENDAR counter current alarm value.
Definition: gr55xx_ll_calendar.h:316
ll_calendar_reload_tick_and_request
__STATIC_INLINE void ll_calendar_reload_tick_and_request(uint32_t tick_number, uint32_t counter)
Reloads CALENDAR tick counter and request.
Definition: gr55xx_ll_calendar.h:576
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:658
ll_calendar_it_enable_alarm
__STATIC_INLINE void ll_calendar_it_enable_alarm(void)
Enable calendar alarm interrupt.
Definition: gr55xx_ll_calendar.h:425
ll_calendar_it_enable_wrap
__STATIC_INLINE void ll_calendar_it_enable_wrap(void)
Enable calendar wrap interrupt.
Definition: gr55xx_ll_calendar.h:592
ll_calendar_it_is_enabled_tick
__STATIC_INLINE uint32_t ll_calendar_it_is_enabled_tick(uint32_t tick_number)
Check if the CALENDAR alarm interrupt is enabled or disabled.
Definition: gr55xx_ll_calendar.h:556
ll_calendar_clear_flag_wrap
__STATIC_INLINE void ll_calendar_clear_flag_wrap(void)
Clear calendar wrap interrupt flag.
Definition: gr55xx_ll_calendar.h:706
ll_calendar_disable_tick
__STATIC_INLINE void ll_calendar_disable_tick(uint32_t tick_number)
Disable calendar tick.
Definition: gr55xx_ll_calendar.h:521
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:467
ll_calendar_it_enable_tick
__STATIC_INLINE void ll_calendar_it_enable_tick(uint32_t tick_number)
Enable calendar tick interrupt.
Definition: gr55xx_ll_calendar.h:504
ll_calendar_enable_tick
__STATIC_INLINE void ll_calendar_enable_tick(uint32_t tick_number, uint32_t tick_mode)
Set calendar tick mode.
Definition: gr55xx_ll_calendar.h:487
ll_calendar_enable_alarm
__STATIC_INLINE void ll_calendar_enable_alarm(void)
Enable calendar alarm.
Definition: gr55xx_ll_calendar.h:411
ll_calendar_reload_alarm_and_request
__STATIC_INLINE void ll_calendar_reload_alarm_and_request(uint32_t alarm)
Reloads CALENDAR alarm and request.
Definition: gr55xx_ll_calendar.h:259
ll_calendar_disable
__STATIC_INLINE void ll_calendar_disable(void)
Disable calendar counter.
Definition: gr55xx_ll_calendar.h:186
ll_calendar_clear_flag_tick
__STATIC_INLINE void ll_calendar_clear_flag_tick(uint32_t tick_number)
Clear calendar tick interrupt flag.
Definition: gr55xx_ll_calendar.h:723
ll_calendar_is_running
__STATIC_INLINE uint32_t ll_calendar_is_running(void)
The CALENDAR is running.
Definition: gr55xx_ll_calendar.h:359
ll_calendar_enable
__STATIC_INLINE void ll_calendar_enable(void)
Enable calendar counter.
Definition: gr55xx_ll_calendar.h:172
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:642
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:397
ll_calendar_clear_it_event
__STATIC_INLINE void ll_calendar_clear_it_event(void)
Clear calendar interrupt event.
Definition: gr55xx_ll_calendar.h:734
ll_calendar_is_busy
__STATIC_INLINE uint32_t ll_calendar_is_busy(void)
The CALENDAR is busy.
Definition: gr55xx_ll_calendar.h:345
ll_calendar_reload_alarm
__STATIC_INLINE void ll_calendar_reload_alarm(uint32_t alarm)
Reloads CALENDAR alarm.
Definition: gr55xx_ll_calendar.h:244
ll_calendar_get_wrapcnt
__STATIC_INLINE uint32_t ll_calendar_get_wrapcnt(void)
Get the CALENDAR wrap-around value.
Definition: gr55xx_ll_calendar.h:331
ll_calendar_it_disable_alarm
__STATIC_INLINE void ll_calendar_it_disable_alarm(void)
Disable calendar alarm interrupt.
Definition: gr55xx_ll_calendar.h:453
CLDR_REG_READ
#define CLDR_REG_READ
Calendar Register Read.
Definition: gr55xx_ll_calendar.h:111
ll_calendar_timer_get_clk
__STATIC_INLINE uint32_t ll_calendar_timer_get_clk(void)
Get the Calendar Timer clock.
Definition: gr55xx_ll_calendar.h:158
ll_calendar_get_read_counter
__STATIC_INLINE uint32_t ll_calendar_get_read_counter(void)
Read the CALENDAR counter current value.
Definition: gr55xx_ll_calendar.h:288
ll_calendar_it_disable_wrap
__STATIC_INLINE void ll_calendar_it_disable_wrap(void)
Disable calendar warp interrupt.
Definition: gr55xx_ll_calendar.h:606
ll_calendar_get_counter
__STATIC_INLINE uint32_t ll_calendar_get_counter(void)
Read the CALENDAR counter config value.
Definition: gr55xx_ll_calendar.h:274
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:620