|
|
|
@ -32,6 +32,7 @@
|
|
|
|
|
#if ENABLED(SDCARD_EEPROM_EMULATION)
|
|
|
|
|
|
|
|
|
|
#include "../shared/eeprom_api.h"
|
|
|
|
|
#include "../../sd/cardreader.h"
|
|
|
|
|
|
|
|
|
|
#ifndef E2END
|
|
|
|
|
#define E2END 0xFFF // 4KB
|
|
|
|
@ -41,13 +42,9 @@
|
|
|
|
|
#define _ALIGN(x) __attribute__ ((aligned(x))) // SDIO uint32_t* compat.
|
|
|
|
|
static char _ALIGN(4) HAL_eeprom_data[HAL_EEPROM_SIZE];
|
|
|
|
|
|
|
|
|
|
#if ENABLED(SDSUPPORT)
|
|
|
|
|
#define EEPROM_FILENAME "eeprom.dat"
|
|
|
|
|
|
|
|
|
|
#include "../../sd/cardreader.h"
|
|
|
|
|
|
|
|
|
|
#define EEPROM_FILENAME "eeprom.dat"
|
|
|
|
|
|
|
|
|
|
bool PersistentStore::access_start() {
|
|
|
|
|
bool PersistentStore::access_start() {
|
|
|
|
|
if (!card.isMounted()) return false;
|
|
|
|
|
|
|
|
|
|
SdFile file, root = card.getroot();
|
|
|
|
@ -60,9 +57,9 @@ static char _ALIGN(4) HAL_eeprom_data[HAL_EEPROM_SIZE];
|
|
|
|
|
HAL_eeprom_data[bytes_read] = 0xFF;
|
|
|
|
|
file.close();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool PersistentStore::access_finish() {
|
|
|
|
|
bool PersistentStore::access_finish() {
|
|
|
|
|
if (!card.isMounted()) return false;
|
|
|
|
|
|
|
|
|
|
SdFile file, root = card.getroot();
|
|
|
|
@ -72,13 +69,7 @@ static char _ALIGN(4) HAL_eeprom_data[HAL_EEPROM_SIZE];
|
|
|
|
|
file.close();
|
|
|
|
|
}
|
|
|
|
|
return (bytes_written == HAL_EEPROM_SIZE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#else // !SDSUPPORT
|
|
|
|
|
|
|
|
|
|
#error "Please define SPI_EEPROM (in Configuration.h) or disable EEPROM_SETTINGS."
|
|
|
|
|
|
|
|
|
|
#endif // !SDSUPPORT
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
|
|
|
|
|
for (size_t i = 0; i < size; i++)
|
|
|
|
|