EEPROM handling


Detailed Description

#include <avr/eeprom.h>

This header file declares the interface to some simple library routines suitable for handling the data EEPROM contained in the AVR microcontrollers. The implementation uses a simple polled mode interface. Applications that require interrupt-controlled EEPROM access to ensure that no time will be wasted in spinloops will have to deploy their own implementation.

Note:
All of the read/write functions first make sure the EEPROM is ready to be accessed. Since this may cause long delays if a write operation is still pending, time-critical applications should first poll the EEPROM e. g. using eeprom_is_ready() before attempting any actual I/O.

This library will not work with the following devices since these devices have the EEPROM IO ports at different locations:


avr-libc declarations

#define eeprom_is_ready()   bit_is_clear(EECR, EEWE)
#define eeprom_busy_wait()   do {} while (!eeprom_is_ready())
uint8_t eeprom_read_byte (const uint8_t *addr)
uint16_t eeprom_read_word (const uint16_t *addr)
void eeprom_read_block (void *buf, const void *addr, size_t n)
void eeprom_write_byte (uint8_t *addr, uint8_t val)
void eeprom_write_word (uint16_t *addr, uint16_t val)
void eeprom_write_block (const void *buf, void *addr, size_t n)

IAR C compatibility defines

#define _EEPUT(addr, val)   eeprom_write_byte ((uint8_t *)(addr), (uint8_t)(val))
#define _EEGET(var, addr)   (var) = eeprom_read_byte ((uint8_t *)(addr))


Define Documentation

#define _EEGET var,
addr   )     (var) = eeprom_read_byte ((uint8_t *)(addr))
 

Read a byte from EEPROM.

#define _EEPUT addr,
val   )     eeprom_write_byte ((uint8_t *)(addr), (uint8_t)(val))
 

Write a byte to EEPROM.

 
#define eeprom_busy_wait  )     do {} while (!eeprom_is_ready())
 

Loops until the eeprom is no longer busy.

Returns:
Nothing.

 
#define eeprom_is_ready  )     bit_is_clear(EECR, EEWE)
 

Returns:
1 if EEPROM is ready for a new read/write operation, 0 if not.


Function Documentation

void eeprom_read_block void *  buf,
const void *  addr,
size_t  n
 

Read a block of n bytes from EEPROM address addr to buf.

uint8_t eeprom_read_byte const uint8_t addr  ) 
 

Read one byte from EEPROM address addr.

uint16_t eeprom_read_word const uint16_t addr  ) 
 

Read one 16-bit word (little endian) from EEPROM address addr.

void eeprom_write_block const void *  buf,
void *  addr,
size_t  n
 

Write a block of n bytes to EEPROM address addr from buf.

void eeprom_write_byte uint8_t addr,
uint8_t  val
 

Write a byte val to EEPROM address addr.

void eeprom_write_word uint16_t addr,
uint16_t  val
 

Write a word val to EEPROM address addr.


Automatically generated by Doxygen 1.3.6 on 15 Feb 2005.