Arduino-TWI
Two-Wire Interface (TWI) library for Arduino
AT24CXX Class Reference

#include <AT24CXX.h>

Inheritance diagram for AT24CXX:
Inheritance graph
Collaboration diagram for AT24CXX:
Collaboration graph

Public Member Functions

 AT24CXX (TWI &twi, uint8_t subaddr=0, const size_t size=32, const uint16_t page_max=32)
 
bool is_ready ()
 
int read (void *dest, uint16_t src, size_t count)
 
int write (uint16_t dest, const void *src, size_t count)
 

Public Attributes

const uint16_t PAGE_MAX
 
const uint16_t PAGE_MASK
 
const size_t SIZE
 

Protected Member Functions

bool acquire ()
 
bool release ()
 
int read (void *buf, size_t count)
 
int write (const void *buf, size_t count)
 
int write (iovec_t *vp)
 

Protected Attributes

TWIm_twi
 
uint8_t m_addr
 

Detailed Description

Driver for the AT24CXX 2-Wire Serial EEPROM. Allows page write and block read. Supports device AT24C32 (8K) to AT24C512 (64K). Default AT24CXX device is AT24C32.

Circuit

The TinyRTC with DS1307 also contains a 24C32 EEPROM.

TinyRTC(24C32)
+------------+
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 48 of file AT24CXX.h.

Constructor & Destructor Documentation

AT24CXX::AT24CXX ( TWI twi,
uint8_t  subaddr = 0,
const size_t  size = 32,
const uint16_t  page_max = 32 
)
inline

Construct AT24CXX serial TWI EEPROM device access to given chip address, page and memory size.

Parameters
[in]twibus manager.
[in]subaddrchip address (0..7, default 0).
[in]sizein Kbits (default 32).
[in]page_maxsize of memory page (default 32 byte).

Definition at line 67 of file AT24CXX.h.

Member Function Documentation

bool TWI::Device::acquire ( )
inlineinherited

Start transaction. Return true(1) if successful otherwise false(0).

Returns
bool.

Definition at line 51 of file TWI.h.

bool AT24CXX::is_ready ( )
inline

Return true(1) if the device is ready, write cycle is completed, otherwise false(0).

Returns
bool.

Definition at line 82 of file AT24CXX.h.

int TWI::Device::read ( void *  buf,
size_t  count 
)
inlineinherited

Read data from device to given buffer.

Parameters
[in]bufbuffer pointer.
[in]countbuffer size in bytes.
Returns
number of bytes read or negative error code.

Definition at line 72 of file TWI.h.

int AT24CXX::read ( void *  dest,
uint16_t  src,
size_t  count 
)
inline

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

Parameters
[in]destbuffer to read from eeprom.
[in]srcaddress in eeprom to read from.
[in]countnumber of bytes to read.
Returns
number of bytes or negative error code.

Definition at line 98 of file AT24CXX.h.

bool TWI::Device::release ( )
inlineinherited

Stop transaction. Return true(1) if successful otherwise false(0).

Returns
bool.

Definition at line 61 of file TWI.h.

int TWI::Device::write ( const void *  buf,
size_t  count 
)
inlineinherited

Write data from the given buffer to device.

Parameters
[in]bufbuffer pointer.
[in]countbuffer size in bytes.
Returns
number of bytes written or negative error code.

Definition at line 83 of file TWI.h.

int TWI::Device::write ( iovec_t vp)
inlineinherited

Write data to device with from given io vector.

Parameters
[in]vpio vector pointer.
Returns
number of bytes written or negative error code.

Definition at line 93 of file TWI.h.

int AT24CXX::write ( uint16_t  dest,
const void *  src,
size_t  count 
)
inline

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

Parameters
[in]destaddress in eeprom to read write to.
[in]srcbuffer to write to eeprom.
[in]countnumber of bytes to write.
Returns
number of bytes or negative error code.

Definition at line 124 of file AT24CXX.h.

Member Data Documentation

uint8_t TWI::Device::m_addr
protectedinherited

Device address.

Definition at line 103 of file TWI.h.

TWI& TWI::Device::m_twi
protectedinherited

Two-Wire Interface Manager.

Definition at line 100 of file TWI.h.

const uint16_t AT24CXX::PAGE_MASK

Memory addres page mask.

Definition at line 54 of file AT24CXX.h.

const uint16_t AT24CXX::PAGE_MAX

Number of bytes in max write page size.

Definition at line 51 of file AT24CXX.h.

const size_t AT24CXX::SIZE

Number of bytes on device.

Definition at line 57 of file AT24CXX.h.


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