Arduino-Storage
External Memory Storage 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 ()
 
virtual int read (void *dst, uint32_t src, size_t count)
 
virtual int write (uint32_t dst, const void *src, size_t count)
 
uint32_t room ()
 
uint32_t alloc (size_t count)
 
void free (uint32_t addr)
 

Public Attributes

const uint16_t PAGE_MAX
 
const uint32_t SIZE
 

Protected Attributes

const uint16_t PAGE_MASK
 
uint32_t m_addr
 

Static Protected Attributes

static const uint8_t RETRY_MAX = 20
 
static const uint8_t RETRY_DELAY_MS = 1
 

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.

Definition at line 34 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 sub-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 44 of file AT24CXX.h.

Member Function Documentation

uint32_t Storage::alloc ( size_t  count)
inlineinherited

Allocate block with given number of bytes on storage. Returns storage address if successful otherwise UINT32_MAX.

Parameters
[in]countnumber of bytes.
Returns
address of allocated block, otherwise UINT32_MAX.

Definition at line 53 of file Storage.h.

void Storage::free ( uint32_t  addr)
inlineinherited

Reset allocation point to given address.

Parameters
[in]addraddress of allocated block.

Definition at line 65 of file Storage.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 62 of file AT24CXX.h.

virtual int AT24CXX::read ( void *  dst,
uint32_t  src,
size_t  count 
)
inlinevirtual

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

Parameters
[in]dstbuffer 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.

Implements Storage.

Definition at line 79 of file AT24CXX.h.

uint32_t Storage::room ( )
inlineinherited

Returns number of bytes that may be allocated.

Returns
number of bytes.

Definition at line 42 of file Storage.h.

virtual int AT24CXX::write ( uint32_t  dst,
const void *  src,
size_t  count 
)
inlinevirtual

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

Parameters
[in]dstaddress 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.

Implements Storage.

Definition at line 106 of file AT24CXX.h.

Member Data Documentation

uint32_t Storage::m_addr
protectedinherited

Address of the next allocation.

Definition at line 398 of file Storage.h.

const uint16_t AT24CXX::PAGE_MASK
protected

Memory addres page mask.

Definition at line 139 of file AT24CXX.h.

const uint16_t AT24CXX::PAGE_MAX

Number of bytes in max write page size.

Definition at line 55 of file AT24CXX.h.

const uint8_t AT24CXX::RETRY_DELAY_MS = 1
staticprotected

Retry delay time: 1 ms

Definition at line 145 of file AT24CXX.h.

const uint8_t AT24CXX::RETRY_MAX = 20
staticprotected

Maximum number of read/write page retries: 20 ms

Definition at line 142 of file AT24CXX.h.

const uint32_t Storage::SIZE
inherited

Number of bytes on device.

Definition at line 30 of file Storage.h.


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