CHGame 0.3.0
Libraries for the CHGame handheld
Loading...
Searching...
No Matches

The Arduino EEPROM API over the option-byte area, for the CH32V003. More...

Classes

class  EEPROMClass
 26 bytes of emulated EEPROM in the option-byte area, worked on in a RAM copy and written by commit() (see EEPROM). More...
 

Variables

EEPROMClass EEPROM
 The emulated EEPROM.
 

Detailed Description

The Arduino EEPROM API over the option-byte area, for the CH32V003.

On the CHGame board (CH32X035) it does not save: commit() writes nothing and returns false.

Note
Saving on the CHGame board? Use the CHGame library's save:: functions: a CRC-checked record of up to 244 bytes in the top two pages of the application flash, shared by every game (each tells its records apart by its own magic), which survives power cuts and re-uploads.

What the library does on the chip it was written for, the CH32V003:

On the CH32X035 that commit() is switched off, and a sketch that includes this header gets a compiler message saying so. The chip's option-byte block is the 16 bytes alone, and WCH's CH32X035 library programs it only as one fast-programmed page, never a half-word at a time as above. A write that did not take after the erase would leave the chip read-protected (removing that with the factory ISP erases the whole flash, bootloader included) or with its user options changed (on this board they keep PB7, SELECT, from being the reset pin). So on this chip begin() reads Data0 and Data1 and sets bytes 2-25 to 0xFF, everything works on the RAM copy as usual, and commit() returns false without writing. Nothing survives a reset.

Variable Documentation

◆ EEPROM

EEPROMClass EEPROM
extern

The emulated EEPROM.

Call EEPROM.begin() first.