| NUC472_NUC442_BSP V3.04.000 The Board Support Package for NUC472/NUC442

rtc.h
Go to the documentation of this file.
1/**************************************************************************/
13#ifndef __RTC_H
14#define __RTC_H
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif
20
21
35#define RTC_TIMEOUT_ERR (-1L)
37#define RTC_INIT_KEY 0xA5EB1357UL
38#define RTC_WRITE_KEY 0xA965
40#define RTC_WAIT_COUNT 0xFFFFFFFF
42#define RTC_YEAR2000 2000
43#define RTC_FCR_REFERENCE 32761
45#define RTC_CLOCK_12 0
46#define RTC_CLOCK_24 1
48#define RTC_AM 1
49#define RTC_PM 2
51#define RTC_TICK_1_SEC ((uint32_t) 0x00000000)
52#define RTC_TICK_1_2_SEC ((uint32_t) 0x00000001)
53#define RTC_TICK_1_4_SEC ((uint32_t) 0x00000002)
54#define RTC_TICK_1_8_SEC ((uint32_t) 0x00000003)
55#define RTC_TICK_1_16_SEC ((uint32_t) 0x00000004)
56#define RTC_TICK_1_32_SEC ((uint32_t) 0x00000005)
57#define RTC_TICK_1_64_SEC ((uint32_t) 0x00000006)
58#define RTC_TICK_1_128_SEC ((uint32_t) 0x00000007)
60#define RTC_SUNDAY ((uint32_t) 0x00000000)
61#define RTC_MONDAY ((uint32_t) 0x00000001)
62#define RTC_TUESDAY ((uint32_t) 0x00000002)
63#define RTC_WEDNESDAY ((uint32_t) 0x00000003)
64#define RTC_THURSDAY ((uint32_t) 0x00000004)
65#define RTC_FRIDAY ((uint32_t) 0x00000005)
66#define RTC_SATURDAY ((uint32_t) 0x00000006)
68#define RTC_TAMPER_0 0
69#define RTC_TAMPER_1 1 /* end of group NUC472_442_RTC_EXPORTED_CONSTANTS */
72
73extern int32_t g_RTC_i32ErrCode;
74
82 typedef struct
83{
84 uint32_t u32Year;
85 uint32_t u32Month;
86 uint32_t u32Day;
87 uint32_t u32DayOfWeek;
88 uint32_t u32Hour;
89 uint32_t u32Minute;
90 uint32_t u32Second;
91 uint32_t u32TimeScale;
92 uint32_t u32AmPm;
93} S_RTC_TIME_DATA_T;
94 /* end of group NUC472_442_RTC_EXPORTED_STRUCTS */
96
97
98
99
100
114#define RTC_READ_SPARE_REGISTER(u32RegNum) (RTC->SPR[u32RegNum])
115
125#define RTC_WRITE_SPARE_REGISTER(u32RegNum, u32RegValue) (RTC->SPR[u32RegNum] = u32RegValue)
126
136#define RTC_IS_LEAP_YEAR ((RTC->LEAPYEAR & (RTC_LEAPYEAR_LEAPYEAR_Msk))?1:0)
137
146#define RTC_CLEAR_ALARM_INT_FLAG (RTC->INTSTS = RTC_INTSTS_ALMIF_Msk)
147
156#define RTC_CLEAR_TICK_INT_FLAG (RTC->INTSTS = RTC_INTSTS_TICKIF_Msk)
157
166#define RTC_CLEAR_TAMPER_FLAG(u32PinNum) (RTC->TAMPSTS = (1 << u32PinNum))
167
176#define RTC_GET_ALARM_INT_FLAG ((RTC->INTSTS & RTC_INTSTS_ALMIF_Msk) >> RTC_INTSTS_ALMIF_Pos)
177
186#define RTC_GET_TICK_INT_FLAG ((RTC->INTSTS & RTC_INTSTS_TICKIF_Msk) >> RTC_INTSTS_TICKIF_Pos)
187
196#define RTC_GET_TAMPER_FLAG(u32PinNum) ( (RTC->TAMPSTS & (1 << u32PinNum)) >> u32PinNum)
197
198
199
200void RTC_Open(S_RTC_TIME_DATA_T *sPt);
201void RTC_Close(void);
202void RTC_32KCalibration(int32_t i32FrequencyX100);
203void RTC_SetTickPeriod(uint32_t u32TickSelection);
204void RTC_EnableInt(uint32_t u32IntFlagMask);
205void RTC_DisableInt(uint32_t u32IntFlagMask);
206uint32_t RTC_GetDayOfWeek(void);
207void RTC_DisableTamperDetection(uint32_t u32PinNumber);
208void RTC_EnableTamperDetection(uint32_t u32PinNumber, uint32_t u32PinCondition, uint32_t u32IntFlag, uint32_t u32ClearFlag, uint32_t u32DestroyEn);
209int32_t RTC_EnableSpareAccess(void);
210void RTC_SetAlarmTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm);
211void RTC_SetAlarmDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day);
212void RTC_SetTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm);
213void RTC_SetDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day, uint32_t u32DayOfWeek);
214void RTC_SetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt);
215void RTC_SetDateAndTime(S_RTC_TIME_DATA_T *sPt);
216void RTC_GetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt);
217void RTC_GetDateAndTime(S_RTC_TIME_DATA_T *sPt);
218
219
220 /* end of group NUC472_442_RTC_EXPORTED_FUNCTIONS */
222
223 /* end of group NUC472_442_RTC_Driver */
225 /* end of group NUC472_442_Device_Driver */
227
228
229#ifdef __cplusplus
230}
231#endif
232
233#endif /* __RTC_H */
234
235
236/*** (C) COPYRIGHT 2012 Nuvoton Technology Corp. ***/
237
238
239
g_RTC_i32ErrCode
int32_t g_RTC_i32ErrCode
RTC_EnableInt
void RTC_EnableInt(uint32_t u32IntFlagMask)
The function is used to enable specified interrupt.
Definition: rtc.c:875
RTC_GetDayOfWeek
uint32_t RTC_GetDayOfWeek(void)
This function is used to get day of week.
Definition: rtc.c:835
RTC_SetDateAndTime
void RTC_SetDateAndTime(S_RTC_TIME_DATA_T *sPt)
This function is used to update date/time to RTC.
Definition: rtc.c:420
RTC_EnableTamperDetection
void RTC_EnableTamperDetection(uint32_t u32PinNumber, uint32_t u32PinCondition, uint32_t u32IntFlag, uint32_t u32ClearFlag, uint32_t u32DestroyEn)
This function is used to:
Definition: rtc.c:741
S_RTC_TIME_DATA_T::u32Month
uint32_t u32Month
Definition: rtc.h:85
S_RTC_TIME_DATA_T::u32AmPm
uint32_t u32AmPm
Definition: rtc.h:92
RTC_GetAlarmDateAndTime
void RTC_GetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt)
Read alarm date/time from RTC setting.
Definition: rtc.c:318
RTC_Open
void RTC_Open(S_RTC_TIME_DATA_T *sPt)
This function is used to:
Definition: rtc.c:124
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:489
S_RTC_TIME_DATA_T::u32Hour
uint32_t u32Hour
Definition: rtc.h:88
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:553
RTC_DisableTamperDetection
void RTC_DisableTamperDetection(uint32_t u32PinNumber)
This function is used to disable tamper detection function.
Definition: rtc.c:812
RTC_Close
void RTC_Close(void)
Disable RTC clock.
Definition: rtc.c:916
RTC_32KCalibration
void RTC_32KCalibration(int32_t i32FrequencyX100)
Set Frequency Compensation Data.
Definition: rtc.c:81
S_RTC_TIME_DATA_T::u32Minute
uint32_t u32Minute
Definition: rtc.h:89
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:587
S_RTC_TIME_DATA_T::u32Day
uint32_t u32Day
Definition: rtc.h:86
S_RTC_TIME_DATA_T::u32DayOfWeek
uint32_t u32DayOfWeek
Definition: rtc.h:87
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:662
RTC_DisableInt
void RTC_DisableInt(uint32_t u32IntFlagMask)
The function is used to disable specified interrupt.
Definition: rtc.c:892
S_RTC_TIME_DATA_T::u32Year
uint32_t u32Year
Definition: rtc.h:84
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:858
RTC_EnableSpareAccess
int32_t RTC_EnableSpareAccess(void)
The spare registers access enable.
Definition: rtc.c:703
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:630
S_RTC_TIME_DATA_T::u32Second
uint32_t u32Second
Definition: rtc.h:90
S_RTC_TIME_DATA_T::u32TimeScale
uint32_t u32TimeScale
Definition: rtc.h:91
RTC_GetDateAndTime
void RTC_GetDateAndTime(S_RTC_TIME_DATA_T *sPt)
Read current date/time from RTC setting.
Definition: rtc.c:224
S_RTC_TIME_DATA_T
RTC define Time Data Struct.
Definition: rtc.h:83