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