Xmega Application Note


eeprom_driver.h

Go to the documentation of this file.
00001 /* This file has been prepared for Doxygen automatic documentation generation.*/
00059 #ifndef EEPROM_DRIVER_H
00060 #define EEPROM_DRIVER_H
00061 
00062 #include "avr_compiler.h"
00063 
00064 #define MAPPED_EEPROM_START 0x1000
00065 #define EEPROM_PAGESIZE 32
00066 #define EEPROM(_pageAddr, _byteAddr) \
00067         ((uint8_t *) MAPPED_EEPROM_START)[_pageAddr*EEPROM_PAGESIZE + _byteAddr]
00068 
00069 
00070 
00071 /* Definitions of macros. */
00072 
00080 #define EEPROM_EnablePowerReduction() ( NVM.CTRLB |= NVM_EPRM_bm )
00081 
00086 #define EEPROM_DisablePowerReduction() ( NVM.CTRLB &= ~NVM_EPRM_bm )
00087 
00097 #define EEPROM_EnableMapping() ( NVM.CTRLB |= NVM_EEMAPEN_bm )
00098 
00104 #define EEPROM_DisableMapping() ( NVM.CTRLB &= ~NVM_EEMAPEN_bm )
00105 
00114 #define NVM_EXEC()      asm("push r30"      "\n\t"      \
00115                             "push r31"      "\n\t"      \
00116                             "push r16"      "\n\t"      \
00117                             "push r18"      "\n\t"      \
00118                             "ldi r30, 0xCB" "\n\t"      \
00119                             "ldi r31, 0x01" "\n\t"      \
00120                             "ldi r16, 0xD8" "\n\t"      \
00121                             "ldi r18, 0x01" "\n\t"      \
00122                             "out 0x34, r16" "\n\t"      \
00123                             "st Z, r18"     "\n\t"      \
00124                             "pop r18"       "\n\t"      \
00125                             "pop r16"       "\n\t"      \
00126                             "pop r31"       "\n\t"      \
00127                             "pop r30"       "\n\t"      \
00128                             )
00129 
00130 /* Prototyping of functions. */
00131 void EEPROM_WriteByte( uint8_t pageAddr, uint8_t byteAddr, uint8_t value );
00132 uint8_t EEPROM_ReadByte( uint8_t pageAddr, uint8_t byteAddr );
00133 void EEPROM_WaitForNVM( void );
00134 void EEPROM_FlushBuffer( void );
00135 void EEPROM_LoadByte( uint8_t byteAddr, uint8_t value );
00136 void EEPROM_LoadPage( const uint8_t * values );
00137 void EEPROM_AtomicWritePage( uint8_t pageAddr );
00138 void EEPROM_ErasePage( uint8_t pageAddress );
00139 void EEPROM_SplitWritePage( uint8_t pageAddr );
00140 void EEPROM_EraseAll( void );
00141 
00142 #endif
@DOC_TITLE@
Generated on Wed Apr 23 08:27:37 2008 for AVR1315 Accessing the XMEGA EEPROM by doxygen 1.5.5