| Nano103 BSP V3.01.002 The Board Support Package for Nano103 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
42 #define RTC_CLOCK_12 0
43 #define RTC_CLOCK_24 1
45 #define RTC_AM 1
46 #define RTC_PM 2
48 #define RTC_TICK_1_SEC ((uint32_t) 0x00000000)
49 #define RTC_TICK_1_2_SEC ((uint32_t) 0x00000001)
50 #define RTC_TICK_1_4_SEC ((uint32_t) 0x00000002)
51 #define RTC_TICK_1_8_SEC ((uint32_t) 0x00000003)
52 #define RTC_TICK_1_16_SEC ((uint32_t) 0x00000004)
53 #define RTC_TICK_1_32_SEC ((uint32_t) 0x00000005)
54 #define RTC_TICK_1_64_SEC ((uint32_t) 0x00000006)
55 #define RTC_TICK_1_128_SEC ((uint32_t) 0x00000007)
57 #define RTC_SUNDAY ((uint32_t) 0x00000000)
58 #define RTC_MONDAY ((uint32_t) 0x00000001)
59 #define RTC_TUESDAY ((uint32_t) 0x00000002)
60 #define RTC_WEDNESDAY ((uint32_t) 0x00000003)
61 #define RTC_THURSDAY ((uint32_t) 0x00000004)
62 #define RTC_FRIDAY ((uint32_t) 0x00000005)
63 #define RTC_SATURDAY ((uint32_t) 0x00000006)
66 #define RTC_SNOOPER_RISING 0
67 #define RTC_SNOOPER_FALLING 1
70 /* end of group NANO103_RTC_EXPORTED_CONSTANTS */
71
72
80 typedef struct
81 {
82 uint32_t u32Year;
83 uint32_t u32Month;
84 uint32_t u32Day;
85 uint32_t u32DayOfWeek;
86 uint32_t u32Hour;
87 uint32_t u32Minute;
88 uint32_t u32Second;
89 uint32_t u32TimeScale;
90 uint32_t u32AmPm;
91 } S_RTC_TIME_DATA_T;
92 /* end of group NANO103_RTC_EXPORTED_STRUCTS */
94
95
108 #define RTC_EnableSpareAccess() (RTC->SPRCTL |= RTC_SPRCTL_SPRRWEN_Msk)
109
118 #define RTC_READ_SPARE_REGISTER(u32RegNum) (RTC->SPR[u32RegNum])
119
129 #define RTC_WRITE_SPARE_REGISTER(u32RegNum, u32RegValue) (RTC->SPR[u32RegNum] = u32RegValue)
130
140 #define RTC_IS_LEAP_YEAR() ((RTC->LEAPYEAR & (RTC_LEAPYEAR_LEAPYEAR_Msk))?1:0)
141
150 #define RTC_CLEAR_ALARM_INT_FLAG() (RTC->INTSTS = RTC_INTSTS_ALMIF_Msk)
151
160 #define RTC_CLEAR_TICK_INT_FLAG() (RTC->INTSTS = RTC_INTSTS_TICKIF_Msk)
161
170 #define RTC_GET_ALARM_INT_FLAG() ((RTC->INTSTS & RTC_INTSTS_ALMIF_Msk) >> RTC_INTSTS_ALMIF_Pos)
171
180 #define RTC_CLEAR_TAMPER_FLAG(u32PinNum) (RTC->INTSTS = RTC_INTSTS_SNPDIF_Msk)
181
190 #define RTC_GET_TICK_INT_FLAG() ((RTC->INTSTS & RTC_INTSTS_TICKIF_Msk) >> RTC_INTSTS_TICKIF_Pos)
191
201 #define RTC_GET_TAMPER_FLAG() ( (RTC->INTSTS & RTC_INTSTS_SNPDIF_Msk) >> RTC_INTSTS_SNPDIF_Pos)
202
203
204 void RTC_Open(S_RTC_TIME_DATA_T *sPt);
205 void RTC_Close(void);
206 void RTC_32KCalibration(int32_t i32FrequencyX100);
207 void RTC_SetTickPeriod(uint32_t u32TickSelection);
208 void RTC_EnableInt(uint32_t u32IntFlagMask);
209 void RTC_DisableInt(uint32_t u32IntFlagMask);
210 uint32_t RTC_GetDayOfWeek(void);
211 void RTC_DisableTamperDetection(void);
212 void RTC_EnableTamperDetection(uint32_t u32PinCondition);
213 void RTC_SetAlarmTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm);
214 void RTC_SetAlarmDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day);
215 void RTC_SetTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm);
216 void RTC_SetDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day, uint32_t u32DayOfWeek);
217 void RTC_SetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt);
218 void RTC_SetDateAndTime(S_RTC_TIME_DATA_T *sPt);
219 void RTC_GetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt);
220 void RTC_GetDateAndTime(S_RTC_TIME_DATA_T *sPt);
221
222
223 /* end of group NANO103_RTC_EXPORTED_FUNCTIONS */
225
226 /* end of group NANO103_RTC_Driver */
228 /* end of group NANO103_Device_Driver */
230
231
232 #ifdef __cplusplus
233 }
234 #endif
235
236 #endif /* __RTC_H__ */
237
238
239 /*** (C) COPYRIGHT 2015 Nuvoton Technology Corp. ***/
240
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:722
RTC_32KCalibration
void RTC_32KCalibration(int32_t i32FrequencyX100)
Set Frequency Compensation Data.
Definition: rtc.c:66
RTC_DisableInt
void RTC_DisableInt(uint32_t u32IntFlagMask)
The function is used to disable specified interrupt.
Definition: rtc.c:758
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:514
S_RTC_TIME_DATA_T::u32Hour
uint32_t u32Hour
Definition: rtc.h:86
RTC_EnableTamperDetection
void RTC_EnableTamperDetection(uint32_t u32PinCondition)
This function is used to: .
Definition: rtc.c:660
RTC_GetDateAndTime
void RTC_GetDateAndTime(S_RTC_TIME_DATA_T *sPt)
Read current date/time from RTC setting.
Definition: rtc.c:194
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:588
RTC_GetAlarmDateAndTime
void RTC_GetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt)
Read alarm date/time from RTC setting.
Definition: rtc.c:287
S_RTC_TIME_DATA_T::u32Year
uint32_t u32Year
Definition: rtc.h:82
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:546
RTC_EnableInt
void RTC_EnableInt(uint32_t u32IntFlagMask)
The function is used to enable specified interrupt.
Definition: rtc.c:740
RTC_SetDateAndTime
void RTC_SetDateAndTime(S_RTC_TIME_DATA_T *sPt)
This function is used to update date/time to RTC.
Definition: rtc.c:384
RTC_GetDayOfWeek
uint32_t RTC_GetDayOfWeek(void)
This function is used to get day of week.
Definition: rtc.c:698
S_RTC_TIME_DATA_T::u32Minute
uint32_t u32Minute
Definition: rtc.h:87
S_RTC_TIME_DATA_T::u32AmPm
uint32_t u32AmPm
Definition: rtc.h:90
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:617
RTC_Open
void RTC_Open(S_RTC_TIME_DATA_T *sPt)
This function is used to: .
Definition: rtc.c:107
S_RTC_TIME_DATA_T
RTC define Time Data Struct.
Definition: rtc.h:80
S_RTC_TIME_DATA_T::u32Day
uint32_t u32Day
Definition: rtc.h:84
S_RTC_TIME_DATA_T::u32DayOfWeek
uint32_t u32DayOfWeek
Definition: rtc.h:85
RTC_Close
void RTC_Close(void)
Disable RTC clock.
Definition: rtc.c:789
RTC_DisableTamperDetection
void RTC_DisableTamperDetection(void)
This function is used to disable tamper detection function.
Definition: rtc.c:683
S_RTC_TIME_DATA_T::u32Month
uint32_t u32Month
Definition: rtc.h:83
S_RTC_TIME_DATA_T::u32Second
uint32_t u32Second
Definition: rtc.h:88
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:451
S_RTC_TIME_DATA_T::u32TimeScale
uint32_t u32TimeScale
Definition: rtc.h:89