#include <DS1302.hh>
|
static const uint8_t | WP = 0x07 |
|
Cosa Device Driver for DS1302, Trickle-Charge Timekeeping Chip.
Circuit
+------------+
(VCC)---------------1-|VCC |
(GND)---------------2-|GND |
(D2)----------------3-|CLK |
(D3)----------------4-|DAT |
(D4)----------------5-|RST |
+------------+
References
- On-line product description, http://www.maximintegrated.com/datasheet/index.mvp/id/2685
- Datasheet, http://datasheets.maximintegrated.com/en/ds/DS1302.pdf
Definition at line 48 of file DS1302.hh.
Command byte.
Enumerator |
---|
WRITE |
Read/write bit in write mode.
|
READ |
Read/write bit in read mode.
|
RTC_BURST |
RTC register burst transfer.
|
RAM_BURST |
RAM burst transfer.
|
ADDR_MASK |
Mask address bits.
|
Definition at line 159 of file DS1302.hh.
Construct device driver for DS1302 Real-Time Clock with the given pins.
- Parameters
-
[in] | cs | chip select pin (default D4). |
[in] | sda | serial data pin (default D3). |
[in] | clk | clock pin (default D2). |
Definition at line 69 of file DS1302.hh.
void DS1302::get_time |
( |
time_t & |
now | ) |
|
Read clock and calender from the device.
- Parameters
-
[in,out] | now | time structure for return value. |
Definition at line 79 of file DS1302.cpp.
uint8_t DS1302::read |
( |
uint8_t |
addr | ) |
|
Low level read data from the device. Internal transfer function. Used within a chip select block. Data direction must be set before calling this function.
- Returns
- data.
- Note
- atomic
Definition at line 24 of file DS1302.cpp.
uint8_t DS1302::read_ram |
( |
uint8_t |
addr | ) |
|
|
inline |
Read given static memory address on the device and return byte.
- Parameters
-
[in] | addr | memory address on the device (0..RAM_MAX-1). |
Definition at line 119 of file DS1302.hh.
void DS1302::read_ram |
( |
void * |
buf, |
|
|
size_t |
size |
|
) |
| |
Burst read memory block from the device starting at address zero(0). Data block is returned in the given buffer.
- Parameters
-
[in] | buf | pointer to buffer to store data read. |
[in] | size | number of bytes to read (max RAM_MAX(31)). |
Definition at line 113 of file DS1302.cpp.
void DS1302::set_time |
( |
time_t & |
now | ) |
|
Write clock and calender to the device.
- Parameters
-
Definition at line 96 of file DS1302.cpp.
void DS1302::write |
( |
uint8_t |
addr, |
|
|
uint8_t |
data |
|
) |
| |
void DS1302::write |
( |
uint8_t |
data | ) |
|
|
protected |
Write low level data to the device. Internal transfer function. Used within a chip select block.
- Parameters
-
[in] | data | to write to the device. |
- Note
- atomic
Definition at line 41 of file DS1302.cpp.
void DS1302::write_protect |
( |
bool |
flag | ) |
|
|
inline |
Set write protect-bit according to flag.
- Parameters
-
[in] | flag | write protect mode. |
Definition at line 97 of file DS1302.hh.
void DS1302::write_ram |
( |
uint8_t |
addr, |
|
|
uint8_t |
data |
|
) |
| |
|
inline |
Write given data to the static memory (31 bytes). Requires handling of write protect (write_protect).
- Parameters
-
[in] | addr | memory address (0..RAM_MAX-1). |
[in] | data | to write to the memory address. |
Definition at line 131 of file DS1302.hh.
void DS1302::write_ram |
( |
void * |
buf, |
|
|
size_t |
size |
|
) |
| |
Burst write data in buffer with given size to the static memory in the device (max 31 bytes). Burst write is always from address zero(0) and includes handling of write protect.
- Parameters
-
[in] | buf | pointer to memory block to write. |
[in] | size | number of bytes to write (max RAM_MAX(31)). |
Definition at line 127 of file DS1302.cpp.
Chip select, asserted high.
Definition at line 167 of file DS1302.hh.
End address of static memory.
Definition at line 60 of file DS1302.hh.
const size_t DS1302::RAM_MAX = 31 |
|
static |
Static memory size.
Definition at line 54 of file DS1302.hh.
const uint8_t DS1302::RAM_START = 32 |
|
static |
Start address of static memory.
Definition at line 57 of file DS1302.hh.
const uint8_t DS1302::RTC_START = 0 |
|
static |
Start address of clock/calender internal registers.
Definition at line 51 of file DS1302.hh.
const uint8_t DS1302::WP = 0x07 |
|
staticprotected |
Write protect register.
Definition at line 156 of file DS1302.hh.
The documentation for this class was generated from the following files: