AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/ports/xplained/ASF/xmega/drivers/nvm/nvm.c
void nvm_eeprom_write_byte(eeprom_addr_t address,
    uint8_t value)
{
    uint8_t old_cmd;

    Assert(address <= EEPROM_SIZE);
    /*  Flush buffer to make sure no unintentional data is written and load
     *  the "Page Load" command into the command register.
     */
    old_cmd = NVM.CMD;
    nvm_eeprom_flush_buffer();
    // Wait until NVM is ready
    nvm_wait_until_ready();
    nvm_eeprom_load_byte_to_buffer(address, value);

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

    /*  Issue EEPROM Atomic Write (Erase&Write) command. Load command, write
     *  the protection signature and execute command.
     */
    NVM.CMD = NVM_CMD_ERASE_WRITE_EEPROM_PAGE_gc;
    nvm_exec();
    NVM.CMD = old_cmd;
}
/**
 * \brief Write one byte to EEPROM using IO mapping.
 *
 * This function writes one byte to EEPROM using IO-mapped access.
 * This function will cancel all ongoing EEPROM page buffer loading
 * operations, if any.
 *
 * \param  address    EEPROM address (max EEPROM_SIZE)
 * \param  value      Byte value to write to EEPROM.
 */
\brief Write one byte to EEPROM using IO mapping.
This function writes one byte to EEPROM using IO-mapped access.
This function will cancel all ongoing EEPROM page buffer loading
operations, if any.

\param  address    EEPROM address (max EEPROM_SIZE)
\param  value      Byte value to write to EEPROM.
\ brief Write one byte to EEPROM using IO mapping . This function writes one byte to EEPROM using IO - mapped access . This function will cancel all ongoing EEPROM page buffer loading operations if any . \ param address EEPROM address ( max EEPROM_SIZE ) \ param value Byte value to write to EEPROM .
void nvm_eeprom_write_byte(eeprom_addr_t address,
    uint8_t value)
{
    uint8_t old_cmd;
    Assert(address <= EEPROM_SIZE);
    old_cmd = NVM.CMD;
    nvm_eeprom_flush_buffer();
    nvm_wait_until_ready();
    nvm_eeprom_load_byte_to_buffer(address, value);
    NVM.ADDR2 = 0x00;
    NVM.ADDR1 = (address >> 8) & 0xFF;
    NVM.ADDR0 = address & 0xFF;
    NVM.CMD = NVM_CMD_ERASE_WRITE_EEPROM_PAGE_gc;
    nvm_exec();
    NVM.CMD = old_cmd;
}
void nvm_eeprom_write_byte ( eeprom_addr_t address , uint8_t value ) { uint8_t old_cmd ; Assert ( address <= EEPROM_SIZE ) ; old_cmd = NVM . CMD ; nvm_eeprom_flush_buffer ( ) ; nvm_wait_until_ready ( ) ; nvm_eeprom_load_byte_to_buffer ( address , value ) ; NVM . ADDR2 = 0x00 ; NVM . ADDR1 = ( address >> 8 ) & 0xFF ; NVM . ADDR0 = address & 0xFF ; NVM . CMD = NVM_CMD_ERASE_WRITE_EEPROM_PAGE_gc ; nvm_exec ( ) ; NVM . CMD = old_cmd ; }
\brief Write one byte to EEPROM using IO mapping.
\ brief Write one byte to EEPROM using IO mapping .
/*  Flush buffer to make sure no unintentional data is written and load
     *  the "Page Load" command into the command register.
     */ // Wait until NVM is ready // Set address to write to /*  Issue EEPROM Atomic Write (Erase&Write) command. Load command, write
     *  the protection signature and execute command.
     */