auto-sync
This commit is contained in:
parent
d881584824
commit
fb131888bf
|
@ -440,6 +440,8 @@ case Force_4b_firing_order:
|
||||||
return "Force_4b_firing_order";
|
return "Force_4b_firing_order";
|
||||||
case FO_1_THEN_2_THEN_4_THEN3:
|
case FO_1_THEN_2_THEN_4_THEN3:
|
||||||
return "FO_1_THEN_2_THEN_4_THEN3";
|
return "FO_1_THEN_2_THEN_4_THEN3";
|
||||||
|
case FO_1_2_4_5_3:
|
||||||
|
return "FO_1_2_4_5_3";
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,6 @@ public:
|
||||||
// todo: this should go, too
|
// todo: this should go, too
|
||||||
engine_configuration_s *engineConfiguration;
|
engine_configuration_s *engineConfiguration;
|
||||||
|
|
||||||
trigger_shape_s triggerShape;
|
|
||||||
|
|
||||||
FuelSchedule crankingInjectionEvents;
|
FuelSchedule crankingInjectionEvents;
|
||||||
FuelSchedule injectionEvents;
|
FuelSchedule injectionEvents;
|
||||||
|
|
||||||
|
@ -64,7 +62,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
void initializeIgnitionActions(float advance, float dwellAngle,
|
void initializeIgnitionActions(float advance, float dwellAngle,
|
||||||
engine_configuration2_s *engineConfiguration2, IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S);
|
IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S);
|
||||||
|
|
||||||
void setDefaultNonPersistentConfiguration(engine_configuration2_s *engineConfiguration2);
|
void setDefaultNonPersistentConfiguration(engine_configuration2_s *engineConfiguration2);
|
||||||
void printConfiguration(engine_configuration_s *engineConfiguration, engine_configuration2_s *engineConfiguration2);
|
void printConfiguration(engine_configuration_s *engineConfiguration, engine_configuration2_s *engineConfiguration2);
|
||||||
|
|
|
@ -36,6 +36,8 @@ public:
|
||||||
Thermistor iat;
|
Thermistor iat;
|
||||||
Thermistor clt;
|
Thermistor clt;
|
||||||
|
|
||||||
|
trigger_shape_s triggerShape;
|
||||||
|
|
||||||
void onTriggerEvent(uint64_t nowNt);
|
void onTriggerEvent(uint64_t nowNt);
|
||||||
EngineState engineState;
|
EngineState engineState;
|
||||||
uint64_t lastTriggerEventTimeNt;
|
uint64_t lastTriggerEventTimeNt;
|
||||||
|
|
|
@ -585,12 +585,12 @@ void applyNonPersistentConfiguration(Logging * logger, Engine *engine) {
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
scheduleMsg(logger, "applyNonPersistentConfiguration()");
|
scheduleMsg(logger, "applyNonPersistentConfiguration()");
|
||||||
#endif
|
#endif
|
||||||
initializeTriggerShape(logger, engineConfiguration, engineConfiguration2, engine);
|
initializeTriggerShape(logger, engineConfiguration, engine);
|
||||||
if (engineConfiguration2->triggerShape.getSize() == 0) {
|
if (engine->triggerShape.getSize() == 0) {
|
||||||
firmwareError("triggerShape size is zero");
|
firmwareError("triggerShape size is zero");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (engineConfiguration2->triggerShape.shaftPositionEventCount == 0) {
|
if (engine->triggerShape.shaftPositionEventCount == 0) {
|
||||||
firmwareError("shaftPositionEventCount is zero");
|
firmwareError("shaftPositionEventCount is zero");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -602,8 +602,7 @@ void prepareShapes(Engine *engine) {
|
||||||
engine_configuration2_s *engineConfiguration2 = engine->engineConfiguration2;
|
engine_configuration2_s *engineConfiguration2 = engine->engineConfiguration2;
|
||||||
|
|
||||||
// todo: looks like this is here only for unit tests. todo: remove
|
// todo: looks like this is here only for unit tests. todo: remove
|
||||||
initializeIgnitionActions(0, 0, engineConfiguration2,
|
initializeIgnitionActions(0, 0, &engineConfiguration2->ignitionEvents[0] PASS_ENGINE_PARAMETER);
|
||||||
&engineConfiguration2->ignitionEvents[0] PASS_ENGINE_PARAMETER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setOperationMode(engine_configuration_s *engineConfiguration, operation_mode_e mode) {
|
void setOperationMode(engine_configuration_s *engineConfiguration, operation_mode_e mode) {
|
||||||
|
|
|
@ -241,11 +241,16 @@ typedef enum {
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
FO_ONE_CYLINDER = 0,
|
FO_ONE_CYLINDER = 0,
|
||||||
|
// 4 cylinder
|
||||||
FO_1_THEN_3_THEN_4_THEN2 = 1,
|
FO_1_THEN_3_THEN_4_THEN2 = 1,
|
||||||
FO_1_THEN_2_THEN_4_THEN3 = 2,
|
FO_1_THEN_2_THEN_4_THEN3 = 2,
|
||||||
FO_1_THEN_3_THEN_2_THEN4 = 3,
|
FO_1_THEN_3_THEN_2_THEN4 = 3,
|
||||||
|
// 6 cylinder
|
||||||
FO_1_THEN_5_THEN_3_THEN_6_THEN_2_THEN_4 = 4,
|
FO_1_THEN_5_THEN_3_THEN_6_THEN_2_THEN_4 = 4,
|
||||||
|
// 8 cylinder
|
||||||
FO_1_8_4_3_6_5_7_2 = 5,
|
FO_1_8_4_3_6_5_7_2 = 5,
|
||||||
|
// 5 cylinder
|
||||||
|
FO_1_2_4_5_3 = 6,
|
||||||
Force_4b_firing_order = ENUM_SIZE_HACK,
|
Force_4b_firing_order = ENUM_SIZE_HACK,
|
||||||
} firing_order_e;
|
} firing_order_e;
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ static void registerSparkEvent(trigger_shape_s * s, IgnitionEventList *list, io_
|
||||||
findTriggerPosition(s, &event->dwellPosition, localAdvance - dwell PASS_ENGINE_PARAMETER);
|
findTriggerPosition(s, &event->dwellPosition, localAdvance - dwell PASS_ENGINE_PARAMETER);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initializeIgnitionActions(float advance, float dwellAngle, engine_configuration2_s *engineConfiguration2,
|
void initializeIgnitionActions(float advance, float dwellAngle,
|
||||||
IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S) {
|
IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S) {
|
||||||
|
|
||||||
efiAssertVoid(engineConfiguration->cylindersCount > 0, "cylindersCount");
|
efiAssertVoid(engineConfiguration->cylindersCount > 0, "cylindersCount");
|
||||||
|
@ -135,7 +135,7 @@ void initializeIgnitionActions(float advance, float dwellAngle, engine_configura
|
||||||
float localAdvance = advance
|
float localAdvance = advance
|
||||||
+ (float) engineConfiguration->engineCycle * i / engineConfiguration->cylindersCount;
|
+ (float) engineConfiguration->engineCycle * i / engineConfiguration->cylindersCount;
|
||||||
|
|
||||||
registerSparkEvent(&engineConfiguration2->triggerShape, list, SPARKOUT_1_OUTPUT, localAdvance,
|
registerSparkEvent(&engine->triggerShape, list, SPARKOUT_1_OUTPUT, localAdvance,
|
||||||
dwellAngle PASS_ENGINE_PARAMETER);
|
dwellAngle PASS_ENGINE_PARAMETER);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -149,7 +149,7 @@ 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(&engineConfiguration2->triggerShape, list, ioPin, localAdvance,
|
registerSparkEvent(&engine->triggerShape, list, ioPin, localAdvance,
|
||||||
dwellAngle PASS_ENGINE_PARAMETER);
|
dwellAngle PASS_ENGINE_PARAMETER);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ void initializeIgnitionActions(float advance, float dwellAngle, engine_configura
|
||||||
+ (float) engineConfiguration->engineCycle * i / engineConfiguration->cylindersCount;
|
+ (float) engineConfiguration->engineCycle * 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(&engineConfiguration2->triggerShape, list, pin, localAdvance,
|
registerSparkEvent(&engine->triggerShape, list, pin, localAdvance,
|
||||||
dwellAngle PASS_ENGINE_PARAMETER);
|
dwellAngle PASS_ENGINE_PARAMETER);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -359,10 +359,9 @@ void prepareOutputSignals(Engine *engine) {
|
||||||
engine_configuration2_s *engineConfiguration2 = engine->engineConfiguration2;
|
engine_configuration2_s *engineConfiguration2 = engine->engineConfiguration2;
|
||||||
|
|
||||||
// todo: move this reset into decoder
|
// todo: move this reset into decoder
|
||||||
engineConfiguration2->triggerShape.calculateTriggerSynchPoint(engineConfiguration,
|
engine->triggerShape.calculateTriggerSynchPoint(engineConfiguration, engine);
|
||||||
&engineConfiguration->triggerConfig, engine);
|
|
||||||
|
|
||||||
trigger_shape_s * ts = &engineConfiguration2->triggerShape;
|
trigger_shape_s * ts = &engine->triggerShape;
|
||||||
|
|
||||||
injectonSignals.clear();
|
injectonSignals.clear();
|
||||||
engineConfiguration2->crankingInjectionEvents.addFuelEvents(ts,
|
engineConfiguration2->crankingInjectionEvents.addFuelEvents(ts,
|
||||||
|
|
|
@ -403,7 +403,7 @@ static void setTriggerType(int value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setToothedWheel(int total, int skipped) {
|
static void setToothedWheel(int total, int skipped) {
|
||||||
setToothedWheelConfiguration(&engineConfiguration2->triggerShape, total, skipped, engineConfiguration);
|
setToothedWheelConfiguration(&engine->triggerShape, total, skipped, engineConfiguration);
|
||||||
// initializeTriggerShape(&logger, engineConfiguration, engineConfiguration2);
|
// initializeTriggerShape(&logger, engineConfiguration, engineConfiguration2);
|
||||||
incrementGlobalConfigurationVersion();
|
incrementGlobalConfigurationVersion();
|
||||||
doPrintConfiguration(engine);
|
doPrintConfiguration(engine);
|
||||||
|
|
|
@ -149,7 +149,7 @@ static ALWAYS_INLINE void handleFuel(uint32_t eventIndex, int rpm DECLARE_ENGINE
|
||||||
if (!isInjectionEnabled(engine->engineConfiguration))
|
if (!isInjectionEnabled(engine->engineConfiguration))
|
||||||
return;
|
return;
|
||||||
efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "lowstck#3");
|
efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "lowstck#3");
|
||||||
efiAssertVoid(eventIndex < engine->engineConfiguration2->triggerShape.getLength(), "event index");
|
efiAssertVoid(eventIndex < engine->triggerShape.getLength(), "event index");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ignition events are defined by addFuelEvents() according to selected
|
* Ignition events are defined by addFuelEvents() according to selected
|
||||||
|
@ -218,7 +218,7 @@ static ALWAYS_INLINE void handleSparkEvent(uint32_t eventIndex, IgnitionEvent *i
|
||||||
* TODO: improve precision
|
* TODO: improve precision
|
||||||
*/
|
*/
|
||||||
|
|
||||||
findTriggerPosition(&engineConfiguration2->triggerShape, &iEvent->sparkPosition,
|
findTriggerPosition(&engine->triggerShape, &iEvent->sparkPosition,
|
||||||
iEvent->advance PASS_ENGINE_PARAMETER);
|
iEvent->advance PASS_ENGINE_PARAMETER);
|
||||||
|
|
||||||
if (iEvent->sparkPosition.eventIndex == eventIndex) {
|
if (iEvent->sparkPosition.eventIndex == eventIndex) {
|
||||||
|
@ -297,7 +297,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex, Eng
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) ckpSignalType;
|
(void) ckpSignalType;
|
||||||
efiAssertVoid(eventIndex < 2 * engine->engineConfiguration2->triggerShape.shaftPositionEventCount, "event index");
|
efiAssertVoid(eventIndex < 2 * engine->triggerShape.shaftPositionEventCount, "event index");
|
||||||
efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "lowstck#2");
|
efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "lowstck#2");
|
||||||
|
|
||||||
// todo: remove these local variables soon?
|
// todo: remove these local variables soon?
|
||||||
|
@ -366,7 +366,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex, Eng
|
||||||
|
|
||||||
// todo: add some check for dwell overflow? like 4 times 6 ms while engine cycle is less then that
|
// todo: add some check for dwell overflow? like 4 times 6 ms while engine cycle is less then that
|
||||||
|
|
||||||
initializeIgnitionActions(fixAngle(-advance PASS_ENGINE_PARAMETER), dwellAngle, engine->engineConfiguration2,
|
initializeIgnitionActions(fixAngle(-advance PASS_ENGINE_PARAMETER), dwellAngle,
|
||||||
&engine->engineConfiguration2->ignitionEvents[revolutionIndex] PASS_ENGINE_PARAMETER);
|
&engine->engineConfiguration2->ignitionEvents[revolutionIndex] PASS_ENGINE_PARAMETER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ void TriggerCentral::handleShaftSignal(Engine *engine, trigger_event_e signal) {
|
||||||
}
|
}
|
||||||
previousShaftEventTimeNt = nowNt;
|
previousShaftEventTimeNt = nowNt;
|
||||||
|
|
||||||
trigger_shape_s * triggerShape = &engine->engineConfiguration2->triggerShape;
|
trigger_shape_s * triggerShape = &engine->triggerShape;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This invocation changes the state of triggerState
|
* This invocation changes the state of triggerState
|
||||||
|
@ -162,7 +162,7 @@ void TriggerCentral::handleShaftSignal(Engine *engine, trigger_event_e signal) {
|
||||||
}
|
}
|
||||||
reportEventToWaveChart(signal, triggerIndexForListeners);
|
reportEventToWaveChart(signal, triggerIndexForListeners);
|
||||||
|
|
||||||
if (triggerState.getCurrentIndex() >= engine->engineConfiguration2->triggerShape.shaftPositionEventCount) {
|
if (triggerState.getCurrentIndex() >= engine->triggerShape.shaftPositionEventCount) {
|
||||||
warning(OBD_PCM_Processor_Fault, "unexpected eventIndex=%d", triggerState.getCurrentIndex());
|
warning(OBD_PCM_Processor_Fault, "unexpected eventIndex=%d", triggerState.getCurrentIndex());
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ extern board_configuration_s *boardConfiguration;
|
||||||
|
|
||||||
static void triggerShapeInfo(Engine *engine) {
|
static void triggerShapeInfo(Engine *engine) {
|
||||||
#if EFI_PROD_CODE || EFI_SIMULATOR
|
#if EFI_PROD_CODE || EFI_SIMULATOR
|
||||||
trigger_shape_s *s = &engineConfiguration2->triggerShape;
|
trigger_shape_s *s = &engine->triggerShape;
|
||||||
for (int i = 0; i < s->getSize(); i++) {
|
for (int i = 0; i < s->getSize(); i++) {
|
||||||
scheduleMsg(&logger, "event %d %f", i, s->eventAngles[i]);
|
scheduleMsg(&logger, "event %d %f", i, s->eventAngles[i]);
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ extern uint32_t maxLockTime;
|
||||||
static void triggerInfo(Engine *engine) {
|
static void triggerInfo(Engine *engine) {
|
||||||
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
|
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
|
||||||
|
|
||||||
trigger_shape_s *ts = &engineConfiguration2->triggerShape;
|
trigger_shape_s *ts = &engine->triggerShape;
|
||||||
|
|
||||||
scheduleMsg(&logger, "Template %s/%d trigger %d", getConfigurationName(engineConfiguration->engineType),
|
scheduleMsg(&logger, "Template %s/%d trigger %d", getConfigurationName(engineConfiguration->engineType),
|
||||||
engineConfiguration->engineType, engineConfiguration->triggerConfig.triggerType);
|
engineConfiguration->engineType, engineConfiguration->triggerConfig.triggerType);
|
||||||
|
@ -222,13 +222,12 @@ static void triggerInfo(Engine *engine) {
|
||||||
scheduleMsg(&logger, "trigger event counters %d/%d/%d/%d", triggerCentral.getHwEventCounter(0),
|
scheduleMsg(&logger, "trigger event counters %d/%d/%d/%d", triggerCentral.getHwEventCounter(0),
|
||||||
triggerCentral.getHwEventCounter(1), triggerCentral.getHwEventCounter(2),
|
triggerCentral.getHwEventCounter(1), triggerCentral.getHwEventCounter(2),
|
||||||
triggerCentral.getHwEventCounter(3));
|
triggerCentral.getHwEventCounter(3));
|
||||||
scheduleMsg(&logger, "expected cycle events %d/%d/%d", engineConfiguration2->triggerShape.expectedEventCount[0],
|
scheduleMsg(&logger, "expected cycle events %d/%d/%d", ts->expectedEventCount[0],
|
||||||
engineConfiguration2->triggerShape.expectedEventCount[1], ts->expectedEventCount[2]);
|
engine->triggerShape.expectedEventCount[1], ts->expectedEventCount[2]);
|
||||||
|
|
||||||
scheduleMsg(&logger, "trigger type=%d/need2ndChannel=%s", engineConfiguration->triggerConfig.triggerType,
|
scheduleMsg(&logger, "trigger type=%d/need2ndChannel=%s", engineConfiguration->triggerConfig.triggerType,
|
||||||
boolToString(engineConfiguration->needSecondTriggerInput));
|
boolToString(engineConfiguration->needSecondTriggerInput));
|
||||||
scheduleMsg(&logger, "expected duty #0=%f/#1=%f", engineConfiguration2->triggerShape.dutyCycle[0],
|
scheduleMsg(&logger, "expected duty #0=%f/#1=%f", ts->dutyCycle[0], ts->dutyCycle[1]);
|
||||||
engineConfiguration2->triggerShape.dutyCycle[1]);
|
|
||||||
|
|
||||||
scheduleMsg(&logger, "isError %s/total errors=%d ord_err=%d/total revolutions=%d/self=%s",
|
scheduleMsg(&logger, "isError %s/total errors=%d ord_err=%d/total revolutions=%d/self=%s",
|
||||||
boolToString(isTriggerDecoderError()),
|
boolToString(isTriggerDecoderError()),
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include "trigger_structure.h"
|
#include "trigger_structure.h"
|
||||||
#include "efiGpio.h"
|
#include "efiGpio.h"
|
||||||
|
#include "engine.h"
|
||||||
|
|
||||||
// todo: better name for this constant
|
// todo: better name for this constant
|
||||||
#define HELPER_PERIOD 100000
|
#define HELPER_PERIOD 100000
|
||||||
|
@ -220,12 +221,12 @@ void initializeSkippedToothTriggerShapeExt(trigger_shape_s *s, int totalTeethCou
|
||||||
* External logger is needed because at this point our logger is not yet initialized
|
* External logger is needed because at this point our logger is not yet initialized
|
||||||
*/
|
*/
|
||||||
void initializeTriggerShape(Logging *logger, engine_configuration_s const *engineConfiguration,
|
void initializeTriggerShape(Logging *logger, engine_configuration_s const *engineConfiguration,
|
||||||
engine_configuration2_s *engineConfiguration2, Engine *engine) {
|
Engine *engine) {
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
scheduleMsg(logger, "initializeTriggerShape()");
|
scheduleMsg(logger, "initializeTriggerShape()");
|
||||||
#endif
|
#endif
|
||||||
const trigger_config_s *triggerConfig = &engineConfiguration->triggerConfig;
|
const trigger_config_s *triggerConfig = &engineConfiguration->triggerConfig;
|
||||||
trigger_shape_s *triggerShape = &engineConfiguration2->triggerShape;
|
trigger_shape_s *triggerShape = &engine->triggerShape;
|
||||||
|
|
||||||
setTriggerSynchronizationGap(triggerShape, 2);
|
setTriggerSynchronizationGap(triggerShape, 2);
|
||||||
triggerShape->useRiseEdge = true;
|
triggerShape->useRiseEdge = true;
|
||||||
|
@ -235,7 +236,7 @@ void initializeTriggerShape(Logging *logger, engine_configuration_s const *engin
|
||||||
case TT_TOOTHED_WHEEL:
|
case TT_TOOTHED_WHEEL:
|
||||||
// todo: move to into configuration definition engineConfiguration2->triggerShape.needSecondTriggerInput = false;
|
// todo: move to into configuration definition engineConfiguration2->triggerShape.needSecondTriggerInput = false;
|
||||||
|
|
||||||
engineConfiguration2->triggerShape.isSynchronizationNeeded =
|
triggerShape->isSynchronizationNeeded =
|
||||||
engineConfiguration->triggerConfig.customIsSynchronizationNeeded;
|
engineConfiguration->triggerConfig.customIsSynchronizationNeeded;
|
||||||
|
|
||||||
initializeSkippedToothTriggerShapeExt(triggerShape, triggerConfig->customTotalToothCount,
|
initializeSkippedToothTriggerShapeExt(triggerShape, triggerConfig->customTotalToothCount,
|
||||||
|
@ -304,9 +305,8 @@ void initializeTriggerShape(Logging *logger, engine_configuration_s const *engin
|
||||||
;
|
;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
trigger_shape_s *s = &engineConfiguration2->triggerShape;
|
triggerShape->assignSize();
|
||||||
s->assignSize();
|
triggerShape->wave.checkSwitchTimes(triggerShape->getSize());
|
||||||
s->wave.checkSwitchTimes(s->getSize());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TriggerStimulatorHelper::TriggerStimulatorHelper() {
|
TriggerStimulatorHelper::TriggerStimulatorHelper() {
|
||||||
|
|
|
@ -91,7 +91,7 @@ uint32_t findTriggerZeroEventIndex(trigger_shape_s * shape, trigger_config_s con
|
||||||
|
|
||||||
class Engine;
|
class Engine;
|
||||||
|
|
||||||
void initializeTriggerShape(Logging *logger, engine_configuration_s const *engineConfiguration, engine_configuration2_s *engineConfiguration2, Engine *engine);
|
void initializeTriggerShape(Logging *logger, engine_configuration_s const *engineConfiguration, Engine *engine);
|
||||||
void initTriggerDecoder(void);
|
void initTriggerDecoder(void);
|
||||||
|
|
||||||
bool_t isTriggerDecoderError(void);
|
bool_t isTriggerDecoderError(void);
|
||||||
|
|
|
@ -94,7 +94,7 @@ static void updateTriggerShapeIfNeeded(PwmConfig *state) {
|
||||||
|
|
||||||
applyNonPersistentConfiguration(&logger, engine);
|
applyNonPersistentConfiguration(&logger, engine);
|
||||||
|
|
||||||
trigger_shape_s *s = &engineConfiguration2->triggerShape;
|
trigger_shape_s *s = &engine->triggerShape;
|
||||||
int *pinStates[PWM_PHASE_MAX_WAVE_PER_PWM] = { s->wave.waves[0].pinStates, s->wave.waves[1].pinStates,
|
int *pinStates[PWM_PHASE_MAX_WAVE_PER_PWM] = { s->wave.waves[0].pinStates, s->wave.waves[1].pinStates,
|
||||||
s->wave.waves[2].pinStates };
|
s->wave.waves[2].pinStates };
|
||||||
copyPwmParameters(state, s->getSize(), s->wave.switchTimes, PWM_PHASE_MAX_WAVE_PER_PWM, pinStates);
|
copyPwmParameters(state, s->getSize(), s->wave.switchTimes, PWM_PHASE_MAX_WAVE_PER_PWM, pinStates);
|
||||||
|
@ -137,7 +137,7 @@ static void resumeStimulator(Engine *engine) {
|
||||||
void initTriggerEmulatorLogic(Engine *engine) {
|
void initTriggerEmulatorLogic(Engine *engine) {
|
||||||
initLogging(&logger, "position sensor(s) emulator");
|
initLogging(&logger, "position sensor(s) emulator");
|
||||||
|
|
||||||
trigger_shape_s *s = &engineConfiguration2->triggerShape;
|
trigger_shape_s *s = &engine->triggerShape;
|
||||||
setTriggerEmulatorRPM(engineConfiguration->bc.triggerSimulatorFrequency, engine);
|
setTriggerEmulatorRPM(engineConfiguration->bc.triggerSimulatorFrequency, engine);
|
||||||
int *pinStates[PWM_PHASE_MAX_WAVE_PER_PWM] = { s->wave.waves[0].pinStates, s->wave.waves[1].pinStates,
|
int *pinStates[PWM_PHASE_MAX_WAVE_PER_PWM] = { s->wave.waves[0].pinStates, s->wave.waves[1].pinStates,
|
||||||
s->wave.waves[2].pinStates };
|
s->wave.waves[2].pinStates };
|
||||||
|
|
|
@ -55,7 +55,8 @@ int trigger_shape_s::getTriggerShapeSynchPointIndex() {
|
||||||
// todo: clean-up!
|
// todo: clean-up!
|
||||||
int getEngineCycleEventCount2(operation_mode_e mode, trigger_shape_s * s);
|
int getEngineCycleEventCount2(operation_mode_e mode, trigger_shape_s * s);
|
||||||
|
|
||||||
void trigger_shape_s::calculateTriggerSynchPoint(engine_configuration_s *engineConfiguration, trigger_config_s const*triggerConfig, Engine *engine) {
|
void trigger_shape_s::calculateTriggerSynchPoint(engine_configuration_s *engineConfiguration, Engine *engine) {
|
||||||
|
trigger_config_s const*triggerConfig = &engineConfiguration->triggerConfig;
|
||||||
setTriggerShapeSynchPointIndex(engineConfiguration, findTriggerZeroEventIndex(this, triggerConfig), engine);
|
setTriggerShapeSynchPointIndex(engineConfiguration, findTriggerZeroEventIndex(this, triggerConfig), engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ public:
|
||||||
|
|
||||||
int getTriggerShapeSynchPointIndex();
|
int getTriggerShapeSynchPointIndex();
|
||||||
|
|
||||||
void calculateTriggerSynchPoint(engine_configuration_s *engineConfiguration, trigger_config_s const*triggerConfig, Engine *engine);
|
void calculateTriggerSynchPoint(engine_configuration_s *engineConfiguration, Engine *engine);
|
||||||
|
|
||||||
void setTriggerShapeSynchPointIndex(engine_configuration_s *engineConfiguration, int triggerShapeSynchPointIndex, Engine *engine);
|
void setTriggerShapeSynchPointIndex(engine_configuration_s *engineConfiguration, int triggerShapeSynchPointIndex, Engine *engine);
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -256,9 +256,9 @@ void firmwareError(const char *fmt, ...) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char UNUSED_RAM_SIZE[20000];
|
static char UNUSED_RAM_SIZE[10000];
|
||||||
|
|
||||||
static char UNUSED_CCM_SIZE[5000] CCM_OPTIONAL;
|
static char UNUSED_CCM_SIZE[15000] CCM_OPTIONAL;
|
||||||
|
|
||||||
int getRusEfiVersion(void) {
|
int getRusEfiVersion(void) {
|
||||||
if (UNUSED_RAM_SIZE == 0)
|
if (UNUSED_RAM_SIZE == 0)
|
||||||
|
|
|
@ -40,7 +40,7 @@ void EngineTestHelper::fireTriggerEvents() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EngineTestHelper::initTriggerShapeAndRpmCalculator() {
|
void EngineTestHelper::initTriggerShapeAndRpmCalculator() {
|
||||||
initializeTriggerShape(NULL, ec, &ec2, &engine);
|
initializeTriggerShape(NULL, ec, &engine);
|
||||||
incrementGlobalConfigurationVersion();
|
incrementGlobalConfigurationVersion();
|
||||||
|
|
||||||
triggerCentral.addEventListener((ShaftPositionListener) &rpmShaftPositionCallback, "rpm reporter", &engine);
|
triggerCentral.addEventListener((ShaftPositionListener) &rpmShaftPositionCallback, "rpm reporter", &engine);
|
||||||
|
|
|
@ -92,9 +92,6 @@ void chDbgAssert(int c, char *msg, void *arg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static engine_configuration2_s ec2;
|
|
||||||
engine_configuration2_s *engineConfiguration2 = &ec2;
|
|
||||||
|
|
||||||
int getRevolutionCounter(void) {
|
int getRevolutionCounter(void) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,18 +159,19 @@ void testAngleResolver(void) {
|
||||||
engine_configuration_s *engineConfiguration = eth.engine.engineConfiguration;
|
engine_configuration_s *engineConfiguration = eth.engine.engineConfiguration;
|
||||||
|
|
||||||
engineConfiguration->globalTriggerAngleOffset = 175;
|
engineConfiguration->globalTriggerAngleOffset = 175;
|
||||||
trigger_shape_s * ts = &engineConfiguration2->triggerShape;
|
assertTrue(engine->engineConfiguration2!=NULL);
|
||||||
|
trigger_shape_s * ts = &engine->triggerShape;
|
||||||
|
|
||||||
confgiureFordAspireTriggerShape(ts);
|
confgiureFordAspireTriggerShape(ts);
|
||||||
|
|
||||||
ts->calculateTriggerSynchPoint(engineConfiguration, &engineConfiguration->triggerConfig, engine);
|
ts->calculateTriggerSynchPoint(engineConfiguration, engine);
|
||||||
|
|
||||||
assertEqualsM("index 2", 232.76, ts->eventAngles[3]); // this angle is relation to synch point
|
assertEqualsM("index 2", 228.0450, ts->eventAngles[3]); // this angle is relation to synch point
|
||||||
assertEqualsM("time 2", 0.3233, ts->wave.getSwitchTime(2));
|
assertEqualsM("time 2", 0.3233, ts->wave.getSwitchTime(2));
|
||||||
assertEqualsM("index 5", 409.8412, ts->eventAngles[6]);
|
assertEqualsM("index 5", 413.7470, ts->eventAngles[6]);
|
||||||
assertEqualsM("time 5", 0.5692, ts->wave.getSwitchTime(5));
|
assertEqualsM("time 5", 0.5692, ts->wave.getSwitchTime(5));
|
||||||
|
|
||||||
assertEquals(9, ts->getTriggerShapeSynchPointIndex());
|
assertEquals(4, ts->getTriggerShapeSynchPointIndex());
|
||||||
|
|
||||||
assertEqualsM("shape size", 10, ts->getSize());
|
assertEqualsM("shape size", 10, ts->getSize());
|
||||||
|
|
||||||
|
@ -180,14 +181,14 @@ void testAngleResolver(void) {
|
||||||
printf("*************************************************** testAngleResolver 0\r\n");
|
printf("*************************************************** testAngleResolver 0\r\n");
|
||||||
findTriggerPosition(ts, &ae.getNextActuatorEvent()->position, 53 - 175 PASS_ENGINE_PARAMETER);
|
findTriggerPosition(ts, &ae.getNextActuatorEvent()->position, 53 - 175 PASS_ENGINE_PARAMETER);
|
||||||
assertEqualsM("size", 1, ae.size);
|
assertEqualsM("size", 1, ae.size);
|
||||||
assertEquals(0, ae.events[0].position.eventIndex);
|
assertEquals(1, ae.events[0].position.eventIndex);
|
||||||
assertEquals(53, ae.events[0].position.angleOffset);
|
assertEquals(3.1588, ae.events[0].position.angleOffset);
|
||||||
|
|
||||||
printf("*************************************************** testAngleResolver 2\r\n");
|
printf("*************************************************** testAngleResolver 2\r\n");
|
||||||
ae.resetEventList();
|
ae.resetEventList();
|
||||||
findTriggerPosition(ts, &ae.getNextActuatorEvent()->position, 51 + 180 - 175 PASS_ENGINE_PARAMETER);
|
findTriggerPosition(ts, &ae.getNextActuatorEvent()->position, 51 + 180 - 175 PASS_ENGINE_PARAMETER);
|
||||||
assertEquals(2, ae.events[0].position.eventIndex);
|
assertEquals(3, ae.events[0].position.eventIndex);
|
||||||
assertEquals(109.1, ae.events[0].position.angleOffset);
|
assertEquals(2.955, ae.events[0].position.angleOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void testPinHelper(void) {
|
void testPinHelper(void) {
|
||||||
|
|
|
@ -44,7 +44,7 @@ int getTheAngle(engine_type_e engineType) {
|
||||||
engine_configuration_s *ec = eth.ec;
|
engine_configuration_s *ec = eth.ec;
|
||||||
initDataStructures(ec);
|
initDataStructures(ec);
|
||||||
|
|
||||||
trigger_shape_s * shape = ð.ec2.triggerShape;
|
trigger_shape_s * shape = ð.engine.triggerShape;
|
||||||
return findTriggerZeroEventIndex(shape, &ec->triggerConfig);
|
return findTriggerZeroEventIndex(shape, &ec->triggerConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ static void testDodgeNeonDecoder(void) {
|
||||||
EngineTestHelper eth(DODGE_NEON_1995);
|
EngineTestHelper eth(DODGE_NEON_1995);
|
||||||
|
|
||||||
engine_configuration_s *ec = eth.ec;
|
engine_configuration_s *ec = eth.ec;
|
||||||
trigger_shape_s * shape = ð.ec2.triggerShape;
|
trigger_shape_s * shape = ð.engine.triggerShape;
|
||||||
assertEquals(8, shape->getTriggerShapeSynchPointIndex());
|
assertEquals(8, shape->getTriggerShapeSynchPointIndex());
|
||||||
|
|
||||||
TriggerState state;
|
TriggerState state;
|
||||||
|
@ -116,7 +116,7 @@ static void test1995FordInline6TriggerDecoder(void) {
|
||||||
engine_configuration_s *engineConfiguration = eth.engine.engineConfiguration;
|
engine_configuration_s *engineConfiguration = eth.engine.engineConfiguration;
|
||||||
Engine *engine = ð.engine;
|
Engine *engine = ð.engine;
|
||||||
|
|
||||||
trigger_shape_s * shape = ð.ec2.triggerShape;
|
trigger_shape_s * shape = ð.engine.triggerShape;
|
||||||
|
|
||||||
assertEqualsM("triggerShapeSynchPointIndex", 0, shape->getTriggerShapeSynchPointIndex());
|
assertEqualsM("triggerShapeSynchPointIndex", 0, shape->getTriggerShapeSynchPointIndex());
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ void testFordAspire(void) {
|
||||||
|
|
||||||
Engine *engine = ð.engine;
|
Engine *engine = ð.engine;
|
||||||
engine_configuration_s *engineConfiguration = eth.ec;
|
engine_configuration_s *engineConfiguration = eth.ec;
|
||||||
assertEquals(4, eth.ec2.triggerShape.getTriggerShapeSynchPointIndex());
|
assertEquals(4, eth.engine.triggerShape.getTriggerShapeSynchPointIndex());
|
||||||
|
|
||||||
assertEquals(800, engineConfiguration->fuelRpmBins[0]);
|
assertEquals(800, engineConfiguration->fuelRpmBins[0]);
|
||||||
assertEquals(7000, engineConfiguration->fuelRpmBins[15]);
|
assertEquals(7000, engineConfiguration->fuelRpmBins[15]);
|
||||||
|
@ -198,7 +198,7 @@ void testMazda323(void) {
|
||||||
printf("*************************************************** testMazda323\r\n");
|
printf("*************************************************** testMazda323\r\n");
|
||||||
|
|
||||||
EngineTestHelper eth(MAZDA_323);
|
EngineTestHelper eth(MAZDA_323);
|
||||||
assertEquals(0, eth.ec2.triggerShape.getTriggerShapeSynchPointIndex());
|
assertEquals(0, eth.engine.triggerShape.getTriggerShapeSynchPointIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
void testMazdaMianaNbDecoder(void) {
|
void testMazdaMianaNbDecoder(void) {
|
||||||
|
@ -208,7 +208,7 @@ void testMazdaMianaNbDecoder(void) {
|
||||||
engine_configuration_s *ec = eth.ec;
|
engine_configuration_s *ec = eth.ec;
|
||||||
Engine *engine = ð.engine;
|
Engine *engine = ð.engine;
|
||||||
engine_configuration_s *engineConfiguration = ec;
|
engine_configuration_s *engineConfiguration = ec;
|
||||||
trigger_shape_s * shape = ð.ec2.triggerShape;
|
trigger_shape_s * shape = ð.engine.triggerShape;
|
||||||
assertEquals(11, shape->getTriggerShapeSynchPointIndex());
|
assertEquals(11, shape->getTriggerShapeSynchPointIndex());
|
||||||
|
|
||||||
TriggerState state;
|
TriggerState state;
|
||||||
|
@ -294,7 +294,7 @@ static void testTriggerDecoder2(const char *msg, engine_type_e type, int synchPo
|
||||||
|
|
||||||
initSpeedDensity(ec);
|
initSpeedDensity(ec);
|
||||||
|
|
||||||
trigger_shape_s *t = ð.ec2.triggerShape;
|
trigger_shape_s *t = ð.engine.triggerShape;
|
||||||
|
|
||||||
assertEqualsM("synchPointIndex", synchPointIndex, t->getTriggerShapeSynchPointIndex());
|
assertEqualsM("synchPointIndex", synchPointIndex, t->getTriggerShapeSynchPointIndex());
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ void testGY6_139QMB(void) {
|
||||||
TriggerState state;
|
TriggerState state;
|
||||||
assertFalseM("shaft_is_synchronized", state.shaft_is_synchronized);
|
assertFalseM("shaft_is_synchronized", state.shaft_is_synchronized);
|
||||||
|
|
||||||
trigger_shape_s * shape = ð.ec2.triggerShape;
|
trigger_shape_s * shape = ð.engine.triggerShape;
|
||||||
|
|
||||||
assertFalseM("shaft_is_synchronized", state.shaft_is_synchronized);
|
assertFalseM("shaft_is_synchronized", state.shaft_is_synchronized);
|
||||||
assertEquals(0, state.getCurrentIndex());
|
assertEquals(0, state.getCurrentIndex());
|
||||||
|
@ -484,8 +484,8 @@ static void testRpmCalculator(void) {
|
||||||
void testTriggerDecoder(void) {
|
void testTriggerDecoder(void) {
|
||||||
printf("*************************************************** testTriggerDecoder\r\n");
|
printf("*************************************************** testTriggerDecoder\r\n");
|
||||||
|
|
||||||
engine_configuration2_s ec2;
|
Engine engine;
|
||||||
trigger_shape_s * s = &ec2.triggerShape;
|
trigger_shape_s * s = &engine.triggerShape;
|
||||||
|
|
||||||
|
|
||||||
initializeSkippedToothTriggerShapeExt(s, 2, 0, FOUR_STROKE_CAM_SENSOR);
|
initializeSkippedToothTriggerShapeExt(s, 2, 0, FOUR_STROKE_CAM_SENSOR);
|
||||||
|
|
Loading…
Reference in New Issue