configuration
This commit is contained in:
@ -7,6 +7,8 @@
|
||||
#include <PontCoopScheduler.h>
|
||||
#include <utils.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#define HIGH GPIO_PIN_SET
|
||||
#define LOW GPIO_PIN_RESET
|
||||
|
||||
@ -48,7 +50,7 @@ static t_deviceStatsBlock deviceStats;
|
||||
static const uint8_t NUM_OF_BLOCKS = 2;
|
||||
static const uint16_t BLOCK_ADDR[] = { 64, 4128 };
|
||||
|
||||
static const uint8_t EEPROM_WRITE_BLOCK_SIZE = 32;
|
||||
#define EEPROM_WRITE_BLOCK_SIZE 32
|
||||
|
||||
|
||||
typedef union {
|
||||
@ -128,14 +130,20 @@ static void eepromHourlyUpdateDeviceStats(void *handle) {
|
||||
}
|
||||
|
||||
void eepromReadConfigBlock(uint8_t blockNum, t_configBlock *destConfigBlock) {
|
||||
uint8_t configBlockSizeMod = sizeof(*destConfigBlock) % EEPROM_WRITE_BLOCK_SIZE;
|
||||
if (configBlockSizeMod != 0) {
|
||||
coloredMsg(LOG_RED, false, "eeRCB, config block size must be dividable by 32");
|
||||
coloredMsg(LOG_RED, false, "eeRCB, current size is %d", sizeof(*destConfigBlock));
|
||||
coloredMsg(LOG_RED, false, "eeRCB, append %d filler octets", configBlockSizeMod);
|
||||
static_assert((sizeof(*destConfigBlock) % EEPROM_WRITE_BLOCK_SIZE == 0), "config block has illegal size, must be dividable by 32");
|
||||
|
||||
for (uint8_t i = 0; i < (sizeof(*destConfigBlock) / EEPROM_WRITE_BLOCK_SIZE); i++) {
|
||||
eepromRead(BLOCK_ADDR[blockNum] + (i * EEPROM_WRITE_BLOCK_SIZE), (uint8_t*) (destConfigBlock + (i * EEPROM_WRITE_BLOCK_SIZE)), EEPROM_WRITE_BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
void eepromWriteConfigBlock(uint8_t blockNum, t_configBlock *destConfigBlock) {
|
||||
for (uint8_t i = 0; i < (sizeof(*destConfigBlock) / EEPROM_WRITE_BLOCK_SIZE); i++) {
|
||||
eepromWrite(BLOCK_ADDR[blockNum] + (i * EEPROM_WRITE_BLOCK_SIZE), (uint8_t*) (destConfigBlock + (i * EEPROM_WRITE_BLOCK_SIZE)), EEPROM_WRITE_BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// active waiting, use only during initialization!
|
||||
static void eepromActiveDelay(uint8_t delay_ms) {
|
||||
activeDelay(delay_ms);
|
||||
|
Reference in New Issue
Block a user