Go to the documentation of this file.00001 #ifndef _DEV_RTC_H_
00002 #define _DEV_RTC_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #include <sys/types.h>
00047 #include <stdint.h>
00048
00049 #include <time.h>
00050
00051 #define RTC_STATUS_PF 0x00000001
00052 #define RTC_STATUS_AL0 0x00000020
00053 #define RTC_STATUS_AL1 0x00000040
00054
00055 #define RTC_ALARM_SECOND 0x00000001
00056 #define RTC_ALARM_MINUTE 0x00000002
00057 #define RTC_ALARM_HOUR 0x00000004
00058 #define RTC_ALARM_MDAY 0x00000008
00059 #define RTC_ALARM_MONTH 0x00000010
00060 #define RTC_ALARM_WDAY 0x00000080
00061 #define RTC_ALARM_YEAR 0x00000100
00062 #define RTC_ALARM_YDAY 0x00000200
00063
00067 #define BCD2BIN(x) ((((uint8_t)(x)) >> 4) * 10 + ((x) & 0x0F))
00068
00072 #define BIN2BCD(x) (((((uint8_t)(x)) / 10) << 4) + (x) % 10)
00073
00077 typedef struct _NUTRTC NUTRTC;
00078
00082 struct _NUTRTC {
00083 void *dcb;
00084 int (*rtc_init) (NUTRTC *rtc);
00085 int (*rtc_gettime) (NUTRTC *rtc, struct _tm *);
00086 int (*rtc_settime) (NUTRTC *rtc, const struct _tm *);
00087 int (*rtc_getalarm) (NUTRTC *rtc, int idx, struct _tm *, int *);
00088 int (*rtc_setalarm) (NUTRTC *rtc, int idx, const struct _tm *, int);
00089 int (*rtc_getstatus) (NUTRTC *rtc, uint32_t *);
00090 int (*rtc_clrstatus) (NUTRTC *rtc, uint32_t);
00091 HANDLE alarm;
00092 };
00093
00094 extern int NutRegisterRtc(NUTRTC *rtc);
00095
00096 extern int NutRtcGetTime(struct _tm *tm);
00097 extern int NutRtcSetTime(const struct _tm *tm);
00098
00099 extern int NutRtcGetAlarm(int idx, struct _tm *tm, int *aflags);
00100 extern int NutRtcSetAlarm(int idx, const struct _tm *tm, int aflags);
00101
00102 extern int NutRtcGetStatus(uint32_t *sflags);
00103 extern int NutRtcClearStatus(uint32_t sflags);
00104
00105 #endif