M4521_BSP V3.02.000
The Board Support Package for M4521
rtc.c
Go to the documentation of this file.
1/**************************************************************************/
12#include "M4521.h"
13
14
16
17/*---------------------------------------------------------------------------------------------------------*/
18/* Macro, type and constant definitions */
19/*---------------------------------------------------------------------------------------------------------*/
20#define RTC_GLOBALS
21
22/*---------------------------------------------------------------------------------------------------------*/
23/* Global file scope (static) variables */
24/*---------------------------------------------------------------------------------------------------------*/
25static volatile uint32_t g_u32hiYear, g_u32loYear, g_u32hiMonth, g_u32loMonth, g_u32hiDay, g_u32loDay;
26static volatile uint32_t g_u32hiHour, g_u32loHour, g_u32hiMin, g_u32loMin, g_u32hiSec, g_u32loSec;
27
29
30
31
32
71{
72 uint32_t u32TimeOutCount = SystemCoreClock; // 1 second timeout
73
74 RTC->INIT = RTC_INIT_KEY;
75
76 if(RTC->INIT != RTC_INIT_ACTIVE_Msk)
77 {
78 RTC->INIT = RTC_INIT_KEY;
79 while(RTC->INIT != RTC_INIT_ACTIVE_Msk)
80 {
81 if(u32TimeOutCount == 0) return -1;
82 u32TimeOutCount--;
83 }
84 }
85
86 if(sPt == 0)
87 return 0;
88
89 /* Set RTC date and time */
91
92 /* Waiting for RTC settings stable */
93 u32TimeOutCount = SystemCoreClock;
94 while((RTC->RWEN & RTC_RWEN_RWENF_Msk) == RTC_RWEN_RWENF_Msk)
95 {
96 if(u32TimeOutCount == 0) return -1;
97 u32TimeOutCount--;
98 }
99
100 return 0;
101}
102
112void RTC_Close(void)
113{
114 CLK->APBCLK0 &= ~CLK_APBCLK0_RTCCKEN_Msk;
115}
116
126void RTC_32KCalibration(int32_t i32FrequencyX100)
127{
128 int32_t i32RegInt, i32RegFra;
129
130 /* Compute integer and fraction for RTC FCR register */
131 i32RegInt = (i32FrequencyX100 / 100) - RTC_FCR_REFERENCE;
132 i32RegFra = (((i32FrequencyX100 % 100)) * 60) / 100;
133
134 /* Judge Integer part is reasonable */
135 if((i32RegInt < 0) | (i32RegInt > 15))
136 {
137 return ;
138 }
139
141 RTC->FREQADJ = (uint32_t)((i32RegInt << 8) | i32RegFra);
142}
143
163{
164 uint32_t u32Tmp;
165
166 sPt->u32TimeScale = RTC->CLKFMT & RTC_CLKFMT_24HEN_Msk; /* 12/24-hour */
167 sPt->u32DayOfWeek = RTC->WEEKDAY & RTC_WEEKDAY_WEEKDAY_Msk; /* Day of the week */
168
169 /* Get [Date digit] data */
170 g_u32hiYear = (RTC->CAL & RTC_CAL_TENYEAR_Msk) >> RTC_CAL_TENYEAR_Pos;
171 g_u32loYear = (RTC->CAL & RTC_CAL_YEAR_Msk) >> RTC_CAL_YEAR_Pos;
172 g_u32hiMonth = (RTC->CAL & RTC_CAL_TENMON_Msk) >> RTC_CAL_TENMON_Pos;
173 g_u32loMonth = (RTC->CAL & RTC_CAL_MON_Msk) >> RTC_CAL_MON_Pos;
174 g_u32hiDay = (RTC->CAL & RTC_CAL_TENDAY_Msk) >> RTC_CAL_TENDAY_Pos;
175 g_u32loDay = (RTC->CAL & RTC_CAL_DAY_Msk) >> RTC_CAL_DAY_Pos;
176
177 /* Get [Time digit] data */
178 g_u32hiHour = (RTC->TIME & RTC_TIME_TENHR_Msk) >> RTC_TIME_TENHR_Pos;
179 g_u32loHour = (RTC->TIME & RTC_TIME_HR_Msk) >> RTC_TIME_HR_Pos;
180 g_u32hiMin = (RTC->TIME & RTC_TIME_TENMIN_Msk) >> RTC_TIME_TENMIN_Pos;
181 g_u32loMin = (RTC->TIME & RTC_TIME_MIN_Msk) >> RTC_TIME_MIN_Pos;
182 g_u32hiSec = (RTC->TIME & RTC_TIME_TENSEC_Msk) >> RTC_TIME_TENSEC_Pos;
183 g_u32loSec = (RTC->TIME & RTC_TIME_SEC_Msk) >> RTC_TIME_SEC_Pos;
184
185 /* Compute to 20XX year */
186 u32Tmp = (g_u32hiYear * 10);
187 u32Tmp += g_u32loYear;
188 sPt->u32Year = u32Tmp + RTC_YEAR2000;
189
190 /* Compute 0~12 month */
191 u32Tmp = (g_u32hiMonth * 10);
192 sPt->u32Month = u32Tmp + g_u32loMonth;
193
194 /* Compute 0~31 day */
195 u32Tmp = (g_u32hiDay * 10);
196 sPt->u32Day = u32Tmp + g_u32loDay;
197
198 /* Compute 12/24 hour */
199 if(sPt->u32TimeScale == RTC_CLOCK_12)
200 {
201 u32Tmp = (g_u32hiHour * 10);
202 u32Tmp += g_u32loHour;
203 sPt->u32Hour = u32Tmp; /* AM: 1~12. PM: 21~32. */
204
205 if(sPt->u32Hour >= 21)
206 {
207 sPt->u32AmPm = RTC_PM;
208 sPt->u32Hour -= 20;
209 }
210 else
211 {
212 sPt->u32AmPm = RTC_AM;
213 }
214
215 u32Tmp = (g_u32hiMin * 10);
216 u32Tmp += g_u32loMin;
217 sPt->u32Minute = u32Tmp;
218
219 u32Tmp = (g_u32hiSec * 10);
220 u32Tmp += g_u32loSec;
221 sPt->u32Second = u32Tmp;
222 }
223 else
224 {
225 u32Tmp = (g_u32hiHour * 10);
226 u32Tmp += g_u32loHour;
227 sPt->u32Hour = u32Tmp;
228
229 u32Tmp = (g_u32hiMin * 10);
230 u32Tmp += g_u32loMin;
231 sPt->u32Minute = u32Tmp;
232
233 u32Tmp = (g_u32hiSec * 10);
234 u32Tmp += g_u32loSec;
235 sPt->u32Second = u32Tmp;
236 }
237}
238
258{
259 uint32_t u32Tmp;
260
261 sPt->u32TimeScale = RTC->CLKFMT & RTC_CLKFMT_24HEN_Msk; /* 12/24-hour */
262 sPt->u32DayOfWeek = RTC->WEEKDAY & RTC_WEEKDAY_WEEKDAY_Msk; /* Day of the week */
263
264 /* Get alarm [Date digit] data */
266 g_u32hiYear = (RTC->CALM & RTC_CALM_TENYEAR_Msk) >> RTC_CALM_TENYEAR_Pos;
267 g_u32loYear = (RTC->CALM & RTC_CALM_YEAR_Msk) >> RTC_CALM_YEAR_Pos;
268 g_u32hiMonth = (RTC->CALM & RTC_CALM_TENMON_Msk) >> RTC_CALM_TENMON_Pos;
269 g_u32loMonth = (RTC->CALM & RTC_CALM_MON_Msk) >> RTC_CALM_MON_Pos;
270 g_u32hiDay = (RTC->CALM & RTC_CALM_TENDAY_Msk) >> RTC_CALM_TENDAY_Pos;
271 g_u32loDay = (RTC->CALM & RTC_CALM_DAY_Msk) >> RTC_CALM_DAY_Pos;
272
273 /* Get alarm [Time digit] data */
275 g_u32hiHour = (RTC->TALM & RTC_TALM_TENHR_Msk) >> RTC_TALM_TENHR_Pos;
276 g_u32loHour = (RTC->TALM & RTC_TALM_HR_Msk) >> RTC_TALM_HR_Pos;
277 g_u32hiMin = (RTC->TALM & RTC_TALM_TENMIN_Msk) >> RTC_TALM_TENMIN_Pos;
278 g_u32loMin = (RTC->TALM & RTC_TALM_MIN_Msk) >> RTC_TALM_MIN_Pos;
279 g_u32hiSec = (RTC->TALM & RTC_TALM_TENSEC_Msk) >> RTC_TALM_TENSEC_Pos;
280 g_u32loSec = (RTC->TALM & RTC_TALM_SEC_Msk) >> RTC_TALM_SEC_Pos;
281
282 /* Compute to 20XX year */
283 u32Tmp = (g_u32hiYear * 10);
284 u32Tmp += g_u32loYear;
285 sPt->u32Year = u32Tmp + RTC_YEAR2000;
286
287 /* Compute 0~12 month */
288 u32Tmp = (g_u32hiMonth * 10);
289 sPt->u32Month = u32Tmp + g_u32loMonth;
290
291 /* Compute 0~31 day */
292 u32Tmp = (g_u32hiDay * 10);
293 sPt->u32Day = u32Tmp + g_u32loDay;
294
295 /* Compute 12/24 hour */
296 if(sPt->u32TimeScale == RTC_CLOCK_12)
297 {
298 u32Tmp = (g_u32hiHour * 10);
299 u32Tmp += g_u32loHour;
300 sPt->u32Hour = u32Tmp; /* AM: 1~12. PM: 21~32. */
301
302 if(sPt->u32Hour >= 21)
303 {
304 sPt->u32AmPm = RTC_PM;
305 sPt->u32Hour -= 20;
306 }
307 else
308 {
309 sPt->u32AmPm = RTC_AM;
310 }
311
312 u32Tmp = (g_u32hiMin * 10);
313 u32Tmp += g_u32loMin;
314 sPt->u32Minute = u32Tmp;
315
316 u32Tmp = (g_u32hiSec * 10);
317 u32Tmp += g_u32loSec;
318 sPt->u32Second = u32Tmp;
319
320 }
321 else
322 {
323 u32Tmp = (g_u32hiHour * 10);
324 u32Tmp += g_u32loHour;
325 sPt->u32Hour = u32Tmp;
326
327 u32Tmp = (g_u32hiMin * 10);
328 u32Tmp += g_u32loMin;
329 sPt->u32Minute = u32Tmp;
330
331 u32Tmp = (g_u32hiSec * 10);
332 u32Tmp += g_u32loSec;
333 sPt->u32Second = u32Tmp;
334 }
335}
336
358{
359 uint32_t u32RegCAL, u32RegTIME;
360
361 if(sPt == 0)
362 return ;
363
364 /*-----------------------------------------------------------------------------------------------------*/
365 /* Set RTC 24/12 hour setting and Day of the Week */
366 /*-----------------------------------------------------------------------------------------------------*/
368 if(sPt->u32TimeScale == RTC_CLOCK_12)
369 {
370 RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk;
371
372 /*-------------------------------------------------------------------------------------------------*/
373 /* Important, range of 12-hour PM mode is 21 up to 32 */
374 /*-------------------------------------------------------------------------------------------------*/
375 if(sPt->u32AmPm == RTC_PM)
376 sPt->u32Hour += 20;
377 }
378 else
379 {
380 RTC->CLKFMT |= RTC_CLKFMT_24HEN_Msk;
381 }
382
383 /* Set Day of the Week */
384 RTC->WEEKDAY = sPt->u32DayOfWeek;
385
386 /*-----------------------------------------------------------------------------------------------------*/
387 /* Set RTC Current Date and Time */
388 /*-----------------------------------------------------------------------------------------------------*/
389 u32RegCAL = ((sPt->u32Year - RTC_YEAR2000) / 10) << 20;
390 u32RegCAL |= (((sPt->u32Year - RTC_YEAR2000) % 10) << 16);
391 u32RegCAL |= ((sPt->u32Month / 10) << 12);
392 u32RegCAL |= ((sPt->u32Month % 10) << 8);
393 u32RegCAL |= ((sPt->u32Day / 10) << 4);
394 u32RegCAL |= (sPt->u32Day % 10);
395
396 u32RegTIME = ((sPt->u32Hour / 10) << 20);
397 u32RegTIME |= ((sPt->u32Hour % 10) << 16);
398 u32RegTIME |= ((sPt->u32Minute / 10) << 12);
399 u32RegTIME |= ((sPt->u32Minute % 10) << 8);
400 u32RegTIME |= ((sPt->u32Second / 10) << 4);
401 u32RegTIME |= (sPt->u32Second % 10);
402
403 /*-----------------------------------------------------------------------------------------------------*/
404 /* Set RTC Calender and Time Loading */
405 /*-----------------------------------------------------------------------------------------------------*/
407 RTC->CAL = (uint32_t)u32RegCAL;
408 RTC->TIME = (uint32_t)u32RegTIME;
409}
410
432{
433 uint32_t u32RegCALM, u32RegTALM;
434
435 if(sPt == 0)
436 return ;
437
438 /*-----------------------------------------------------------------------------------------------------*/
439 /* Set RTC 24/12 hour setting and Day of the Week */
440 /*-----------------------------------------------------------------------------------------------------*/
442 if(sPt->u32TimeScale == RTC_CLOCK_12)
443 {
444 RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk;
445
446 /*-------------------------------------------------------------------------------------------------*/
447 /* Important, range of 12-hour PM mode is 21 up to 32 */
448 /*-------------------------------------------------------------------------------------------------*/
449 if(sPt->u32AmPm == RTC_PM)
450 sPt->u32Hour += 20;
451 }
452 else
453 {
454 RTC->CLKFMT |= RTC_CLKFMT_24HEN_Msk;
455 }
456
457 /* Set Day of the Week */
458 RTC->WEEKDAY = sPt->u32DayOfWeek;
459
460 /*-----------------------------------------------------------------------------------------------------*/
461 /* Set RTC Alarm Date and Time */
462 /*-----------------------------------------------------------------------------------------------------*/
463 u32RegCALM = ((sPt->u32Year - RTC_YEAR2000) / 10) << 20;
464 u32RegCALM |= (((sPt->u32Year - RTC_YEAR2000) % 10) << 16);
465 u32RegCALM |= ((sPt->u32Month / 10) << 12);
466 u32RegCALM |= ((sPt->u32Month % 10) << 8);
467 u32RegCALM |= ((sPt->u32Day / 10) << 4);
468 u32RegCALM |= (sPt->u32Day % 10);
469
470 u32RegTALM = ((sPt->u32Hour / 10) << 20);
471 u32RegTALM |= ((sPt->u32Hour % 10) << 16);
472 u32RegTALM |= ((sPt->u32Minute / 10) << 12);
473 u32RegTALM |= ((sPt->u32Minute % 10) << 8);
474 u32RegTALM |= ((sPt->u32Second / 10) << 4);
475 u32RegTALM |= (sPt->u32Second % 10);
476
478 RTC->CALM = (uint32_t)u32RegCALM;
479 RTC->TALM = (uint32_t)u32RegTALM;
480}
481
496void RTC_SetDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day, uint32_t u32DayOfWeek)
497{
498 uint32_t u32RegCAL;
499
500 u32RegCAL = ((u32Year - RTC_YEAR2000) / 10) << 20;
501 u32RegCAL |= (((u32Year - RTC_YEAR2000) % 10) << 16);
502 u32RegCAL |= ((u32Month / 10) << 12);
503 u32RegCAL |= ((u32Month % 10) << 8);
504 u32RegCAL |= ((u32Day / 10) << 4);
505 u32RegCAL |= (u32Day % 10);
506
508
509 /* Set Day of the Week */
510 RTC->WEEKDAY = u32DayOfWeek & RTC_WEEKDAY_WEEKDAY_Msk;
511
512 /* Set RTC Calender Loading */
513 RTC->CAL = (uint32_t)u32RegCAL;
514}
515
529void RTC_SetTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
530{
531 uint32_t u32RegTIME;
532
533 /* Important, range of 12-hour PM mode is 21 up to 32 */
534 if((u32TimeMode == RTC_CLOCK_12) && (u32AmPm == RTC_PM))
535 u32Hour += 20;
536
537 u32RegTIME = ((u32Hour / 10) << 20);
538 u32RegTIME |= ((u32Hour % 10) << 16);
539 u32RegTIME |= ((u32Minute / 10) << 12);
540 u32RegTIME |= ((u32Minute % 10) << 8);
541 u32RegTIME |= ((u32Second / 10) << 4);
542 u32RegTIME |= (u32Second % 10);
543
544 /*-----------------------------------------------------------------------------------------------------*/
545 /* Set RTC 24/12 hour setting and Day of the Week */
546 /*-----------------------------------------------------------------------------------------------------*/
548 if(u32TimeMode == RTC_CLOCK_12)
549 {
550 RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk;
551 }
552 else
553 {
554 RTC->CLKFMT |= RTC_CLKFMT_24HEN_Msk;
555 }
556
557 RTC->TIME = (uint32_t)u32RegTIME;
558}
559
571void RTC_SetAlarmDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day)
572{
573 uint32_t u32RegCALM;
574
575 u32RegCALM = ((u32Year - RTC_YEAR2000) / 10) << 20;
576 u32RegCALM |= (((u32Year - RTC_YEAR2000) % 10) << 16);
577 u32RegCALM |= ((u32Month / 10) << 12);
578 u32RegCALM |= ((u32Month % 10) << 8);
579 u32RegCALM |= ((u32Day / 10) << 4);
580 u32RegCALM |= (u32Day % 10);
581
583
584 /* Set RTC Alarm Date */
585 RTC->CALM = (uint32_t)u32RegCALM;
586}
587
601void RTC_SetAlarmTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
602{
603 uint32_t u32RegTALM;
604
605 /* Important, range of 12-hour PM mode is 21 up to 32 */
606 if((u32TimeMode == RTC_CLOCK_12) && (u32AmPm == RTC_PM))
607 u32Hour += 20;
608
609 u32RegTALM = ((u32Hour / 10) << 20);
610 u32RegTALM |= ((u32Hour % 10) << 16);
611 u32RegTALM |= ((u32Minute / 10) << 12);
612 u32RegTALM |= ((u32Minute % 10) << 8);
613 u32RegTALM |= ((u32Second / 10) << 4);
614 u32RegTALM |= (u32Second % 10);
615
616 /*-----------------------------------------------------------------------------------------------------*/
617 /* Set RTC 24/12 hour setting and Day of the Week */
618 /*-----------------------------------------------------------------------------------------------------*/
620 if(u32TimeMode == RTC_CLOCK_12)
621 {
622 RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk;
623 }
624 else
625 {
626 RTC->CLKFMT |= RTC_CLKFMT_24HEN_Msk;
627 }
628
629 /* Set RTC Alarm Time */
630 RTC->TALM = (uint32_t)u32RegTALM;
631}
632
648uint32_t RTC_GetDayOfWeek(void)
649{
650 return (RTC->WEEKDAY & RTC_WEEKDAY_WEEKDAY_Msk);
651}
652
671void RTC_SetTickPeriod(uint32_t u32TickSelection)
672{
674
675 RTC->TICK = (RTC->TICK & ~RTC_TICK_TICK_Msk) | u32TickSelection;
676}
677
690void RTC_EnableInt(uint32_t u32IntFlagMask)
691{
692 RTC->INTEN |= u32IntFlagMask;
693}
694
707void RTC_DisableInt(uint32_t u32IntFlagMask)
708{
709 if(u32IntFlagMask & RTC_INTEN_ALMIEN_Msk)
710 {
711 RTC->INTEN &= ~RTC_INTEN_ALMIEN_Msk;
712 RTC->INTSTS = RTC_INTSTS_ALMIF_Msk;
713 }
714
715 if(u32IntFlagMask & RTC_INTEN_TICKIEN_Msk)
716 {
717 RTC->INTEN &= ~RTC_INTEN_TICKIEN_Msk;
718 RTC->INTSTS = RTC_INTSTS_TICKIF_Msk;
719 }
720
721 if(u32IntFlagMask & RTC_INTEN_SNPDIEN_Msk)
722 {
723 RTC->INTEN &= ~RTC_INTEN_SNPDIEN_Msk;
724 RTC->INTSTS = RTC_INTSTS_SNPDIF_Msk;
725 }
726}
727
738{
739 uint32_t u32TimeOutCount = SystemCoreClock; // 1 second timeout
741
742 RTC->SPRCTL |= RTC_SPRCTL_SPRRWEN_Msk;
743
744 while(!(RTC->SPRCTL & RTC_SPRCTL_SPRRWRDY_Msk))
745 {
746 if(u32TimeOutCount == 0) return;
747 u32TimeOutCount--;
748 }
749}
750
761{
763
764 RTC->SPRCTL &= ~RTC_SPRCTL_SPRRWEN_Msk;
765}
766
780void RTC_EnableSnooperDetection(uint32_t u32PinCondition)
781{
783
784 RTC->SPRCTL = ((RTC->SPRCTL & ~RTC_SNOOPER_DETECT_Msk) | u32PinCondition) | RTC_SPRCTL_SNPDEN_Msk;
785}
786
797{
799
800 RTC->SPRCTL &= ~RTC_SPRCTL_SNPDEN_Msk;
801}
802 /* end of group RTC_EXPORTED_FUNCTIONS */
804 /* end of group RTC_Driver */
806 /* end of group Standard_Driver */
808
809/*** (C) COPYRIGHT 2022 Nuvoton Technology Corp. ***/
#define RTC_TALM_MIN_Msk
Definition: M4521.h:7740
#define RTC_INTEN_TICKIEN_Msk
Definition: M4521.h:7776
#define RTC_CAL_TENDAY_Msk
Definition: M4521.h:7713
#define RTC_CAL_TENYEAR_Msk
Definition: M4521.h:7725
#define RTC_SPRCTL_SPRRWRDY_Msk
Definition: M4521.h:7845
#define RTC_SPRCTL_SNPDEN_Msk
Definition: M4521.h:7830
#define RTC_INTSTS_SNPDIF_Msk
Definition: M4521.h:7788
#define RTC_CALM_DAY_Pos
Definition: M4521.h:7751
#define RTC_TIME_SEC_Msk
Definition: M4521.h:7692
#define RTC_TIME_TENSEC_Msk
Definition: M4521.h:7695
#define RTC_TALM_HR_Pos
Definition: M4521.h:7745
#define RTC_TALM_TENMIN_Pos
Definition: M4521.h:7742
#define RTC_TALM_SEC_Pos
Definition: M4521.h:7733
#define RTC_INTSTS_ALMIF_Msk
Definition: M4521.h:7782
#define RTC_CAL_YEAR_Msk
Definition: M4521.h:7722
#define RTC_TIME_TENSEC_Pos
Definition: M4521.h:7694
#define RTC_CAL_MON_Pos
Definition: M4521.h:7715
#define RTC_SPRCTL_SPRRWEN_Msk
Definition: M4521.h:7836
#define RTC_CALM_DAY_Msk
Definition: M4521.h:7752
#define RTC_TALM_TENSEC_Pos
Definition: M4521.h:7736
#define RTC_TIME_MIN_Msk
Definition: M4521.h:7698
#define RTC_TALM_TENMIN_Msk
Definition: M4521.h:7743
#define RTC_CALM_TENYEAR_Msk
Definition: M4521.h:7767
#define RTC_TIME_TENHR_Pos
Definition: M4521.h:7706
#define RTC_CALM_YEAR_Pos
Definition: M4521.h:7763
#define RTC_INTEN_ALMIEN_Msk
Definition: M4521.h:7773
#define RTC_TIME_HR_Msk
Definition: M4521.h:7704
#define RTC_CAL_TENMON_Pos
Definition: M4521.h:7718
#define RTC_CALM_TENDAY_Pos
Definition: M4521.h:7754
#define RTC_CAL_DAY_Pos
Definition: M4521.h:7709
#define RTC_CLKFMT_24HEN_Msk
Definition: M4521.h:7728
#define RTC_CALM_TENMON_Pos
Definition: M4521.h:7760
#define RTC_TALM_HR_Msk
Definition: M4521.h:7746
#define RTC_CAL_TENMON_Msk
Definition: M4521.h:7719
#define RTC_INTSTS_TICKIF_Msk
Definition: M4521.h:7785
#define RTC_CALM_MON_Msk
Definition: M4521.h:7758
#define RTC_CAL_TENYEAR_Pos
Definition: M4521.h:7724
#define RTC_TIME_TENMIN_Msk
Definition: M4521.h:7701
#define RTC_CAL_MON_Msk
Definition: M4521.h:7716
#define RTC_TALM_TENSEC_Msk
Definition: M4521.h:7737
#define RTC_CAL_TENDAY_Pos
Definition: M4521.h:7712
#define RTC_WEEKDAY_WEEKDAY_Msk
Definition: M4521.h:7731
#define RTC_CAL_YEAR_Pos
Definition: M4521.h:7721
#define RTC_INTEN_SNPDIEN_Msk
Definition: M4521.h:7779
#define RTC_CALM_TENMON_Msk
Definition: M4521.h:7761
#define RTC_CALM_MON_Pos
Definition: M4521.h:7757
#define RTC_TIME_TENMIN_Pos
Definition: M4521.h:7700
#define RTC_INIT_ACTIVE_Msk
Definition: M4521.h:7674
#define RTC_TIME_HR_Pos
Definition: M4521.h:7703
#define RTC_TIME_MIN_Pos
Definition: M4521.h:7697
#define RTC_TALM_TENHR_Pos
Definition: M4521.h:7748
#define RTC_CALM_TENDAY_Msk
Definition: M4521.h:7755
#define RTC_TALM_SEC_Msk
Definition: M4521.h:7734
#define RTC_CAL_DAY_Msk
Definition: M4521.h:7710
#define RTC_CALM_YEAR_Msk
Definition: M4521.h:7764
#define RTC_TIME_SEC_Pos
Definition: M4521.h:7691
#define RTC_TIME_TENHR_Msk
Definition: M4521.h:7707
#define RTC_TALM_TENHR_Msk
Definition: M4521.h:7749
#define RTC_TALM_MIN_Pos
Definition: M4521.h:7739
#define RTC_RWEN_RWENF_Msk
Definition: M4521.h:7683
#define RTC_CALM_TENYEAR_Pos
Definition: M4521.h:7766
#define CLK
Definition: M4521.h:13822
#define RTC
Definition: M4521.h:13838
#define RTC_CLOCK_12
Definition: rtc.h:41
#define RTC_INIT_KEY
Definition: rtc.h:35
#define RTC_PM
Definition: rtc.h:44
#define RTC_FCR_REFERENCE
Definition: rtc.h:83
#define RTC_AM
Definition: rtc.h:43
#define RTC_YEAR2000
Definition: rtc.h:82
void RTC_EnableInt(uint32_t u32IntFlagMask)
Enable RTC Interrupt.
Definition: rtc.c:690
void RTC_DisableSnooperDetection(void)
Disable Snooper Pin Detect.
Definition: rtc.c:796
uint32_t RTC_GetDayOfWeek(void)
Get Day of the Week.
Definition: rtc.c:648
void RTC_SetDateAndTime(S_RTC_TIME_DATA_T *sPt)
Update Current RTC Date and Time.
Definition: rtc.c:357
uint32_t u32Month
Definition: rtc.h:97
uint32_t u32AmPm
Definition: rtc.h:104
void RTC_GetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt)
Get RTC Alarm Date and Time.
Definition: rtc.c:257
void RTC_SetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt)
Update RTC Alarm Date and Time.
Definition: rtc.c:431
uint32_t u32Hour
Definition: rtc.h:100
void RTC_EnableSpareAccess(void)
Enable Spare Registers Access.
Definition: rtc.c:737
int32_t RTC_Open(S_RTC_TIME_DATA_T *sPt)
Initialize RTC module and start counting.
Definition: rtc.c:70
void RTC_SetDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day, uint32_t u32DayOfWeek)
Update RTC Current Date.
Definition: rtc.c:496
void RTC_Close(void)
Disable RTC Clock.
Definition: rtc.c:112
void RTC_32KCalibration(int32_t i32FrequencyX100)
Set 32k Frequency Compensation Data.
Definition: rtc.c:126
uint32_t u32Minute
Definition: rtc.h:101
void RTC_SetTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
Update RTC Current Time.
Definition: rtc.c:529
uint32_t u32Day
Definition: rtc.h:98
uint32_t u32DayOfWeek
Definition: rtc.h:99
void RTC_SetAlarmTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
Update RTC Alarm Time.
Definition: rtc.c:601
void RTC_DisableInt(uint32_t u32IntFlagMask)
Disable RTC Interrupt.
Definition: rtc.c:707
static __INLINE void RTC_WaitAccessEnable(void)
Wait RTC Access Enable.
Definition: rtc.h:231
uint32_t u32Year
Definition: rtc.h:96
void RTC_DisableSpareRegister(void)
Disable Spare Register.
Definition: rtc.c:760
void RTC_SetTickPeriod(uint32_t u32TickSelection)
Set RTC Tick Period Time.
Definition: rtc.c:671
void RTC_EnableSnooperDetection(uint32_t u32PinCondition)
Enable Snooper Pin Detect.
Definition: rtc.c:780
void RTC_SetAlarmDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day)
Update RTC Alarm Date.
Definition: rtc.c:571
uint32_t u32Second
Definition: rtc.h:102
uint32_t u32TimeScale
Definition: rtc.h:103
void RTC_GetDateAndTime(S_RTC_TIME_DATA_T *sPt)
Get Current RTC Date and Time.
Definition: rtc.c:162
uint32_t SystemCoreClock
Definition: system_M4521.c:24