Download avr-libc Reference Manual
Transcript
5.3
EEPROM handling
}
return crc;
}
5.3
EEPROM handling
5.3.1
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, timecritical applications should first poll the EEPROM e. g. using eeprom is ready()
before attempting any actual I/O.
Note:
This library will not work with the ATmega169 since this device has 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)
Backwards compatibility defines
• #define eeprom rb(addr) eeprom read byte ((uint8 t ∗)(addr))
• #define eeprom rw(addr) eeprom read word ((uint16 t ∗)(addr))
• #define eeprom wb(addr, val) eeprom write byte ((uint8 t ∗)(addr), (uint8 t)(val))
Generated on Fri Apr 23 15:00:23 2004 for avr-libc by Doxygen
11