From ba6ac21069705668cc83e29614e262b50038c70a Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Fri, 27 Nov 2020 16:19:01 +0100 Subject: [PATCH] configuration --- cube/User/Src/eeprom.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cube/User/Src/eeprom.c b/cube/User/Src/eeprom.c index 9f20868..d2019ad 100644 --- a/cube/User/Src/eeprom.c +++ b/cube/User/Src/eeprom.c @@ -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");