| NANO100_BSP V3.05.000 The Board Support Package for Nano100BN 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 /* 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
121#define RTC_WRITE_SPARE_REGISTER(u32RegNum, u32RegValue) (RTC->SPR[u32RegNum] = u32RegValue)
122
132#define RTC_IS_LEAP_YEAR() ((RTC->LIR & (RTC_LIR_LIR_Msk))?1:0)
133
142#define RTC_CLEAR_ALARM_INT_FLAG() (RTC->RIIR = RTC_RIIR_AIF_Msk)
143
152#define RTC_CLEAR_TICK_INT_FLAG() (RTC->RIIR = RTC_RIIR_TIF_Msk)
153
162#define RTC_CLEAR_TAMPER_FLAG(u32PinNum) (RTC->RIIR = RTC_RIIR_SNOOPIF_Msk)
163
172#define RTC_GET_ALARM_INT_FLAG() ((RTC->RIIR & RTC_RIIR_AIF_Msk) >> RTC_RIIR_AIF_Pos)
173
182#define RTC_GET_TICK_INT_FLAG() ((RTC->RIIR & RTC_RIIR_TIF_Msk) >> RTC_RIIR_TIF_Pos)
183
193#define RTC_GET_TAMPER_FLAG() ( (RTC->RIIR & RTC_RIIR_SNOOPIF_Msk) >> RTC_RIIR_SNOOPIF_Pos)
194
203#define RTC_ENABLE_TICK_WAKEUP() (RTC->TTR |= RTC_TTR_TWKE_Msk);
204
213#define RTC_DISABLE_TICK_WAKEUP() (RTC->TTR &= ~RTC_TTR_TWKE_Msk);
214
215
216 void RTC_Open(S_RTC_TIME_DATA_T *sPt);
217 void RTC_Close(void);
218 void RTC_32KCalibration(int32_t i32FrequencyX100);
219 void RTC_SetTickPeriod(uint32_t u32TickSelection);
220 void RTC_EnableInt(uint32_t u32IntFlagMask);
221 void RTC_DisableInt(uint32_t u32IntFlagMask);
222uint32_t RTC_GetDayOfWeek(void);
223 void RTC_DisableTamperDetection(void);
224 void RTC_EnableTamperDetection(uint32_t u32PinCondition);
225 void RTC_SetAlarmTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm);
226 void RTC_SetAlarmDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day);
227 void RTC_SetTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm);
228 void RTC_SetDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day, uint32_t u32DayOfWeek);
229 void RTC_SetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt);
230 void RTC_SetDateAndTime(S_RTC_TIME_DATA_T *sPt);
231 void RTC_GetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt);
232 void RTC_GetDateAndTime(S_RTC_TIME_DATA_T *sPt);
233
234
235 /* end of group NANO100_RTC_EXPORTED_FUNCTIONS */
237
238 /* end of group NANO100_RTC_Driver */
240 /* end of group NANO100_Device_Driver */
242
243
244#ifdef __cplusplus
245}
246#endif
247
248#endif /* __RTC_H__ */
249
250
251/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/
252
253
254
RTC_EnableInt
void RTC_EnableInt(uint32_t u32IntFlagMask)
The function is used to enable specified interrupt.
Definition: rtc.c:882
RTC_GetDayOfWeek
uint32_t RTC_GetDayOfWeek(void)
This function is used to get day of week.
Definition: rtc.c:833
RTC_SetDateAndTime
void RTC_SetDateAndTime(S_RTC_TIME_DATA_T *sPt)
This function is used to update date/time to RTC.
Definition: rtc.c:422
S_RTC_TIME_DATA_T::u32Month
uint32_t u32Month
Definition: rtc.h:84
S_RTC_TIME_DATA_T::u32AmPm
uint32_t u32AmPm
Definition: rtc.h:91
RTC_GetAlarmDateAndTime
void RTC_GetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt)
Read alarm date/time from RTC setting.
Definition: rtc.c:312
RTC_Open
void RTC_Open(S_RTC_TIME_DATA_T *sPt)
This function is used to write initial key to let RTC start count and set current time.
Definition: rtc.c:104
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:504
S_RTC_TIME_DATA_T::u32Hour
uint32_t u32Hour
Definition: rtc.h:87
RTC_EnableTamperDetection
void RTC_EnableTamperDetection(uint32_t u32PinCondition)
This function is used to enable tamper detection function and set tamper control register,...
Definition: rtc.c:773
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:581
RTC_Close
void RTC_Close(void)
Disable RTC clock.
Definition: rtc.c:943
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_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:625
S_RTC_TIME_DATA_T::u32Day
uint32_t u32Day
Definition: rtc.h:85
S_RTC_TIME_DATA_T::u32DayOfWeek
uint32_t u32DayOfWeek
Definition: rtc.h:86
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:720
RTC_DisableInt
void RTC_DisableInt(uint32_t u32IntFlagMask)
The function is used to disable specified interrupt.
Definition: rtc.c:907
RTC_DisableTamperDetection
void RTC_DisableTamperDetection(void)
This function is used to disable tamper detection function.
Definition: rtc.c:811
S_RTC_TIME_DATA_T::u32Year
uint32_t u32Year
Definition: rtc.h:83
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:857
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:677
S_RTC_TIME_DATA_T::u32Second
uint32_t u32Second
Definition: rtc.h:89
S_RTC_TIME_DATA_T::u32TimeScale
uint32_t u32TimeScale
Definition: rtc.h:90
RTC_GetDateAndTime
void RTC_GetDateAndTime(S_RTC_TIME_DATA_T *sPt)
Read current date/time from RTC setting.
Definition: rtc.c:219
S_RTC_TIME_DATA_T
RTC define Time Data Struct.
Definition: rtc.h:82