/* ----- file RTC.H ----- */ /* Use it for interfacing the Real-Time Clock (rtc,RTC) AND the RAM inside */ /* the RTC */ #ifndef _RTC_H_ #define _RTC_H_ #ifndef _MISC_H_ #include "MISC.H" #endif /* defines the structure REAL_TIME for all time routines */ typedef struct REAL_TIME { BCD8 Weekday; /* day of week (sun=0 to sat=6) */ BCD16 Year; /* year within century */ BCD8 Month; BCD8 Date; /* day of month */ BCD8 Hour; BCD8 Minute; BCD8 Second; } REAL_TIME; #define SUNDAY 0 #define MONDAY 1 #define TUESDAY 2 #define WEDNESDAY 3 #define THURSDAY 4 #define FRIDAY 5 #define SATURDAY 6 #define RTC_SUCCESSFUL 0x00 #define RTC_NOT_INITIALIZED 0xFD #define RTC_WRITE_ERROR 0xFE #define RTC_READ_ERROR 0xFF /* ----- function prototypes ----- */ /****************************************************************************/ /* Use the following functions for accessing the internal SRAM of the RTC */ /* */ /* ----- serial-RAM ----- (256-bytes, 1x256-byte page) */ /* WARNING: The time/calendar-fields within the internal RAM are not */ /* protected against accesses by these RAM-Functions !!! */ /****************************************************************************/ /* function to write a sequence of bytes to RTC-RAM */ extern BYTE RTCPutRAM( BYTE *SourcePtr, BYTE DeviceID, BYTE DestAddr, WORD Size ); /****************************************************************************/ /* function to read a sequence of bytes from RTC-RAM */ extern BYTE RTCGetRAM( BYTE *DestPtr, BYTE DeviceID, BYTE SourceAddr, WORD Size ); /****************************************************************************/ /* Use the following functions and datatypes for setting and getting of time*/ /* and alarm */ /****************************************************************************/ /* function to set the real-time of the RTC */ extern BYTE RTCSetTime( REAL_TIME *RealTime, BYTE DeviceID ); /****************************************************************************/ /* function to get the current real-time from RTC */ extern BYTE RTCGetTime( REAL_TIME *RealTime, BYTE DeviceID ); /****************************************************************************/ /* function to set the alarm-time of the RTC */ /* WARNING: The fields Year and Weekday will be ignored because of using a */ /* dated alarm (s. manual of RTC) */ extern BYTE RTCSetAlarm( REAL_TIME *AlarmTime, BYTE DeviceID ); /****************************************************************************/ /* function to get the current real-time from RTC */ extern BYTE RTCGetAlarm( REAL_TIME *AlarmTime, BYTE DeviceID ); /****************************************************************************/ /* function to read the alarm status of the RTC and to release it if set */ extern BYTE RTCGetAlarmStatus( BYTE *AlarmStatus, BYTE DeviceID ); #endif /* end RAM_RTC.H */