auto-sync
This commit is contained in:
parent
dd3a950158
commit
5c2cae9b0f
|
@ -73,8 +73,7 @@ void registerActuatorEventExt(engine_configuration_s const *engineConfiguration,
|
|||
|
||||
void resetConfigurationExt(Logging * logger, engine_type_e engineType,
|
||||
engine_configuration_s *engineConfiguration,
|
||||
engine_configuration2_s *engineConfiguration2,
|
||||
board_configuration_s *boardConfiguration);
|
||||
engine_configuration2_s *engineConfiguration2);
|
||||
void applyNonPersistentConfiguration(Logging * logger, engine_configuration_s *engineConfiguration,
|
||||
engine_configuration2_s *engineConfiguration2);
|
||||
|
||||
|
|
|
@ -377,12 +377,11 @@ void setDefaultConfiguration(engine_configuration_s *engineConfiguration, board_
|
|||
boardConfiguration->isSdCardEnabled = false;
|
||||
boardConfiguration->isFastAdcEnabled = true;
|
||||
boardConfiguration->isEngineControlEnabled = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void resetConfigurationExt(Logging * logger, engine_type_e engineType, engine_configuration_s *engineConfiguration,
|
||||
engine_configuration2_s *engineConfiguration2, board_configuration_s *boardConfiguration) {
|
||||
engine_configuration2_s *engineConfiguration2) {
|
||||
board_configuration_s *boardConfiguration = &engineConfiguration->bc;
|
||||
/**
|
||||
* Let's apply global defaults first
|
||||
*/
|
||||
|
|
|
@ -78,11 +78,7 @@ void writeToFlash(void) {
|
|||
#endif /* EFI_INTERNAL_FLASH */
|
||||
}
|
||||
|
||||
static int isValidCrc(persistent_config_container_s *state) {
|
||||
if (state->version != FLASH_DATA_VERSION) {
|
||||
scheduleMsg(&logger, "Unexpected flash version: %d", state->version);
|
||||
return FALSE;
|
||||
}
|
||||
static bool isValidCrc(persistent_config_container_s *state) {
|
||||
crc_t result = flashStateCrc(state);
|
||||
int isValidCrc_b = result == state->value;
|
||||
if (!isValidCrc_b) {
|
||||
|
@ -92,8 +88,7 @@ static int isValidCrc(persistent_config_container_s *state) {
|
|||
}
|
||||
|
||||
static void doResetConfiguration(void) {
|
||||
resetConfigurationExt(&logger, engineConfiguration->engineType, engineConfiguration, engineConfiguration2,
|
||||
boardConfiguration);
|
||||
resetConfigurationExt(&logger, engineConfiguration->engineType, engineConfiguration, engineConfiguration2);
|
||||
}
|
||||
|
||||
void readFromFlash(void) {
|
||||
|
@ -104,9 +99,12 @@ void readFromFlash(void) {
|
|||
//setDefaultNonPersistentConfiguration(engineConfiguration2);
|
||||
|
||||
if (!isValidCrc(&persistentState) || persistentState.size != PERSISTENT_SIZE) {
|
||||
printMsg(&logger, "Need to reset flash to default");
|
||||
resetConfigurationExt(&logger, defaultEngineType, engineConfiguration, engineConfiguration2,
|
||||
boardConfiguration);
|
||||
printMsg(&logger, "Need to reset flash to default due to CRC");
|
||||
resetConfigurationExt(&logger, defaultEngineType, engineConfiguration, engineConfiguration2);
|
||||
} else if (persistentState.version != FLASH_DATA_VERSION) {
|
||||
printMsg(&logger, "Need to reset flash to default due to version change");
|
||||
resetConfigurationExt(&logger, defaultEngineType, engineConfiguration, engineConfiguration2);
|
||||
|
||||
} else {
|
||||
printMsg(&logger, "Got valid configuration from flash!");
|
||||
applyNonPersistentConfiguration(&logger, engineConfiguration, engineConfiguration2);
|
||||
|
|
|
@ -180,8 +180,7 @@ static void setIdleMode(int mode) {
|
|||
|
||||
void setEngineType(int value) {
|
||||
engineConfiguration->engineType = (engine_type_e) value;
|
||||
resetConfigurationExt(&logger, (engine_type_e) value, engineConfiguration, engineConfiguration2,
|
||||
boardConfiguration);
|
||||
resetConfigurationExt(&logger, (engine_type_e) value, engineConfiguration, engineConfiguration2);
|
||||
#if EFI_INTERNAL_FLASH
|
||||
writeToFlash();
|
||||
// scheduleReset();
|
||||
|
|
|
@ -173,8 +173,7 @@ void initHardware(Logging *logger, Engine *engine) {
|
|||
*/
|
||||
if (SHOULD_INGORE_FLASH()) {
|
||||
engineConfiguration->engineType = FORD_ASPIRE_1996;
|
||||
resetConfigurationExt(logger, engineConfiguration->engineType, engineConfiguration, engineConfiguration2,
|
||||
boardConfiguration);
|
||||
resetConfigurationExt(logger, engineConfiguration->engineType, engineConfiguration, engineConfiguration2);
|
||||
writeToFlash();
|
||||
} else {
|
||||
readFromFlash();
|
||||
|
|
Loading…
Reference in New Issue