let spark deal with spark limpManager

This commit is contained in:
Andrey 2022-08-31 23:59:23 -04:00
parent 28d797d5c2
commit 9f4f85a097
3 changed files with 7 additions and 9 deletions

View File

@ -397,10 +397,6 @@ void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp, angle_
return; return;
} }
LimpState limitedSparkState = engine->limpManager.allowIgnition();
engine->outputChannels.sparkCutReason = (int8_t)limitedSparkState.reason;
bool limitedSpark = !limitedSparkState.value;
LimpState limitedFuelState = engine->limpManager.allowInjection(); LimpState limitedFuelState = engine->limpManager.allowInjection();
engine->outputChannels.fuelCutReason = (int8_t)limitedFuelState.reason; engine->outputChannels.fuelCutReason = (int8_t)limitedFuelState.reason;
bool limitedFuel = !limitedFuelState.value; bool limitedFuel = !limitedFuelState.value;
@ -433,7 +429,7 @@ void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp, angle_
/** /**
* For spark we schedule both start of coil charge and actual spark based on trigger angle * For spark we schedule both start of coil charge and actual spark based on trigger angle
*/ */
onTriggerEventSparkLogic(limitedSpark, trgEventIndex, rpm, edgeTimestamp); onTriggerEventSparkLogic(trgEventIndex, rpm, edgeTimestamp);
} }
// Check if the engine is not stopped or cylinder cleanup is activated // Check if the engine is not stopped or cylinder cleanup is activated

View File

@ -423,9 +423,7 @@ static void prepareIgnitionSchedule() {
initializeIgnitionActions(); initializeIgnitionActions();
} }
void onTriggerEventSparkLogic(bool limitedSpark, uint32_t trgEventIndex, int rpm, efitick_t edgeTimestamp void onTriggerEventSparkLogic(uint32_t trgEventIndex, int rpm, efitick_t edgeTimestamp) {
) {
ScopePerf perf(PE::OnTriggerEventSparkLogic); ScopePerf perf(PE::OnTriggerEventSparkLogic);
if (!isValidRpm(rpm) || !engineConfiguration->isIgnitionEnabled) { if (!isValidRpm(rpm) || !engineConfiguration->isIgnitionEnabled) {
@ -433,6 +431,10 @@ void onTriggerEventSparkLogic(bool limitedSpark, uint32_t trgEventIndex, int rpm
return; return;
} }
LimpState limitedSparkState = engine->limpManager.allowIgnition();
engine->outputChannels.sparkCutReason = (int8_t)limitedSparkState.reason;
bool limitedSpark = !limitedSparkState.value;
if (!engine->ignitionEvents.isReady) { if (!engine->ignitionEvents.isReady) {
prepareIgnitionSchedule(); prepareIgnitionSchedule();
} }

View File

@ -7,7 +7,7 @@
#pragma once #pragma once
void onTriggerEventSparkLogic(bool limitedSpark, uint32_t trgEventIndex, int rpm, efitick_t edgeTimestamp); void onTriggerEventSparkLogic(uint32_t trgEventIndex, int rpm, efitick_t edgeTimestamp);
void turnSparkPinHigh(IgnitionEvent *event); void turnSparkPinHigh(IgnitionEvent *event);
void fireSparkAndPrepareNextSchedule(IgnitionEvent *event); void fireSparkAndPrepareNextSchedule(IgnitionEvent *event);
int getNumberOfSparks(ignition_mode_e mode); int getNumberOfSparks(ignition_mode_e mode);