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>
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 (NUTRTC *rtc, struct _tm *tm) |
Get date and time from an PCF8563 hardware clock. | |
int | PcfRtcSetClock (NUTRTC *rtc, const struct _tm *tm) |
Set an PCF8563 hardware clock. | |
int | PcfRtcGetAlarm (NUTRTC *rtc, int idx, struct _tm *tm, int *aflgs) |
Get alarm date and time of an PCF8563 hardware clock. | |
int | PcfRtcSetAlarm (NUTRTC *rtc, int idx, const struct _tm *tm, int aflgs) |
Set alarm of an PCF8563 hardware clock. | |
int | PcfRtcGetStatus (NUTRTC *rtc, uint32_t *sflgs) |
Query RTC status flags. | |
int | PcfRtcClearStatus (NUTRTC *rtc, uint32_t sflgs) |
Clear RTC status flags. | |
int | PcfRtcInit (NUTRTC *rtc) |
Initialize the interface to an Intersil PCF8563 hardware clock. | |
Variables | |
NUTRTC | rtcPcf8563 |
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. * * *
#define I2C_SLA_RTC 0x51 |
Referenced by PcfRtcReadRegs(), and PcfRtcWrite().
Read RTC registers.
reg | The first register to read. |
buff | Pointer to a buffer that receives the register contents. |
cnt | The number of registers to read. |
References I2C_SLA_RTC, NUT_WAIT_INFINITE, rc, and TwMasterTransact.
Referenced by PcfRtcGetClock(), and PcfRtcGetStatus().
int PcfRtcWrite | ( | int | nv, |
const uint8_t * | buff, | ||
size_t | cnt | ||
) |
Write to RTC registers.
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. |
References I2C_SLA_RTC, NUT_WAIT_INFINITE, and TwMasterTransact.
Referenced by PcfRtcSetClock().
Get date and time from an PCF8563 hardware clock.
tm | Points to a structure that receives the date and time information. |
References BCD2BIN, PcfRtcReadRegs(), rc, _tm::tm_hour, _tm::tm_mday, _tm::tm_min, _tm::tm_mon, _tm::tm_sec, _tm::tm_wday, and _tm::tm_year.
Set an PCF8563 hardware clock.
New time will be taken over at the beginning of the next second.
tm | Points to a structure which contains the date and time information. |
References BIN2BCD, memset(), PcfRtcWrite(), _tm::tm_hour, _tm::tm_mday, _tm::tm_min, _tm::tm_mon, _tm::tm_sec, _tm::tm_wday, and _tm::tm_year.
Get alarm date and time of an PCF8563 hardware clock.
Not implemented.
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. |
Set alarm of an PCF8563 hardware clock.
Not implemented.
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.
|
Query RTC status flags.
sflgs | Points to an unsigned long that receives the status flags.
|
References PcfRtcReadRegs(), rc, and RTC_STATUS_PF.
Referenced by PcfRtcInit().
Clear RTC status flags.
sflgs | Status flags to clear. |
int PcfRtcInit | ( | NUTRTC * | rtc | ) |
Initialize the interface to an Intersil PCF8563 hardware clock.
References PcfRtcGetStatus(), rc, and TwInit.