refactoring: moving method closer to usage

This commit is contained in:
Andrey 2022-09-05 00:32:36 -04:00
parent 388a5e9738
commit 0ed576031e
3 changed files with 28 additions and 29 deletions

View File

@ -331,34 +331,6 @@ static void handleFuel(const bool limitedFuel, uint32_t trgEventIndex, int rpm,
fs->onTriggerTooth(rpm, nowNt, currentPhase, nextPhase);
}
bool noFiringUntilVvtSync(vvt_mode_e vvtMode) {
auto operationMode = engine->getOperationMode();
// V-Twin MAP phase sense needs to always wait for sync
if (vvtMode == VVT_MAP_V_TWIN) {
return true;
}
if (engineConfiguration->isPhaseSyncRequiredForIgnition) {
// in rare cases engines do not like random sequential mode
return true;
}
// Odd cylinder count engines don't work properly with wasted spark, so wait for full sync (so that sequential works)
// See https://github.com/rusefi/rusefi/issues/4195 for the issue to properly support this case
if (engineConfiguration->specs.cylindersCount > 1 && engineConfiguration->specs.cylindersCount % 2 == 1) {
return true;
}
// Symmetrical crank modes require cam sync before firing
// non-symmetrical cranks can use faster spin-up mode (firing in wasted/batch before VVT sync)
// Examples include Nissan MR/VQ, Miata NB, etc
return
operationMode == FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR ||
operationMode == FOUR_STROKE_THREE_TIMES_CRANK_SENSOR ||
operationMode == FOUR_STROKE_TWELVE_TIMES_CRANK_SENSOR;
}
/**
* This is the main trigger event handler.
* Both injection and ignition are controlled from this method.

View File

@ -12,7 +12,6 @@
#include "event_registry.h"
void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp, angle_t currentPhase, angle_t nextPhase);
bool noFiringUntilVvtSync(vvt_mode_e vvtMode);
void startSimultaneousInjection(void* = nullptr);
void endSimultaneousInjection(InjectionEvent *event);

View File

@ -6,6 +6,34 @@
#define CLEANUP_MODE_TPS 90
static bool noFiringUntilVvtSync(vvt_mode_e vvtMode) {
auto operationMode = engine->getOperationMode();
// V-Twin MAP phase sense needs to always wait for sync
if (vvtMode == VVT_MAP_V_TWIN) {
return true;
}
if (engineConfiguration->isPhaseSyncRequiredForIgnition) {
// in rare cases engines do not like random sequential mode
return true;
}
// Odd cylinder count engines don't work properly with wasted spark, so wait for full sync (so that sequential works)
// See https://github.com/rusefi/rusefi/issues/4195 for the issue to properly support this case
if (engineConfiguration->specs.cylindersCount > 1 && engineConfiguration->specs.cylindersCount % 2 == 1) {
return true;
}
// Symmetrical crank modes require cam sync before firing
// non-symmetrical cranks can use faster spin-up mode (firing in wasted/batch before VVT sync)
// Examples include Nissan MR/VQ, Miata NB, etc
return
operationMode == FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR ||
operationMode == FOUR_STROKE_THREE_TIMES_CRANK_SENSOR ||
operationMode == FOUR_STROKE_TWELVE_TIMES_CRANK_SENSOR;
}
void LimpManager::updateState(int rpm, efitick_t nowNt) {
Clearable allowFuel = engineConfiguration->isInjectionEnabled;
Clearable allowSpark = engineConfiguration->isIgnitionEnabled;