1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-25 17:25:18 +03:00

Removed profile storage code from writeEEProm() to remove the boolean

flag from the method signature.  Now it is clear when the current
profile needs to be stored.
This commit is contained in:
Dominic Clifton 2014-04-21 01:02:53 +01:00
parent e969d184e6
commit 3daaf66b14
7 changed files with 28 additions and 20 deletions

View file

@ -93,7 +93,13 @@ void readEEPROM(void)
}
void writeEEPROM(uint8_t b, uint8_t updateProfile)
void copyCurrentProfileToProfileSlot(uint8_t profileSlotIndex)
{
// copy current in-memory profile to stored configuration
memcpy(&mcfg.profile[profileSlotIndex], &cfg, sizeof(config_t));
}
void writeEEPROM(uint8_t b)
{
FLASH_Status status;
uint32_t i;
@ -108,12 +114,6 @@ void writeEEPROM(uint8_t b, uint8_t updateProfile)
mcfg.magic_ef = 0xEF;
mcfg.chk = 0;
// when updateProfile = true, we copy contents of cfg to global configuration. when false, only profile number is updated, and then that profile is loaded on readEEPROM()
if (updateProfile) {
// copy current in-memory profile to stored configuration
memcpy(&mcfg.profile[mcfg.current_profile], &cfg, sizeof(config_t));
}
// recalculate checksum before writing
for (p = (const uint8_t *)&mcfg; p < ((const uint8_t *)&mcfg + sizeof(master_t)); p++)
chk ^= *p;
@ -155,8 +155,7 @@ void checkFirstTime(bool reset)
// check the EEPROM integrity before resetting values
if (!validEEPROM() || reset) {
resetConf();
// no need to memcpy profile again, we just did it in resetConf() above
writeEEPROM(0, false);
writeEEPROM(0);
}
}