I would like to encapsulate the usage of the Arduino functions EEPROM.put and EEPROM.write inside another function (which also begins and ends communication with EEPROM), so I have created these two functions:
void eeprom_save(uint addr, uint8_t *data, uint len) {
EEPROM.begin(len);
EEPROM.put(addr, *data);
EEPROM.commit();
EEPROM.end();
}
void eeprom_load(uint addr, uint8_t *data, uint len) {
EEPROM.begin(len);
EEPROM.get(addr, *data);
EEPROM.end();
}
I'm calling the functions like so:
uint8_t scale_data[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
eeprom_save(0, scale_data, sizeof(scale_data));
// ... here is some code to clear the scale_data, to read back from EEPROM ...
eeprom_load(0, scale_data, sizeof(scale_data));
As far as I could analyze, it saves the values properly to EEPROM, but reading the EEPROM with my function eeprom_load does not work (returns only 0, 0, 0, 0, 0, ...)
PS: I'm using the ESP8266 Cores EEPROM implementation.
I guess I have some trouble understanding the pointers used?
How to solve this?