This commit is contained in:
parent
45bc673ec4
commit
bb15cb20fd
|
@ -414,7 +414,7 @@ public:
|
||||||
* pre-calculated offset for given sequence index within engine cycle
|
* pre-calculated offset for given sequence index within engine cycle
|
||||||
* (not cylinder ID)
|
* (not cylinder ID)
|
||||||
*/
|
*/
|
||||||
angle_t ignitionPositionWithEngineCycle[IGNITION_PIN_COUNT];
|
angle_t ignitionPositionWithinEngineCycle[IGNITION_PIN_COUNT];
|
||||||
/**
|
/**
|
||||||
* pre-calculated reference to which output pin should be used for
|
* pre-calculated reference to which output pin should be used for
|
||||||
* given sequence index within engine cycle
|
* given sequence index within engine cycle
|
||||||
|
|
|
@ -733,5 +733,5 @@ int getRusEfiVersion(void) {
|
||||||
if (initBootloader() != 0)
|
if (initBootloader() != 0)
|
||||||
return 123;
|
return 123;
|
||||||
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
|
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
|
||||||
return 20180721;
|
return 20180722;
|
||||||
}
|
}
|
||||||
|
|
|
@ -537,7 +537,7 @@ void prepareOutputSignals(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
#endif /* EFI_UNIT_TEST */
|
#endif /* EFI_UNIT_TEST */
|
||||||
|
|
||||||
for (int i = 0; i < CONFIG(specs.cylindersCount); i++) {
|
for (int i = 0; i < CONFIG(specs.cylindersCount); i++) {
|
||||||
ENGINE(ignitionPositionWithEngineCycle[i])= ENGINE(engineCycle) * i / CONFIG(specs.cylindersCount);
|
ENGINE(ignitionPositionWithinEngineCycle[i])= ENGINE(engineCycle) * i / CONFIG(specs.cylindersCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareIgnitionPinIndices(CONFIG(ignitionMode) PASS_ENGINE_PARAMETER_SUFFIX);
|
prepareIgnitionPinIndices(CONFIG(ignitionMode) PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
|
@ -66,11 +66,15 @@ static void turnSparkPinLow2(IgnitionEvent *event, IgnitionOutputPin *output) {
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
void prepareCylinderIgnitionSchedule(IgnitionEvent *event DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
static void prepareCylinderIgnitionSchedule(angle_t dwellAngle, IgnitionEvent *event DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
// todo: clean up this implementation? does not look too nice as is.
|
// todo: clean up this implementation? does not look too nice as is.
|
||||||
|
|
||||||
// change of sign here from 'before TDC' to 'after TDC'
|
// change of sign here from 'before TDC' to 'after TDC'
|
||||||
const angle_t localAdvance = -ENGINE(engineState.timingAdvance) + ENGINE(ignitionPositionWithEngineCycle[event->cylinderIndex]) + CONFIG(timing_offset_cylinder[event->cylinderIndex]);
|
angle_t ignitionPositionWithinEngineCycle = ENGINE(ignitionPositionWithinEngineCycle[event->cylinderIndex]);
|
||||||
|
assertAngleRange(ignitionPositionWithinEngineCycle, "aPWEC", CUSTOM_ERR_6566);
|
||||||
|
cfg_float_t_1f timing_offset_cylinder = CONFIG(timing_offset_cylinder[event->cylinderIndex]);
|
||||||
|
const angle_t localAdvance = -ENGINE(engineState.timingAdvance) + ignitionPositionWithinEngineCycle + timing_offset_cylinder;
|
||||||
|
|
||||||
efiAssertVoid(!cisnan(localAdvance), "localAdvance#1");
|
efiAssertVoid(!cisnan(localAdvance), "localAdvance#1");
|
||||||
const int index = ENGINE(ignitionPin[event->cylinderIndex]);
|
const int index = ENGINE(ignitionPin[event->cylinderIndex]);
|
||||||
const int coilIndex = ID2INDEX(getCylinderId(index PASS_ENGINE_PARAMETER_SUFFIX));
|
const int coilIndex = ID2INDEX(getCylinderId(index PASS_ENGINE_PARAMETER_SUFFIX));
|
||||||
|
@ -85,7 +89,6 @@ void prepareCylinderIgnitionSchedule(IgnitionEvent *event DECLARE_ENGINE_PARAMET
|
||||||
} else {
|
} else {
|
||||||
secondOutput = NULL;
|
secondOutput = NULL;
|
||||||
}
|
}
|
||||||
angle_t dwellAngle = ENGINE(engineState.dwellAngle);
|
|
||||||
|
|
||||||
assertPinAssigned(output);
|
assertPinAssigned(output);
|
||||||
|
|
||||||
|
@ -116,7 +119,13 @@ void turnSparkPinLow(IgnitionEvent *event) {
|
||||||
EXPAND_Engine;
|
EXPAND_Engine;
|
||||||
#endif
|
#endif
|
||||||
// now that we've just fired a coil let's prepare the new schedule for the next engine revolution
|
// now that we've just fired a coil let's prepare the new schedule for the next engine revolution
|
||||||
prepareCylinderIgnitionSchedule(event PASS_ENGINE_PARAMETER_SUFFIX);
|
|
||||||
|
angle_t dwellAngle = ENGINE(engineState.dwellAngle);
|
||||||
|
if (cisnan(dwellAngle)) {
|
||||||
|
// we are here if engine has just stopped
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
prepareCylinderIgnitionSchedule(dwellAngle, event PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void turnSparkPinHigh2(IgnitionEvent *event, IgnitionOutputPin *output) {
|
static void turnSparkPinHigh2(IgnitionEvent *event, IgnitionOutputPin *output) {
|
||||||
|
@ -257,7 +266,8 @@ static ALWAYS_INLINE void handleSparkEvent(bool limitedSpark, uint32_t trgEventI
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initializeIgnitionActions(IgnitionEventList *list DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
static void initializeIgnitionActions(IgnitionEventList *list DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
if (cisnan(ENGINE(engineState.timingAdvance))) {
|
angle_t dwellAngle = ENGINE(engineState.dwellAngle);
|
||||||
|
if (cisnan(ENGINE(engineState.timingAdvance)) || cisnan(dwellAngle)) {
|
||||||
// error should already be reported
|
// error should already be reported
|
||||||
// need to invalidate previous ignition schedule
|
// need to invalidate previous ignition schedule
|
||||||
list->isReady = false;
|
list->isReady = false;
|
||||||
|
@ -270,7 +280,7 @@ static void initializeIgnitionActions(IgnitionEventList *list DECLARE_ENGINE_PAR
|
||||||
#if EFI_UNIT_TEST || defined(__DOXYGEN__)
|
#if EFI_UNIT_TEST || defined(__DOXYGEN__)
|
||||||
list->elements[cylinderIndex].engine = engine;
|
list->elements[cylinderIndex].engine = engine;
|
||||||
#endif /* EFI_UNIT_TEST */
|
#endif /* EFI_UNIT_TEST */
|
||||||
prepareCylinderIgnitionSchedule(&list->elements[cylinderIndex] PASS_ENGINE_PARAMETER_SUFFIX);
|
prepareCylinderIgnitionSchedule(dwellAngle, &list->elements[cylinderIndex] PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
}
|
}
|
||||||
list->isReady = true;
|
list->isReady = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue