auto-sync
This commit is contained in:
parent
d6ff30e894
commit
7b046bdadd
|
@ -53,7 +53,7 @@ void Engine::addConfigurationListener(configuration_callback_t callback) {
|
|||
configurationListeners.registerCallback((VoidInt)invokeEnginePreCalculate, this);
|
||||
}
|
||||
|
||||
Engine::Engine() {
|
||||
Engine::Engine(persistent_config_s *config) {
|
||||
lastTriggerEventTimeNt = 0;
|
||||
isCylinderCleanupMode = false;
|
||||
engineCycleEventCount = 0;
|
||||
|
@ -62,7 +62,7 @@ Engine::Engine() {
|
|||
isTestMode = false;
|
||||
isSpinning = false;
|
||||
adcToVoltageInputDividerCoefficient = NAN;
|
||||
engineConfiguration = NULL;
|
||||
engineConfiguration = &config->engineConfiguration;
|
||||
engineConfiguration2 = NULL;
|
||||
engineState.iat = engineState.clt = NAN;
|
||||
memset(&ignitionPin, 0, sizeof(ignitionPin));
|
||||
|
|
|
@ -118,7 +118,7 @@ typedef void (*configuration_callback_t)(Engine*);
|
|||
|
||||
class Engine {
|
||||
public:
|
||||
Engine();
|
||||
Engine(persistent_config_s *config);
|
||||
void init();
|
||||
RpmCalculator rpmCalculator;
|
||||
engine_configuration_s *engineConfiguration;
|
||||
|
@ -249,9 +249,9 @@ private:
|
|||
void setPumpsCounter(engine_configuration_s *engineConfiguration, int newValue);
|
||||
};
|
||||
|
||||
void prepareShapes(Engine *engine);
|
||||
void prepareShapes(DECLARE_ENGINE_PARAMETER_F);
|
||||
void resetConfigurationExt(Logging * logger, engine_type_e engineType DECLARE_ENGINE_PARAMETER_S);
|
||||
void applyNonPersistentConfiguration(Logging * logger, Engine *engine);
|
||||
void applyNonPersistentConfiguration(Logging * logger DECLARE_ENGINE_PARAMETER_S);
|
||||
void prepareOutputSignals(DECLARE_ENGINE_PARAMETER_F);
|
||||
|
||||
#endif /* ENGINE_H_ */
|
||||
|
|
|
@ -652,7 +652,7 @@ void resetConfigurationExt(Logging * logger, engine_type_e engineType DECLARE_EN
|
|||
default:
|
||||
firmwareError("Unexpected engine type: %d", engineType);
|
||||
}
|
||||
applyNonPersistentConfiguration(logger, engine);
|
||||
applyNonPersistentConfiguration(logger PASS_ENGINE_PARAMETER);
|
||||
|
||||
#if EFI_TUNER_STUDIO
|
||||
syncTunerStudioCopy();
|
||||
|
@ -662,8 +662,8 @@ void resetConfigurationExt(Logging * logger, engine_type_e engineType DECLARE_EN
|
|||
engine_configuration2_s::engine_configuration2_s() {
|
||||
}
|
||||
|
||||
void applyNonPersistentConfiguration(Logging * logger, Engine *engine) {
|
||||
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
|
||||
void applyNonPersistentConfiguration(Logging * logger DECLARE_ENGINE_PARAMETER_S) {
|
||||
|
||||
// todo: this would require 'initThermistors() to re-establish a reference, todo: fix
|
||||
// memset(engineConfiguration2, 0, sizeof(engine_configuration2_s));
|
||||
#if EFI_PROD_CODE
|
||||
|
@ -688,8 +688,7 @@ void applyNonPersistentConfiguration(Logging * logger, Engine *engine) {
|
|||
|
||||
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
|
||||
|
||||
void prepareShapes(Engine *engine) {
|
||||
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
|
||||
void prepareShapes(DECLARE_ENGINE_PARAMETER_F) {
|
||||
engine_configuration2_s *engineConfiguration2 = engine->engineConfiguration2;
|
||||
prepareOutputSignals(PASS_ENGINE_PARAMETER_F);
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ float getRealMafFuel(float airSpeed, int rpm DECLARE_ENGINE_PARAMETER_S) {
|
|||
|
||||
float getBaseFuel(int rpm DECLARE_ENGINE_PARAMETER_S) {
|
||||
if (engineConfiguration->algorithm == LM_SPEED_DENSITY) {
|
||||
return getSpeedDensityFuel(engine, rpm);
|
||||
return getSpeedDensityFuel(rpm PASS_ENGINE_PARAMETER);
|
||||
} else if (engineConfiguration->algorithm == LM_REAL_MAF) {
|
||||
return getRealMafFuel(getRealMaf(PASS_ENGINE_PARAMETER_F), rpm PASS_ENGINE_PARAMETER);
|
||||
} else {
|
||||
|
@ -117,7 +117,7 @@ float getFuelMs(int rpm DECLARE_ENGINE_PARAMETER_S) {
|
|||
float baseFuel = getBaseFuel(rpm PASS_ENGINE_PARAMETER);
|
||||
float fuelPerCycle = getRunningFuel(baseFuel, rpm PASS_ENGINE_PARAMETER);
|
||||
theoreticalInjectionLength = fuelPerCycle
|
||||
/ getNumberOfInjections(engineConfiguration, engine->engineConfiguration->injectionMode);
|
||||
/ getNumberOfInjections(engineConfiguration, engineConfiguration->injectionMode);
|
||||
}
|
||||
return theoreticalInjectionLength + ENGINE(injectorLagMs);
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ float getBaseTableFuel(engine_configuration_s *engineConfiguration, int rpm, flo
|
|||
* @return Duration of fuel injection while craning, in milliseconds
|
||||
*/
|
||||
float getCrankingFuel(DECLARE_ENGINE_PARAMETER_F) {
|
||||
return getCrankingFuel3(engine->engineConfiguration, getCoolantTemperature(PASS_ENGINE_PARAMETER_F),
|
||||
return getCrankingFuel3(engineConfiguration, getCoolantTemperature(PASS_ENGINE_PARAMETER_F),
|
||||
engine->rpmCalculator.getRevolutionCounterSinceStart());
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -92,7 +92,7 @@ engine_configuration2_s * engineConfiguration2 = &ec2;
|
|||
/**
|
||||
* todo: this should probably become 'static', i.e. private, and propagated around explicitly?
|
||||
*/
|
||||
Engine _engine;
|
||||
Engine _engine(&persistentState.persistentConfiguration);
|
||||
Engine * engine = &_engine;
|
||||
#endif
|
||||
|
||||
|
@ -322,7 +322,7 @@ static THD_WORKING_AREA(csThreadStack, UTILITY_THREAD_STACK_SIZE); // declare th
|
|||
static void getShort(int offset) {
|
||||
if (isOutOfBounds(offset))
|
||||
return;
|
||||
uint16_t *ptr = (uint16_t *) (&((char *) engine->engineConfiguration)[offset]);
|
||||
uint16_t *ptr = (uint16_t *) (&((char *) engineConfiguration)[offset]);
|
||||
uint16_t value = *ptr;
|
||||
/**
|
||||
* this response is part of dev console API
|
||||
|
@ -333,7 +333,7 @@ static void getShort(int offset) {
|
|||
static void setShort(const int offset, const int value) {
|
||||
if (isOutOfBounds(offset))
|
||||
return;
|
||||
uint16_t *ptr = (uint16_t *) (&((char *) engine->engineConfiguration)[offset]);
|
||||
uint16_t *ptr = (uint16_t *) (&((char *) engineConfiguration)[offset]);
|
||||
*ptr = (uint16_t) value;
|
||||
getShort(offset);
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ static void setShort(const int offset, const int value) {
|
|||
static void getInt(int offset) {
|
||||
if (isOutOfBounds(offset))
|
||||
return;
|
||||
int *ptr = (int *) (&((char *) engine->engineConfiguration)[offset]);
|
||||
int *ptr = (int *) (&((char *) engineConfiguration)[offset]);
|
||||
int value = *ptr;
|
||||
/**
|
||||
* this response is part of dev console API
|
||||
|
@ -352,7 +352,7 @@ static void getInt(int offset) {
|
|||
static void setInt(const int offset, const int value) {
|
||||
if (isOutOfBounds(offset))
|
||||
return;
|
||||
int *ptr = (int *) (&((char *) engine->engineConfiguration)[offset]);
|
||||
int *ptr = (int *) (&((char *) engineConfiguration)[offset]);
|
||||
*ptr = value;
|
||||
getInt(offset);
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ static void setInt(const int offset, const int value) {
|
|||
static void getFloat(int offset) {
|
||||
if (isOutOfBounds(offset))
|
||||
return;
|
||||
float *ptr = (float *) (&((char *) engine->engineConfiguration)[offset]);
|
||||
float *ptr = (float *) (&((char *) engineConfiguration)[offset]);
|
||||
float value = *ptr;
|
||||
/**
|
||||
* this response is part of dev console API
|
||||
|
@ -451,7 +451,7 @@ void initEngineContoller(Logging *sharedLogger, Engine *engine) {
|
|||
* This has to go after 'initInjectorCentral' and 'initInjectorCentral' in order to
|
||||
* properly detect un-assigned output pins
|
||||
*/
|
||||
prepareShapes(engine);
|
||||
prepareShapes(PASS_ENGINE_PARAMETER_F);
|
||||
#endif
|
||||
|
||||
#if EFI_PWM_TESTER || defined(__DOXYGEN__)
|
||||
|
|
|
@ -109,7 +109,7 @@ void readFromFlash(void) {
|
|||
resetConfigurationExt(logger, DEFAULT_ENGINE_TYPE PASS_ENGINE_PARAMETER);
|
||||
} else if (persistentState.version == FLASH_DATA_VERSION && persistentState.size == PERSISTENT_SIZE) {
|
||||
printMsg(logger, "Got valid configuration from flash!");
|
||||
applyNonPersistentConfiguration(logger, engine);
|
||||
applyNonPersistentConfiguration(logger PASS_ENGINE_PARAMETER);
|
||||
} else if (hasValidEngineType(engineConfiguration)) {
|
||||
printMsg(logger, "Resetting but saving engine type [%d]", engineConfiguration->engineType);
|
||||
resetConfigurationExt(logger, engineConfiguration->engineType PASS_ENGINE_PARAMETER);
|
||||
|
|
|
@ -195,7 +195,7 @@ static void showLine(lcd_line_e line) {
|
|||
lcdPrintf("version %s", VCS_VERSION);
|
||||
return;
|
||||
case LL_CONFIG:
|
||||
lcdPrintf("config %s", getConfigurationName(engine->engineConfiguration->engineType));
|
||||
lcdPrintf("config %s", getConfigurationName(engineConfiguration->engineType));
|
||||
return;
|
||||
case LL_RPM:
|
||||
lcdPrintf("RPM %d", getRpmE(engine));
|
||||
|
|
|
@ -73,14 +73,14 @@ float sdMath(engine_configuration_s *engineConfiguration, float VE, float MAP, f
|
|||
return airMass / (AFR * injectorFlowRate);
|
||||
}
|
||||
|
||||
EXTERN_ENGINE;
|
||||
|
||||
/**
|
||||
* @return per cylinder injection time, in Milliseconds
|
||||
*/
|
||||
float getSpeedDensityFuel(Engine *engine, int rpm) {
|
||||
float getSpeedDensityFuel(int rpm DECLARE_ENGINE_PARAMETER_S) {
|
||||
//int rpm = engine->rpmCalculator->rpm();
|
||||
|
||||
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
|
||||
|
||||
float tps = getTPS(PASS_ENGINE_PARAMETER_F);
|
||||
float coolantC = engine->engineState.clt;
|
||||
float intakeC = engine->engineState.iat;
|
||||
|
@ -89,7 +89,7 @@ float getSpeedDensityFuel(Engine *engine, int rpm) {
|
|||
float VE = veMap.getValue(map, rpm);
|
||||
float AFR = afrMap.getValue(map, rpm);
|
||||
|
||||
return sdMath(engine->engineConfiguration, VE, map, AFR, tChargeK) * 1000;
|
||||
return sdMath(engineConfiguration, VE, map, AFR, tChargeK) * 1000;
|
||||
}
|
||||
|
||||
void setDetaultVETable(engine_configuration_s *engineConfiguration) {
|
||||
|
|
|
@ -19,6 +19,6 @@ float sdMath(engine_configuration_s *engineConfiguration, float VE, float MAP, f
|
|||
|
||||
void setDetaultVETable(engine_configuration_s *engineConfiguration);
|
||||
void initSpeedDensity(engine_configuration_s *engineConfiguration);
|
||||
float getSpeedDensityFuel(Engine *engine, int rpm);
|
||||
float getSpeedDensityFuel(int rpm DECLARE_ENGINE_PARAMETER_S);
|
||||
|
||||
#endif /* SPEED_DENSITY_H_ */
|
||||
|
|
|
@ -64,8 +64,8 @@ float decodePressure(float voltage, air_pressure_sensor_config_s * config) {
|
|||
*/
|
||||
float getMapByVoltage(float voltage DECLARE_ENGINE_PARAMETER_S) {
|
||||
// todo: migrate to mapDecoder once parameter listeners are ready
|
||||
air_pressure_sensor_config_s * config = &engineConfiguration->map.sensor;
|
||||
return decodePressure(voltage, config);
|
||||
air_pressure_sensor_config_s * apConfig = &engineConfiguration->map.sensor;
|
||||
return decodePressure(voltage, apConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -207,7 +207,7 @@ static void testCltByR(float resistance) {
|
|||
float kTemp = getKelvinTemperature(resistance, thermistor->config);
|
||||
scheduleMsg(logger, "for R=%f we have %f", resistance, (kTemp - KELV));
|
||||
|
||||
initThermistorCurve(&engine->clt, &engine->engineConfiguration->clt, engine->engineConfiguration->cltAdcChannel);
|
||||
initThermistorCurve(&engine->clt, &engineConfiguration->clt, engineConfiguration->cltAdcChannel);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -102,7 +102,7 @@ static void updateTriggerShapeIfNeeded(PwmConfig *state) {
|
|||
scheduleMsg(logger, "Stimulator: updating trigger shape: %d/%d %d", emulatorConfigVersion.getVersion(),
|
||||
getGlobalConfigurationVersion(), currentTimeMillis());
|
||||
|
||||
applyNonPersistentConfiguration(logger, engine);
|
||||
applyNonPersistentConfiguration(logger PASS_ENGINE_PARAMETER);
|
||||
|
||||
TriggerShape *s = &engine->triggerShape;
|
||||
pin_state_t *pinStates[PWM_PHASE_MAX_WAVE_PER_PWM] = { s->wave.waves[0].pinStates, s->wave.waves[1].pinStates,
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
static Logging * logger;
|
||||
|
||||
#if EFI_POTENTIOMETER || defined(__DOXYGEN__)
|
||||
Mcp42010Driver config[DIGIPOT_COUNT];
|
||||
static Mcp42010Driver potConfig[DIGIPOT_COUNT];
|
||||
|
||||
void initPotentiometer(Mcp42010Driver *driver, SPIDriver *spi, brain_pin_e csPin) {
|
||||
driver->spiConfig.cr1 = SPI_POT_CONFIG;
|
||||
|
@ -74,11 +74,11 @@ void setPotResistance(Mcp42010Driver *driver, int channel, int resistance) {
|
|||
}
|
||||
|
||||
static void setPotResistanceCommand(int index, int value) {
|
||||
setPotResistance(&config[index / 2], index % 2, value);
|
||||
setPotResistance(&potConfig[index / 2], index % 2, value);
|
||||
}
|
||||
|
||||
static void setPotValue1(int value) {
|
||||
sendToPot(&config[0], 1, value);
|
||||
sendToPot(&potConfig[0], 1, value);
|
||||
}
|
||||
|
||||
#endif /* EFI_POTENTIOMETER */
|
||||
|
@ -98,7 +98,7 @@ void initPotentiometers(Logging *sharedLogger, board_configuration_s *boardConfi
|
|||
continue;
|
||||
}
|
||||
|
||||
initPotentiometer(&config[i], getSpiDevice(boardConfiguration->digitalPotentiometerSpiDevice),
|
||||
initPotentiometer(&potConfig[i], getSpiDevice(boardConfiguration->digitalPotentiometerSpiDevice),
|
||||
csPin);
|
||||
}
|
||||
|
||||
|
@ -106,8 +106,8 @@ void initPotentiometers(Logging *sharedLogger, board_configuration_s *boardConfi
|
|||
|
||||
addConsoleActionI("potd1", setPotValue1);
|
||||
|
||||
setPotResistance(&config[0], 0, 3000);
|
||||
setPotResistance(&config[0], 1, 7000);
|
||||
setPotResistance(&potConfig[0], 0, 3000);
|
||||
setPotResistance(&potConfig[0], 1, 7000);
|
||||
#else
|
||||
print("digiPot logic disabled\r\n");
|
||||
#endif
|
||||
|
|
|
@ -172,8 +172,6 @@ void swo_init()
|
|||
void runRusEfi(void) {
|
||||
msObjectInit(&firmwareErrorMessageStream, errorMessageBuffer, sizeof(errorMessageBuffer), 0);
|
||||
|
||||
// that's dirty, this assignment should be nicer or in a better spot
|
||||
engine->engineConfiguration = engineConfiguration;
|
||||
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
|
||||
engine->engineConfiguration2 = engineConfiguration2;
|
||||
#endif
|
||||
|
|
|
@ -13,10 +13,8 @@
|
|||
|
||||
extern int timeNow;
|
||||
|
||||
EngineTestHelper::EngineTestHelper(engine_type_e engineType) {
|
||||
EngineTestHelper::EngineTestHelper(engine_type_e engineType) : engine (&persistentConfig) {
|
||||
ec = &persistentConfig.engineConfiguration;
|
||||
this->engine.engineConfiguration = &persistentConfig.engineConfiguration;
|
||||
|
||||
|
||||
engine_configuration_s *engineConfiguration = ec;
|
||||
|
||||
|
@ -43,7 +41,7 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType) {
|
|||
initSpeedDensity(ec);
|
||||
|
||||
resetConfigurationExt(NULL, engineType PASS_ENGINE_PARAMETER);
|
||||
prepareShapes(engine);
|
||||
prepareShapes(PASS_ENGINE_PARAMETER_F);
|
||||
engine->engineConfiguration->mafAdcChannel = (adc_channel_e)TEST_MAF_CHANNEL;
|
||||
}
|
||||
|
||||
|
|
|
@ -473,7 +473,8 @@ static void testRpmCalculator(void) {
|
|||
void testTriggerDecoder(void) {
|
||||
printf("*************************************************** testTriggerDecoder\r\n");
|
||||
|
||||
Engine engine;
|
||||
persistent_config_s config;
|
||||
Engine engine(&config);
|
||||
TriggerShape * s = &engine.triggerShape;
|
||||
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ void rusEfiFunctionalTest(void) {
|
|||
// todo: reduce code duplication with initEngineContoller
|
||||
|
||||
resetConfigurationExt(NULL, FORD_ESCORT_GT PASS_ENGINE_PARAMETER);
|
||||
prepareShapes(engine);
|
||||
prepareShapes(PASS_ENGINE_PARAMETER_F);
|
||||
|
||||
initSensors(&sharedLogger PASS_ENGINE_PARAMETER);
|
||||
|
||||
|
|
Loading…
Reference in New Issue