Driver for the AT25xxx series of EEPROMs. More...

Detailed Description

Driver for the AT25xxx series of EEPROMs.

Author
Benjamin Valentin benja.nosp@m.min..nosp@m.valen.nosp@m.tin@.nosp@m.ml-pa.nosp@m..com

Definition in file at25xxx.h.

#include <stdint.h>
#include <stdbool.h>
#include "periph/spi.h"
#include "periph/gpio.h"
+ Include dependency graph for at25xxx.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  at25xxx_params_t
 struct holding all params needed for device initialization More...
 
struct  at25xxx_t
 struct that represents an AT25XXX device More...
 

Functions

int at25xxx_init (at25xxx_t *dev, const at25xxx_params_t *params)
 Initialize an AT25XXX device handle with AT25XXX parameters. More...
 
uint8_t at25xxx_read_byte (const at25xxx_t *dev, uint32_t pos)
 Read a byte at a given position pos. More...
 
int at25xxx_read (const at25xxx_t *dev, uint32_t pos, void *data, size_t len)
 Sequentially read len bytes from a given position pos. More...
 
void at25xxx_write_byte (const at25xxx_t *dev, uint32_t pos, uint8_t data)
 Write a byte at a given position pos. More...
 
int at25xxx_write (const at25xxx_t *dev, uint32_t pos, const void *data, size_t len)
 Sequentially write len bytes from a given position pos. More...
 
int at25xxx_write_page (const at25xxx_t *dev, uint32_t page, uint32_t offset, const void *data, size_t len)
 Sequentially write len bytes to a given page. More...
 
int at25xxx_set (const at25xxx_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 at25xxx_clear (const at25xxx_t *dev, uint32_t pos, size_t len)
 Set len bytes from position pos to 0. More...
 

Function Documentation

◆ at25xxx_clear()

int at25xxx_clear ( const at25xxx_t dev,
uint32_t  pos,
size_t  len 
)

Set len bytes from position pos to 0.

This is a wrapper around

See also
at25xxx_set.
Parameters
[in]devAT25XXX device handle
[in]posposition in EEPROM memory
[in]lenrequested length to be written
Returns
0 on success
-ERANGE if pos + len > EEPROM size

◆ at25xxx_init()

int at25xxx_init ( at25xxx_t dev,
const at25xxx_params_t params 
)

Initialize an AT25XXX device handle with AT25XXX parameters.

Parameters
[in,out]devAT25XXX device handle
[in]paramsAT25XXX parameters
Returns
0 on success, -1 on failure

◆ at25xxx_read()

int at25xxx_read ( const at25xxx_t dev,
uint32_t  pos,
void *  data,
size_t  len 
)

Sequentially read len bytes from a given position pos.

Parameters
[in]devAT25XXX device handle
[in]posposition in EEPROM memory
[out]dataread buffer
[in]lenrequested length to be read
Returns
0 on success
-ERANGE if pos + len > EEPROM size

◆ at25xxx_read_byte()

uint8_t at25xxx_read_byte ( const at25xxx_t dev,
uint32_t  pos 
)

Read a byte at a given position pos.

Parameters
[in]devAT25XXX device handle
[in]posposition in EEPROM memory
Returns
read byte

◆ at25xxx_set()

int at25xxx_set ( const at25xxx_t dev,
uint32_t  pos,
uint8_t  val,
size_t  len 
)

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

Parameters
[in]devAT25XXX device handle
[in]posposition in EEPROM memory
[in]valvalue to be set
[in]lenrequested length to be written
Returns
0 on success
-ERANGE if pos + len > EEPROM size

◆ at25xxx_write()

int at25xxx_write ( const at25xxx_t dev,
uint32_t  pos,
const void *  data,
size_t  len 
)

Sequentially write len bytes from a given position pos.

Parameters
[in]devAT25XXX device handle
[in]posposition in EEPROM memory
[in]datawrite buffer
[in]lenrequested length to be written
Returns
0 on success
-ERANGE if pos + len > EEPROM size

◆ at25xxx_write_byte()

void at25xxx_write_byte ( const at25xxx_t dev,
uint32_t  pos,
uint8_t  data 
)

Write a byte at a given position pos.

Parameters
[in]devAT25XXX device handle
[in]posposition in EEPROM memory
[in]datavalue to be written

◆ at25xxx_write_page()

int at25xxx_write_page ( const at25xxx_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.

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