auto-sync

This commit is contained in:
rusEfi 2015-04-08 22:09:55 -05:00
parent 3d17d5d7ad
commit bbd11d3fc0
7 changed files with 33 additions and 40 deletions

View File

@ -376,6 +376,8 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_F) {
engineConfiguration->hasBaroSensor = false;
engineConfiguration->isDigitalChartEnabled = true;
engineConfiguration->useOnlyFrontForTrigger = false;
boardConfiguration->idle.solenoidFrequency = 200;
// set_idle_position 50
boardConfiguration->idlePosition = 50;

View File

@ -109,26 +109,19 @@ void TriggerCentral::resetCounters() {
static char shaft_signal_msg_index[15];
static ALWAYS_INLINE void reportEventToWaveChart(trigger_event_e ckpSignalType, int index) {
static bool_t isUpEvent[6] = { false, true, false, true, false, true };
static const char *eventId[6] = { CRANK1, CRANK1, CRANK2, CRANK2, CRANK3, CRANK3 };
static ALWAYS_INLINE void reportEventToWaveChart(trigger_event_e ckpSignalType, int index DECLARE_ENGINE_PARAMETER_S) {
itoa10(&shaft_signal_msg_index[2], index);
if (ckpSignalType == SHAFT_PRIMARY_UP) {
shaft_signal_msg_index[0] = 'u';
addWaveChartEvent(CRANK1, (char* ) shaft_signal_msg_index);
} else if (ckpSignalType == SHAFT_PRIMARY_DOWN) {
shaft_signal_msg_index[0] = 'd';
addWaveChartEvent(CRANK1, (char* ) shaft_signal_msg_index);
} else if (ckpSignalType == SHAFT_SECONDARY_UP) {
shaft_signal_msg_index[0] = 'u';
addWaveChartEvent(CRANK2, (char* ) shaft_signal_msg_index);
} else if (ckpSignalType == SHAFT_SECONDARY_DOWN) {
shaft_signal_msg_index[0] = 'd';
addWaveChartEvent(CRANK2, (char* ) shaft_signal_msg_index);
} else if (ckpSignalType == SHAFT_3RD_UP) {
shaft_signal_msg_index[0] = 'u';
addWaveChartEvent(CRANK3, (char* ) shaft_signal_msg_index);
} else if (ckpSignalType == SHAFT_3RD_DOWN) {
shaft_signal_msg_index[0] = 'd';
addWaveChartEvent(CRANK3, (char* ) shaft_signal_msg_index);
bool_t isUp = isUpEvent[(int) ckpSignalType];
shaft_signal_msg_index[0] = isUp ? 'u' : 'd';
addWaveChartEvent(eventId[(int )ckpSignalType], (char* ) shaft_signal_msg_index);
if (engineConfiguration->useOnlyFrontForTrigger) {
// let's add the opposite event right away
shaft_signal_msg_index[0] = isUp ? 'd' : 'u';
addWaveChartEvent(eventId[(int )ckpSignalType], (char* ) shaft_signal_msg_index);
}
}
@ -181,7 +174,7 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal DECLARE_ENGINE_PAR
triggerIndexForListeners = triggerState.getCurrentIndex() + (isEven ? 0 : TRIGGER_SHAPE(size));
}
reportEventToWaveChart(signal, triggerIndexForListeners);
reportEventToWaveChart(signal, triggerIndexForListeners PASS_ENGINE_PARAMETER);
if (triggerState.current_index >= TRIGGER_SHAPE(size)) {
warning(OBD_PCM_Processor_Fault, "unexpected eventIndex=%d", triggerState.current_index);
@ -236,9 +229,10 @@ void triggerInfo(Engine *engine) {
TriggerShape *ts = &engine->triggerShape;
scheduleMsg(logger, "Template %s (%d) trigger %s (%d) useRiseEdge=%s only=", getConfigurationName(engineConfiguration->engineType),
engineConfiguration->engineType, getTrigger_type_e(engineConfiguration->trigger.type),
engineConfiguration->trigger.type, boolToString(TRIGGER_SHAPE(useRiseEdge)));
scheduleMsg(logger, "Template %s (%d) trigger %s (%d) useRiseEdge=%s onlyFront=%s",
getConfigurationName(engineConfiguration->engineType), engineConfiguration->engineType,
getTrigger_type_e(engineConfiguration->trigger.type), engineConfiguration->trigger.type,
boolToString(TRIGGER_SHAPE(useRiseEdge)), boolToString(engineConfiguration->useOnlyFrontForTrigger));
scheduleMsg(logger, "trigger#1 event counters up=%d/down=%d", triggerCentral.getHwEventCounter(0),
triggerCentral.getHwEventCounter(1));
@ -266,14 +260,10 @@ void triggerInfo(Engine *engine) {
#endif
#if EFI_PROD_CODE
scheduleMsg(logger, "sn=%s ignitionMathTime=%d schTime=%d injectonSchTime=%d zeroTestTime=%d advanceTime=%d triggerMaxDuration=%d",
boolToString(ts->isSynchronizationNeeded),
engine->m.ignitionMathTime,
engine->m.ignitionSchTime,
engine->m.injectonSchTime,
engine->m.zeroTestTime,
engine->m.advanceTime,
triggerMaxDuration);
scheduleMsg(logger,
"sn=%s ignitionMathTime=%d schTime=%d injectonSchTime=%d zeroTestTime=%d advanceTime=%d triggerMaxDuration=%d",
boolToString(ts->isSynchronizationNeeded), engine->m.ignitionMathTime, engine->m.ignitionSchTime,
engine->m.injectonSchTime, engine->m.zeroTestTime, engine->m.advanceTime, triggerMaxDuration);
triggerMaxDuration = 0;
@ -286,7 +276,6 @@ void triggerInfo(Engine *engine) {
getPin_output_mode_e(boardConfiguration->triggerSimulatorPinModes[0]),
boardConfiguration->triggerSimulatorFrequency);
if (engine->triggerShape.needSecondTriggerInput) {
scheduleMsg(logger, "secondary trigger input: %s", hwPortname(boardConfiguration->triggerInputPins[1]));
#if EFI_EMULATE_POSITION_SENSORS || defined(__DOXYGEN__)

View File

@ -121,8 +121,6 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, uint64_t now
eventCount[triggerWheel]++;
eventCountExt[signal]++;
bool_t isLessImportant = (TRIGGER_SHAPE(useRiseEdge) && signal != SHAFT_PRIMARY_UP)
|| (!TRIGGER_SHAPE(useRiseEdge) && signal != SHAFT_PRIMARY_DOWN);
uint64_t currentDurationLong = getCurrentGapDuration(nowNt);
@ -133,7 +131,7 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, uint64_t now
currentDuration =
currentDurationLong > 10 * US2NT(US_PER_SECOND_LL) ? 10 * US2NT(US_PER_SECOND_LL) : currentDurationLong;
if (isLessImportant) {
if (isLessImportant(signal)) {
/**
* For less important events we simply increment the index.
*/

View File

@ -101,4 +101,8 @@ void initTriggerDecoderLogger(Logging *sharedLogger);
bool_t isTriggerDecoderError(void);
#define isLessImportant(signal) ((TRIGGER_SHAPE(useRiseEdge) && signal != SHAFT_PRIMARY_UP) \
|| (!TRIGGER_SHAPE(useRiseEdge) && signal != SHAFT_PRIMARY_DOWN))
#endif /* TRIGGER_DECODER_H_ */

View File

@ -55,11 +55,8 @@ int TriggerShape::getTriggerShapeSynchPointIndex() {
void TriggerShape::calculateTriggerSynchPoint(DECLARE_ENGINE_PARAMETER_F) {
trigger_config_s const*triggerConfig = &engineConfiguration->trigger;
setTriggerShapeSynchPointIndex(engineConfiguration, findTriggerZeroEventIndex(this, triggerConfig PASS_ENGINE_PARAMETER), engine);
}
void TriggerShape::setTriggerShapeSynchPointIndex(engine_configuration_s *engineConfiguration, int triggerShapeSynchPointIndex, Engine *engine) {
this->triggerShapeSynchPointIndex = triggerShapeSynchPointIndex;
triggerShapeSynchPointIndex = findTriggerZeroEventIndex(this, triggerConfig PASS_ENGINE_PARAMETER);
engine->engineCycleEventCount = getLength();

View File

@ -106,7 +106,6 @@ public:
void calculateTriggerSynchPoint(DECLARE_ENGINE_PARAMETER_F);
void setTriggerShapeSynchPointIndex(engine_configuration_s *engineConfiguration, int triggerShapeSynchPointIndex, Engine *engine);
private:
trigger_shape_helper h;

View File

@ -41,6 +41,8 @@ static void shaft_icu_width_callback(ICUDriver *icup) {
// todo: add support for 3rd channel
trigger_event_e signal = isPrimary ? SHAFT_PRIMARY_UP : SHAFT_SECONDARY_UP;
if (isLessImportant(signal) && CONFIG(useOnlyFrontForTrigger))
return;
hwHandleShaftSignal(signal);
}
@ -53,6 +55,8 @@ static void shaft_icu_period_callback(ICUDriver *icup) {
// todo: add support for 3rd channel
// icucnt_t last_period = icuGetPeriod(icup); so far we are fine with system time
trigger_event_e signal = isPrimary ? SHAFT_PRIMARY_DOWN : SHAFT_SECONDARY_DOWN;
if (isLessImportant(signal) && CONFIG(useOnlyFrontForTrigger))
return;
hwHandleShaftSignal(signal);
}