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.

Notes:

  • In addition to the write functions there is a set of update ones. This functions read each byte first and skip the burning if the old value is the same with new. The scaning direction is from high address to low, to obtain quick return in common cases.

  • 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. But this functions are not wait until SELFPRGEN in SPMCSR becomes zero. Do this manually, if your softwate contains the Flash burning.

  • As these functions modify IO registers, they are known to be non-reentrant. If any of these functions are used from both, standard and interrupt context, the applications must ensure proper protection (e.g. by disabling interrupts before accessing them).

  • All write functions force erase_and_write programming mode.

  • For Xmega the EEPROM start address is 0, like other architectures. The reading functions add the 0x2000 value to use EEPROM mapping into data space.

Macro Definition Documentation

#define __EEGET(var, addr) (var) = \fBeeprom_read_byte\fP ((const \fBuint8_t\fP *)(addr))

Read a byte from EEPROM. Compatibility define for IAR C.

#define __EEPUT(addr, val) \fBeeprom_write_byte\fP ((\fBuint8_t\fP *)(addr), (\fBuint8_t\fP)(val))

Write a byte to EEPROM. Compatibility define for IAR C.

#define _EEGET(var, addr) (var) = \fBeeprom_read_byte\fP ((const \fBuint8_t\fP *)(addr))

Read a byte from EEPROM. Compatibility define for IAR C.

#define _EEPUT(addr, val) \fBeeprom_write_byte\fP ((\fBuint8_t\fP *)(addr), (\fBuint8_t\fP)(val))

Write a byte to EEPROM. Compatibility define for IAR C.

#define EEMEM __attribute__((section('.eeprom')))

Attribute expression causing a variable to be allocated within the .eeprom section.

#define eeprom_busy_wait() do {} while (!\fBeeprom_is_ready\fP())

Loops until the eeprom is no longer busy.

Returns:

Nothing.

#define eeprom_is_ready()

Returns:

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

Function Documentation

void eeprom_read_block (void *__dst, const void *__src, size_t__n)

Read a block of __n bytes from EEPROM address __src to SRAM __dst.

\fBuint8_t\fP eeprom_read_byte (const \fBuint8_t\fP *__p)

Read one byte from EEPROM address __p.

\fBuint32_t\fP eeprom_read_dword (const \fBuint32_t\fP *__p)

Read one 32-bit double word (little endian) from EEPROM address __p.

float eeprom_read_float (const float *__p)

Read one float value (little endian) from EEPROM address __p.

\fBuint16_t\fP eeprom_read_word (const \fBuint16_t\fP *__p)

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

void eeprom_update_block (const void *__src, void *__dst, size_t__n)

Update a block of __n bytes to EEPROM address __dst from __src.

Note:

The argument order is mismatch with common functions like strcpy().

void eeprom_update_byte (\fBuint8_t\fP *__p, \fBuint8_t\fP__value)

Update a byte __value to EEPROM address __p.

void eeprom_update_dword (\fBuint32_t\fP *__p, \fBuint32_t\fP__value)

Update a 32-bit double word __value to EEPROM address __p.

void eeprom_update_float (float *__p, float__value)

Update a float __value to EEPROM address __p.

void eeprom_update_word (\fBuint16_t\fP *__p, \fBuint16_t\fP__value)

Update a word __value to EEPROM address __p.

void eeprom_write_block (const void *__src, void *__dst, size_t__n)

Write a block of __n bytes to EEPROM address __dst from __src.

Note:

The argument order is mismatch with common functions like strcpy().

void eeprom_write_byte (\fBuint8_t\fP *__p, \fBuint8_t\fP__value)

Write a byte __value to EEPROM address __p.

void eeprom_write_dword (\fBuint32_t\fP *__p, \fBuint32_t\fP__value)

Write a 32-bit double word __value to EEPROM address __p.

void eeprom_write_float (float *__p, float__value)

Write a float __value to EEPROM address __p.

void eeprom_write_word (\fBuint16_t\fP *__p, \fBuint16_t\fP__value)

Write a word __value to EEPROM address __p.

Author

Generated automatically by Doxygen for avr-libc from the source code.