auto-sync
This commit is contained in:
parent
bf6e308989
commit
7847f1b7cc
|
@ -28,6 +28,7 @@
|
||||||
#include "OutputSignalList.h"
|
#include "OutputSignalList.h"
|
||||||
#include "trigger_decoder.h"
|
#include "trigger_decoder.h"
|
||||||
#include "event_registry.h"
|
#include "event_registry.h"
|
||||||
|
#include "efiGpio.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* default Volumetric Efficiency
|
* default Volumetric Efficiency
|
||||||
|
@ -38,7 +39,6 @@
|
||||||
// return interpolate(500, 0.5, 5000, 1.1, rpm);
|
// return interpolate(500, 0.5, 5000, 1.1, rpm);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return number of milliseconds in one crankshaft revolution
|
* @return number of milliseconds in one crankshaft revolution
|
||||||
*/
|
*/
|
||||||
|
@ -102,7 +102,8 @@ int isCrankingRT(engine_configuration_s *engineConfiguration, int rpm) {
|
||||||
return rpm > 0 && rpm < engineConfiguration->crankingSettings.crankingRpm;
|
return rpm > 0 && rpm < engineConfiguration->crankingSettings.crankingRpm;
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputSignalList injectonSignals CCM_OPTIONAL;
|
OutputSignalList injectonSignals CCM_OPTIONAL
|
||||||
|
;
|
||||||
|
|
||||||
static void registerSparkEvent(engine_configuration_s const *engineConfiguration, trigger_shape_s * s,
|
static void registerSparkEvent(engine_configuration_s const *engineConfiguration, trigger_shape_s * s,
|
||||||
IgnitionEventList *list, io_pin_e pin, float localAdvance, float dwell) {
|
IgnitionEventList *list, io_pin_e pin, float localAdvance, float dwell) {
|
||||||
|
@ -111,6 +112,9 @@ static void registerSparkEvent(engine_configuration_s const *engineConfiguration
|
||||||
if (event == NULL)
|
if (event == NULL)
|
||||||
return; // error already reported
|
return; // error already reported
|
||||||
|
|
||||||
|
if (!isPinAssigned(pin)) {
|
||||||
|
warning(OBD_PCM_Processor_Fault, "pin not assigned for coil #%d", (int) pin - (int) SPARKOUT_1_OUTPUT);
|
||||||
|
}
|
||||||
event->io_pin = pin;
|
event->io_pin = pin;
|
||||||
|
|
||||||
event->advance = localAdvance;
|
event->advance = localAdvance;
|
||||||
|
@ -131,8 +135,8 @@ void initializeIgnitionActions(float advance, float dwellAngle, engine_configura
|
||||||
// todo: extract method
|
// todo: extract method
|
||||||
float localAdvance = advance + 720.0f * i / engineConfiguration->cylindersCount;
|
float localAdvance = advance + 720.0f * i / engineConfiguration->cylindersCount;
|
||||||
|
|
||||||
registerSparkEvent(engineConfiguration, &engineConfiguration2->triggerShape, list,
|
registerSparkEvent(engineConfiguration, &engineConfiguration2->triggerShape, list, SPARKOUT_1_OUTPUT,
|
||||||
SPARKOUT_1_OUTPUT, localAdvance, dwellAngle);
|
localAdvance, dwellAngle);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IM_WASTED_SPARK:
|
case IM_WASTED_SPARK:
|
||||||
|
@ -144,8 +148,8 @@ void initializeIgnitionActions(float advance, float dwellAngle, engine_configura
|
||||||
int id = getCylinderId(engineConfiguration->firingOrder, wastedIndex) - 1;
|
int id = getCylinderId(engineConfiguration->firingOrder, wastedIndex) - 1;
|
||||||
io_pin_e ioPin = (io_pin_e) (SPARKOUT_1_OUTPUT + id);
|
io_pin_e ioPin = (io_pin_e) (SPARKOUT_1_OUTPUT + id);
|
||||||
|
|
||||||
registerSparkEvent(engineConfiguration, &engineConfiguration2->triggerShape, list,
|
registerSparkEvent(engineConfiguration, &engineConfiguration2->triggerShape, list, ioPin, localAdvance,
|
||||||
ioPin, localAdvance, dwellAngle);
|
dwellAngle);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,8 +159,8 @@ void initializeIgnitionActions(float advance, float dwellAngle, engine_configura
|
||||||
float localAdvance = advance + 720.0f * i / engineConfiguration->cylindersCount;
|
float localAdvance = advance + 720.0f * i / engineConfiguration->cylindersCount;
|
||||||
|
|
||||||
io_pin_e pin = (io_pin_e) ((int) SPARKOUT_1_OUTPUT + getCylinderId(engineConfiguration->firingOrder, i) - 1);
|
io_pin_e pin = (io_pin_e) ((int) SPARKOUT_1_OUTPUT + getCylinderId(engineConfiguration->firingOrder, i) - 1);
|
||||||
registerSparkEvent(engineConfiguration, &engineConfiguration2->triggerShape, list, pin,
|
registerSparkEvent(engineConfiguration, &engineConfiguration2->triggerShape, list, pin, localAdvance,
|
||||||
localAdvance, dwellAngle);
|
dwellAngle);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -165,12 +169,13 @@ void initializeIgnitionActions(float advance, float dwellAngle, engine_configura
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void registerInjectionEvent(engine_configuration_s const *e,
|
static void registerInjectionEvent(engine_configuration_s const *e, trigger_shape_s *s, ActuatorEventList *list,
|
||||||
trigger_shape_s *s,
|
io_pin_e pin, float angle) {
|
||||||
ActuatorEventList *list,
|
|
||||||
io_pin_e pin,
|
if (!isPinAssigned(pin)) {
|
||||||
float angle
|
warning(OBD_PCM_Processor_Fault, "pin not assigned for injector #%d", (int) pin - (int) INJECTOR_1_OUTPUT);
|
||||||
) {
|
}
|
||||||
|
|
||||||
registerActuatorEventExt(e, s, list->getNextActuatorEvent(), injectonSignals.add(pin), angle);
|
registerActuatorEventExt(e, s, list->getNextActuatorEvent(), injectonSignals.add(pin), angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +272,7 @@ void findTriggerPosition(engine_configuration_s const *engineConfiguration, trig
|
||||||
|
|
||||||
if (middle == left) {
|
if (middle == left) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (angleOffset < s->eventAngles[middle]) {
|
if (angleOffset < s->eventAngles[middle]) {
|
||||||
right = middle;
|
right = middle;
|
||||||
|
@ -296,9 +301,9 @@ void registerActuatorEventExt(engine_configuration_s const *engineConfiguration,
|
||||||
efiAssertVoid(s->getSize() > 0, "uninitialized trigger_shape_s");
|
efiAssertVoid(s->getSize() > 0, "uninitialized trigger_shape_s");
|
||||||
|
|
||||||
if (e == NULL) {
|
if (e == NULL) {
|
||||||
// error already reported
|
// error already reported
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
e->actuator = actuator;
|
e->actuator = actuator;
|
||||||
|
|
||||||
findTriggerPosition(engineConfiguration, s, &e->position, angleOffset);
|
findTriggerPosition(engineConfiguration, s, &e->position, angleOffset);
|
||||||
|
@ -308,7 +313,7 @@ static int order_1_THEN_3_THEN_4_THEN2[] = { 1, 3, 4, 2 };
|
||||||
|
|
||||||
static int order_1_THEN_5_THEN_3_THEN_6_THEN_2_THEN_4[] = { 1, 5, 3, 6, 2, 4 };
|
static int order_1_THEN_5_THEN_3_THEN_6_THEN_2_THEN_4[] = { 1, 5, 3, 6, 2, 4 };
|
||||||
|
|
||||||
static int order_1_8_4_3_6_5_7_2[] = {1, 8, 4, 3, 6, 5, 7, 2};
|
static int order_1_8_4_3_6_5_7_2[] = { 1, 8, 4, 3, 6, 5, 7, 2 };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param index from zero to cylindersCount - 1
|
* @param index from zero to cylindersCount - 1
|
||||||
|
|
|
@ -68,3 +68,11 @@ void setOutputPinValue(io_pin_e pin, int logicValue) {
|
||||||
setPinValue(&outputs[pin], getElectricalValue(logicValue, mode), logicValue);
|
setPinValue(&outputs[pin], getElectricalValue(logicValue, mode), logicValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isPinAssigned(io_pin_e pin) {
|
||||||
|
#if EFI_PROD_CODE
|
||||||
|
return outputs[pin].port != GPIO_NULL;
|
||||||
|
#else
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ int getLogicPinValue(OutputPin * outputPin);
|
||||||
int getOutputPinValue(io_pin_e pin);
|
int getOutputPinValue(io_pin_e pin);
|
||||||
int getElectricalValue(int logicalValue, pin_output_mode_e mode);
|
int getElectricalValue(int logicalValue, pin_output_mode_e mode);
|
||||||
void setOutputPinValue(io_pin_e pin, int logicValue);
|
void setOutputPinValue(io_pin_e pin, int logicValue);
|
||||||
|
bool isPinAssigned(io_pin_e pin);
|
||||||
void setPinValue(OutputPin * outputPin, int electricalValue, int logicValue);
|
void setPinValue(OutputPin * outputPin, int electricalValue, int logicValue);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -210,8 +210,10 @@ void initRpmCalculator(void) {
|
||||||
void scheduleByAngle(scheduling_s *timer, float angle, schfunc_t callback, void *param) {
|
void scheduleByAngle(scheduling_s *timer, float angle, schfunc_t callback, void *param) {
|
||||||
int rpm = getRpm();
|
int rpm = getRpm();
|
||||||
if (!isValidRpm(rpm)) {
|
if (!isValidRpm(rpm)) {
|
||||||
// this might happen in case of a single trigger event after a pause
|
/**
|
||||||
warning(OBD_PCM_Processor_Fault, "Invalid rpm: %d", rpm);
|
* this might happen in case of a single trigger event after a pause - this is normal, so no
|
||||||
|
* warning here
|
||||||
|
*/
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float delayMs = getOneDegreeTimeMs(rpm) * angle;
|
float delayMs = getOneDegreeTimeMs(rpm) * angle;
|
||||||
|
|
Loading…
Reference in New Issue