Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages | Examples

pcf8563.c File Reference


Detailed Description

RTC for Philips PCF8563 clock chip.

 *
 * $Log: pcf8563.c,v $
 * Revision 1.3  2006/10/05 17:18:49  haraldkipp
 * Hardware independant RTC layer added.
 *
 * Revision 1.2  2006/06/28 17:23:47  haraldkipp
 * Bugfix. PcfRtcGetClock() returned wrong century.
 *
 * Revision 1.1  2006/04/07 13:54:17  haraldkipp
 * PCF8563 RTC driver added.
 *
 *
 * 


Defines

#define I2C_SLA_RTC   0x51

Functions

int PcfRtcReadRegs (u_char reg, u_char *buff, size_t cnt)
 Read RTC registers.
int PcfRtcWrite (int nv, CONST u_char *buff, size_t cnt)
 Write to RTC registers.
int PcfRtcGetClock (struct _tm *tm)
 Get date and time from an PCF8563 hardware clock.
int PcfRtcSetClock (CONST struct _tm *tm)
 Set an PCF8563 hardware clock.
int PcfRtcGetAlarm (int idx, struct _tm *tm, int *aflgs)
 Get alarm date and time of an PCF8563 hardware clock.
int PcfRtcSetAlarm (int idx, CONST struct _tm *tm, int aflgs)
 Set alarm of an PCF8563 hardware clock.
int PcfRtcGetStatus (u_long *sflgs)
 Query RTC status flags.
int PcfRtcClearStatus (u_long sflgs)
 Clear RTC status flags.
int PcfRtcInit (void)
 Initialize the interface to an Intersil PCF8563 hardware clock.

Variables

NUTRTC rtcPcf8563


Function Documentation

int PcfRtcReadRegs u_char  reg,
u_char buff,
size_t  cnt
 

Read RTC registers.

Parameters:
reg The first register to read.
buff Pointer to a buffer that receives the register contents.
cnt The number of registers to read.
Returns:
0 on success or -1 in case of an error.

int PcfRtcWrite int  nv,
CONST u_char buff,
size_t  cnt
 

Write to RTC registers.

Parameters:
nv Must be set to 1 when writing to non-volatile registers. In this case the routine will poll for write cycle completion before returning to the caller. Set to zero if writing to volatile registers.
buff This buffer must contain all bytes to be transfered to the RTC chip, including the register address.
cnt Number of valid bytes in the buffer.
Returns:
0 on success or -1 in case of an error.

int PcfRtcGetClock struct _tm tm  ) 
 

Get date and time from an PCF8563 hardware clock.

Parameters:
tm Points to a structure that receives the date and time information.
Returns:
0 on success or -1 in case of an error.

int PcfRtcSetClock CONST struct _tm tm  ) 
 

Set an PCF8563 hardware clock.

New time will be taken over at the beginning of the next second.

Parameters:
tm Points to a structure which contains the date and time information.
Returns:
0 on success or -1 in case of an error.

int PcfRtcGetAlarm int  idx,
struct _tm tm,
int *  aflgs
 

Get alarm date and time of an PCF8563 hardware clock.

Not implemented.

Parameters:
idx Zero based index. Two alarms are supported.
tm Points to a structure that receives the date and time information.
aflgs Points to an unsigned long that receives the enable flags.
Returns:
0 on success or -1 in case of an error.

int PcfRtcSetAlarm int  idx,
CONST struct _tm tm,
int  aflgs
 

Set alarm of an PCF8563 hardware clock.

Not implemented.

Parameters:
idx Zero based index. Two alarms are supported.
tm Points to a structure which contains the date and time information. May be NULL to clear the alarm.
aflgs Each bit enables a specific comparision.
  • Bit 0: Seconds
  • Bit 1: Minutes
  • Bit 2: Hours
  • Bit 3: Day of month
  • Bit 4: Month
  • Bit 7: Day of week (Sunday is zero)
Returns:
0 on success or -1 in case of an error.

int PcfRtcGetStatus u_long sflgs  ) 
 

Query RTC status flags.

Parameters:
sflgs Points to an unsigned long that receives the status flags.
  • Bit 0: Power fail.
  • Bit 5: Alarm 0 occured (not implemented).
  • Bit 6: Alarm 1 occured (not implemented).
Returns:
0 on success or -1 in case of an error.

int PcfRtcClearStatus u_long  sflgs  ) 
 

Clear RTC status flags.

Parameters:
sflgs Status flags to clear.
Returns:
Always 0.

int PcfRtcInit void   ) 
 

Initialize the interface to an Intersil PCF8563 hardware clock.

Returns:
0 on success or -1 in case of an error.


Variable Documentation

NUTRTC rtcPcf8563
 

Initial value:

 {
    PcfRtcInit,         
    PcfRtcGetClock,     
    PcfRtcSetClock,     
    PcfRtcGetAlarm,     
    PcfRtcSetAlarm,     
    PcfRtcGetStatus,    
    PcfRtcClearStatus   
}


© 2000-2006 by egnite Software GmbH - visit http://www.ethernut.de/