AVR Libc Home Page AVRs AVR Libc Development Pages
Main Page User Manual Library Reference FAQ Alphabetical Index Example Projects

<avr/eeprom.h>: EEPROM handling


Defines

#define EEMEM   __attribute__((section(".eeprom")))
#define eeprom_is_ready()
#define eeprom_busy_wait()   do {} while (!eeprom_is_ready())

Functions

static __ATTR_PURE__
__inline__ uint8_t 
eeprom_read_byte (const uint8_t *__p)
static __ATTR_PURE__
__inline__ uint16_t 
eeprom_read_word (const uint16_t *__p)
static __ATTR_PURE__
__inline__ uint32_t 
eeprom_read_dword (const uint32_t *__p)
static __inline__ void eeprom_read_block (void *__dst, const void *__src, size_t __n)
static __inline__ void eeprom_write_byte (uint8_t *__p, uint8_t __value)
static __inline__ void eeprom_write_word (uint16_t *__p, uint16_t __value)
static __inline__ void eeprom_write_dword (uint32_t *__p, uint32_t __value)
static __inline__ void eeprom_write_block (const void *__src, void *__dst, size_t __n)

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. 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.


Define Documentation

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

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

#define _EEPUT ( addr,
val   )     eeprom_write_byte ((uint8_t *)(addr), (uint8_t)(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 (!eeprom_is_ready())

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

static __inline__ void eeprom_read_block ( void *  __dst,
const void *  __src,
size_t  __n 
) [static]

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

static __ATTR_PURE__ __inline__ uint8_t eeprom_read_byte ( const uint8_t __p  )  [static]

Read one byte from EEPROM address __p.

static __ATTR_PURE__ __inline__ uint32_t eeprom_read_dword ( const uint32_t __p  )  [static]

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

static __ATTR_PURE__ __inline__ uint16_t eeprom_read_word ( const uint16_t __p  )  [static]

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

static __inline__ void eeprom_write_block ( const void *  __src,
void *  __dst,
size_t  __n 
) [static]

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

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

static __inline__ void eeprom_write_byte ( uint8_t __p,
uint8_t  __value 
) [static]

Write a byte __value to EEPROM address __p.

static __inline__ void eeprom_write_dword ( uint32_t __p,
uint32_t  __value 
) [static]

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

static __inline__ void eeprom_write_word ( uint16_t __p,
uint16_t  __value 
) [static]

Write a word __value to EEPROM address __p.


Automatically generated by Doxygen 1.5.7 on 5 Mar 2009.