Injection/Ignition angle inaccuracy on 60-2? EngineSniffer vs Real Hardware #778

refactoring only
This commit is contained in:
rusefi 2019-05-07 16:45:29 -04:00
parent ec58466ea4
commit 61231fb1af
4 changed files with 28 additions and 21 deletions

View File

@ -346,6 +346,9 @@ public:
LocalVersionHolder versionForConfigurationListeners;
LocalVersionHolder auxParametersVersion;
int globalSparkIdCoutner = 0;
int getGlobalConfigurationVersion(void) const;
/**
* true if a recent configuration change has changed any of the trigger settings which

View File

@ -530,7 +530,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex D
/**
* For spark we schedule both start of coil charge and actual spark based on trigger angle
*/
handleSpark(limitedSpark, trgEventIndex, rpm PASS_ENGINE_PARAMETER_SUFFIX);
onTriggerEventSparkLogic(limitedSpark, trgEventIndex, rpm PASS_ENGINE_PARAMETER_SUFFIX);
#if EFI_HISTOGRAMS
int diff = hal_lld_get_counter_value() - beforeCallback;
if (diff > 0)

View File

@ -171,8 +171,6 @@ void turnSparkPinHigh(IgnitionEvent *event) {
}
}
static int globalSparkIdCoutner = 0;
static ALWAYS_INLINE void handleSparkEvent(bool limitedSpark, uint32_t trgEventIndex, IgnitionEvent *iEvent,
int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) {
@ -198,7 +196,7 @@ static ALWAYS_INLINE void handleSparkEvent(bool limitedSpark, uint32_t trgEventI
return;
}
iEvent->sparkId = globalSparkIdCoutner++;
iEvent->sparkId = engine->globalSparkIdCoutner++;
/**
* We are alternating two event lists in order to avoid a potential issue around revolution boundary
@ -334,23 +332,8 @@ static ALWAYS_INLINE void prepareIgnitionSchedule(DECLARE_ENGINE_PARAMETER_SIGNA
engine->m.ignitionSchTime = GET_TIMESTAMP() - engine->m.beforeIgnitionSch;
}
void handleSpark(bool limitedSpark, uint32_t trgEventIndex, int rpm
DECLARE_ENGINE_PARAMETER_SUFFIX) {
if (!isValidRpm(rpm) || !CONFIG(isIgnitionEnabled)) {
// this might happen for instance in case of a single trigger event after a pause
return;
}
if (!ENGINE(ignitionEvents.isReady)) {
prepareIgnitionSchedule(PASS_ENGINE_PARAMETER_SIGNATURE);
}
/**
* Ignition schedule is defined once per revolution
* See initializeIgnitionActions()
*/
static void scheduleAllSparkEventsUntilNextTriggerTooth(uint32_t trgEventIndex DECLARE_ENGINE_PARAMETER_SUFFIX) {
IgnitionEvent *current, *tmp;
LL_FOREACH_SAFE(ENGINE(iHead), current, tmp)
@ -370,6 +353,27 @@ void handleSpark(bool limitedSpark, uint32_t trgEventIndex, int rpm
engine->executor.scheduleForLater(sDown, (int) timeTillIgnitionUs, (schfunc_t) &turnSparkPinLow, current);
}
}
}
void onTriggerEventSparkLogic(bool limitedSpark, uint32_t trgEventIndex, int rpm
DECLARE_ENGINE_PARAMETER_SUFFIX) {
if (!isValidRpm(rpm) || !CONFIG(isIgnitionEnabled)) {
// this might happen for instance in case of a single trigger event after a pause
return;
}
if (!ENGINE(ignitionEvents.isReady)) {
prepareIgnitionSchedule(PASS_ENGINE_PARAMETER_SIGNATURE);
}
/**
* Ignition schedule is defined once per revolution
* See initializeIgnitionActions()
*/
scheduleAllSparkEventsUntilNextTriggerTooth(trgEventIndex PASS_ENGINE_PARAMETER_SUFFIX);
// scheduleSimpleMsg(&logger, "eventId spark ", eventIndex);
if (ENGINE(ignitionEvents.isReady)) {

View File

@ -11,7 +11,7 @@
#include "engine.h"
int isInjectionEnabled(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void handleSpark(bool limitedSpark, uint32_t trgEventIndex, int rpm DECLARE_ENGINE_PARAMETER_SUFFIX);
void onTriggerEventSparkLogic(bool limitedSpark, uint32_t trgEventIndex, int rpm DECLARE_ENGINE_PARAMETER_SUFFIX);
void initSparkLogic(Logging *sharedLogger);
void turnSparkPinHigh(IgnitionEvent *event);
void turnSparkPinLow(IgnitionEvent *event);