AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/ports/xplained/ASF/xmega/drivers/nvm/nvm.c
void nvm_eeprom_atomic_write_page(uint8_t page_addr)
{
    // Wait until NVM is ready
    nvm_wait_until_ready();

    // Calculate page address
    uint16_t address = (uint16_t) (page_addr * EEPROM_PAGE_SIZE);

    Assert(address <= EEPROM_SIZE);

    // Set address
    NVM.ADDR2 = 0x00;
    NVM.ADDR1 = (address >> 8) & 0xFF;
    NVM.ADDR0 = address & 0xFF;

    // Issue EEPROM Atomic Write (Erase&Write) command
    nvm_issue_command(NVM_CMD_ERASE_WRITE_EEPROM_PAGE_gc);
}
/**
 * \brief Erase and write bytes from page buffer into EEPROM.
 *
 * This function writes the contents of an already loaded EEPROM page
 * buffer into EEPROM memory.
 *
 * As this is an atomic write, the page in EEPROM will be erased
 * automatically before writing. Note that only the page buffer locations
 * that have been loaded will be used when writing to EEPROM. Page buffer
 * locations that have not been loaded will be left untouched in EEPROM.
 *
 * \param  page_addr  EEPROM Page address, between 0 and EEPROM_SIZE/EEPROM_PAGE_SIZE
 */
\brief Erase and write bytes from page buffer into EEPROM.
This function writes the contents of an already loaded EEPROM page
buffer into EEPROM memory.

As this is an atomic write, the page in EEPROM will be erased
automatically before writing. Note that only the page buffer locations
that have been loaded will be used when writing to EEPROM. Page buffer
locations that have not been loaded will be left untouched in EEPROM.


\ brief Erase and write bytes from page buffer into EEPROM . This function writes the contents of an already loaded EEPROM page buffer into EEPROM memory . As this is an atomic write the page in EEPROM will be erased automatically before writing . Note that only the page buffer locations that have been loaded will be used when writing to EEPROM . Page buffer locations that have not been loaded will be left untouched in EEPROM .
void nvm_eeprom_atomic_write_page(uint8_t page_addr)
{
    nvm_wait_until_ready();
    uint16_t address = (uint16_t) (page_addr * EEPROM_PAGE_SIZE);
    Assert(address <= EEPROM_SIZE);
    NVM.ADDR2 = 0x00;
    NVM.ADDR1 = (address >> 8) & 0xFF;
    NVM.ADDR0 = address & 0xFF;
    nvm_issue_command(NVM_CMD_ERASE_WRITE_EEPROM_PAGE_gc);
}
void nvm_eeprom_atomic_write_page ( uint8_t page_addr ) { nvm_wait_until_ready ( ) ; uint16_t address = ( uint16_t ) ( page_addr * EEPROM_PAGE_SIZE ) ; Assert ( address <= EEPROM_SIZE ) ; NVM . ADDR2 = 0x00 ; NVM . ADDR1 = ( address >> 8 ) & 0xFF ; NVM . ADDR0 = address & 0xFF ; nvm_issue_command ( NVM_CMD_ERASE_WRITE_EEPROM_PAGE_gc ) ; }
\brief Erase and write bytes from page buffer into EEPROM.
\ brief Erase and write bytes from page buffer into EEPROM .
// Wait until NVM is ready // Calculate page address // Set address // Issue EEPROM Atomic Write (Erase&Write) command