Differences from AVR / Arduino:
- It's not EEPROM, but actually Flash backed RAM under the hood.
- The maximum size defined by SPI_FLASH_SEC_SIZE = 4096, so that's likely the max EEPROM size.
- Call EEPROM.begin(size) before using.
- Call EEPROM.commit() to actually write it.
- EEPROM.read(addr) and EEPROM.write(addr, value) are RAM based, and fast.
- For my own libraries there isn't much need to duplicate the RAM storage of things like config registers in an additional uint8_t reg[size] array, but for 32 bytes it's not catastrophic.
- Stick to the standard of:
- EEPROM_init() writes hard-coded values into EEPROM and commits them.
- EEPROM_close() just calls EEPROM.end() - for now.
- EEPROM_save(len) changes the len byte and commit() writes.
- EEPROM_load() does an initial read at the default length (i.e. 32 bytes) and if the len is different, then perform an EEPROM.end() and EEPROM.begin(len) to adjust.
- Config reg array layout is:
- Byte 0: Version [0..255]
- Byte 1: Length in bytes
- Bytes [2..Length] are EEPROM written
- Bytes above Length, i.e. [32..63], are dynamic variables and used for RAM management on space constrained systems; not written to EEPROM.