AT24CXXX EEPROM unit

Device driver interface for the AT24CXXX EEPROM units. More...

Detailed Description

Device driver interface for the AT24CXXX EEPROM units.

Files

file  at24cxxx_defines.h
 Constants for AT24CXXX EEPROM devices.
 
file  at24cxxx_params.h
 Default configuration for AT24CXXX.
 
file  at24cxxx.h
 Device driver interface for AT24CXXX EEPROM units.
 

Data Structures

struct  at24cxxx_params
 Struct that holds initialization parameters. More...
 
struct  at24cxxx_t
 Struct that represents an AT24CXXX device. More...
 

Typedefs

typedef struct at24cxxx_params at24cxxx_params_t
 Struct that holds initialization parameters.
 

Enumerations

enum  { AT24CXXX_OK, AT24CXXX_I2C_ERROR }
 Return values.
 

Functions

int at24cxxx_init (at24cxxx_t *dev, const at24cxxx_params_t *params)
 Initialize an AT24CXXX device handle with AT24CXXX parameters. More...
 
int at24cxxx_read_byte (const at24cxxx_t *dev, uint32_t pos, void *dest)
 Read a byte at a given position pos. More...
 
int at24cxxx_read (const at24cxxx_t *dev, uint32_t pos, void *data, size_t len)
 Sequentially read len bytes from a given position pos. More...
 
int at24cxxx_write_byte (const at24cxxx_t *dev, uint32_t pos, uint8_t data)
 Write a byte at a given position pos. More...
 
int at24cxxx_write (const at24cxxx_t *dev, uint32_t pos, const void *data, size_t len)
 Sequentially write len bytes from a given position pos. More...
 
int at24cxxx_write_page (const at24cxxx_t *dev, uint32_t page, uint32_t offset, const void *data, size_t len)
 Sequentially write len bytes to a given page. More...
 
int at24cxxx_set (const at24cxxx_t *dev, uint32_t pos, uint8_t val, size_t len)
 Set len bytes from a given position pos to the value val. More...
 
int at24cxxx_clear (const at24cxxx_t *dev, uint32_t pos, size_t len)
 Set len bytes from position pos to AT24CXXX_CLEAR_BYTE. More...
 
int at24cxxx_erase (const at24cxxx_t *dev)
 Set the entire EEPROM memory to AT24CXXX_CLEAR_BYTE. More...
 
int at24cxxx_enable_write_protect (const at24cxxx_t *dev)
 Enable write protection. More...
 
int at24cxxx_disable_write_protect (const at24cxxx_t *dev)
 Disable write protection. More...
 

Function Documentation

◆ at24cxxx_clear()

int at24cxxx_clear ( const at24cxxx_t dev,
uint32_t  pos,
size_t  len 
)

Set len bytes from position pos to AT24CXXX_CLEAR_BYTE.

This is a wrapper around

See also
at24cxxx_set.
Parameters
[in]devAT24CXXX device handle
[in]posPosition in EEPROM memory
[in]lenRequested length to be written
Returns
See also
at24cxxx_set

◆ at24cxxx_disable_write_protect()

int at24cxxx_disable_write_protect ( const at24cxxx_t dev)

Disable write protection.

Parameters
[in]devAT24CXXX device handle
Returns
AT24CXXX_OK on success
-ENOTSUP if pin_wp was initialized with GPIO_UNDEF

◆ at24cxxx_enable_write_protect()

int at24cxxx_enable_write_protect ( const at24cxxx_t dev)

Enable write protection.

Parameters
[in]devAT24CXXX device handle
Returns
AT24CXXX_OK on success
-ENOTSUP if pin_wp was initialized with GPIO_UNDEF

◆ at24cxxx_erase()

int at24cxxx_erase ( const at24cxxx_t dev)

Set the entire EEPROM memory to AT24CXXX_CLEAR_BYTE.

This is a wrapper around

See also
at24cxxx_clear.
Parameters
[in]devAT24CXXX device handle
Returns
See also
at24cxxx_set

◆ at24cxxx_init()

int at24cxxx_init ( at24cxxx_t dev,
const at24cxxx_params_t params 
)

Initialize an AT24CXXX device handle with AT24CXXX parameters.

Parameters
[in,out]devAT24CXXX device handle
[in]paramsAT24CXXX parameters
Returns
AT24CXXX_OK on success
-AT24CXXX_I2C_ERROR if i2c could not be acquired
-EINVAL if input parameters are NULL

◆ at24cxxx_read()

int at24cxxx_read ( const at24cxxx_t dev,
uint32_t  pos,
void *  data,
size_t  len 
)

Sequentially read len bytes from a given position pos.

Parameters
[in]devAT24CXXX device handle
[in]posPosition in EEPROM memory
[out]dataRead buffer
[in]lenRequested length to be read
Returns
AT24CXXX_OK on success
-ERANGE if pos + len is out of bounds
See also
i2c_read_regs

◆ at24cxxx_read_byte()

int at24cxxx_read_byte ( const at24cxxx_t dev,
uint32_t  pos,
void *  dest 
)

Read a byte at a given position pos.

Parameters
[in]devAT24CXXX device handle
[in]posPosition in EEPROM memory
[out]destRead byte
Returns
AT24CXXX_OK on success
-ERANGE if pos is out of bounds
See also
i2c_read_regs

◆ at24cxxx_set()

int at24cxxx_set ( const at24cxxx_t dev,
uint32_t  pos,
uint8_t  val,
size_t  len 
)

Set len bytes from a given position pos to the value val.

Writing is performed in chunks of size AT24CXXX_SET_BUFFER_SIZE.

Parameters
[in]devAT24CXXX device handle
[in]posPosition in EEPROM memory
[in]valValue to be set
[in]lenRequested length to be written
Returns
AT24CXXX_OK on success
-ERANGE if pos + len is out of bounds
See also
i2c_write_byte

◆ at24cxxx_write()

int at24cxxx_write ( const at24cxxx_t dev,
uint32_t  pos,
const void *  data,
size_t  len 
)

Sequentially write len bytes from a given position pos.

Writing is performed in chunks of size AT24CXXX_PAGE_SIZE.

Parameters
[in]devAT24CXXX device handle
[in]posPosition in EEPROM memory
[in]dataWrite buffer
[in]lenRequested length to be written
Returns
AT24CXXX_OK on success
-ERANGE if pos + len is out of bounds
See also
i2c_write_regs

◆ at24cxxx_write_byte()

int at24cxxx_write_byte ( const at24cxxx_t dev,
uint32_t  pos,
uint8_t  data 
)

Write a byte at a given position pos.

Parameters
[in]devAT24CXXX device handle
[in]posPosition in EEPROM memory
[in]dataValue to be written
Returns
AT24CXXX_OK on success
-ERANGE if pos is out of bounds
See also
i2c_write_regs

◆ at24cxxx_write_page()

int at24cxxx_write_page ( const at24cxxx_t dev,
uint32_t  page,
uint32_t  offset,
const void *  data,
size_t  len 
)

Sequentially write len bytes to a given page.

The function will write up to the page boundary and then return the number of bytes written up to that.

Parameters
[in]devAT24CXXX device handle
[in]pagepage of EEPROM memory
[in]offsetoffset from the start of the page, must be < page size
[in]datawrite buffer
[in]lenrequested length to be written
Returns
number of bytes written on success
error on failure