#include <dev/rtc.h>
Go to the source code of this file.
Functions | |
int | DS1307Init (NUTRTC *rtc) |
Initialize the interface to an Dallas DS1307 hardware clock. | |
int | DS1307RtcGetClock (NUTRTC *rtc, struct _tm *tm) |
Get date and time from an DS1307 hardware clock. | |
int | DS1307RtcSetClock (NUTRTC *rtc, const struct _tm *tm) |
Set the DS1307 hardware clock. | |
int | DS1307RtcReadRegs (uint8_t addr, uint8_t *buff, size_t len) |
Read RTC registers. | |
int | DS1307RtcWrite (const uint8_t *buff, size_t len) |
Write to RTC registers. | |
int | DS1307RamRead (uint8_t addr, uint8_t *buff, size_t cnt) |
Read contents from DS1307 RAM. | |
int | DS1307RamWrite (uint8_t addr, const void *buff, size_t len) |
Store buffer contents in DS1307 RAM. | |
Variables | |
NUTRTC | rtcDs1307 |
int DS1307Init | ( | NUTRTC * | rtc | ) |
Initialize the interface to an Dallas DS1307 hardware clock.
References DS1307RtcReadRegs(), DS1307RtcWrite(), rc, and TwInit.
Get date and time from an DS1307 hardware clock.
tm | Points to a structure that receives the date and time information. |
References BCD2BIN, DS1307RtcReadRegs(), rc, _tm::tm_hour, _tm::tm_mday, _tm::tm_min, _tm::tm_mon, _tm::tm_sec, _tm::tm_wday, and _tm::tm_year.
Set the DS1307 hardware clock.
tm | Points to a structure which contains the date and time information. |
References BIN2BCD, DS1307RtcWrite(), memset(), _tm::tm_hour, _tm::tm_mday, _tm::tm_min, _tm::tm_mon, _tm::tm_sec, _tm::tm_wday, and _tm::tm_year.
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 DS1307Init(), DS1307RamRead(), and DS1307RtcGetClock().
int DS1307RtcWrite | ( | const uint8_t * | buff, |
size_t | cnt | ||
) |
Write to RTC 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, rc, and TwMasterTransact.
Referenced by DS1307Init(), and DS1307RtcSetClock().
Read contents from DS1307 RAM.
addr | Start location. |
buff | Points to a buffer that receives the contents. |
cnt | Number of bytes to read. |
References DS1307RtcReadRegs(), and rc.
int DS1307RamWrite | ( | uint8_t | addr, |
const void * | buff, | ||
size_t | len | ||
) |
Store buffer contents in DS1307 RAM.
addr | Storage start location. |
buff | Points to a buffer that contains the bytes to store. |
len | Number of valid bytes in the buffer. |
References free(), I2C_SLA_RTC, malloc(), memcpy(), NUT_WAIT_INFINITE, rc, and TwMasterTransact.