Nut/OS  4.10.3
API Reference
pcf8563.c File Reference

RTC for Philips PCF8563 clock chip. More...

#include <cfg/os.h>
#include <dev/twif.h>
#include <sys/event.h>
#include <sys/timer.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <dev/pcf8563.h>
Include dependency graph for pcf8563.c:

Go to the source code of this file.

Defines

#define I2C_SLA_RTC   0x51

Functions

int PcfRtcReadRegs (uint8_t reg, uint8_t *buff, size_t cnt)
 Read RTC registers.
int PcfRtcWrite (int nv, CONST uint8_t *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 (uint32_t *sflgs)
 Query RTC status flags.
int PcfRtcClearStatus (uint32_t sflgs)
 Clear RTC status flags.
int PcfRtcInit (void)
 Initialize the interface to an Intersil PCF8563 hardware clock.

Variables

NUTRTC rtcPcf8563

Detailed Description

RTC for Philips PCF8563 clock chip.

 *
 * $Log$
 * Revision 1.4  2008/08/11 06:59:42  haraldkipp
 * BSD types replaced by stdint types (feature request #1282721).
 *
 * 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.
 *
 *
 * 

Definition in file pcf8563.c.


Define Documentation

#define I2C_SLA_RTC   0x51

Definition at line 69 of file pcf8563.c.

Referenced by PcfRtcReadRegs(), and PcfRtcWrite().


Function Documentation

int PcfRtcReadRegs ( uint8_t  reg,
uint8_t buff,
size_t  cnt 
)

Read RTC registers.

Parameters:
regThe first register to read.
buffPointer to a buffer that receives the register contents.
cntThe number of registers to read.
Returns:
0 on success or -1 in case of an error.

Definition at line 83 of file pcf8563.c.

References I2C_SLA_RTC, NUT_WAIT_INFINITE, and TwMasterTransact().

Referenced by PcfRtcGetClock(), and PcfRtcGetStatus().

Here is the call graph for this function:

int PcfRtcWrite ( int  nv,
CONST uint8_t buff,
size_t  cnt 
)

Write to RTC registers.

Parameters:
nvMust 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.
buffThis buffer must contain all bytes to be transfered to the RTC chip, including the register address.
cntNumber of valid bytes in the buffer.
Returns:
0 on success or -1 in case of an error.

Definition at line 106 of file pcf8563.c.

References I2C_SLA_RTC, NUT_WAIT_INFINITE, and TwMasterTransact().

Referenced by PcfRtcSetClock().

Here is the call graph for this function:

int PcfRtcGetClock ( struct _tm tm)

Get date and time from an PCF8563 hardware clock.

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

Definition at line 119 of file pcf8563.c.

References BCD2BIN, PcfRtcReadRegs(), _tm::tm_hour, _tm::tm_mday, _tm::tm_min, _tm::tm_mon, _tm::tm_sec, _tm::tm_wday, and _tm::tm_year.

Here is the call graph for this function:

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:
tmPoints to a structure which contains the date and time information.
Returns:
0 on success or -1 in case of an error.

Definition at line 149 of file pcf8563.c.

References BIN2BCD, memset(), and PcfRtcWrite().

Here is the call graph for this function:

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

Get alarm date and time of an PCF8563 hardware clock.

Not implemented.

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

Definition at line 186 of file pcf8563.c.

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

Set alarm of an PCF8563 hardware clock.

Not implemented.

Parameters:
idxZero based index. Two alarms are supported.
tmPoints to a structure which contains the date and time information. May be NULL to clear the alarm.
aflgsEach 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.

Definition at line 209 of file pcf8563.c.

int PcfRtcGetStatus ( uint32_t sflgs)

Query RTC status flags.

Parameters:
sflgsPoints 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.

Definition at line 224 of file pcf8563.c.

References PcfRtcReadRegs(), and RTC_STATUS_PF.

Referenced by PcfRtcInit().

Here is the call graph for this function:

int PcfRtcClearStatus ( uint32_t  sflgs)

Clear RTC status flags.

Parameters:
sflgsStatus flags to clear.
Returns:
Always 0.

Definition at line 245 of file pcf8563.c.

int PcfRtcInit ( void  )

Initialize the interface to an Intersil PCF8563 hardware clock.

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

Definition at line 258 of file pcf8563.c.

References PcfRtcGetStatus(), and TwInit().

Here is the call graph for this function:


Variable Documentation