summaryrefslogtreecommitdiff
path: root/EEPROM_IO.h
blob: 1c59780f6b94b0262fc1494b206e89fa051ef681 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <Arduino.h>


/*********************************************************************************/
/* EEPROM read/write functions                                                   */

template <class T> int eepromWrite(int ee, const T& value) {
    const byte* p = (const byte*)(const void*)&value;
    unsigned int i;
    for (i = 0; i < sizeof(value); i++)
	  EEPROM.write(ee++, *p++);
    return i;
}


template <class T> int eepromRead(int ee, T& value) {
    byte* p = (byte*)(void*)&value;
    unsigned int i;
    for (i = 0; i < sizeof(value); i++)
	  *p++ = EEPROM.read(ee++);
    return i;
}