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

#include <DS3231.hh>

Inheritance diagram for DS3231:
Inheritance graph
Collaboration diagram for DS3231:
Collaboration graph

Classes

struct  alarm1_t
 
struct  alarm2_t
 
union  control_t
 
union  status_t
 
struct  timekeeper_t
 

Public Types

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

Public Member Functions

 DS3231 ()
 
int read (void *regs, uint8_t size, uint8_t pos=0)
 
int write (void *regs, uint8_t size, uint8_t pos=0)
 
bool get_time (time_t &now)
 
bool set_time (time_t &now)
 
bool get_alarm1 (alarm1_t &alarm, uint8_t &mask)
 
bool set_alarm1 (alarm1_t &alarm, uint8_t mask)
 
bool get_alarm2 (alarm2_t &alarm, uint8_t &mask)
 
bool set_alarm2 (alarm2_t &alarm, uint8_t mask)
 
int16_t temperature ()
 
bool square_wave (bool flag)
 

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 DS3231, Extremely Accurate I2C-Integrated RTC/TCXO/Crystal.

Circuit

The Mini RTC pro module with pull-up resistors (4K7) for TWI signals.

Mini RTC pro
+------------+
1-|32KHz |
2-|SQW |
(A5/SCL)------------3-|SCL |
(A4/SDA)------------4-|SDA |
(GND)---------------5-|GND |
(GND)---------------6-|VCC |
+------------+

References

  1. Maxim Integrated product description; http://datasheets.maximintegrated.com/en/ds/DS3231.pdf

Definition at line 50 of file DS3231.hh.

Member Enumeration Documentation

anonymous enum

Square-Wave Output Frequency.

Enumerator
RS_1_HZ 
RS_1024_HZ 
RS_4096_HZ 
RS_8192_HZ 

Definition at line 151 of file DS3231.hh.

Constructor & Destructor Documentation

DS3231::DS3231 ( )
inline

Construct DS3231 device with bus address(0x68).

Definition at line 189 of file DS3231.hh.

Member Function Documentation

bool DS3231::get_alarm1 ( alarm1_t alarm,
uint8_t &  mask 
)
inline

Read alarm1 setting, time and mask, from real-time clock. Return true(1) if successful otherwise false(0).

Parameters
[out]alarmtime structure.
[out]maskalarm mask bits.
Returns
boolean.

Definition at line 242 of file DS3231.hh.

bool DS3231::get_alarm2 ( alarm2_t alarm,
uint8_t &  mask 
)
inline

Read alarm2 setting, time and mask, from real-time clock. Return true(1) if successful otherwise false(0).

Parameters
[out]alarmtime structure.
[out]maskalarm mask bits.
Returns
boolean.

Definition at line 268 of file DS3231.hh.

bool DS3231::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 217 of file DS3231.hh.

int DS3231::read ( void *  regs,
uint8_t  size,
uint8_t  pos = 0 
)

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

Parameters
[in]regsbuffer to read from register block.
[in]sizenumber of bytes to read.
[in]posaddress in register file to read from.
Returns
number of bytes or negative error code.

Definition at line 25 of file DS3231.cpp.

bool DS3231::set_alarm1 ( alarm1_t alarm,
uint8_t  mask 
)
inline

Set real-time clock alarm1 with the given time and mask. Return true(1) if successful otherwise false(0).

Parameters
[in]alarmtime structure to set.
[out]maskalarm mask bits.
Returns
boolean.

Definition at line 255 of file DS3231.hh.

bool DS3231::set_alarm2 ( alarm2_t alarm,
uint8_t  mask 
)
inline

Set real-time clock alarm with the given time and mask. Return true(1) if successful otherwise false(0).

Parameters
[in]alarmtime structure to set.
[out]maskalarm mask bits.
Returns
boolean.

Definition at line 281 of file DS3231.hh.

bool DS3231::set_time ( time_t now)
inline

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

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

Definition at line 229 of file DS3231.hh.

bool DS3231::square_wave ( bool  flag)

Enable/disable square wave output (1 Hz). Returns true(1) if successful otherwise false(0).

Parameters

Definition at line 81 of file DS3231.cpp.

int16_t DS3231::temperature ( )

Read temperature from real-time clock, signed fixpoint<8:2>

Returns
temperature.

Definition at line 73 of file DS3231.cpp.

int DS3231::write ( void *  regs,
uint8_t  size,
uint8_t  pos = 0 
)

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

Parameters
[in]regsbuffer to write to register block.
[in]sizenumber of bytes to write.
[in]posaddress in register file to read write to.
Returns
number of bytes or negative error code.

Definition at line 35 of file DS3231.cpp.


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