Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If no ENABLE_EEPROM_SETTINGS is used in MakeFile, a 0 byte eeprom is generated #149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Firmware/Chameleon-Mini/Log.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ static uint8_t LogMem[LOG_SIZE];
static uint8_t *LogMemPtr;
static uint16_t LogMemLeft;
static uint16_t LogFRAMAddr = FRAM_LOG_START_ADDR;
static uint8_t EEMEM LogFRAMAddrValid = false;
#if ENABLE_EEPROM_SETTINGS
static uint8_t EEMEM LogFRAMAddrValid = false;
#else
static uint8_t LogFRAMAddrValid = false;
#endif
static bool EnableLogSRAMtoFRAM = false;
LogFuncType CurrentLogFunc;

Expand Down Expand Up @@ -67,19 +71,24 @@ void LogInit(void)
LogMemPtr = LogMem;
LogMemLeft = sizeof(LogMem);

#if ENABLE_EEPROM_SETTINGS
uint8_t result;
ReadEEPBlock((uint16_t) &LogFRAMAddrValid, &result, 1);
#endif
memset(LogMemPtr, LOG_EMPTY, LOG_SIZE);
#if ENABLE_EEPROM_SETTINGS
if (result)
{
MemoryReadBlock(&LogFRAMAddr, FRAM_LOG_ADDR_ADDR, 2);
} else {
#endif
LogFRAMAddr = FRAM_LOG_START_ADDR;
MemoryWriteBlock(&LogFRAMAddr, FRAM_LOG_ADDR_ADDR, 2);
#if ENABLE_EEPROM_SETTINGS
result = true;
WriteEEPBlock((uint16_t) &LogFRAMAddrValid, &result, 1);
}

#endif
LogEntry(LOG_INFO_SYSTEM_BOOT, NULL, 0);
}

Expand Down
8 changes: 8 additions & 0 deletions Firmware/Chameleon-Mini/Settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
#define INDEX_TO_SETTING(I) (I + SETTINGS_FIRST)

SettingsType GlobalSettings;
#if ENABLE_EEPROM_SETTINGS
SettingsType EEMEM StoredSettings = {
#else
SettingsType StoredSettings = {
#endif
.ActiveSettingIdx = SETTING_TO_INDEX(DEFAULT_SETTING),
.ActiveSettingPtr = &GlobalSettings.Settings[SETTING_TO_INDEX(DEFAULT_SETTING)],

Expand All @@ -30,7 +34,11 @@ SettingsType EEMEM StoredSettings = {
};

void SettingsLoad(void) {
#if ENABLE_EEPROM_SETTINGS
ReadEEPBlock((uint16_t) &StoredSettings, &GlobalSettings, sizeof(SettingsType));
#else
GlobalSettings = StoredSettings;
#endif
}

void SettingsSave(void) {
Expand Down