Nano103 BSP  V3.01.002
The Board Support Package for Nano103 Series
rtc.c
Go to the documentation of this file.
1 /**************************************************************************/
14 #include <stdio.h>
15 #include "Nano103.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 
43 void RTC_RWEN(void)
44 {
45  RTC->RWEN = RTC_WRITE_KEY;
46  while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)) RTC->RWEN = RTC_WRITE_KEY;
47 
48  while(RTC->RWEN & RTC_RWEN_RTCBUSY_Msk);
49 }
50 
52 
66 void RTC_32KCalibration(int32_t i32FrequencyX10000)
67 {
68  uint64_t u64Compensate;
69 
70  //u64Compensate = (uint64_t)(0x64000000000);
71  u64Compensate = (uint64_t)(0x2710000000000);
72  u64Compensate = (uint64_t)(u64Compensate / (uint64_t)i32FrequencyX10000);
73 
74  if(u64Compensate >= 0x400000)
75  {
76  u64Compensate = 0x3FFFFF;
77  }
78 
79  RTC_RWEN();
80  RTC->FREQADJ = (uint32_t)u64Compensate;
81 
82 }
83 
108 {
109  uint32_t u32Reg;
110 
111  RTC->INIT = RTC_INIT_KEY;
112 
113  if(RTC->INIT != 0x1)
114  {
115  RTC->INIT = RTC_INIT_KEY;
116 
117  while(RTC->INIT != 0x1);
118  }
119 
120  if(sPt == NULL)
121  return;
122 
123  /*-----------------------------------------------------------------------------------------------------*/
124  /* Second, set RTC 24/12 hour setting */
125  /*-----------------------------------------------------------------------------------------------------*/
126  if (sPt->u32TimeScale == RTC_CLOCK_12)
127  {
128  RTC_RWEN();
129  RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk;
130 
131  /*-------------------------------------------------------------------------------------------------*/
132  /* important, range of 12-hour PM mode is 21 up to 32 */
133  /*-------------------------------------------------------------------------------------------------*/
134  if (sPt->u32AmPm == RTC_PM)
135  sPt->u32Hour += 20;
136  }
137  else
138  {
139  RTC_RWEN();
140  RTC->CLKFMT |= RTC_CLKFMT_24HEN_Msk;
141  }
142 
143  /*-----------------------------------------------------------------------------------------------------*/
144  /* Set RTC Calender Loading */
145  /*-----------------------------------------------------------------------------------------------------*/
146  u32Reg = ((sPt->u32Year - RTC_YEAR2000) / 10) << 20;
147  u32Reg |= (((sPt->u32Year - RTC_YEAR2000) % 10) << 16);
148  u32Reg |= ((sPt->u32Month / 10) << 12);
149  u32Reg |= ((sPt->u32Month % 10) << 8);
150  u32Reg |= ((sPt->u32Day / 10) << 4);
151  u32Reg |= (sPt->u32Day % 10);
152  g_u32Reg = u32Reg;
153 
154  RTC_RWEN();
155  RTC->CAL = (uint32_t)g_u32Reg;
156 
157  /*-----------------------------------------------------------------------------------------------------*/
158  /* Set RTC Time Loading */
159  /*-----------------------------------------------------------------------------------------------------*/
160  u32Reg = ((sPt->u32Hour / 10) << 20);
161  u32Reg |= ((sPt->u32Hour % 10) << 16);
162  u32Reg |= ((sPt->u32Minute / 10) << 12);
163  u32Reg |= ((sPt->u32Minute % 10) << 8);
164  u32Reg |= ((sPt->u32Second / 10) << 4);
165  u32Reg |= (sPt->u32Second % 10);
166  g_u32Reg = u32Reg;
167 
168  RTC_RWEN();
169  RTC->TIME = (uint32_t)g_u32Reg;
170 
171  RTC_RWEN();
172  RTC->WEEKDAY = sPt->u32DayOfWeek;
173 
174 }
175 
195 {
196  uint32_t u32Tmp;
197 
198  sPt->u32TimeScale = RTC->CLKFMT & RTC_CLKFMT_24HEN_Msk; /* 12/24-hour */
199  sPt->u32DayOfWeek = RTC->WEEKDAY & RTC_WEEKDAY_WEEKDAY_Msk; /* Day of week */
200 
201  g_u32hiYear = (RTC->CAL & RTC_CAL_TENYEAR_Msk) >> RTC_CAL_TENYEAR_Pos;
202  g_u32loYear = (RTC->CAL & RTC_CAL_YEAR_Msk) >> RTC_CAL_YEAR_Pos;
203  g_u32hiMonth = (RTC->CAL & RTC_CAL_TENMON_Msk) >> RTC_CAL_TENMON_Pos;
204  g_u32loMonth = (RTC->CAL & RTC_CAL_MON_Msk) >> RTC_CAL_MON_Pos;
205  g_u32hiDay = (RTC->CAL & RTC_CAL_TENDAY_Msk) >> RTC_CAL_TENDAY_Pos;
206  g_u32loDay = (RTC->CAL & RTC_CAL_DAY_Msk);
207 
208  g_u32hiHour = (RTC->TIME & RTC_TIME_TENHR_Msk) >> RTC_TIME_TENHR_Pos;
209  g_u32loHour = (RTC->TIME & RTC_TIME_HR_Msk) >> RTC_TIME_HR_Pos;
210  g_u32hiMin = (RTC->TIME & RTC_TIME_TENMIN_Msk) >> RTC_TIME_TENMIN_Pos;
211  g_u32loMin = (RTC->TIME & RTC_TIME_MIN_Msk) >> RTC_TIME_MIN_Pos;
212  g_u32hiSec = (RTC->TIME & RTC_TIME_TENSEC_Msk) >> RTC_TIME_TENSEC_Pos;
213  g_u32loSec = (RTC->TIME & RTC_TIME_SEC_Msk);
214 
215  u32Tmp = (g_u32hiYear * 10); /* Compute to 20XX year */
216  u32Tmp += g_u32loYear;
217  sPt->u32Year = u32Tmp + RTC_YEAR2000;
218 
219  u32Tmp = (g_u32hiMonth * 10); /* Compute 0~12 month */
220  sPt->u32Month = u32Tmp + g_u32loMonth;
221 
222  u32Tmp = (g_u32hiDay * 10); /* Compute 0~31 day */
223  sPt->u32Day = u32Tmp + g_u32loDay;
224 
225  if (sPt->u32TimeScale == RTC_CLOCK_12) /* Compute12/24 hour */
226  {
227  u32Tmp = (g_u32hiHour * 10);
228  u32Tmp+= g_u32loHour;
229  sPt->u32Hour = u32Tmp; /* AM: 1~12. PM: 21~32. */
230 
231  if (sPt->u32Hour >= 21)
232  {
233  sPt->u32AmPm = RTC_PM;
234  sPt->u32Hour -= 20;
235  }
236  else
237  {
238  sPt->u32AmPm = RTC_AM;
239  }
240 
241  u32Tmp = (g_u32hiMin * 10);
242  u32Tmp+= g_u32loMin;
243  sPt->u32Minute = u32Tmp;
244 
245  u32Tmp = (g_u32hiSec * 10);
246  u32Tmp+= g_u32loSec;
247  sPt->u32Second = u32Tmp;
248 
249  }
250  else
251  {
252  u32Tmp = (g_u32hiHour * 10);
253  u32Tmp += g_u32loHour;
254  sPt->u32Hour = u32Tmp;
255 
256  u32Tmp = (g_u32hiMin * 10);
257  u32Tmp += g_u32loMin;
258  sPt->u32Minute = u32Tmp;
259 
260  u32Tmp = (g_u32hiSec * 10);
261  u32Tmp += g_u32loSec;
262  sPt->u32Second = u32Tmp;
263  }
264 
265 }
266 
267 
268 
288 {
289  uint32_t u32Tmp;
290 
291  sPt->u32TimeScale = RTC->CLKFMT & RTC_CLKFMT_24HEN_Msk; /* 12/24-hour */
292  sPt->u32DayOfWeek = RTC->WEEKDAY & RTC_WEEKDAY_WEEKDAY_Msk; /* Day of week */
293 
294  g_u32hiYear = (RTC->CALM & RTC_CALM_TENYEAR_Msk) >> RTC_CALM_TENYEAR_Pos;
295  g_u32loYear = (RTC->CALM & RTC_CALM_YEAR_Msk) >> RTC_CALM_YEAR_Pos;
296  g_u32hiMonth = (RTC->CALM & RTC_CALM_TENMON_Msk) >> RTC_CALM_TENMON_Pos;
297  g_u32loMonth = (RTC->CALM & RTC_CALM_MON_Msk) >> RTC_CALM_MON_Pos;
298  g_u32hiDay = (RTC->CALM & RTC_CALM_TENDAY_Msk) >> RTC_CALM_TENDAY_Pos;
299  g_u32loDay = (RTC->CALM & RTC_CALM_DAY_Msk);
300 
301  g_u32hiHour = (RTC->TALM & RTC_TALM_TENHR_Msk) >> RTC_TALM_TENHR_Pos;
302  g_u32loHour = (RTC->TALM & RTC_TALM_HR_Msk) >> RTC_TALM_HR_Pos;
303  g_u32hiMin = (RTC->TALM & RTC_TALM_TENMIN_Msk) >> RTC_TALM_TENMIN_Pos;
304  g_u32loMin = (RTC->TALM & RTC_TALM_MIN_Msk) >> RTC_TALM_MIN_Pos;
305  g_u32hiSec = (RTC->TALM & RTC_TALM_TENSEC_Msk) >> RTC_TALM_TENSEC_Pos;
306  g_u32loSec = (RTC->TALM & RTC_TALM_SEC_Msk);
307 
308  u32Tmp = (g_u32hiYear * 10); /* Compute to 20XX year */
309  u32Tmp += g_u32loYear;
310  sPt->u32Year = u32Tmp + RTC_YEAR2000;
311 
312  u32Tmp = (g_u32hiMonth * 10); /* Compute 0~12 month */
313  sPt->u32Month = u32Tmp + g_u32loMonth;
314 
315  u32Tmp = (g_u32hiDay * 10); /* Compute 0~31 day */
316  sPt->u32Day = u32Tmp + g_u32loDay;
317 
318  if (sPt->u32TimeScale == RTC_CLOCK_12) /* Compute12/24 hour */
319  {
320  u32Tmp = (g_u32hiHour * 10);
321  u32Tmp += g_u32loHour;
322  sPt->u32Hour = u32Tmp; /* AM: 1~12. PM: 21~32. */
323 
324  if (sPt->u32Hour >= 21)
325  {
326  sPt->u32AmPm = RTC_PM;
327  sPt->u32Hour -= 20;
328  }
329  else
330  {
331  sPt->u32AmPm = RTC_AM;
332  }
333 
334  u32Tmp = (g_u32hiMin * 10);
335  u32Tmp += g_u32loMin;
336  sPt->u32Minute = u32Tmp;
337 
338  u32Tmp = (g_u32hiSec * 10);
339  u32Tmp += g_u32loSec;
340  sPt->u32Second = u32Tmp;
341 
342  }
343  else
344  {
345  u32Tmp = (g_u32hiHour * 10);
346  u32Tmp += g_u32loHour;
347  sPt->u32Hour = u32Tmp;
348 
349  u32Tmp = (g_u32hiMin * 10);
350  u32Tmp+= g_u32loMin;
351  sPt->u32Minute = u32Tmp;
352 
353  u32Tmp = (g_u32hiSec * 10);
354  u32Tmp += g_u32loSec;
355  sPt->u32Second = u32Tmp;
356  }
357 
358 }
359 
360 
361 
385 {
386  uint32_t u32Reg;
387 
388  if (sPt->u32TimeScale == RTC_CLOCK_12)
389  {
390  RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk;
391 
392  /*-----------------------------------------------------------------------------------------*/
393  /* important, range of 12-hour PM mode is 21 upto 32 */
394  /*-----------------------------------------------------------------------------------------*/
395  if (sPt->u32AmPm == RTC_PM)
396  sPt->u32Hour += 20;
397  }
398  else
399  {
400  RTC_RWEN();
401  RTC->CLKFMT |= RTC_CLKFMT_24HEN_Msk;
402  }
403 
404  RTC_RWEN();
405  RTC->WEEKDAY = sPt->u32DayOfWeek & RTC_WEEKDAY_WEEKDAY_Msk;
406 
407  u32Reg = ((sPt->u32Year - RTC_YEAR2000) / 10) << 20;
408  u32Reg |= (((sPt->u32Year - RTC_YEAR2000) % 10) << 16);
409  u32Reg |= ((sPt->u32Month / 10) << 12);
410  u32Reg |= ((sPt->u32Month % 10) << 8);
411  u32Reg |= ((sPt->u32Day / 10) << 4);
412  u32Reg |= (sPt->u32Day % 10);
413  g_u32Reg = u32Reg;
414 
415  RTC_RWEN();
416  RTC->CAL = (uint32_t)g_u32Reg;
417 
418  u32Reg = ((sPt->u32Hour / 10) << 20);
419  u32Reg |= ((sPt->u32Hour % 10) << 16);
420  u32Reg |= ((sPt->u32Minute / 10) << 12);
421  u32Reg |= ((sPt->u32Minute % 10) << 8);
422  u32Reg |= ((sPt->u32Second / 10) << 4);
423  u32Reg |= (sPt->u32Second % 10);
424  g_u32Reg = u32Reg;
425 
426  RTC_RWEN();
427  RTC->TIME = (uint32_t)g_u32Reg;
428 
429 }
430 
452 {
453  uint32_t u32Reg;
454 
455  RTC_RWEN();
456 
457  if (sPt->u32TimeScale == RTC_CLOCK_12)
458  {
459  RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk;
460 
461  /*-----------------------------------------------------------------------------------------*/
462  /* important, range of 12-hour PM mode is 21 up to 32 */
463  /*-----------------------------------------------------------------------------------------*/
464  if (sPt->u32AmPm == RTC_PM)
465  sPt->u32Hour += 20;
466  }
467  else
468  {
469  RTC->CLKFMT |= RTC_CLKFMT_24HEN_Msk;
470  }
471 
472  RTC_RWEN();
473  RTC->WEEKDAY = sPt->u32DayOfWeek & RTC_WEEKDAY_WEEKDAY_Msk;
474 
475 
476  u32Reg = ((sPt->u32Year - RTC_YEAR2000) / 10) << 20;
477  u32Reg |= (((sPt->u32Year - RTC_YEAR2000) % 10) << 16);
478  u32Reg |= ((sPt->u32Month / 10) << 12);
479  u32Reg |= ((sPt->u32Month % 10) << 8);
480  u32Reg |= ((sPt->u32Day / 10) << 4);
481  u32Reg |= (sPt->u32Day % 10);
482  g_u32Reg = u32Reg;
483 
484  RTC_RWEN();
485  RTC->CALM = (uint32_t)g_u32Reg;
486 
487  u32Reg = ((sPt->u32Hour / 10) << 20);
488  u32Reg |= ((sPt->u32Hour % 10) << 16);
489  u32Reg |= ((sPt->u32Minute / 10) << 12);
490  u32Reg |= ((sPt->u32Minute % 10) << 8);
491  u32Reg |= ((sPt->u32Second / 10) << 4);
492  u32Reg |= (sPt->u32Second % 10);
493  g_u32Reg = u32Reg;
494 
495  RTC_RWEN();
496  RTC->TALM = (uint32_t)g_u32Reg;
497 
498 }
499 
500 
514 void RTC_SetDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day, uint32_t u32DayOfWeek)
515 {
516  __IO uint32_t u32Reg;
517 
518  RTC_RWEN();
519  RTC->WEEKDAY = u32DayOfWeek & RTC_WEEKDAY_WEEKDAY_Msk;
520 
521  u32Reg = ((u32Year - RTC_YEAR2000) / 10) << 20;
522  u32Reg |= (((u32Year - RTC_YEAR2000) % 10) << 16);
523  u32Reg |= ((u32Month / 10) << 12);
524  u32Reg |= ((u32Month % 10) << 8);
525  u32Reg |= ((u32Day / 10) << 4);
526  u32Reg |= (u32Day % 10);
527  g_u32Reg = u32Reg;
528 
529  RTC_RWEN();
530  RTC->CAL = (uint32_t)g_u32Reg;
531 
532 }
533 
546 void RTC_SetTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
547 {
548  __IO uint32_t u32Reg;
549 
550  RTC_RWEN();
551 
552  if (u32TimeMode == RTC_CLOCK_12)
553  {
554  RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk;
555 
556  if (u32AmPm == RTC_PM) /* important, range of 12-hour PM mode is 21 upto 32 */
557  u32Hour += 20;
558  }
559  else if(u32TimeMode == RTC_CLOCK_24)
560  {
561  RTC->CLKFMT |= RTC_CLKFMT_24HEN_Msk;
562  }
563 
564  u32Reg = ((u32Hour / 10) << 20);
565  u32Reg |= ((u32Hour % 10) << 16);
566  u32Reg |= ((u32Minute / 10) << 12);
567  u32Reg |= ((u32Minute % 10) << 8);
568  u32Reg |= ((u32Second / 10) << 4);
569  u32Reg |= (u32Second % 10);
570 
571  g_u32Reg = u32Reg;
572 
573  RTC_RWEN();
574  RTC->TIME = (uint32_t)g_u32Reg;
575 
576 }
577 
588 void RTC_SetAlarmDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day)
589 {
590  __IO uint32_t u32Reg;
591 
592  u32Reg = ((u32Year - RTC_YEAR2000) / 10) << 20;
593  u32Reg |= (((u32Year - RTC_YEAR2000) % 10) << 16);
594  u32Reg |= ((u32Month / 10) << 12);
595  u32Reg |= ((u32Month % 10) << 8);
596  u32Reg |= ((u32Day / 10) << 4);
597  u32Reg |= (u32Day % 10);
598  g_u32Reg = u32Reg;
599 
600  RTC_RWEN();
601  RTC->CALM = (uint32_t)g_u32Reg;
602 
603 }
604 
617 void RTC_SetAlarmTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
618 {
619  __IO uint32_t u32Reg;
620 
621  RTC_RWEN();
622 
623  if (u32TimeMode == RTC_CLOCK_12)
624  {
625  RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk;
626 
627  if (u32AmPm == RTC_PM) /* important, range of 12-hour PM mode is 21 up to 32 */
628  u32Hour += 20;
629  }
630  else if(u32TimeMode == RTC_CLOCK_24)
631  {
632  RTC->CLKFMT |= RTC_CLKFMT_24HEN_Msk;
633  }
634 
635  u32Reg = ((u32Hour / 10) << 20);
636  u32Reg |= ((u32Hour % 10) << 16);
637  u32Reg |= ((u32Minute / 10) << 12);
638  u32Reg |= ((u32Minute % 10) << 8);
639  u32Reg |= ((u32Second / 10) << 4);
640  u32Reg |= (u32Second % 10);
641 
642  g_u32Reg = u32Reg;
643 
644  RTC_RWEN();
645  RTC->TALM = (uint32_t)g_u32Reg;
646 
647 }
648 
649 
660 void RTC_EnableTamperDetection(uint32_t u32PinCondition)
661 {
662  RTC_RWEN();
663 
664  /* detection edge select */
665  if(u32PinCondition)
666  RTC->SPRCTL |= RTC_SPRCTL_SNPTYPE0_Msk;
667  else
668  RTC->SPRCTL &= ~RTC_SPRCTL_SNPTYPE0_Msk;
669 
670  RTC_RWEN();
671  /* enable snooper pin event detection */
672  RTC->SPRCTL |= RTC_SPRCTL_SNPDEN_Msk;
673 }
674 
684 {
685  RTC_RWEN();
686 
687  RTC->SPRCTL &= ~RTC_SPRCTL_SNPDEN_Msk;
688 }
689 
698 uint32_t RTC_GetDayOfWeek(void)
699 {
700  return (RTC->WEEKDAY & RTC_WEEKDAY_WEEKDAY_Msk);
701 }
702 
703 
722 void RTC_SetTickPeriod(uint32_t u32TickSelection)
723 {
724  RTC_RWEN();
725 
726  RTC->TICK = RTC->TICK & ~RTC_TICK_TICK_Msk | u32TickSelection;
727 }
728 
740 void RTC_EnableInt(uint32_t u32IntFlagMask)
741 {
742  RTC_RWEN();
743 
744  RTC->INTEN |= u32IntFlagMask;
745 }
746 
758 void RTC_DisableInt(uint32_t u32IntFlagMask)
759 {
760  RTC_RWEN();
761  if(u32IntFlagMask & RTC_INTEN_TICKIEN_Msk)
762  {
763  RTC->INTEN &= ~RTC_INTEN_TICKIEN_Msk;
764  RTC->INTSTS = RTC_INTSTS_TICKIF_Msk;
765  }
766 
767  RTC_RWEN();
768  if(u32IntFlagMask & RTC_INTEN_ALMIEN_Msk)
769  {
770  RTC->INTEN &= ~RTC_INTEN_ALMIEN_Msk;
771  RTC->INTSTS = RTC_INTSTS_ALMIF_Msk;
772  }
773 
774  RTC_RWEN();
775  if(u32IntFlagMask & RTC_INTEN_SNPDIEN_Msk)
776  {
777  RTC->INTEN &= ~RTC_INTEN_SNPDIEN_Msk;
778  RTC->INTSTS = RTC_INTSTS_SNPDIF_Msk;
779  }
780 
781 }
782 
789 void RTC_Close (void)
790 {
791  CLK->APBCLK &= ~CLK_APBCLK_RTCCKEN_Msk;
792 }
793 
794  /* end of group NANO103_RTC_EXPORTED_FUNCTIONS */
796  /* end of group NANO103_RTC_Driver */
798  /* end of group NANO103_Device_Driver */
800 
801 /*** (C) COPYRIGHT 2015 Nuvoton Technology Corp. ***/
802 
803 
#define RTC_TALM_TENHR_Msk
Definition: Nano103.h:18730
#define RTC_CALM_DAY_Msk
Definition: Nano103.h:18733
#define RTC_CAL_TENYEAR_Msk
Definition: Nano103.h:18706
#define RTC_TIME_TENSEC_Pos
Definition: Nano103.h:18675
#define RTC_CALM_TENYEAR_Pos
Definition: Nano103.h:18747
#define RTC_TALM_MIN_Pos
Definition: Nano103.h:18720
#define RTC_TIME_TENSEC_Msk
Definition: Nano103.h:18676
void RTC_SetTickPeriod(uint32_t u32TickSelection)
The function is used to set time tick period for periodic time tick Interrupt.
Definition: rtc.c:722
void RTC_32KCalibration(int32_t i32FrequencyX100)
Set Frequency Compensation Data.
Definition: rtc.c:66
#define RTC_CALM_TENDAY_Pos
Definition: Nano103.h:18735
void RTC_DisableInt(uint32_t u32IntFlagMask)
The function is used to disable specified interrupt.
Definition: rtc.c:758
#define RTC_TALM_HR_Pos
Definition: Nano103.h:18726
#define RTC_INIT_KEY
Definition: rtc.h:35
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:514
#define RTC_TIME_TENHR_Pos
Definition: Nano103.h:18687
uint32_t u32Hour
Definition: rtc.h:86
#define RTC_TALM_MIN_Msk
Definition: Nano103.h:18721
void RTC_EnableTamperDetection(uint32_t u32PinCondition)
This function is used to: .
Definition: rtc.c:660
void RTC_GetDateAndTime(S_RTC_TIME_DATA_T *sPt)
Read current date/time from RTC setting.
Definition: rtc.c:194
#define RTC_INTSTS_TICKIF_Msk
Definition: Nano103.h:18766
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:588
#define RTC_CALM_TENMON_Pos
Definition: Nano103.h:18741
#define RTC_TALM_TENHR_Pos
Definition: Nano103.h:18729
#define RTC_SPRCTL_SNPTYPE0_Msk
Definition: Nano103.h:18814
#define RTC_CAL_YEAR_Pos
Definition: Nano103.h:18702
#define RTC_CAL_MON_Pos
Definition: Nano103.h:18696
#define RTC_TICK_TICK_Msk
Definition: Nano103.h:18772
#define RTC_CAL_TENMON_Msk
Definition: Nano103.h:18700
void RTC_GetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt)
Read alarm date/time from RTC setting.
Definition: rtc.c:287
#define RTC_INTEN_SNPDIEN_Msk
Definition: Nano103.h:18760
#define RTC_CALM_YEAR_Msk
Definition: Nano103.h:18745
uint32_t u32Year
Definition: rtc.h:82
#define RTC
Pointer to RTC register structure.
Definition: Nano103.h:24863
#define RTC_RWEN_RTCBUSY_Msk
Definition: Nano103.h:18667
#define RTC_YEAR2000
Definition: rtc.h:40
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:546
#define RTC_CLOCK_24
Definition: rtc.h:43
#define RTC_TIME_HR_Msk
Definition: Nano103.h:18685
#define RTC_TIME_TENHR_Msk
Definition: Nano103.h:18688
#define RTC_CALM_MON_Pos
Definition: Nano103.h:18738
#define RTC_TIME_HR_Pos
Definition: Nano103.h:18684
#define RTC_TALM_TENSEC_Pos
Definition: Nano103.h:18717
#define RTC_WRITE_KEY
Definition: rtc.h:36
void RTC_EnableInt(uint32_t u32IntFlagMask)
The function is used to enable specified interrupt.
Definition: rtc.c:740
void RTC_SetDateAndTime(S_RTC_TIME_DATA_T *sPt)
This function is used to update date/time to RTC.
Definition: rtc.c:384
#define RTC_SPRCTL_SNPDEN_Msk
Definition: Nano103.h:18811
#define RTC_INTSTS_SNPDIF_Msk
Definition: Nano103.h:18769
#define RTC_CALM_TENMON_Msk
Definition: Nano103.h:18742
#define RTC_TALM_HR_Msk
Definition: Nano103.h:18727
#define RTC_CALM_TENYEAR_Msk
Definition: Nano103.h:18748
#define RTC_CAL_TENDAY_Msk
Definition: Nano103.h:18694
#define RTC_RWEN_RWENF_Msk
Definition: Nano103.h:18664
uint32_t RTC_GetDayOfWeek(void)
This function is used to get day of week.
Definition: rtc.c:698
uint32_t u32Minute
Definition: rtc.h:87
#define RTC_INTSTS_ALMIF_Msk
Definition: Nano103.h:18763
uint32_t u32AmPm
Definition: rtc.h:90
#define RTC_TIME_MIN_Msk
Definition: Nano103.h:18679
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:617
#define RTC_CLOCK_12
Definition: rtc.h:42
#define RTC_TALM_SEC_Msk
Definition: Nano103.h:18715
#define RTC_TALM_TENMIN_Pos
Definition: Nano103.h:18723
#define RTC_WEEKDAY_WEEKDAY_Msk
Definition: Nano103.h:18712
#define NULL
NULL pointer.
Definition: Nano103.h:25045
#define RTC_CAL_DAY_Msk
Definition: Nano103.h:18691
#define RTC_CALM_MON_Msk
Definition: Nano103.h:18739
#define RTC_TIME_TENMIN_Msk
Definition: Nano103.h:18682
#define RTC_TALM_TENMIN_Msk
Definition: Nano103.h:18724
#define RTC_CALM_TENDAY_Msk
Definition: Nano103.h:18736
#define RTC_TIME_MIN_Pos
Definition: Nano103.h:18678
#define RTC_CLKFMT_24HEN_Msk
Definition: Nano103.h:18709
NANO103 peripheral access layer header file. This file contains all the peripheral register's definit...
#define RTC_AM
Definition: rtc.h:45
void RTC_Open(S_RTC_TIME_DATA_T *sPt)
This function is used to: .
Definition: rtc.c:107
#define RTC_CAL_TENMON_Pos
Definition: Nano103.h:18699
RTC define Time Data Struct.
Definition: rtc.h:80
uint32_t u32Day
Definition: rtc.h:84
#define RTC_PM
Definition: rtc.h:46
#define RTC_TIME_SEC_Msk
Definition: Nano103.h:18673
#define RTC_INTEN_TICKIEN_Msk
Definition: Nano103.h:18757
#define RTC_CAL_YEAR_Msk
Definition: Nano103.h:18703
uint32_t u32DayOfWeek
Definition: rtc.h:85
void RTC_Close(void)
Disable RTC clock.
Definition: rtc.c:789
#define RTC_CAL_TENYEAR_Pos
Definition: Nano103.h:18705
void RTC_DisableTamperDetection(void)
This function is used to disable tamper detection function.
Definition: rtc.c:683
#define RTC_INTEN_ALMIEN_Msk
Definition: Nano103.h:18754
#define CLK
Pointer to CLK register structure.
Definition: Nano103.h:24884
uint32_t u32Month
Definition: rtc.h:83
uint32_t u32Second
Definition: rtc.h:88
#define RTC_CAL_TENDAY_Pos
Definition: Nano103.h:18693
void RTC_SetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt)
This function is used to set alarm date/time to RTC.
Definition: rtc.c:451
#define RTC_TALM_TENSEC_Msk
Definition: Nano103.h:18718
#define RTC_TIME_TENMIN_Pos
Definition: Nano103.h:18681
#define RTC_CALM_YEAR_Pos
Definition: Nano103.h:18744
uint32_t u32TimeScale
Definition: rtc.h:89
#define RTC_CAL_MON_Msk
Definition: Nano103.h:18697
#define CLK_APBCLK_RTCCKEN_Msk
Definition: Nano103.h:4987