Arduino-RTC
Real-Time Clock (RTC) library for Arduino
DS1307 Class Reference

#include <DS1307.h>

Inheritance diagram for DS1307:
Inheritance graph
Collaboration diagram for DS1307:
Collaboration graph

Classes

union  control_t
 
struct  rtc_t
 
struct  timekeeper_t
 

Public Types

enum  Rate { RS_1_HZ = 0, RS_4096_HZ = 1, RS_8192_HZ = 2, RS_32768_HZ = 3 }
 

Public Member Functions

 DS1307 (TWI &twi)
 
bool get_time (struct tm &now)
 
bool set_time (struct tm &now)
 
bool enable (Rate rs=RS_1_HZ)
 
bool disable ()
 
bool read_ram (uint8_t addr, void *buf, size_t count)
 
bool write_ram (uint8_t addr, const void *buf, size_t count)
 

Static Public Attributes

static const uint8_t RAM_START = 0x08
 
static const uint8_t RAM_END = 0x3f
 
static const uint8_t RAM_MAX = RAM_END - RAM_START + 1
 

Detailed Description

Driver for the DS1307, 64 X 8, Serial I2C Real-Time Clock, a low-power, full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM.

For further details see Maxim Integrated product description; http://datasheets.maximintegrated.com/en/ds/DS1307.pdf

Circuit

+------------+
1-|SQ |
2-|DS DS|-1
(A5/SCL)------------3-|SCL SCL|-2
(A4/SDA)------------4-|SDA SDA|-3
(VCC)---------------5-|VCC VCC|-4
(GND)---------------6-|GND GND|-5
7-|BAT |
+------------+

Definition at line 47 of file DS1307.h.

Member Enumeration Documentation

Square Wave Output Rate Selection (pp. 9).

Enumerator
RS_1_HZ 
RS_4096_HZ 
RS_8192_HZ 
RS_32768_HZ 

Definition at line 102 of file DS1307.h.

Constructor & Destructor Documentation

DS1307::DS1307 ( TWI &  twi)
inline

Construct DS1307 device driver with bus address(0x68).

Definition at line 52 of file DS1307.h.

Member Function Documentation

bool DS1307::disable ( )
inline

Disable clock output. Return true(1) if successful otherwise false(0).

Returns
bool.

Definition at line 131 of file DS1307.h.

bool DS1307::enable ( Rate  rs = RS_1_HZ)
inline

Enable clock output with given rate. Return true(1) if successful otherwise false(0).

Parameters
[in]rsrate selection (default 1 Hz).
Returns
bool.

Definition at line 115 of file DS1307.h.

bool DS1307::get_time ( struct tm now)
inline

Read current time from real-time clock. Return true(1) if successful otherwise false(0).

Parameters
[out]nowtime structure return value.
Returns
boolean.

Definition at line 60 of file DS1307.h.

bool DS1307::read_ram ( uint8_t  addr,
void *  buf,
size_t  count 
)
inline

Read ram block with the given size into the buffer. Return true(1) if successful otherwise false.

Parameters
[in]addraddress on device.
[in]bufbuffer to read from ram.
[in]countnumber of bytes to read.
Returns
bool.

Definition at line 155 of file DS1307.h.

bool DS1307::set_time ( struct tm now)
inline

Set the current time from real-time clock with the given time. Return true(1) if successful otherwise false(0).

Parameters
[in]nowtime structure to set.
Returns
boolean.

Definition at line 83 of file DS1307.h.

bool DS1307::write_ram ( uint8_t  addr,
const void *  buf,
size_t  count 
)
inline

Write ram block at given position with the contents from buffer. Return true(1) if successful otherwise false.

Parameters
[in]addraddress on device.
[in]bufbuffer to write to ram.
[in]countnumber of bytes to write.
Returns
bool.

Definition at line 172 of file DS1307.h.

Member Data Documentation

const uint8_t DS1307::RAM_END = 0x3f
static

End of application RAM.

Definition at line 143 of file DS1307.h.

const uint8_t DS1307::RAM_MAX = RAM_END - RAM_START + 1
static

Max size of application RAM (56 bytes).

Definition at line 146 of file DS1307.h.

const uint8_t DS1307::RAM_START = 0x08
static

Start of application RAM.

Definition at line 140 of file DS1307.h.


The documentation for this class was generated from the following file: