This commit is contained in:
rusefillc 2022-10-21 22:45:46 -04:00
parent 17e340622b
commit 7a1e729cd8
4 changed files with 26 additions and 14 deletions

View File

@ -471,9 +471,13 @@ void commonInitEngineController() {
initLaunchControl();
#endif
#if EFI_UNIT_TEST
engine->rpmCalculator.Register();
#endif /* EFI_UNIT_TEST */
#if EFI_SHAFT_POSITION_INPUT
/**
* there is an implicit dependency on the fact that 'tachometer' listener is the 1st listener - this case
* other listeners can access current RPM value
*/
initRpmCalculator();
#endif /* EFI_SHAFT_POSITION_INPUT */
#if (EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT) || EFI_SIMULATOR || EFI_UNIT_TEST
if (engineConfiguration->isEngineControlEnabled) {

View File

@ -381,6 +381,21 @@ void tdcMarkCallback(
}
}
void initRpmCalculator() {
#if ! HW_CHECK_MODE
if (hasFirmwareError()) {
return;
}
#endif // HW_CHECK_MODE
// Only register if not configured to read RPM over OBD2
if (!engineConfiguration->consumeObdSensors) {
engine->rpmCalculator.Register();
}
}
/**
* Schedules a callback 'angle' degree of crankshaft from now.
* The callback would be executed once after the duration of time which

View File

@ -174,6 +174,10 @@ void rpmShaftPositionCallback(trigger_event_e ckpSignalType, uint32_t trgEventIn
void tdcMarkCallback(
uint32_t trgEventIndex, efitick_t edgeTimestamp);
/**
* @brief Initialize RPM calculator
*/
void initRpmCalculator();
operation_mode_e lookupOperationMode();
#define getRevolutionCounter() (engine->rpmCalculator.getRevolutionCounterM())

View File

@ -183,20 +183,9 @@ void startTriggerDebugPins() {
}
void applyNewTriggerInputPins() {
if (hasFirmwareError()) {
return;
}
#if EFI_PROD_CODE
// first we will turn off all the changed pins
stopTriggerInputPins();
if (engineConfiguration->triggerInputDebugPins[0] != activeConfiguration.triggerInputDebugPins[0]) {
engine->rpmCalculator.unregister();
if (!hasFirmwareError() && engineConfiguration->triggerInputDebugPins[0] != Gpio::Unassigned) {
// if we do not have primary input channel maybe it's BCM mode and we inject RPM value via Lua?
engine->rpmCalculator.Register();
}
}
// then we will enable all the changed pins
startTriggerInputPins();
#endif /* EFI_PROD_CODE */