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

rtc.h
Go to the documentation of this file.
1 /**************************************************************************/
12 #ifndef __RTC_H__
13 #define __RTC_H__
14
15 #ifdef __cplusplus
16 extern "C"
17 {
18 #endif
19
20
35 #define RTC_INIT_KEY 0xA5EB1357
36 #define RTC_WRITE_KEY 0xA965
38 #define RTC_WAIT_COUNT 0xFFFFFFFF
40 #define RTC_YEAR2000 2000
41 #define RTC_FCR_REFERENCE 32761
43 #define RTC_CLOCK_12 0
44 #define RTC_CLOCK_24 1
46 #define RTC_AM 1
47 #define RTC_PM 2
49 #define RTC_TICK_1_SEC ((uint32_t) 0x00000000)
50 #define RTC_TICK_1_2_SEC ((uint32_t) 0x00000001)
51 #define RTC_TICK_1_4_SEC ((uint32_t) 0x00000002)
52 #define RTC_TICK_1_8_SEC ((uint32_t) 0x00000003)
53 #define RTC_TICK_1_16_SEC ((uint32_t) 0x00000004)
54 #define RTC_TICK_1_32_SEC ((uint32_t) 0x00000005)
55 #define RTC_TICK_1_64_SEC ((uint32_t) 0x00000006)
56 #define RTC_TICK_1_128_SEC ((uint32_t) 0x00000007)
58 #define RTC_SUNDAY ((uint32_t) 0x00000000)
59 #define RTC_MONDAY ((uint32_t) 0x00000001)
60 #define RTC_TUESDAY ((uint32_t) 0x00000002)
61 #define RTC_WEDNESDAY ((uint32_t) 0x00000003)
62 #define RTC_THURSDAY ((uint32_t) 0x00000004)
63 #define RTC_FRIDAY ((uint32_t) 0x00000005)
64 #define RTC_SATURDAY ((uint32_t) 0x00000006)
67 #define RTC_SNOOPER_RISING 0
68 #define RTC_SNOOPER_FALLING 1
71 /* end of group NANO100_RTC_EXPORTED_CONSTANTS */
72
73
81 typedef struct
82 {
83 uint32_t u32Year;
84 uint32_t u32Month;
85 uint32_t u32Day;
86 uint32_t u32DayOfWeek;
87 uint32_t u32Hour;
88 uint32_t u32Minute;
89 uint32_t u32Second;
90 uint32_t u32TimeScale;
91 uint32_t u32AmPm;
92 } S_RTC_TIME_DATA_T;
93 /* end of group NANO100_RTC_EXPORTED_STRUCTS */
95
96
110 #define RTC_READ_SPARE_REGISTER(u32RegNum) (RTC->SPR[u32RegNum])
111
122 #define RTC_WRITE_SPARE_REGISTER(u32RegNum, u32RegValue) (RTC->SPR[u32RegNum] = u32RegValue)
123
133 #define RTC_IS_LEAP_YEAR() ((RTC->LIR & (RTC_LIR_LIR_Msk))?1:0)
134
143 #define RTC_CLEAR_ALARM_INT_FLAG() (RTC->RIIR = RTC_RIIR_AIF_Msk)
144
153 #define RTC_CLEAR_TICK_INT_FLAG() (RTC->RIIR = RTC_RIIR_TIF_Msk)
154
163 #define RTC_CLEAR_TAMPER_FLAG(u32PinNum) (RTC->RIIR = RTC_RIIR_SNOOPIF_Msk)
164
173 #define RTC_GET_ALARM_INT_FLAG() ((RTC->RIIR & RTC_RIIR_AIF_Msk) >> RTC_RIIR_AIF_Pos)
174
183 #define RTC_GET_TICK_INT_FLAG() ((RTC->RIIR & RTC_RIIR_TIF_Msk) >> RTC_RIIR_TIF_Pos)
184
194 #define RTC_GET_TAMPER_FLAG() ( (RTC->RIIR & RTC_RIIR_SNOOPIF_Msk) >> RTC_RIIR_SNOOPIF_Pos)
195
204 #define RTC_ENABLE_TICK_WAKEUP() (RTC->TTR |= RTC_TTR_TWKE_Msk);
205
214 #define RTC_DISABLE_TICK_WAKEUP() (RTC->TTR &= ~RTC_TTR_TWKE_Msk);
215
216
217 void RTC_Open(S_RTC_TIME_DATA_T *sPt);
218 void RTC_Close(void);
219 void RTC_32KCalibration(int32_t i32FrequencyX100);
220 void RTC_SetTickPeriod(uint32_t u32TickSelection);
221 void RTC_EnableInt(uint32_t u32IntFlagMask);
222 void RTC_DisableInt(uint32_t u32IntFlagMask);
223 uint32_t RTC_GetDayOfWeek(void);
224 void RTC_DisableTamperDetection(void);
225 void RTC_EnableTamperDetection(uint32_t u32PinCondition);
226 void RTC_SetAlarmTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm);
227 void RTC_SetAlarmDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day);
228 void RTC_SetTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm);
229 void RTC_SetDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day, uint32_t u32DayOfWeek);
230 void RTC_SetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt);
231 void RTC_SetDateAndTime(S_RTC_TIME_DATA_T *sPt);
232 void RTC_GetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt);
233 void RTC_GetDateAndTime(S_RTC_TIME_DATA_T *sPt);
234
235
236 /* end of group NANO100_RTC_EXPORTED_FUNCTIONS */
238
239 /* end of group NANO100_RTC_Driver */
241 /* end of group NANO100_Device_Driver */
243
244
245 #ifdef __cplusplus
246 }
247 #endif
248
249 #endif /* __RTC_H__ */
250
251
252 /*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/
253
254
255
RTC_DisableTamperDetection
void RTC_DisableTamperDetection(void)
This function is used to disable tamper detection function.
Definition: rtc.c:721
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_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
S_RTC_TIME_DATA_T::u32Year
uint32_t u32Year
Definition: rtc.h:83
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
RTC_GetDateAndTime
void RTC_GetDateAndTime(S_RTC_TIME_DATA_T *sPt)
Read current date/time from RTC setting.
Definition: rtc.c:199
RTC_Close
void RTC_Close(void)
Disable RTC clock.
Definition: rtc.c:829
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_32KCalibration
void RTC_32KCalibration(int32_t i32FrequencyX100)
Set Frequency Compensation Data.
Definition: rtc.c:58
S_RTC_TIME_DATA_T::u32Minute
uint32_t u32Minute
Definition: rtc.h:88
RTC_EnableInt
void RTC_EnableInt(uint32_t u32IntFlagMask)
The function is used to enable specified interrupt.
Definition: rtc.c:780
S_RTC_TIME_DATA_T::u32AmPm
uint32_t u32AmPm
Definition: rtc.h:91
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_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
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_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
S_RTC_TIME_DATA_T::u32Second
uint32_t u32Second
Definition: rtc.h:89
RTC_Open
void RTC_Open(S_RTC_TIME_DATA_T *sPt)
This function is used to: .
Definition: rtc.c:102
S_RTC_TIME_DATA_T::u32TimeScale
uint32_t u32TimeScale
Definition: rtc.h:90
RTC_DisableInt
void RTC_DisableInt(uint32_t u32IntFlagMask)
The function is used to disable specified interrupt.
Definition: rtc.c:799