#ifndef __PFC8583_H_ #define __PFC8583_H_ #include "global.h" #include "utils.h" #include "i2csig.h" #ifndef RTCDEVICEID #define RTCDEVICEID 0xA2 #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; BCD8 Sec100; } 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 ); /****************************************************************************/ /* functions handling the area of ram unused from clock/alarm-operations */ /* rtc-registers 0x00 - 0x0f is used by rtc for controls, counters, alarms .. 0x10 - 0x12 is used for setting year-informations by clock/alarmfunctions 0x13 is free for furthermore date-settings 0x14 - 0xff can be read, set by following funcs, for configurations, - whatever... so, if you give for DestAddr, or SourceAddr 0 this means 0x14. because functions set offset internally. So, for Dest-/SourceAddr you can use the values 0 - 235, for having 236 free bytes for reading-/writing. (So, 236 is also the max value for Size). */ extern BYTE RTCPutCfgRAM(BYTE *SourcePtr, BYTE DeviceID, BYTE DestAddr, WORD Size); extern BYTE RTCGetCfgRAM(BYTE *DestPtr, BYTE DeviceID, BYTE SourceAddr, WORD Size); #endif