configuration
This commit is contained in:
parent
39ca9d963b
commit
ba6ac21069
@ -51,7 +51,7 @@ static const uint8_t NUM_OF_BLOCKS = 2;
|
||||
static const uint16_t BLOCK_ADDR[] = { 64, 4128 };
|
||||
|
||||
#define EEPROM_WRITE_BLOCK_SIZE 32
|
||||
|
||||
#define EEPROM_AFTER_WRITE_DELAY 7
|
||||
|
||||
typedef union {
|
||||
struct __attribute__((__packed__)) s_spiMsg {
|
||||
@ -140,6 +140,7 @@ void eepromReadConfigBlock(uint8_t blockNum, t_configBlock *destConfigBlock) {
|
||||
void eepromWriteConfigBlock(uint8_t blockNum, t_configBlock *srcConfigBlock) {
|
||||
for (uint8_t i = 0; i < (sizeof(*srcConfigBlock) / EEPROM_WRITE_BLOCK_SIZE); i++) {
|
||||
eepromWrite(BLOCK_ADDR[blockNum] + (i * EEPROM_WRITE_BLOCK_SIZE), ((uint8_t*)srcConfigBlock) + (i * EEPROM_WRITE_BLOCK_SIZE), EEPROM_WRITE_BLOCK_SIZE);
|
||||
eepromActiveDelay(EEPROM_AFTER_WRITE_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,7 +166,7 @@ void eepromInit() {
|
||||
deviceStats.s.totalFailures = 0;
|
||||
logMsg("eeI, about to write device stats for the first time");
|
||||
eepromWrite(DEVICE_STATS_ADDR, deviceStats.b, sizeof(deviceStats));
|
||||
eepromActiveDelay(7);
|
||||
eepromActiveDelay(EEPROM_AFTER_WRITE_DELAY);
|
||||
|
||||
uint8_t emptyBlock[32];
|
||||
memset(emptyBlock, 0, sizeof(emptyBlock));
|
||||
@ -173,7 +174,7 @@ void eepromInit() {
|
||||
for (uint8_t j = 0; j <= 127; j++) {
|
||||
uint16_t addr = BLOCK_ADDR[i] + sizeof(emptyBlock) * j;
|
||||
eepromWrite(addr, emptyBlock, sizeof(emptyBlock));
|
||||
eepromActiveDelay(7);
|
||||
eepromActiveDelay(EEPROM_AFTER_WRITE_DELAY);
|
||||
}
|
||||
}
|
||||
logMsg("eeI, storage blocks initialized");
|
||||
@ -184,7 +185,7 @@ void eepromInit() {
|
||||
eepromHeader.s.writeCounter = 1;
|
||||
logMsg("eeI, about to write header for the first time");
|
||||
eepromWrite(EEPROM_HEADER_ADDR, eepromHeader.b, sizeof(eepromHeader));
|
||||
eepromActiveDelay(7);
|
||||
eepromActiveDelay(EEPROM_AFTER_WRITE_DELAY);
|
||||
logMsg("eeI, eeprom has been initialized");
|
||||
} else {
|
||||
logMsg("eeI, eeprom is initialized");
|
||||
@ -200,7 +201,7 @@ void eepromInit() {
|
||||
deviceStats.s.totalPowercycles += 1;
|
||||
logMsg("eeI, about to write device stats with updated power cycles counter");
|
||||
eepromWrite(DEVICE_STATS_ADDR, deviceStats.b, sizeof(deviceStats));
|
||||
eepromActiveDelay(7);
|
||||
eepromActiveDelay(EEPROM_AFTER_WRITE_DELAY);
|
||||
|
||||
schAdd(eepromHourlyUpdateDeviceStats, NULL, 0, 60 * 60 * 1000);
|
||||
logMsg("eeI, hourly device stats update scheduled");
|
||||
|
Loading…
x
Reference in New Issue
Block a user