82#if defined(CH32X035) && !defined(EEPROM_NO_WARNING)
83#pragma message "EEPROM does not save on the CH32X035 (the CHGame board): commit() writes nothing and returns false. Save with the CHGame library's save:: (CHGame.h). Define EEPROM_NO_WARNING to silence this."
95#define CR_OPTPG_Set ((uint32_t)0x00000010)
96#define CR_OPTPG_Reset ((uint32_t)0xFFFFFFEF)
97#define CR_OPTER_Set ((uint32_t)0x00000020)
98#define CR_OPTER_Reset ((uint32_t)0xFFFFFFDF)
99#define CR_STRT_Set ((uint32_t)0x00000040)
100#define CR_LOCK_Set ((uint32_t)0x00000080)
108#define FLASH_KEY1 ((uint32_t)0x45670123)
109#define FLASH_KEY2 ((uint32_t)0xCDEF89AB)
168 void write(
int const idx, uint8_t
const val);
200 T &
get(
int const address, T &t) {
201 if (address < 0 || address +
sizeof(T) >
_size)
203 memcpy((uint8_t*) &t,
_data + address,
sizeof(T));
216 const T &
put(
int const address,
const T &t) {
217 if (address < 0 || address +
sizeof(T) >
_size)
219 if (memcmp(
_data + address, (
const uint8_t*)&t,
sizeof(T)) != 0) {
221 memcpy(
_data + address, (
const uint8_t*)&t,
sizeof(T));
255#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_EEPROM)
26 bytes of emulated EEPROM in the option-byte area, worked on in a RAM copy and written by commit() ...
Definition EEPROM.h:117
bool end(void)
Commits, then forgets the RAM copy (its 26 bytes are not freed); begin() starts again.
void write(int const idx, uint8_t const val)
Changes a byte of the RAM copy; commit() writes it.
uint32_t ReadOptionBytes(void)
Reads the option bytes Data0 and Data1 straight from the chip (no begin() needed).
uint8_t & operator[](int const address)
A byte of the RAM copy, to read or change; marks the copy changed.
Definition EEPROM.h:238
EEPROMClass(void)
Makes the object; nothing is read until begin().
uint8_t const * getConstDataPtr() const
The 26-byte RAM copy, read-only.
~EEPROMClass(void)
Calls end(), which commits any change.
uint8_t const & operator[](int const address) const
A byte of the RAM copy, read-only.
Definition EEPROM.h:244
void begin(void)
Copies the 26 bytes from the option-byte area into RAM (26 bytes on the heap, allocated the first tim...
size_t length()
The emulated EEPROM's size.
Definition EEPROM.h:230
size_t _size
The copy's size: 26 after begin(), else 0.
Definition EEPROM.h:252
uint8_t read(int const idx)
Reads a byte of the RAM copy.
bool commit(void)
Writes the RAM copy to the option-byte area, if anything changed since begin() or the last commit().
void erase(void)
Sets the 26 bytes of the RAM copy to 0xFF; commit() writes them.
T & get(int const address, T &t)
Copies sizeof(T) bytes of the RAM copy into t.
Definition EEPROM.h:200
const T & put(int const address, const T &t)
Copies t into the RAM copy, if it differs; commit() writes it.
Definition EEPROM.h:216
uint8_t * getDataPtr()
The 26-byte RAM copy, to change in place; marks it changed, so the next commit() writes it.
bool _dirty
Whether the copy changed since begin() or the last commit().
Definition EEPROM.h:250
uint8_t * _data
The RAM copy (26 bytes after begin()).
Definition EEPROM.h:248
EEPROMClass EEPROM
The emulated EEPROM.