auto-sync

This commit is contained in:
rusEfi 2014-09-29 19:02:57 -05:00
parent bf6e308989
commit 7847f1b7cc
4 changed files with 36 additions and 20 deletions

View File

@ -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);
} }

View File

@ -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
}

View File

@ -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

View File

@ -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;