I2C EEPROM 1.0
Library for 24CXX I2C EEPROMs
Data Structures | Typedefs | Functions
i2ceeprom.h File Reference

A Library for Interfacing AVR with 24CXX EEPROMs. More...

Data Structures

struct  eeprom
 This creates a new EEPROM instance. More...
 

Typedefs

typedef struct eeprom eeprom
 This creates a new EEPROM instance. More...
 

Functions

void eeprom_init (eeprom *a, uint8_t dev_address, uint16_t size)
 To set the EEPROM properties. More...
 
void eeprom_write (eeprom *a, uint32_t mem_address, uint8_t *data, uint16_t datasize)
 To write a byte array of data. More...
 
void eeprom_read (eeprom *a, uint16_t mem_address, uint8_t *data, uint16_t datasize)
 To read a byte array. More...
 
void eeprom_byte_write (eeprom *a, uint16_t mem_address, uint8_t data)
 To write a byte. More...
 
void eeprom_byte_read (eeprom *a, uint16_t mem_address, uint8_t *data)
 To read a byte. More...
 

Detailed Description

A Library for Interfacing AVR with 24CXX EEPROMs.

#include "i2ceeprom.h"
A Library for Interfacing AVR with 24CXX EEPROMs.

Basic functions for use with 24CXX EEPROMs.

Requires: I2C Master library by Peter Fleury pfleu.nosp@m.ry@g.nosp@m.mx.ch

Version
1.0
Author
Sandeep Kumar http://www.github.com/w0qs1
Usage Example:
#include <avr/io.h>
#include <util/delay.h>
#include <i2cmaster.h>
#include <i2ceeprom.h>
#define EEPROM_ADDRESS 0xA0
int main(void) {
eeprom eep1; // Create a new EEPROM instance
eeprom_init(&eep1, EEPROM_ADDRESS, 8); // AT24C08 -> 8Kbit EEPROM
uint8_t data_write[] = {0xCA, 0xFE, 0xBA, 0xBE};
eeprom_write(&eep1, 0x00, data_write, 4); // Write 4 bytes
uint8_t data_read[4];
eeprom_read(&eep1, 0x00, data_read, 4); // Read 4 bytes
uint8_t data_byte;
eeprom_byte_read(&eep1, 0x00, &data_byte); // Read a single byte
eeprom_byte_write(&eep1, 0x100, data_byte); // Write a single byte
}
void eeprom_read(eeprom *a, uint16_t mem_address, uint8_t *data, uint16_t datasize)
To read a byte array.
Definition: i2ceeprom.h:248
void eeprom_init(eeprom *a, uint8_t dev_address, uint16_t size)
To set the EEPROM properties.
Definition: i2ceeprom.h:73
void eeprom_byte_write(eeprom *a, uint16_t mem_address, uint8_t data)
To write a byte.
Definition: i2ceeprom.h:322
void eeprom_byte_read(eeprom *a, uint16_t mem_address, uint8_t *data)
To read a byte.
Definition: i2ceeprom.h:362
void eeprom_write(eeprom *a, uint32_t mem_address, uint8_t *data, uint16_t datasize)
To write a byte array of data.
Definition: i2ceeprom.h:87
This creates a new EEPROM instance.
Definition: i2ceeprom.h:60

Typedef Documentation

◆ eeprom

typedef struct eeprom eeprom

This creates a new EEPROM instance.

Note
The address of the instance must be passed in a function call

Function Documentation

◆ eeprom_byte_read()

void eeprom_byte_read ( eeprom a,
uint16_t  mem_address,
uint8_t *  data 
)

To read a byte.

Parameters
*aAddress of the EEPROM instance
mem_addressLocation of the byte in EEPROM
*dataAddress of the data byte
Returns
None

◆ eeprom_byte_write()

void eeprom_byte_write ( eeprom a,
uint16_t  mem_address,
uint8_t  data 
)

To write a byte.

Parameters
*aAddress of the EEPROM instance
mem_addressAddress for the byte to be stored
dataByte data
Returns
None

◆ eeprom_init()

void eeprom_init ( eeprom a,
uint8_t  dev_address,
uint16_t  size 
)

To set the EEPROM properties.

Note
This is used to set the I2C address and the size of the EEPROM.
Parameters
*aAddress of the EEPROM instance
dev_addressI2C address of the EEPROM
sizeSize of the EEPROM in Kbits
Returns
None

◆ eeprom_read()

void eeprom_read ( eeprom a,
uint16_t  mem_address,
uint8_t *  data,
uint16_t  datasize 
)

To read a byte array.

Parameters
*aAddress of the EEPROM instance
mem_addressStarting address
*dataData Array
datasizeSize of the data array
Returns
None

◆ eeprom_write()

void eeprom_write ( eeprom a,
uint32_t  mem_address,
uint8_t *  data,
uint16_t  datasize 
)

To write a byte array of data.

Parameters
*aAddress of the EEPROM instance
mem_addressStarting address
*dataData Array
datasizeSize of the data array
Returns
None