auto-sync

This commit is contained in:
rusEfi 2016-11-28 14:01:52 -05:00
parent 2c176a1204
commit 8c0308cca7
3 changed files with 31 additions and 22 deletions

View File

@ -43,6 +43,7 @@ IgnitionEvent::IgnitionEvent() {
memset(outputs, 0, sizeof(outputs)); memset(outputs, 0, sizeof(outputs));
advance = NAN; advance = NAN;
sparkId = 0; sparkId = 0;
cylinderIndex = 0;
} }
IgnitionOutputPin * IgnitionEvent::getOutputForLoggins() { IgnitionOutputPin * IgnitionEvent::getOutputForLoggins() {

View File

@ -56,7 +56,11 @@ public:
event_trigger_position_s dwellPosition; event_trigger_position_s dwellPosition;
event_trigger_position_s sparkPosition; event_trigger_position_s sparkPosition;
IgnitionEvent *next; IgnitionEvent *next;
/**
* @see globalSparkIdCoutner
*/
int sparkId; int sparkId;
int cylinderIndex;
char *name; char *name;
IgnitionOutputPin *getOutputForLoggins(); IgnitionOutputPin *getOutputForLoggins();
}; };

View File

@ -222,29 +222,33 @@ static void addIgnitionEvent(int cylinderIndex, angle_t localAdvance, angle_t dw
} }
static void initializeIgnitionActions(angle_t advance, angle_t dwellAngle, static void prepareIgnitionSchedule(int cylinderIndex, IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S) {
IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S) { // todo: clean up this implementation? does not look too nice as is.
// change of sign here from 'before TDC' to 'after TDC'
angle_t localAdvance = -ENGINE(engineState.timingAdvance) + ENGINE(angleExtra[cylinderIndex]);
const int index = ENGINE(ignitionPin[cylinderIndex]);
const int coilIndex = ID2INDEX(getCylinderId(CONFIG(specs.firingOrder), index));
IgnitionOutputPin *output = &enginePins.coils[coilIndex];
IgnitionOutputPin *secondOutput;
if (CONFIG(ignitionMode) == IM_WASTED_SPARK && CONFIG(twoWireBatchIgnition)) {
int secondIndex = index + CONFIG(specs.cylindersCount) / 2;
int secondCoilIndex = ID2INDEX(getCylinderId(CONFIG(specs.firingOrder), secondIndex));
secondOutput = &enginePins.coils[secondCoilIndex];
} else {
secondOutput = NULL;
}
addIgnitionEvent(cylinderIndex, localAdvance, ENGINE(engineState.dwellAngle), list, output, secondOutput PASS_ENGINE_PARAMETER);
}
static void initializeIgnitionActions(IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S) {
efiAssertVoid(engineConfiguration->specs.cylindersCount > 0, "cylindersCount"); efiAssertVoid(engineConfiguration->specs.cylindersCount > 0, "cylindersCount");
for (int i = 0; i < CONFIG(specs.cylindersCount); i++) { for (int cylinderIndex = 0; cylinderIndex < CONFIG(specs.cylindersCount); cylinderIndex++) {
// todo: clean up this implementation? does not look too nice as is. list->elements[cylinderIndex].cylinderIndex = cylinderIndex;
prepareIgnitionSchedule(cylinderIndex, list PASS_ENGINE_PARAMETER);
// change of sign here from 'before TDC' to 'after TDC'
angle_t localAdvance = -advance + ENGINE(angleExtra[i]);
const int index = ENGINE(ignitionPin[i]);
const int coilIndex = ID2INDEX(getCylinderId(CONFIG(specs.firingOrder), index));
IgnitionOutputPin *output = &enginePins.coils[coilIndex];
IgnitionOutputPin *secondOutput;
if (CONFIG(ignitionMode) == IM_WASTED_SPARK && CONFIG(twoWireBatchIgnition)) {
int secondIndex = index + CONFIG(specs.cylindersCount) / 2;
int secondCoilIndex = ID2INDEX(getCylinderId(CONFIG(specs.firingOrder), secondIndex));
secondOutput = &enginePins.coils[secondCoilIndex];
} else {
secondOutput = NULL;
}
addIgnitionEvent(i, localAdvance, dwellAngle, list, output, secondOutput PASS_ENGINE_PARAMETER);
} }
list->isReady = true; list->isReady = true;
} }
@ -282,7 +286,7 @@ static ALWAYS_INLINE void prepareIgnitionSchedule(int rpm, int revolutionIndex D
list->isReady = false; list->isReady = false;
return; return;
} }
initializeIgnitionActions(ENGINE(engineState.timingAdvance), ENGINE(engineState.dwellAngle), list PASS_ENGINE_PARAMETER); initializeIgnitionActions(list PASS_ENGINE_PARAMETER);
engine->m.ignitionSchTime = GET_TIMESTAMP() - engine->m.beforeIgnitionSch; engine->m.ignitionSchTime = GET_TIMESTAMP() - engine->m.beforeIgnitionSch;
} }