| Nano100AN Series BSP V3.02.002 The Board Support Package for Nano100AN Series

rtc.c
Go to the documentation of this file.
1 /**************************************************************************/
14 #include <stdio.h>
15 #include "Nano100Series.h"
16
17 /*---------------------------------------------------------------------------------------------------------*/
18 /* Includes of local headers */
19 /*---------------------------------------------------------------------------------------------------------*/
20
21
22
30
32 /*---------------------------------------------------------------------------------------------------------*/
33 /* Macro, type and constant definitions */
34 /*---------------------------------------------------------------------------------------------------------*/
35 #define RTC_GLOBALS
36
37 /*---------------------------------------------------------------------------------------------------------*/
38 /* Global file scope (static) variables */
39 /*---------------------------------------------------------------------------------------------------------*/
40 static volatile uint32_t g_u32Reg, g_u32Reg1,g_u32hiYear,g_u32loYear,g_u32hiMonth,g_u32loMonth,g_u32hiDay,g_u32loDay;
41 static volatile uint32_t g_u32hiHour,g_u32loHour,g_u32hiMin,g_u32loMin,g_u32hiSec,g_u32loSec;
42
44
58 void RTC_32KCalibration(int32_t i32FrequencyX100)
59 {
60 int32_t i32RegInt,i32RegFra ;
61
62 /* Compute Integer and Fraction for RTC register*/
63 i32RegInt = (i32FrequencyX100/100) - RTC_FCR_REFERENCE;
64 i32RegFra = (((i32FrequencyX100%100)) * 60) / 100;
65
66 /* Judge Integer part is reasonable */
67 if ( (i32RegInt < 0) | (i32RegInt > 15) )
68 {
69 return;
70 }
71
72 RTC->AER = RTC_WRITE_KEY;
73 while(!(RTC->AER & RTC_AER_ENF_Msk));
74
75 RTC->FCR = (uint32_t)((i32RegInt<<8) | i32RegFra);
76
77 }
78
102 void RTC_Open (S_RTC_TIME_DATA_T *sPt)
103 {
104 uint32_t u32Reg;
105
106 volatile int32_t i32delay=1000;
107
108 RTC->INIR = RTC_INIT_KEY;
109
110 if(RTC->INIR != 0x1)
111 {
112 RTC->INIR = RTC_INIT_KEY;
113
114 while(RTC->INIR != 0x1);
115 }
116
117 if(sPt == NULL)
118 return;
119
120 /*-----------------------------------------------------------------------------------------------------*/
121 /* Second, set RTC 24/12 hour setting */
122 /*-----------------------------------------------------------------------------------------------------*/
123 if (sPt->u32TimeScale == RTC_CLOCK_12)
124 {
125 RTC->AER = RTC_WRITE_KEY;
126 while(!(RTC->AER & RTC_AER_ENF_Msk)) RTC->AER = RTC_WRITE_KEY;
127 RTC->TSSR &= ~RTC_TSSR_24H_12H_Msk;
128
129 /*-------------------------------------------------------------------------------------------------*/
130 /* important, range of 12-hour PM mode is 21 up to 32 */
131 /*-------------------------------------------------------------------------------------------------*/
132 if (sPt->u32AmPm == RTC_PM)
133 sPt->u32Hour += 20;
134 }
135 else
136 {
137 RTC->AER = RTC_WRITE_KEY;
138 while(!(RTC->AER & RTC_AER_ENF_Msk)) RTC->AER = RTC_WRITE_KEY;
139 RTC->TSSR |= RTC_TSSR_24H_12H_Msk;
140 }
141
142 /*-----------------------------------------------------------------------------------------------------*/
143 /* Set RTC Calender Loading */
144 /*-----------------------------------------------------------------------------------------------------*/
145 u32Reg = ((sPt->u32Year - RTC_YEAR2000) / 10) << 20;
146 u32Reg |= (((sPt->u32Year - RTC_YEAR2000) % 10) << 16);
147 u32Reg |= ((sPt->u32Month / 10) << 12);
148 u32Reg |= ((sPt->u32Month % 10) << 8);
149 u32Reg |= ((sPt->u32Day / 10) << 4);
150 u32Reg |= (sPt->u32Day % 10);
151 g_u32Reg = u32Reg;
152
153 RTC->AER = RTC_WRITE_KEY;
154 while(!(RTC->AER & RTC_AER_ENF_Msk));
155
156 RTC->CLR = (uint32_t)g_u32Reg;
157
158 /*-----------------------------------------------------------------------------------------------------*/
159 /* Set RTC Time Loading */
160 /*-----------------------------------------------------------------------------------------------------*/
161 u32Reg = ((sPt->u32Hour / 10) << 20);
162 u32Reg |= ((sPt->u32Hour % 10) << 16);
163 u32Reg |= ((sPt->u32Minute / 10) << 12);
164 u32Reg |= ((sPt->u32Minute % 10) << 8);
165 u32Reg |= ((sPt->u32Second / 10) << 4);
166 u32Reg |= (sPt->u32Second % 10);
167 g_u32Reg = u32Reg;
168
169 RTC->AER = RTC_WRITE_KEY;
170 while(!(RTC->AER & RTC_AER_ENF_Msk));
171
172 RTC->TLR = (uint32_t)g_u32Reg;
173
174 RTC->DWR = sPt->u32DayOfWeek;
175
176 /* Waiting for RTC settings stable */
177 while(i32delay--);
178
179 }
180
199 void RTC_GetDateAndTime(S_RTC_TIME_DATA_T *sPt)
200 {
201 uint32_t u32Tmp;
202
203 sPt->u32TimeScale = RTC->TSSR & RTC_TSSR_24H_12H_Msk; /* 12/24-hour */
204 sPt->u32DayOfWeek = RTC->DWR & RTC_DWR_DWR_Msk; /* Day of week */
205
206 g_u32hiYear = (RTC->CLR & RTC_CLR_10YEAR_Msk) >> RTC_CLR_10YEAR_Pos;
207 g_u32loYear = (RTC->CLR & RTC_CLR_1YEAR_Msk) >> RTC_CLR_1YEAR_Pos;
208 g_u32hiMonth = (RTC->CLR & RTC_CLR_10MON_Msk) >> RTC_CLR_10MON_Pos;
209 g_u32loMonth = (RTC->CLR & RTC_CLR_1MON_Msk) >> RTC_CLR_1MON_Pos;
210 g_u32hiDay = (RTC->CLR & RTC_CLR_10DAY_Msk) >> RTC_CLR_10DAY_Pos;
211 g_u32loDay = (RTC->CLR & RTC_CLR_1DAY_Msk);
212
213 g_u32hiHour = (RTC->TLR & RTC_TLR_10HR_Msk) >> RTC_TLR_10HR_Pos;
214 g_u32loHour = (RTC->TLR & RTC_TLR_1HR_Msk) >> RTC_TLR_1HR_Pos;
215 g_u32hiMin = (RTC->TLR & RTC_TLR_10MIN_Msk) >> RTC_TLR_10MIN_Pos;
216 g_u32loMin = (RTC->TLR & RTC_TLR_1MIN_Msk) >> RTC_TLR_1MIN_Pos;
217 g_u32hiSec = (RTC->TLR & RTC_TLR_10SEC_Msk) >> RTC_TLR_10SEC_Pos;
218 g_u32loSec = (RTC->TLR & RTC_TLR_1SEC_Msk);
219
220 u32Tmp = (g_u32hiYear * 10); /* Compute to 20XX year */
221 u32Tmp += g_u32loYear;
222 sPt->u32Year = u32Tmp + RTC_YEAR2000;
223
224 u32Tmp = (g_u32hiMonth * 10); /* Compute 0~12 month */
225 sPt->u32Month = u32Tmp + g_u32loMonth;
226
227 u32Tmp = (g_u32hiDay * 10); /* Compute 0~31 day */
228 sPt->u32Day = u32Tmp + g_u32loDay;
229
230 if (sPt->u32TimeScale == RTC_CLOCK_12) /* Compute12/24 hour */
231 {
232 u32Tmp = (g_u32hiHour * 10);
233 u32Tmp+= g_u32loHour;
234 sPt->u32Hour = u32Tmp; /* AM: 1~12. PM: 21~32. */
235
236 if (sPt->u32Hour >= 21)
237 {
238 sPt->u32AmPm = RTC_PM;
239 sPt->u32Hour -= 20;
240 }
241 else
242 {
243 sPt->u32AmPm = RTC_AM;
244 }
245
246 u32Tmp = (g_u32hiMin * 10);
247 u32Tmp+= g_u32loMin;
248 sPt->u32Minute = u32Tmp;
249
250 u32Tmp = (g_u32hiSec * 10);
251 u32Tmp+= g_u32loSec;
252 sPt->u32Second = u32Tmp;
253
254 }
255 else
256 {
257 u32Tmp = (g_u32hiHour * 10);
258 u32Tmp += g_u32loHour;
259 sPt->u32Hour = u32Tmp;
260
261 u32Tmp = (g_u32hiMin * 10);
262 u32Tmp += g_u32loMin;
263 sPt->u32Minute = u32Tmp;
264
265 u32Tmp = (g_u32hiSec * 10);
266 u32Tmp += g_u32loSec;
267 sPt->u32Second = u32Tmp;
268 }
269
270 }
271
272
273
292 void RTC_GetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt)
293 {
294 uint32_t u32Tmp;
295
296 sPt->u32TimeScale = RTC->TSSR & RTC_TSSR_24H_12H_Msk; /* 12/24-hour */
297 sPt->u32DayOfWeek = RTC->DWR & RTC_DWR_DWR_Msk; /* Day of week */
298
299 RTC->AER = RTC_WRITE_KEY;
300 while(!(RTC->AER & RTC_AER_ENF_Msk));
301
302 g_u32hiYear = (RTC->CAR & RTC_CAR_10YEAR_Msk) >> RTC_CAR_10YEAR_Pos;
303 g_u32loYear = (RTC->CAR & RTC_CAR_1YEAR_Msk) >> RTC_CAR_1YEAR_Pos;
304 g_u32hiMonth = (RTC->CAR & RTC_CAR_10MON_Msk) >> RTC_CAR_10MON_Pos;
305 g_u32loMonth = (RTC->CAR & RTC_CAR_1MON_Msk) >> RTC_CAR_1MON_Pos;
306 g_u32hiDay = (RTC->CAR & RTC_CAR_10DAY_Msk) >> RTC_CAR_10DAY_Pos;
307 g_u32loDay = (RTC->CAR & RTC_CAR_1DAY_Msk);
308
309 RTC->AER = RTC_WRITE_KEY;
310 while(!(RTC->AER & RTC_AER_ENF_Msk));
311
312 g_u32hiHour = (RTC->TAR & RTC_TAR_10HR_Msk) >> RTC_TAR_10HR_Pos;
313 g_u32loHour = (RTC->TAR & RTC_TAR_1HR_Msk) >> RTC_TAR_1HR_Pos;
314 g_u32hiMin = (RTC->TAR & RTC_TAR_10MIN_Msk) >> RTC_TAR_10MIN_Pos;
315 g_u32loMin = (RTC->TAR & RTC_TAR_1MIN_Msk) >> RTC_TAR_1MIN_Pos;
316 g_u32hiSec = (RTC->TAR & RTC_TAR_10SEC_Msk) >> RTC_TAR_10SEC_Pos;
317 g_u32loSec = (RTC->TAR & RTC_TAR_1SEC_Msk);
318
319 u32Tmp = (g_u32hiYear * 10); /* Compute to 20XX year */
320 u32Tmp += g_u32loYear;
321 sPt->u32Year = u32Tmp + RTC_YEAR2000;
322
323 u32Tmp = (g_u32hiMonth * 10); /* Compute 0~12 month */
324 sPt->u32Month = u32Tmp + g_u32loMonth;
325
326 u32Tmp = (g_u32hiDay * 10); /* Compute 0~31 day */
327 sPt->u32Day = u32Tmp + g_u32loDay;
328
329 if (sPt->u32TimeScale == RTC_CLOCK_12) /* Compute12/24 hour */
330 {
331 u32Tmp = (g_u32hiHour * 10);
332 u32Tmp += g_u32loHour;
333 sPt->u32Hour = u32Tmp; /* AM: 1~12. PM: 21~32. */
334
335 if (sPt->u32Hour >= 21)
336 {
337 sPt->u32AmPm = RTC_PM;
338 sPt->u32Hour -= 20;
339 }
340 else
341 {
342 sPt->u32AmPm = RTC_AM;
343 }
344
345 u32Tmp = (g_u32hiMin * 10);
346 u32Tmp += g_u32loMin;
347 sPt->u32Minute = u32Tmp;
348
349 u32Tmp = (g_u32hiSec * 10);
350 u32Tmp += g_u32loSec;
351 sPt->u32Second = u32Tmp;
352
353 }
354 else
355 {
356 u32Tmp = (g_u32hiHour * 10);
357 u32Tmp += g_u32loHour;
358 sPt->u32Hour = u32Tmp;
359
360 u32Tmp = (g_u32hiMin * 10);
361 u32Tmp+= g_u32loMin;
362 sPt->u32Minute = u32Tmp;
363
364 u32Tmp = (g_u32hiSec * 10);
365 u32Tmp += g_u32loSec;
366 sPt->u32Second = u32Tmp;
367 }
368
369 }
370
371
372
395 void RTC_SetDateAndTime(S_RTC_TIME_DATA_T *sPt)
396 {
397 uint32_t u32Reg;
398
399 RTC->AER = RTC_WRITE_KEY;
400 while(!(RTC->AER & RTC_AER_ENF_Msk));
401
402 if (sPt->u32TimeScale == RTC_CLOCK_12)
403 {
404 RTC->TSSR &= ~RTC_TSSR_24H_12H_Msk;
405
406 /*-----------------------------------------------------------------------------------------*/
407 /* important, range of 12-hour PM mode is 21 up to 32 */
408 /*-----------------------------------------------------------------------------------------*/
409 if (sPt->u32AmPm == RTC_PM)
410 sPt->u32Hour += 20;
411 }
412 else
413 {
414 RTC->TSSR |= RTC_TSSR_24H_12H_Msk;
415 }
416
417 RTC->DWR = sPt->u32DayOfWeek & RTC_DWR_DWR_Msk;
418
419 u32Reg = ((sPt->u32Year - RTC_YEAR2000) / 10) << 20;
420 u32Reg |= (((sPt->u32Year - RTC_YEAR2000) % 10) << 16);
421 u32Reg |= ((sPt->u32Month / 10) << 12);
422 u32Reg |= ((sPt->u32Month % 10) << 8);
423 u32Reg |= ((sPt->u32Day / 10) << 4);
424 u32Reg |= (sPt->u32Day % 10);
425 g_u32Reg = u32Reg;
426
427 RTC->AER = RTC_WRITE_KEY;
428 while(!(RTC->AER & RTC_AER_ENF_Msk));
429
430 RTC->CLR = (uint32_t)g_u32Reg;
431
432 u32Reg = ((sPt->u32Hour / 10) << 20);
433 u32Reg |= ((sPt->u32Hour % 10) << 16);
434 u32Reg |= ((sPt->u32Minute / 10) << 12);
435 u32Reg |= ((sPt->u32Minute % 10) << 8);
436 u32Reg |= ((sPt->u32Second / 10) << 4);
437 u32Reg |= (sPt->u32Second % 10);
438 g_u32Reg = u32Reg;
439
440 RTC->AER = RTC_WRITE_KEY;
441 while(!(RTC->AER & RTC_AER_ENF_Msk));
442
443 RTC->TLR = (uint32_t)g_u32Reg;
444
445 }
446
467 void RTC_SetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt)
468 {
469 uint32_t u32Reg;
470
471 RTC->AER = RTC_WRITE_KEY;
472 while(!(RTC->AER & RTC_AER_ENF_Msk));
473
474 if (sPt->u32TimeScale == RTC_CLOCK_12)
475 {
476 RTC->TSSR &= ~RTC_TSSR_24H_12H_Msk;
477
478 /*-----------------------------------------------------------------------------------------*/
479 /* important, range of 12-hour PM mode is 21 up to 32 */
480 /*-----------------------------------------------------------------------------------------*/
481 if (sPt->u32AmPm == RTC_PM)
482 sPt->u32Hour += 20;
483 }
484 else
485 {
486 RTC->TSSR |= RTC_TSSR_24H_12H_Msk;
487 }
488
489 RTC->DWR = sPt->u32DayOfWeek & RTC_DWR_DWR_Msk;
490
491
492 u32Reg = ((sPt->u32Year - RTC_YEAR2000) / 10) << 20;
493 u32Reg |= (((sPt->u32Year - RTC_YEAR2000) % 10) << 16);
494 u32Reg |= ((sPt->u32Month / 10) << 12);
495 u32Reg |= ((sPt->u32Month % 10) << 8);
496 u32Reg |= ((sPt->u32Day / 10) << 4);
497 u32Reg |= (sPt->u32Day % 10);
498 g_u32Reg = u32Reg;
499
500 RTC->AER = RTC_WRITE_KEY;
501 while(!(RTC->AER & RTC_AER_ENF_Msk));
502
503 RTC->CAR = (uint32_t)g_u32Reg;
504
505 u32Reg = ((sPt->u32Hour / 10) << 20);
506 u32Reg |= ((sPt->u32Hour % 10) << 16);
507 u32Reg |= ((sPt->u32Minute / 10) << 12);
508 u32Reg |= ((sPt->u32Minute % 10) << 8);
509 u32Reg |= ((sPt->u32Second / 10) << 4);
510 u32Reg |= (sPt->u32Second % 10);
511 g_u32Reg = u32Reg;
512
513 RTC->AER = RTC_WRITE_KEY;
514 while(!(RTC->AER & RTC_AER_ENF_Msk));
515
516 RTC->TAR = (uint32_t)g_u32Reg;
517
518 }
519
520
534 void RTC_SetDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day, uint32_t u32DayOfWeek)
535 {
536 __IO uint32_t u32Reg;
537
538 RTC->AER = RTC_WRITE_KEY;
539 while(!(RTC->AER & RTC_AER_ENF_Msk)) RTC->AER = RTC_WRITE_KEY;
540
541 RTC->DWR = u32DayOfWeek & RTC_DWR_DWR_Msk;
542
543 u32Reg = ((u32Year - RTC_YEAR2000) / 10) << 20;
544 u32Reg |= (((u32Year - RTC_YEAR2000) % 10) << 16);
545 u32Reg |= ((u32Month / 10) << 12);
546 u32Reg |= ((u32Month % 10) << 8);
547 u32Reg |= ((u32Day / 10) << 4);
548 u32Reg |= (u32Day % 10);
549 g_u32Reg = u32Reg;
550
551 RTC->AER = RTC_WRITE_KEY;
552 while(!(RTC->AER & RTC_AER_ENF_Msk));
553
554 RTC->CLR = (uint32_t)g_u32Reg;
555
556 }
557
570 void RTC_SetTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
571 {
572 __IO uint32_t u32Reg;
573
574 RTC->AER = RTC_WRITE_KEY;
575 while(!(RTC->AER & RTC_AER_ENF_Msk));
576
577 if (u32TimeMode == RTC_CLOCK_12)
578 {
579 RTC->TSSR &= ~RTC_TSSR_24H_12H_Msk;
580
581 if (u32AmPm == RTC_PM) /* important, range of 12-hour PM mode is 21 up to 32 */
582 u32Hour += 20;
583 }
584 else if(u32TimeMode == RTC_CLOCK_24)
585 {
586 RTC->TSSR |= RTC_TSSR_24H_12H_Msk;
587 }
588
589 u32Reg = ((u32Hour / 10) << 20);
590 u32Reg |= ((u32Hour % 10) << 16);
591 u32Reg |= ((u32Minute / 10) << 12);
592 u32Reg |= ((u32Minute % 10) << 8);
593 u32Reg |= ((u32Second / 10) << 4);
594 u32Reg |= (u32Second % 10);
595
596 g_u32Reg = u32Reg;
597
598 RTC->AER = RTC_WRITE_KEY;
599 while(!(RTC->AER & RTC_AER_ENF_Msk));
600
601 RTC->TLR = (uint32_t)g_u32Reg;
602
603 }
604
615 void RTC_SetAlarmDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day)
616 {
617 __IO uint32_t u32Reg;
618
619 RTC->AER = RTC_WRITE_KEY;
620 while(!(RTC->AER & RTC_AER_ENF_Msk)) RTC->AER = RTC_WRITE_KEY;
621
622 u32Reg = ((u32Year - RTC_YEAR2000) / 10) << 20;
623 u32Reg |= (((u32Year - RTC_YEAR2000) % 10) << 16);
624 u32Reg |= ((u32Month / 10) << 12);
625 u32Reg |= ((u32Month % 10) << 8);
626 u32Reg |= ((u32Day / 10) << 4);
627 u32Reg |= (u32Day % 10);
628 g_u32Reg = u32Reg;
629
630 RTC->AER = RTC_WRITE_KEY;
631 while(!(RTC->AER & RTC_AER_ENF_Msk)) RTC->AER = RTC_WRITE_KEY;
632
633 RTC->CAR = (uint32_t)g_u32Reg;
634
635 }
636
649 void RTC_SetAlarmTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
650 {
651 __IO uint32_t u32Reg;
652
653 RTC->AER = RTC_WRITE_KEY;
654 while(!(RTC->AER & RTC_AER_ENF_Msk)) RTC->AER = RTC_WRITE_KEY;
655
656 if (u32TimeMode == RTC_CLOCK_12)
657 {
658 RTC->TSSR &= ~RTC_TSSR_24H_12H_Msk;
659
660 if (u32AmPm == RTC_PM) /* important, range of 12-hour PM mode is 21 up to 32 */
661 u32Hour += 20;
662 }
663 else if(u32TimeMode == RTC_CLOCK_24)
664 {
665 RTC->TSSR |= RTC_TSSR_24H_12H_Msk;
666 }
667
668 u32Reg = ((u32Hour / 10) << 20);
669 u32Reg |= ((u32Hour % 10) << 16);
670 u32Reg |= ((u32Minute / 10) << 12);
671 u32Reg |= ((u32Minute % 10) << 8);
672 u32Reg |= ((u32Second / 10) << 4);
673 u32Reg |= (u32Second % 10);
674
675 g_u32Reg = u32Reg;
676
677 RTC->AER = RTC_WRITE_KEY;
678 while(!(RTC->AER & RTC_AER_ENF_Msk)) RTC->AER = RTC_WRITE_KEY;
679
680 RTC->TAR = (uint32_t)g_u32Reg;
681
682 }
683
684
695 void RTC_EnableTamperDetection(uint32_t u32PinCondition)
696 {
697 RTC->AER = RTC_WRITE_KEY;
698 while(!(RTC->AER & RTC_AER_ENF_Msk)) RTC->AER = RTC_WRITE_KEY;
699
700 /* detection edge select */
701 if(u32PinCondition)
702 RTC->SPRCTL |= RTC_SPRCTL_SNOOPEDGE_Msk;
703 else
704 RTC->SPRCTL &= ~RTC_SPRCTL_SNOOPEDGE_Msk;
705
706 while(!(RTC->SPRCTL & RTC_SPRCTL_SPRRDY_Msk));
707
708 /* enable snooper pin event detection */
709 RTC->SPRCTL |= RTC_SPRCTL_SNOOPEN_Msk;
710 while(!(RTC->SPRCTL & RTC_SPRCTL_SPRRDY_Msk));
711 }
712
721 void RTC_DisableTamperDetection(void)
722 {
723 RTC->AER = RTC_WRITE_KEY;
724 while(!(RTC->AER & RTC_AER_ENF_Msk)) RTC->AER = RTC_WRITE_KEY;
725
726 RTC->SPRCTL &= ~RTC_SPRCTL_SNOOPEN_Msk;
727 }
728
737 uint32_t RTC_GetDayOfWeek(void)
738 {
739 return (RTC->DWR & RTC_DWR_DWR_Msk);
740 }
741
742
761 void RTC_SetTickPeriod(uint32_t u32TickSelection)
762 {
763 RTC->AER = RTC_WRITE_KEY;
764 while(!(RTC->AER & RTC_AER_ENF_Msk)) RTC->AER = RTC_WRITE_KEY;
765
766 RTC->TTR = RTC->TTR & ~RTC_TTR_TTR_Msk | u32TickSelection;
767 }
768
780 void RTC_EnableInt(uint32_t u32IntFlagMask)
781 {
782 RTC->AER = RTC_WRITE_KEY;
783 while(!(RTC->AER & RTC_AER_ENF_Msk)) RTC->AER = RTC_WRITE_KEY;
784
785 RTC->RIER |= u32IntFlagMask;
786 }
787
799 void RTC_DisableInt(uint32_t u32IntFlagMask)
800 {
801 RTC->AER = RTC_WRITE_KEY;
802 while(!(RTC->AER & RTC_AER_ENF_Msk)) RTC->AER = RTC_WRITE_KEY;
803
804 if(u32IntFlagMask & RTC_RIER_TIER_Msk)
805 {
806 RTC->RIER &= ~RTC_RIER_TIER_Msk;
807 RTC->RIIR = RTC_RIIR_TIF_Msk;
808 }
809
810 if(u32IntFlagMask & RTC_RIER_AIER_Msk)
811 {
812 RTC->RIER &= ~RTC_RIER_AIER_Msk;
813 RTC->RIIR = RTC_RIIR_AIF_Msk;
814 }
815
816 if(u32IntFlagMask & RTC_RIER_SNOOPIER_Msk)
817 {
818 RTC->RIER &= ~RTC_RIER_SNOOPIER_Msk;
819 RTC->RIIR = RTC_RIIR_SNOOPIF_Msk;
820 }
821 }
822
829 void RTC_Close (void)
830 {
831 CLK->APBCLK &= ~CLK_APBCLK_RTC_EN_Msk;
832 }
833
834 /* end of group NANO100_RTC_EXPORTED_FUNCTIONS */
836 /* end of group NANO100_RTC_Driver */
838 /* end of group NANO100_Device_Driver */
840
841 /*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/
842
843
RTC_TTR_TTR_Msk
#define RTC_TTR_TTR_Msk
Definition: Nano100Series.h:6912
RTC_DisableTamperDetection
void RTC_DisableTamperDetection(void)
This function is used to disable tamper detection function.
Definition: rtc.c:721
RTC_RIIR_SNOOPIF_Msk
#define RTC_RIIR_SNOOPIF_Msk
Definition: Nano100Series.h:6909
RTC_RIER_AIER_Msk
#define RTC_RIER_AIER_Msk
Definition: Nano100Series.h:6894
RTC_TAR_10MIN_Pos
#define RTC_TAR_10MIN_Pos
Definition: Nano100Series.h:6863
RTC_SetAlarmTime
void RTC_SetAlarmTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
This function is used to set alarm date to RTC.
Definition: rtc.c:649
RTC_GetDayOfWeek
uint32_t RTC_GetDayOfWeek(void)
This function is used to get day of week.
Definition: rtc.c:737
RTC_CAR_1MON_Pos
#define RTC_CAR_1MON_Pos
Definition: Nano100Series.h:6878
RTC_RIER_SNOOPIER_Msk
#define RTC_RIER_SNOOPIER_Msk
Definition: Nano100Series.h:6900
RTC_TAR_1HR_Msk
#define RTC_TAR_1HR_Msk
Definition: Nano100Series.h:6867
RTC_TLR_10MIN_Pos
#define RTC_TLR_10MIN_Pos
Definition: Nano100Series.h:6821
RTC_GetAlarmDateAndTime
void RTC_GetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt)
Read alarm date/time from RTC setting.
Definition: rtc.c:292
S_RTC_TIME_DATA_T::u32Hour
uint32_t u32Hour
Definition: rtc.h:87
CLK
#define CLK
Pointer to CLK register structure.
Definition: Nano100Series.h:10121
RTC_CLR_10DAY_Msk
#define RTC_CLR_10DAY_Msk
Definition: Nano100Series.h:6834
RTC
#define RTC
Pointer to RTC register structure.
Definition: Nano100Series.h:10100
RTC_SPRCTL_SNOOPEN_Msk
#define RTC_SPRCTL_SNOOPEN_Msk
Definition: Nano100Series.h:6918
RTC_CAR_10YEAR_Pos
#define RTC_CAR_10YEAR_Pos
Definition: Nano100Series.h:6887
RTC_TAR_1MIN_Msk
#define RTC_TAR_1MIN_Msk
Definition: Nano100Series.h:6861
RTC_CAR_10DAY_Msk
#define RTC_CAR_10DAY_Msk
Definition: Nano100Series.h:6876
RTC_TSSR_24H_12H_Msk
#define RTC_TSSR_24H_12H_Msk
Definition: Nano100Series.h:6849
RTC_TLR_1MIN_Pos
#define RTC_TLR_1MIN_Pos
Definition: Nano100Series.h:6818
RTC_TAR_10SEC_Msk
#define RTC_TAR_10SEC_Msk
Definition: Nano100Series.h:6858
S_RTC_TIME_DATA_T::u32Year
uint32_t u32Year
Definition: rtc.h:83
Nano100Series.h
Nano100 series peripheral access layer header file. This file contains all the peripheral register's ...
RTC_EnableTamperDetection
void RTC_EnableTamperDetection(uint32_t u32PinCondition)
This function is used to: .
Definition: rtc.c:695
RTC_SetDateAndTime
void RTC_SetDateAndTime(S_RTC_TIME_DATA_T *sPt)
This function is used to update date/time to RTC.
Definition: rtc.c:395
NULL
#define NULL
NULL pointer.
Definition: Nano100Series.h:10283
RTC_CLR_1YEAR_Msk
#define RTC_CLR_1YEAR_Msk
Definition: Nano100Series.h:6843
RTC_CLR_1MON_Pos
#define RTC_CLR_1MON_Pos
Definition: Nano100Series.h:6836
RTC_GetDateAndTime
void RTC_GetDateAndTime(S_RTC_TIME_DATA_T *sPt)
Read current date/time from RTC setting.
Definition: rtc.c:199
RTC_TLR_1MIN_Msk
#define RTC_TLR_1MIN_Msk
Definition: Nano100Series.h:6819
RTC_CLR_10YEAR_Pos
#define RTC_CLR_10YEAR_Pos
Definition: Nano100Series.h:6845
RTC_PM
#define RTC_PM
Definition: rtc.h:47
RTC_TAR_10HR_Pos
#define RTC_TAR_10HR_Pos
Definition: Nano100Series.h:6869
RTC_Close
void RTC_Close(void)
Disable RTC clock.
Definition: rtc.c:829
RTC_RIIR_AIF_Msk
#define RTC_RIIR_AIF_Msk
Definition: Nano100Series.h:6903
RTC_TAR_10SEC_Pos
#define RTC_TAR_10SEC_Pos
Definition: Nano100Series.h:6857
RTC_TAR_1HR_Pos
#define RTC_TAR_1HR_Pos
Definition: Nano100Series.h:6866
RTC_SetTickPeriod
void RTC_SetTickPeriod(uint32_t u32TickSelection)
The function is used to set time tick period for periodic time tick Interrupt.
Definition: rtc.c:761
RTC_CLOCK_24
#define RTC_CLOCK_24
Definition: rtc.h:44
RTC_CLR_1MON_Msk
#define RTC_CLR_1MON_Msk
Definition: Nano100Series.h:6837
RTC_CLR_10MON_Pos
#define RTC_CLR_10MON_Pos
Definition: Nano100Series.h:6839
RTC_CLR_1DAY_Msk
#define RTC_CLR_1DAY_Msk
Definition: Nano100Series.h:6831
RTC_CLR_10DAY_Pos
#define RTC_CLR_10DAY_Pos
Definition: Nano100Series.h:6833
RTC_32KCalibration
void RTC_32KCalibration(int32_t i32FrequencyX100)
Set Frequency Compensation Data.
Definition: rtc.c:58
RTC_AM
#define RTC_AM
Definition: rtc.h:46
RTC_TLR_10SEC_Pos
#define RTC_TLR_10SEC_Pos
Definition: Nano100Series.h:6815
RTC_TAR_1MIN_Pos
#define RTC_TAR_1MIN_Pos
Definition: Nano100Series.h:6860
S_RTC_TIME_DATA_T::u32Minute
uint32_t u32Minute
Definition: rtc.h:88
RTC_SPRCTL_SNOOPEDGE_Msk
#define RTC_SPRCTL_SNOOPEDGE_Msk
Definition: Nano100Series.h:6921
RTC_EnableInt
void RTC_EnableInt(uint32_t u32IntFlagMask)
The function is used to enable specified interrupt.
Definition: rtc.c:780
RTC_CAR_1YEAR_Pos
#define RTC_CAR_1YEAR_Pos
Definition: Nano100Series.h:6884
S_RTC_TIME_DATA_T::u32AmPm
uint32_t u32AmPm
Definition: rtc.h:91
RTC_CAR_10YEAR_Msk
#define RTC_CAR_10YEAR_Msk
Definition: Nano100Series.h:6888
RTC_AER_ENF_Msk
#define RTC_AER_ENF_Msk
Definition: Nano100Series.h:6804
RTC_CAR_10MON_Msk
#define RTC_CAR_10MON_Msk
Definition: Nano100Series.h:6882
RTC_CAR_1MON_Msk
#define RTC_CAR_1MON_Msk
Definition: Nano100Series.h:6879
RTC_CAR_1DAY_Msk
#define RTC_CAR_1DAY_Msk
Definition: Nano100Series.h:6873
RTC_INIT_KEY
#define RTC_INIT_KEY
Definition: rtc.h:35
RTC_SetDate
void RTC_SetDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day, uint32_t u32DayOfWeek)
This function is used to update date to RTC.
Definition: rtc.c:534
RTC_TLR_1HR_Msk
#define RTC_TLR_1HR_Msk
Definition: Nano100Series.h:6825
CLK_APBCLK_RTC_EN_Msk
#define CLK_APBCLK_RTC_EN_Msk
Definition: Nano100Series.h:1090
RTC_TLR_1SEC_Msk
#define RTC_TLR_1SEC_Msk
Definition: Nano100Series.h:6813
RTC_CLR_10YEAR_Msk
#define RTC_CLR_10YEAR_Msk
Definition: Nano100Series.h:6846
RTC_CAR_1YEAR_Msk
#define RTC_CAR_1YEAR_Msk
Definition: Nano100Series.h:6885
RTC_TLR_10SEC_Msk
#define RTC_TLR_10SEC_Msk
Definition: Nano100Series.h:6816
RTC_CLOCK_12
#define RTC_CLOCK_12
Definition: rtc.h:43
RTC_CAR_10MON_Pos
#define RTC_CAR_10MON_Pos
Definition: Nano100Series.h:6881
RTC_SetAlarmDateAndTime
void RTC_SetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt)
This function is used to set alarm date/time to RTC.
Definition: rtc.c:467
RTC_FCR_REFERENCE
#define RTC_FCR_REFERENCE
Definition: rtc.h:41
S_RTC_TIME_DATA_T
RTC define Time Data Struct.
Definition: rtc.h:81
S_RTC_TIME_DATA_T::u32Day
uint32_t u32Day
Definition: rtc.h:85
RTC_SetAlarmDate
void RTC_SetAlarmDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day)
This function is used to set alarm date to RTC.
Definition: rtc.c:615
S_RTC_TIME_DATA_T::u32DayOfWeek
uint32_t u32DayOfWeek
Definition: rtc.h:86
RTC_TAR_10HR_Msk
#define RTC_TAR_10HR_Msk
Definition: Nano100Series.h:6870
RTC_TLR_10HR_Msk
#define RTC_TLR_10HR_Msk
Definition: Nano100Series.h:6828
RTC_WRITE_KEY
#define RTC_WRITE_KEY
Definition: rtc.h:36
RTC_CAR_10DAY_Pos
#define RTC_CAR_10DAY_Pos
Definition: Nano100Series.h:6875
RTC_DWR_DWR_Msk
#define RTC_DWR_DWR_Msk
Definition: Nano100Series.h:6852
RTC_YEAR2000
#define RTC_YEAR2000
Definition: rtc.h:40
RTC_SetTime
void RTC_SetTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
This function is used to update time to RTC.
Definition: rtc.c:570
S_RTC_TIME_DATA_T::u32Month
uint32_t u32Month
Definition: rtc.h:84
RTC_TLR_10HR_Pos
#define RTC_TLR_10HR_Pos
Definition: Nano100Series.h:6827
S_RTC_TIME_DATA_T::u32Second
uint32_t u32Second
Definition: rtc.h:89
RTC_SPRCTL_SPRRDY_Msk
#define RTC_SPRCTL_SPRRDY_Msk
Definition: Nano100Series.h:6924
RTC_TAR_1SEC_Msk
#define RTC_TAR_1SEC_Msk
Definition: Nano100Series.h:6855
RTC_CLR_10MON_Msk
#define RTC_CLR_10MON_Msk
Definition: Nano100Series.h:6840
RTC_Open
void RTC_Open(S_RTC_TIME_DATA_T *sPt)
This function is used to: .
Definition: rtc.c:102
RTC_RIIR_TIF_Msk
#define RTC_RIIR_TIF_Msk
Definition: Nano100Series.h:6906
S_RTC_TIME_DATA_T::u32TimeScale
uint32_t u32TimeScale
Definition: rtc.h:90
RTC_TLR_1HR_Pos
#define RTC_TLR_1HR_Pos
Definition: Nano100Series.h:6824
RTC_TAR_10MIN_Msk
#define RTC_TAR_10MIN_Msk
Definition: Nano100Series.h:6864
RTC_TLR_10MIN_Msk
#define RTC_TLR_10MIN_Msk
Definition: Nano100Series.h:6822
RTC_DisableInt
void RTC_DisableInt(uint32_t u32IntFlagMask)
The function is used to disable specified interrupt.
Definition: rtc.c:799
RTC_RIER_TIER_Msk
#define RTC_RIER_TIER_Msk
Definition: Nano100Series.h:6897
RTC_CLR_1YEAR_Pos
#define RTC_CLR_1YEAR_Pos
Definition: Nano100Series.h:6842