26#error "EEPROM library is NOT supported by SubCore." 
   41#define EEPROM_EMU "/mnt/spif/eeprom.emu" 
   57    EERef( 
const int index )
 
   61    uint8_t operator*() 
const;
 
   62    void createInitialFile() 
const;
 
   63    operator uint8_t()
 const             { 
return **
this; }
 
   66    EERef &operator=( 
const EERef &ref ) { 
return *
this = *ref; }
 
   67    EERef &operator=( uint8_t in );
 
   68    EERef &operator +=( uint8_t in )     { 
return *
this = **
this + in; }
 
   69    EERef &operator -=( uint8_t in )     { 
return *
this = **
this - in; }
 
   70    EERef &operator *=( uint8_t in )     { 
return *
this = **
this * in; }
 
   71    EERef &operator /=( uint8_t in )     { 
return *
this = **
this / in; }
 
   72    EERef &operator ^=( uint8_t in )     { 
return *
this = **
this ^ in; }
 
   73    EERef &operator %=( uint8_t in )     { 
return *
this = **
this % in; }
 
   74    EERef &operator &=( uint8_t in )     { 
return *
this = **
this & in; }
 
   75    EERef &operator |=( uint8_t in )     { 
return *
this = **
this | in; }
 
   76    EERef &operator <<=( uint8_t in )    { 
return *
this = **
this << in; }
 
   77    EERef &operator >>=( uint8_t in )    { 
return *
this = **
this >> in; }
 
   79    EERef &update( uint8_t in )          { 
return  in != *
this ? *
this = in : *
this; }
 
   83    EERef& operator--()                  { 
return *
this -= 1; }
 
   88        return ++(*this), ret;
 
   91    uint8_t operator-- (
int){ 
 
   93        return --(*this), ret;
 
  109    EEPtr( 
const int index )
 
  112    operator int()
 const                { 
return index; }
 
  113    EEPtr &operator=( 
int in )          { 
return index = in, *
this; }
 
  116    bool operator!=( 
const EEPtr &ptr ) { 
return index != ptr.index; }
 
  117    EERef operator*()                   { 
return index; }
 
  121    EEPtr& operator--()                 { 
return --index, *
this; }
 
  123    EEPtr operator-- (
int)              { 
return index--; }
 
  145        long eepromsize = E2END;
 
  147        if (initialized != 0) {
 
  153        if (0 == stat(EEPROM_EMU, &statBuf)) {
 
  154            filesize = statBuf.st_size;
 
  157        if (eepromsize == filesize) {
 
  164        if ((fp = fopen(EEPROM_EMU, 
"wb")) == NULL) {
 
  165            printf(
"ERROR: eeprom open failure\n");
 
  168        uint8_t *ptr = (uint8_t*)zalloc(eepromsize);
 
  169        ret = fwrite(ptr, 1, eepromsize, fp);
 
  170        if (ret != eepromsize) {
 
  171            printf(
"ERROR: eeprom init failure (%d)\n", ret);
 
  187    EERef operator[]( 
const int idx )    { init(); 
return idx; }
 
  188    uint8_t read( 
int idx )              { init(); 
return EERef( idx ); }
 
  189    void write( 
int idx, uint8_t val )   { init(); (
EERef( idx )) = val; }
 
  190    void update( 
int idx, uint8_t val )  { init(); 
EERef( idx ).update( val ); }
 
  193    EEPtr begin()                        { 
return 0x00; }
 
  194    EEPtr end()                          { 
return length(); } 
 
  195    uint16_t length()                    { 
return E2END; }
 
  198    template< 
typename T > T &get( 
int idx, T &t ){
 
  204        if ((fp = fopen(EEPROM_EMU, 
"rb")) == NULL) {
 
  205            printf(
"ERROR: eeprom open failure\n");
 
  209        ret = fseek(fp, idx, SEEK_SET);
 
  211            printf(
"ERROR: eeprom seek failure\n");
 
  212            goto errout_with_close;
 
  215        ret = fread((uint8_t*)&t, 1, 
sizeof(T), fp);
 
  216        if (ret != 
sizeof(T)) {
 
  217            printf(
"ERROR: eeprom read failure (%d)\n", ret);
 
  226    template< 
typename T > 
const T &put( 
int idx, 
const T &t ){
 
  232        if ((fp = fopen(EEPROM_EMU, 
"rb+")) == NULL) {
 
  233            printf(
"ERROR: eeprom open failure\n");
 
  237        ret = fseek(fp, idx, SEEK_SET);
 
  239            printf(
"ERROR: eeprom seek failure\n");
 
  240            goto errout_with_close;
 
  243        ret = fwrite((uint8_t*)&t, 1, 
sizeof(T), fp);
 
  244        if (ret != 
sizeof(T)) {
 
  245            printf(
"ERROR: eeprom write failure (%d)\n", ret);
 
EEPtr & operator++()
Definition: EEPROM.h:120
 
EERef & operator++()
Definition: EEPROM.h:82