auto-sync
This commit is contained in:
parent
8a116552a3
commit
6d6f02036d
|
@ -83,9 +83,16 @@ void Engine::onTriggerEvent(efitick_t nowNt) {
|
||||||
lastTriggerEventTimeNt = nowNt;
|
lastTriggerEventTimeNt = nowNt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Engine::Engine() {
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
Engine::Engine(persistent_config_s *config) {
|
Engine::Engine(persistent_config_s *config) {
|
||||||
init(config);
|
setConfig(config);
|
||||||
engineState.warmupAfrPid.init(&config->engineConfiguration.warmupAfrPid, 0.5, 1.5);
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Engine::reset() {
|
||||||
isEngineChartEnabled = false;
|
isEngineChartEnabled = false;
|
||||||
sensorChartMode = SC_OFF;
|
sensorChartMode = SC_OFF;
|
||||||
actualLastInjection = 0;
|
actualLastInjection = 0;
|
||||||
|
@ -130,6 +137,7 @@ EngineState::EngineState() {
|
||||||
warningCounter = 0;
|
warningCounter = 0;
|
||||||
lastErrorCode = 0;
|
lastErrorCode = 0;
|
||||||
crankingTime = 0;
|
crankingTime = 0;
|
||||||
|
timeSinceCranking = 0;
|
||||||
targetAFR = 0;
|
targetAFR = 0;
|
||||||
tpsAccelEnrich = 0;
|
tpsAccelEnrich = 0;
|
||||||
tChargeK = 0;
|
tChargeK = 0;
|
||||||
|
@ -232,10 +240,11 @@ void Engine::preCalculate() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::init(persistent_config_s *config) {
|
void Engine::setConfig(persistent_config_s *config) {
|
||||||
this->config = config;
|
this->config = config;
|
||||||
engineConfiguration = &config->engineConfiguration;
|
engineConfiguration = &config->engineConfiguration;
|
||||||
memset(config, 0, sizeof(persistent_config_s));
|
memset(config, 0, sizeof(persistent_config_s));
|
||||||
|
engineState.warmupAfrPid.init(&config->engineConfiguration.warmupAfrPid, 0.5, 1.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::printKnockState(void) {
|
void Engine::printKnockState(void) {
|
||||||
|
@ -297,7 +306,7 @@ void Engine::watchdog() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
isSpinning = false;
|
isSpinning = false;
|
||||||
ignitionList()->isReady = false;
|
ignitionEvents.isReady = false;
|
||||||
#if EFI_PROD_CODE || EFI_SIMULATOR
|
#if EFI_PROD_CODE || EFI_SIMULATOR
|
||||||
scheduleMsg(&logger, "engine has STOPPED");
|
scheduleMsg(&logger, "engine has STOPPED");
|
||||||
scheduleMsg(&logger, "templog engine has STOPPED [%x][%x] [%x][%x] %d",
|
scheduleMsg(&logger, "templog engine has STOPPED [%x][%x] [%x][%x] %d",
|
||||||
|
@ -312,10 +321,6 @@ void Engine::watchdog() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
IgnitionEventList * Engine::ignitionList() {
|
|
||||||
return &engineConfiguration2->ignitionEvents;
|
|
||||||
}
|
|
||||||
|
|
||||||
injection_mode_e Engine::getCurrentInjectionMode(DECLARE_ENGINE_PARAMETER_F) {
|
injection_mode_e Engine::getCurrentInjectionMode(DECLARE_ENGINE_PARAMETER_F) {
|
||||||
int rpm = rpmCalculator.rpmValue;
|
int rpm = rpmCalculator.rpmValue;
|
||||||
return isCrankingR(rpm) ? CONFIG(crankingInjectionMode) : CONFIG(injectionMode);
|
return isCrankingR(rpm) ? CONFIG(crankingInjectionMode) : CONFIG(injectionMode);
|
||||||
|
|
|
@ -76,11 +76,9 @@ public:
|
||||||
FuelSchedule *injectionEvents;
|
FuelSchedule *injectionEvents;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OutputSignalPair fuelActuators[INJECTION_PIN_COUNT];
|
|
||||||
|
|
||||||
float fsioLastValue[LE_COMMAND_COUNT];
|
float fsioLastValue[LE_COMMAND_COUNT];
|
||||||
|
|
||||||
IgnitionEventList ignitionEvents;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ThermistorMath {
|
class ThermistorMath {
|
||||||
|
@ -241,10 +239,15 @@ typedef void (*configuration_callback_t)(Engine*);
|
||||||
class Engine {
|
class Engine {
|
||||||
public:
|
public:
|
||||||
Engine(persistent_config_s *config);
|
Engine(persistent_config_s *config);
|
||||||
void init(persistent_config_s *config);
|
Engine();
|
||||||
|
void setConfig(persistent_config_s *config);
|
||||||
|
void reset();
|
||||||
void prepareFuelSchedule(DECLARE_ENGINE_PARAMETER_F);
|
void prepareFuelSchedule(DECLARE_ENGINE_PARAMETER_F);
|
||||||
injection_mode_e getCurrentInjectionMode(DECLARE_ENGINE_PARAMETER_F);
|
injection_mode_e getCurrentInjectionMode(DECLARE_ENGINE_PARAMETER_F);
|
||||||
IgnitionEventList *ignitionList(); // todo: inline/rename/refactor
|
|
||||||
|
OutputSignalPair fuelActuators[INJECTION_PIN_COUNT];
|
||||||
|
IgnitionEventList ignitionEvents;
|
||||||
|
|
||||||
|
|
||||||
WallFuel wallFuel;
|
WallFuel wallFuel;
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,9 @@ typedef enum {
|
||||||
FO_1_2_3 = 10,
|
FO_1_2_3 = 10,
|
||||||
|
|
||||||
// 4 cylinder
|
// 4 cylinder
|
||||||
FO_1_3_4_2 = 1,
|
FO_1_3_4_2 = 1, // typical inline 4
|
||||||
FO_1_2_4_3 = 2,
|
FO_1_2_4_3 = 2,
|
||||||
FO_1_3_2_4 = 3,
|
FO_1_3_2_4 = 3, // for example horizontally opposed engine
|
||||||
// 8 cylinder
|
// 8 cylinder
|
||||||
FO_1_8_4_3_6_5_7_2 = 5,
|
FO_1_8_4_3_6_5_7_2 = 5,
|
||||||
FO_1_8_7_2_6_5_4_3 = 11,
|
FO_1_8_7_2_6_5_4_3 = 11,
|
||||||
|
|
|
@ -101,7 +101,7 @@ engine_configuration2_s * engineConfiguration2 = &ec2;
|
||||||
* todo: eliminate constructor parameter so that _engine could be moved to CCM_OPTIONAL
|
* todo: eliminate constructor parameter so that _engine could be moved to CCM_OPTIONAL
|
||||||
* todo: this should probably become 'static', i.e. private, and propagated around explicitly?
|
* todo: this should probably become 'static', i.e. private, and propagated around explicitly?
|
||||||
*/
|
*/
|
||||||
Engine _engine(&persistentState.persistentConfiguration);
|
Engine _engine CCM_OPTIONAL;
|
||||||
Engine * engine = &_engine;
|
Engine * engine = &_engine;
|
||||||
#endif /* EFI_PROD_CODE */
|
#endif /* EFI_PROD_CODE */
|
||||||
|
|
||||||
|
@ -137,16 +137,6 @@ static msg_t csThread(void) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void updateErrorCodes(void) {
|
|
||||||
/**
|
|
||||||
* technically we can set error codes right inside the getMethods, but I a bit on a fence about it
|
|
||||||
*/
|
|
||||||
setError(!isValidIntakeAirTemperature(getIntakeAirTemperature(PASS_ENGINE_PARAMETER_F)),
|
|
||||||
OBD_Intake_Air_Temperature_Circuit_Malfunction);
|
|
||||||
setError(!isValidCoolantTemperature(getCoolantTemperature(PASS_ENGINE_PARAMETER_F)),
|
|
||||||
OBD_Engine_Coolant_Temperature_Circuit_Malfunction);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||||
Overflow64Counter halTime;
|
Overflow64Counter halTime;
|
||||||
|
|
||||||
|
@ -253,8 +243,6 @@ static void periodicSlowCallback(Engine *engine) {
|
||||||
runFsio();
|
runFsio();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
updateErrorCodes();
|
|
||||||
|
|
||||||
cylinderCleanupControl(engine);
|
cylinderCleanupControl(engine);
|
||||||
|
|
||||||
scheduleNextSlowInvocation();
|
scheduleNextSlowInvocation();
|
||||||
|
|
|
@ -304,7 +304,7 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
|
||||||
getRevolutionCounter());
|
getRevolutionCounter());
|
||||||
#endif /* EFI_DEFAILED_LOGGING */
|
#endif /* EFI_DEFAILED_LOGGING */
|
||||||
|
|
||||||
OutputSignalPair *pair = &ENGINE(engineConfiguration2)->fuelActuators[injEventIndex];
|
OutputSignalPair *pair = &ENGINE(fuelActuators[injEventIndex]);
|
||||||
|
|
||||||
if (event->isSimultanious) {
|
if (event->isSimultanious) {
|
||||||
/**
|
/**
|
||||||
|
@ -489,7 +489,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex D
|
||||||
engine->fuelScheduleForThisEngineCycle->usedAtEngineCycle = ENGINE(rpmCalculator).getRevolutionCounter();
|
engine->fuelScheduleForThisEngineCycle->usedAtEngineCycle = ENGINE(rpmCalculator).getRevolutionCounter();
|
||||||
|
|
||||||
if (triggerVersion.isOld()) {
|
if (triggerVersion.isOld()) {
|
||||||
engine->ignitionList()->isReady = false; // we need to rebuild ignition schedule
|
engine->ignitionEvents.isReady = false; // we need to rebuild ignition schedule
|
||||||
engine->fuelScheduleForThisEngineCycle->isReady = false;
|
engine->fuelScheduleForThisEngineCycle->isReady = false;
|
||||||
// todo: move 'triggerIndexByAngle' change into trigger initialization, why is it invoked from here if it's only about trigger shape & optimization?
|
// todo: move 'triggerIndexByAngle' change into trigger initialization, why is it invoked from here if it's only about trigger shape & optimization?
|
||||||
prepareOutputSignals(PASS_ENGINE_PARAMETER_F);
|
prepareOutputSignals(PASS_ENGINE_PARAMETER_F);
|
||||||
|
|
|
@ -254,6 +254,12 @@ void prepareIgnitionSchedule(IgnitionEvent *event DECLARE_ENGINE_PARAMETER_S) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initializeIgnitionActions(IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S) {
|
static void initializeIgnitionActions(IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S) {
|
||||||
|
if (cisnan(ENGINE(engineState.timingAdvance))) {
|
||||||
|
// error should already be reported
|
||||||
|
// need to invalidate previous ignition schedule
|
||||||
|
list->isReady = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
efiAssertVoid(engineConfiguration->specs.cylindersCount > 0, "cylindersCount");
|
efiAssertVoid(engineConfiguration->specs.cylindersCount > 0, "cylindersCount");
|
||||||
|
|
||||||
for (int cylinderIndex = 0; cylinderIndex < CONFIG(specs.cylindersCount); cylinderIndex++) {
|
for (int cylinderIndex = 0; cylinderIndex < CONFIG(specs.cylindersCount); cylinderIndex++) {
|
||||||
|
@ -291,14 +297,8 @@ static ALWAYS_INLINE void prepareIgnitionSchedule(int rpm DECLARE_ENGINE_PARAMET
|
||||||
|
|
||||||
// todo: add some check for dwell overflow? like 4 times 6 ms while engine cycle is less then that
|
// todo: add some check for dwell overflow? like 4 times 6 ms while engine cycle is less then that
|
||||||
|
|
||||||
IgnitionEventList *list = engine->ignitionList();
|
IgnitionEventList *list = &engine->ignitionEvents;
|
||||||
|
|
||||||
if (cisnan(ENGINE(engineState.timingAdvance))) {
|
|
||||||
// error should already be reported
|
|
||||||
// need to invalidate previous ignition schedule
|
|
||||||
list->isReady = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
initializeIgnitionActions(list PASS_ENGINE_PARAMETER);
|
initializeIgnitionActions(list PASS_ENGINE_PARAMETER);
|
||||||
engine->m.ignitionSchTime = GET_TIMESTAMP() - engine->m.beforeIgnitionSch;
|
engine->m.ignitionSchTime = GET_TIMESTAMP() - engine->m.beforeIgnitionSch;
|
||||||
}
|
}
|
||||||
|
@ -311,8 +311,7 @@ void handleSpark(bool limitedSpark, uint32_t trgEventIndex, int rpm
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IgnitionEventList *list = engine->ignitionList();
|
if (!engine->ignitionEvents.isReady) {
|
||||||
if (!list->isReady) {
|
|
||||||
prepareIgnitionSchedule(rpm PASS_ENGINE_PARAMETER);
|
prepareIgnitionSchedule(rpm PASS_ENGINE_PARAMETER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,9 +341,9 @@ void handleSpark(bool limitedSpark, uint32_t trgEventIndex, int rpm
|
||||||
}
|
}
|
||||||
|
|
||||||
// scheduleSimpleMsg(&logger, "eventId spark ", eventIndex);
|
// scheduleSimpleMsg(&logger, "eventId spark ", eventIndex);
|
||||||
if (list->isReady) {
|
if (engine->ignitionEvents.isReady) {
|
||||||
for (int i = 0; i < CONFIG(specs.cylindersCount); i++) {
|
for (int i = 0; i < CONFIG(specs.cylindersCount); i++) {
|
||||||
IgnitionEvent *event = &list->elements[i];
|
IgnitionEvent *event = &engine->ignitionEvents.elements[i];
|
||||||
if (event->dwellPosition.eventIndex != trgEventIndex)
|
if (event->dwellPosition.eventIndex != trgEventIndex)
|
||||||
continue;
|
continue;
|
||||||
handleSparkEvent(limitedSpark, trgEventIndex, event, rpm PASS_ENGINE_PARAMETER);
|
handleSparkEvent(limitedSpark, trgEventIndex, event, rpm PASS_ENGINE_PARAMETER);
|
||||||
|
|
|
@ -200,7 +200,7 @@ void runRusEfi(void) {
|
||||||
*/
|
*/
|
||||||
initializeConsole(&sharedLogger);
|
initializeConsole(&sharedLogger);
|
||||||
|
|
||||||
engine->init(config);
|
engine->setConfig(config);
|
||||||
|
|
||||||
addConsoleAction("reboot", scheduleReboot);
|
addConsoleAction("reboot", scheduleReboot);
|
||||||
|
|
||||||
|
@ -281,9 +281,9 @@ void firmwareError(obd_code_e code, const char *errorMsg, ...) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char UNUSED_RAM_SIZE[1100];
|
static char UNUSED_RAM_SIZE[11100];
|
||||||
|
|
||||||
static char UNUSED_CCM_SIZE[26500] CCM_OPTIONAL;
|
static char UNUSED_CCM_SIZE[16500] CCM_OPTIONAL;
|
||||||
|
|
||||||
int getRusEfiVersion(void) {
|
int getRusEfiVersion(void) {
|
||||||
if (UNUSED_RAM_SIZE[0] != 0)
|
if (UNUSED_RAM_SIZE[0] != 0)
|
||||||
|
|
|
@ -148,7 +148,7 @@ void test1995FordInline6TriggerDecoder(void) {
|
||||||
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_F);
|
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_F);
|
||||||
eth.fireTriggerEvents(48);
|
eth.fireTriggerEvents(48);
|
||||||
|
|
||||||
IgnitionEventList *ecl = ð.ec2.ignitionEvents;
|
IgnitionEventList *ecl = ð.engine.ignitionEvents;
|
||||||
assertEqualsM("ford inline ignition events size", 1, ecl->isReady);
|
assertEqualsM("ford inline ignition events size", 1, ecl->isReady);
|
||||||
assertEqualsM("event index", 0, ecl->elements[0].dwellPosition.eventIndex);
|
assertEqualsM("event index", 0, ecl->elements[0].dwellPosition.eventIndex);
|
||||||
assertEqualsM("angle offset#1", 7, ecl->elements[0].dwellPosition.angleOffset);
|
assertEqualsM("angle offset#1", 7, ecl->elements[0].dwellPosition.angleOffset);
|
||||||
|
@ -300,7 +300,7 @@ void testRpmCalculator(void) {
|
||||||
|
|
||||||
EngineTestHelper eth(FORD_INLINE_6_1995);
|
EngineTestHelper eth(FORD_INLINE_6_1995);
|
||||||
EXPAND_EngineTestHelper;
|
EXPAND_EngineTestHelper;
|
||||||
IgnitionEventList *ilist = ð.engine.engineConfiguration2->ignitionEvents;
|
IgnitionEventList *ilist = ð.engine.ignitionEvents;
|
||||||
assertEqualsM("size #1", 0, ilist->isReady);
|
assertEqualsM("size #1", 0, ilist->isReady);
|
||||||
|
|
||||||
assertEqualsM("engineCycle", 720, eth.engine.engineCycle);
|
assertEqualsM("engineCycle", 720, eth.engine.engineCycle);
|
||||||
|
|
Loading…
Reference in New Issue