78 NVM.CMD = NVM_CMD_LOAD_EEPROM_BUFFER_gc;
81 uint16_t address = (uint16_t) (pageAddr * EEPROM_PAGESIZE) | (byteAddr & (EEPROM_PAGESIZE - 1));
84 NVM.ADDR0 = address & 0xFF;
85 NVM.ADDR1 = (address >> 8) & 0x1F;
94 NVM.CMD = NVM_CMD_ERASE_WRITE_EEPROM_PAGE_gc;
98 void EEPROM_WriteBytes ( uint8_t pageAddr, uint8_t byteAddr, uint8_t len, uint32_t value )
100 uint8_t temp_data = 0;
102 for (
int i = 0; i < len; i++ )
104 temp_data = (value >> ((len - i - 1) * 8)) & 0xFF;
125 uint16_t address = (uint16_t) (pageAddr * EEPROM_PAGESIZE) | (byteAddr & (EEPROM_PAGESIZE - 1));
128 NVM.ADDR0 = address & 0xFF;
129 NVM.ADDR1 = (address >> 8) & 0x1F;
133 NVM.CMD = NVM_CMD_READ_EEPROM_gc;
139 uint32_t EEPROM_ReadBytes ( uint8_t pageAddr, uint8_t byteAddr, uint8_t len )
141 uint32_t temp_data = 0;
143 for (
int i = 0; i < len; i++ )
144 temp_data = (temp_data << 8) |
EEPROM_ReadByte ( pageAddr, byteAddr + i );
162 while ( (NVM.STATUS & NVM_NVMBUSY_bm) == NVM_NVMBUSY_bm );
179 if ( (NVM.STATUS & NVM_EELOAD_bm) != 0 )
181 NVM.CMD = NVM_CMD_ERASE_EEPROM_BUFFER_gc;
205 NVM.CMD = NVM_CMD_LOAD_EEPROM_BUFFER_gc;
208 NVM.ADDR0 = byteAddr & 0xFF;
234 NVM.CMD = NVM_CMD_LOAD_EEPROM_BUFFER_gc;
243 for ( uint8_t i = 0; i < EEPROM_PAGESIZE; ++i )
269 uint16_t address = (uint16_t) (pageAddr * EEPROM_PAGESIZE);
272 NVM.ADDR0 = address & 0xFF;
273 NVM.ADDR1 = (address >> 8) & 0x1F;
277 NVM.CMD = NVM_CMD_ERASE_WRITE_EEPROM_PAGE_gc;
293 uint16_t address = (uint16_t) (pageAddr * EEPROM_PAGESIZE);
296 NVM.ADDR0 = address & 0xFF;
297 NVM.ADDR1 = (address >> 8) & 0x1F;
301 NVM.CMD = NVM_CMD_ERASE_EEPROM_PAGE_gc;
321 uint16_t address = (uint16_t) (pageAddr * EEPROM_PAGESIZE);
324 NVM.ADDR0 = address & 0xFF;
325 NVM.ADDR1 = (address >> 8) & 0x1F;
329 NVM.CMD = NVM_CMD_WRITE_EEPROM_PAGE_gc;
343 NVM.CMD = NVM_CMD_ERASE_EEPROM_gc;
void EEPROM_SplitWritePage(uint8_t pageAddr)
Write (without erasing) EEPROM page.
void EEPROM_LoadByte(uint8_t byteAddr, uint8_t value)
Load single byte into temporary page buffer.
void EEPROM_LoadPage(const uint8_t *values)
Load entire page into temporary EEPROM page buffer.
uint8_t EEPROM_ReadByte(uint8_t pageAddr, uint8_t byteAddr)
Read one byte from EEPROM using IO mapping.
void EEPROM_FlushBuffer(void)
Flush temporary EEPROM page buffer.
void EEPROM_AtomicWritePage(uint8_t pageAddr)
Write already loaded page into EEPROM.
#define NVM_EXEC()
Non-Volatile Memory Execute Command.
void EEPROM_EraseAll(void)
Erase entire EEPROM memory.
void EEPROM_ErasePage(uint8_t pageAddr)
Erase EEPROM page.
XMEGA EEPROM driver header file.
void EEPROM_WaitForNVM(void)
Wait for any NVM access to finish, including EEPROM.
void EEPROM_WriteByte(uint8_t pageAddr, uint8_t byteAddr, uint8_t value)
Write one byte to EEPROM using IO mapping.