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

ds1307rtc.c File Reference


Detailed Description

RTC and RAM routines for the Dallas DS1307 clock chip.

 *
 * $Log: ds1307rtc.c,v $
 * Revision 1.4  2006/10/08 16:39:33  haraldkipp
 * Corrected range check in DS1307RamRead(). Thanks to Helmut Holbach.
 *
 * Revision 1.3  2006/10/05 17:18:49  haraldkipp
 * Hardware independant RTC layer added.
 *
 * Revision 1.2  2006/08/25 13:42:55  olereinhardt
 * avr-gcc 3.4 does not understand binary representation of numbers,
 * changed to hex
 *
 * Revision 1.1  2006/06/30 22:05:51  christianwelzel
 * Initial check in.
 *
 *
 * 


Defines

#define I2C_SLA_RTC   0x68

Functions

int DS1307RtcReadRegs (u_char reg, u_char *buff, size_t cnt)
 Read RTC registers.
int DS1307RtcWrite (CONST u_char *buff, size_t cnt)
 Write to RTC registers.
int DS1307RtcGetClock (struct _tm *tm)
 Get date and time from an DS1307 hardware clock.
int DS1307RtcSetClock (CONST struct _tm *tm)
 Set the DS1307 hardware clock.
int DS1307RamRead (u_char addr, u_char *buff, size_t cnt)
 Read contents from DS1307 RAM.
int DS1307RamWrite (u_char addr, CONST void *buff, size_t len)
 Store buffer contents in DS1307 RAM.
int DS1307Init (void)
 Initialize the interface to an Dallas DS1307 hardware clock.

Variables

NUTRTC rtcDs1307


Function Documentation

int DS1307RtcReadRegs 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 DS1307RtcWrite CONST u_char buff,
size_t  cnt
 

Write to RTC registers.

Parameters:
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 DS1307RtcGetClock struct _tm tm  ) 
 

Get date and time from an DS1307 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 DS1307RtcSetClock CONST struct _tm tm  ) 
 

Set the DS1307 hardware clock.

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 DS1307RamRead u_char  addr,
u_char buff,
size_t  cnt
 

Read contents from DS1307 RAM.

Parameters:
addr Start location.
buff Points to a buffer that receives the contents.
cnt Number of bytes to read.
Returns:
0 on success or -1 in case of an error.

int DS1307RamWrite u_char  addr,
CONST void *  buff,
size_t  len
 

Store buffer contents in DS1307 RAM.

Parameters:
addr Storage start location.
buff Points to a buffer that contains the bytes to store.
len Number of valid bytes in the buffer.
Returns:
0 on success or -1 in case of an error.

int DS1307Init void   ) 
 

Initialize the interface to an Dallas DS1307 hardware clock.

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


Variable Documentation

NUTRTC rtcDs1307
 

Initial value:

 {
    DS1307Init,         
    DS1307RtcGetClock,  
    DS1307RtcSetClock,  
    NULL,               
    NULL,               
    NULL,               
    NULL                
}


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