AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/ports/xplained/ASF/xmega/drivers/nvm/nvm.c
void nvm_eeprom_erase_and_write_buffer(eeprom_addr_t address,
    const void *buf,
    uint16_t len)
{
    while (len) {
        if (((address % EEPROM_PAGE_SIZE) == 0) && (len >= EEPROM_PAGE_SIZE)) {
            // A full page can be written
            nvm_eeprom_load_page_to_buffer((uint8_t *) buf);
            nvm_eeprom_atomic_write_page(address / EEPROM_PAGE_SIZE);
            address += EEPROM_PAGE_SIZE;
            buf = (uint8_t *) buf + EEPROM_PAGE_SIZE;
            len -= EEPROM_PAGE_SIZE;
        } else {
            nvm_eeprom_write_byte(address++, *(uint8_t *) buf);
            buf = (uint8_t *) buf + 1;
            len--;
        }
    }
}
/**
 * \brief Write buffer within the eeprom
 *
 * \param address   the address to where to write
 * \param buf       pointer to the data
 * \param len       the number of bytes to write
 */
\brief Write buffer within the eeprom
\param address   the address to where to write
\param buf       pointer to the data
\param len       the number of bytes to write
\ brief Write buffer within the eeprom \ param address the address to where to write \ param buf pointer to the data \ param len the number of bytes to write
void nvm_eeprom_erase_and_write_buffer(eeprom_addr_t address,
    const void *buf,
    uint16_t len)
{
    while (len) {
        if (((address % EEPROM_PAGE_SIZE) == 0) && (len >= EEPROM_PAGE_SIZE)) {
            nvm_eeprom_load_page_to_buffer((uint8_t *) buf);
            nvm_eeprom_atomic_write_page(address / EEPROM_PAGE_SIZE);
            address += EEPROM_PAGE_SIZE;
            buf = (uint8_t *) buf + EEPROM_PAGE_SIZE;
            len -= EEPROM_PAGE_SIZE;
        } else {
            nvm_eeprom_write_byte(address++, *(uint8_t *) buf);
            buf = (uint8_t *) buf + 1;
            len--;
        }
    }
}
void nvm_eeprom_erase_and_write_buffer ( eeprom_addr_t address , const void * buf , uint16_t len ) { while ( len ) { if ( ( ( address % EEPROM_PAGE_SIZE ) == 0 ) && ( len >= EEPROM_PAGE_SIZE ) ) { nvm_eeprom_load_page_to_buffer ( ( uint8_t * ) buf ) ; nvm_eeprom_atomic_write_page ( address / EEPROM_PAGE_SIZE ) ; address += EEPROM_PAGE_SIZE ; buf = ( uint8_t * ) buf + EEPROM_PAGE_SIZE ; len -= EEPROM_PAGE_SIZE ; } else { nvm_eeprom_write_byte ( address ++ , * ( uint8_t * ) buf ) ; buf = ( uint8_t * ) buf + 1 ; len -- ; } } }
\brief Write buffer within the eeprom
 \param address   the address to where to write
 \param buf       pointer to the data
 \param len       the number of bytes to write
\ brief Write buffer within the eeprom \ param address the address to where to write \ param buf pointer to the data \ param len the number of bytes to write
// A full page can be written