COSA
An Object-Oriented Platform for Arduino Programming
DS1307 Class Reference

#include <DS1307.hh>

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

Classes

union  control_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 ()
 
int read (void *ram, uint8_t size=sizeof(time_t), uint8_t pos=0)
 
int write (void *ram, uint8_t size=sizeof(time_t), uint8_t pos=0)
 
bool get_time (time_t &now)
 
bool set_time (time_t &now)
 
bool enable (Rate rs=RS_1_HZ)
 
bool disable ()
 

Static Public Attributes

static const uint8_t RAM_START = sizeof(timekeeper_t)
 
static const uint8_t RAM_END = 0x3f
 
static const uint8_t RAM_MAX = RAM_END - RAM_START + 1
 

Private Member Functions

bool is_async () const
 
void sync_request ()
 
void async_request ()
 
virtual void on_completion (uint8_t type, int count)
 

Private Attributes

uint8_t m_addr
 
bool m_async
 

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

TinyRTC(DS1307)
+------------+
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 50 of file DS1307.hh.

Member Enumeration Documentation

Rate Selection (pp. 9).

Enumerator
RS_1_HZ 
RS_4096_HZ 
RS_8192_HZ 
RS_32768_HZ 

Definition at line 86 of file DS1307.hh.

Constructor & Destructor Documentation

DS1307::DS1307 ( )
inline

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

Definition at line 113 of file DS1307.hh.

Member Function Documentation

bool DS1307::disable ( )

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

Returns
bool.

Definition at line 57 of file DS1307.cpp.

bool DS1307::enable ( Rate  rs = RS_1_HZ)

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 45 of file DS1307.cpp.

bool DS1307::get_time ( time_t 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 141 of file DS1307.hh.

int DS1307::read ( void *  ram,
uint8_t  size = sizeof(time_t),
uint8_t  pos = 0 
)

Read ram block with the given size into the buffer from the position. Return number of bytes read or negative error code.

Parameters
[in]rambuffer to read from ram.
[in]sizenumber of bytes to read.
[in]posaddress in ram to read from.
Returns
number of bytes or negative error code.

Definition at line 24 of file DS1307.cpp.

bool DS1307::set_time ( time_t 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 153 of file DS1307.hh.

int DS1307::write ( void *  ram,
uint8_t  size = sizeof(time_t),
uint8_t  pos = 0 
)

Write ram block at given position with the contents from buffer. Return number of bytes written or negative error code.

Parameters
[in]bufbuffer to write to ram.
[in]sizenumber of bytes to write.
[in]posaddress in ram to read write to.
Returns
number of bytes or negative error code.

Definition at line 34 of file DS1307.cpp.

Member Data Documentation

const uint8_t DS1307::RAM_END = 0x3f
static

End of application RAM.

Definition at line 105 of file DS1307.hh.

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

Max size of application RAM (56 bytes).

Definition at line 108 of file DS1307.hh.

const uint8_t DS1307::RAM_START = sizeof(timekeeper_t)
static

Start of application RAM.

Definition at line 102 of file DS1307.hh.


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