auto-sync
This commit is contained in:
parent
0c8c7ec120
commit
154c24090e
|
@ -13,6 +13,10 @@
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "engine_state.h"
|
#include "engine_state.h"
|
||||||
|
|
||||||
|
#if EFI_PROD_CODE || EFI_SIMULATOR
|
||||||
|
static Logging logger;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We are executing these heavy (logarithm) methods from outside the trigger callbacks for performance reasons.
|
* We are executing these heavy (logarithm) methods from outside the trigger callbacks for performance reasons.
|
||||||
*/
|
*/
|
||||||
|
@ -21,3 +25,36 @@ void Engine::updateSlowSensors() {
|
||||||
engineState.clt = getCoolantTemperature();
|
engineState.clt = getCoolantTemperature();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Engine::onTriggerEvent(uint64_t nowUs) {
|
||||||
|
isSpinning = true;
|
||||||
|
lastTriggerEventTimeUs = nowUs;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Engine::init() {
|
||||||
|
#if EFI_PROD_CODE || EFI_SIMULATOR
|
||||||
|
initLogging(&logger, "engine");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
void Engine::watchdog() {
|
||||||
|
if (!isSpinning) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uint64_t nowUs = getTimeNowUs();
|
||||||
|
/**
|
||||||
|
* Lowest possible cranking is about 240 RPM, that's 4 revolutions per second.
|
||||||
|
* 0.25 second is 250000 uS
|
||||||
|
*/
|
||||||
|
if (nowUs - lastTriggerEventTimeUs < 250000) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isSpinning = true;
|
||||||
|
scheduleMsg(&logger, "engine has STOPPED");
|
||||||
|
|
||||||
|
|
||||||
|
for (int i = 0; i < engineConfiguration->cylindersCount; i++) {
|
||||||
|
// io_pin_e pin = (io_pin_e) ((int) INJECTOR_1_OUTPUT + i);
|
||||||
|
|
||||||
|
//pin = (io_pin_e) ((int) SPARKOUT_1_OUTPUT + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -19,6 +19,25 @@ public:
|
||||||
float iat;
|
float iat;
|
||||||
float clt;
|
float clt;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class RpmCalculator;
|
||||||
|
|
||||||
|
class Engine {
|
||||||
|
public:
|
||||||
|
void init();
|
||||||
|
RpmCalculator *rpmCalculator;
|
||||||
|
engine_configuration_s *engineConfiguration;
|
||||||
|
engine_configuration2_s *engineConfiguration2;
|
||||||
|
|
||||||
|
void onTriggerEvent(uint64_t nowUs);
|
||||||
|
EngineState engineState;
|
||||||
|
uint64_t lastTriggerEventTimeUs;
|
||||||
|
|
||||||
|
void updateSlowSensors();
|
||||||
|
void watchdog();
|
||||||
|
private:
|
||||||
/**
|
/**
|
||||||
* By the way:
|
* By the way:
|
||||||
* 'cranking' means engine is not stopped and the rpm are below crankingRpm
|
* 'cranking' means engine is not stopped and the rpm are below crankingRpm
|
||||||
|
@ -29,18 +48,4 @@ public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class RpmCalculator;
|
|
||||||
|
|
||||||
class Engine {
|
|
||||||
public:
|
|
||||||
RpmCalculator *rpmCalculator;
|
|
||||||
engine_configuration_s *engineConfiguration;
|
|
||||||
engine_configuration2_s *engineConfiguration2;
|
|
||||||
|
|
||||||
|
|
||||||
EngineState engineState;
|
|
||||||
|
|
||||||
void updateSlowSensors();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* ENGINE_H_ */
|
#endif /* ENGINE_H_ */
|
||||||
|
|
|
@ -172,6 +172,7 @@ static void onEvenyGeneralMilliseconds(void *arg) {
|
||||||
if (!engine.rpmCalculator->isRunning())
|
if (!engine.rpmCalculator->isRunning())
|
||||||
writeToFlashIfPending();
|
writeToFlashIfPending();
|
||||||
|
|
||||||
|
engine.watchdog();
|
||||||
engine.updateSlowSensors();
|
engine.updateSlowSensors();
|
||||||
|
|
||||||
updateErrorCodes();
|
updateErrorCodes();
|
||||||
|
|
|
@ -93,12 +93,17 @@ static void reportEventToWaveChart(trigger_event_e ckpSignalType, int index) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: improve this
|
||||||
|
extern Engine engine;
|
||||||
|
|
||||||
void TriggerCentral::handleShaftSignal(configuration_s *configuration, trigger_event_e signal, uint64_t nowUs) {
|
void TriggerCentral::handleShaftSignal(configuration_s *configuration, trigger_event_e signal, uint64_t nowUs) {
|
||||||
efiAssertVoid(configuration!=NULL, "configuration");
|
efiAssertVoid(configuration!=NULL, "configuration");
|
||||||
|
|
||||||
efiAssertVoid(configuration->engineConfiguration!=NULL, "engineConfiguration");
|
efiAssertVoid(configuration->engineConfiguration!=NULL, "engineConfiguration");
|
||||||
efiAssertVoid(configuration->engineConfiguration2!=NULL, "engineConfiguration2");
|
efiAssertVoid(configuration->engineConfiguration2!=NULL, "engineConfiguration2");
|
||||||
|
|
||||||
|
engine.onTriggerEvent(nowUs);
|
||||||
|
|
||||||
#if EFI_HISTOGRAMS && EFI_PROD_CODE
|
#if EFI_HISTOGRAMS && EFI_PROD_CODE
|
||||||
int beforeCallback = hal_lld_get_counter_value();
|
int beforeCallback = hal_lld_get_counter_value();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -150,6 +150,8 @@ void runRusEfi(void) {
|
||||||
initializeConsole();
|
initializeConsole();
|
||||||
initLogging(&logging, "main");
|
initLogging(&logging, "main");
|
||||||
|
|
||||||
|
engine.init();
|
||||||
|
|
||||||
addConsoleAction("reset", scheduleReset);
|
addConsoleAction("reset", scheduleReset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue