00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00019 #ifndef __RTC_H__
00020 #define __RTC_H__
00021
00022 typedef struct
00023 {
00024 uint32_t seconds;
00025 uint32_t minutes;
00026 uint32_t hours;
00027 uint32_t day_of_month;
00028 uint32_t day_of_week;
00029 uint32_t day_of_year;
00030 uint32_t month;
00031 uint32_t year;
00032 }
00033 rtc_time_t;
00034
00035 #define RTC_TIME_BASE 0xe0024020
00036 #define RTC_ALARM_BASE 0xe0024060
00037
00038
00039 #define IMSEC 0x00000001
00040 #define IMMIN 0x00000002
00041 #define IMHOUR 0x00000004
00042 #define IMDOM 0x00000008
00043 #define IMDOW 0x00000010
00044 #define IMDOY 0x00000020
00045 #define IMMON 0x00000040
00046 #define IMYEAR 0x00000080
00047
00048 #define AMRSEC 0x00000001
00049 #define AMRMIN 0x00000002
00050 #define AMRHOUR 0x00000004
00051 #define AMRDOM 0x00000008
00052 #define AMRDOW 0x00000010
00053 #define AMRDOY 0x00000020
00054 #define AMRMON 0x00000040
00055 #define AMRYEAR 0x00000080
00056
00057
00058 #define PREINT_RTC ((Fpclk/32768)-1)
00059 #define PREFRAC_RTC (Fpclk-((PREINT_RTC+1)*32768))
00060
00061 #if 0
00062 #define PREINT_RTC 0x000001C8
00063 #define PREFRAC_RTC 0x000061C0
00064 #endif
00065
00066 #define ILR_RTCCIF 0x01
00067 #define ILR_RTCALF 0x02
00068
00069 #define CCR_CLKEN 0x01
00070 #define CCR_CTCRST 0x02
00071 #define CCR_CLKSRC 0x10
00072
00073 extern void rtc_init(void);
00074 extern void rtc_start(void);
00075 extern void rtc_stop(void);
00076 extern void rtc_clear_tick_counter(void);
00077 extern void rtc_set_time(const rtc_time_t *p_time);
00078 extern void rtc_get_time(rtc_time_t *p_time);
00079 extern void rtc_set_alarm(const rtc_time_t *p_time);
00080 extern void rtc_set_alarm_mask(uint32_t mask);
00081
00082 extern volatile uint32_t rtc_alarm_active;
00083
00084
00085 #endif // __RTC_H__
00086
00087
00088