Chapter 3

EEPROM

This module provides “gentle” EEPROM writing routines to help extend the life of the on-chip EEPROM. Before each EEPROM data byte is written, these functions read the byte from the EEPROM and only write the new byte if the values are different.

3.1  Usage

To use the EEPROM writing functions, use this:

  #include <eeprom-gentle.h>

3.2  Functions

void gentle_eeprom_write_byte(uint8_t *addr, uint8_t val)   function

Writes a single byte val to EEPROM address addr, but only if the byte in the EEPROM is different.

void gentle_eeprom_write_word(uint16_t *addr, uint16_t val)   function

Writes the bytes of a single 16 bit word val to EEPROM address addr, but only the bytes that are different than what is currently found in the EEPROM.

void gentle_eeprom_write_dword(uint16_t *addr, uint32_t val)   function

Writes the bytes of a single 32 bit word val to EEPROM address addr, but only the bytes that are different than what is currently found in the EEPROM.

void gentle_eeprom_write_block(const void *buf, void *addr, size_t n)   function

Writes n bytes of the block pointed to by buf to EEPROM address addr, but only the bytes that are different than what is currently found in the EEPROM.