diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 19daee0f1b..b8dac888f3 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -289,10 +289,11 @@ void triggerInfo(void) { TriggerShape *ts = &engine->triggerShape; - scheduleMsg(logger, "Template %s (%d) trigger %s (%d) useRiseEdge=%s onlyFront=%s", + scheduleMsg(logger, "Template %s (%d) trigger %s (%d) useRiseEdge=%s onlyFront=%s gapBothDirections=%s", getConfigurationName(engineConfiguration->engineType), engineConfiguration->engineType, getTrigger_type_e(engineConfiguration->trigger.type), engineConfiguration->trigger.type, - boolToString(TRIGGER_SHAPE(useRiseEdge)), boolToString(engineConfiguration->useOnlyFrontForTrigger)); + boolToString(TRIGGER_SHAPE(useRiseEdge)), boolToString(engineConfiguration->useOnlyFrontForTrigger), + boolToString(TRIGGER_SHAPE(gapBothDirections))); if (engineConfiguration->trigger.type == TT_TOOTHED_WHEEL) { scheduleMsg(logger, "total %d/skipped %d", engineConfiguration->trigger.customTotalToothCount, diff --git a/firmware/controllers/trigger/trigger_chrysler.cpp b/firmware/controllers/trigger/trigger_chrysler.cpp index 5ffb391cca..6203ead55a 100644 --- a/firmware/controllers/trigger/trigger_chrysler.cpp +++ b/firmware/controllers/trigger/trigger_chrysler.cpp @@ -35,8 +35,8 @@ void configureNeon2003TriggerShape(TriggerShape *s) { s->tdcPosition = 496; // are these non-default values really needed here now that the gap is finally precise? - s->setTriggerSynchronizationGap(1); - s->setSecondTriggerSynchronizationGap(1); + s->setTriggerSynchronizationGap2(0.75, 1.40); + s->setSecondTriggerSynchronizationGap2(0.7, 1.25); float EPS_ANGLE = 0.3; diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 1712194388..937d66e154 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -59,6 +59,8 @@ float actualSynchGap; static Logging * logger; efitick_t lastDecodingErrorTime = US2NT(-10000000LL); +// the boolean flag is a performance optimization so that complex comparison is avoided if no error +bool_t someSortOfTriggerError = false; /** * @return TRUE is something is wrong with trigger decoding @@ -201,16 +203,16 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no ; #if EFI_PROD_CODE || defined(__DOXYGEN__) - if (engineConfiguration->isPrintTriggerSynchDetails) { + if (engineConfiguration->isPrintTriggerSynchDetails || someSortOfTriggerError) { #else if (printTriggerDebug) { #endif /* EFI_PROD_CODE */ float gap = 1.0 * currentDuration / toothed_previous_duration; + float prevGap = 1.0 * toothed_previous_duration / durationBeforePrevious; #if EFI_PROD_CODE || defined(__DOXYGEN__) - scheduleMsg(logger, "gap=%f @ %d", gap, currentCycle.current_index); + scheduleMsg(logger, "gap=%f/%f @ %d while expected %f/%f and %f/%f", gap, prevGap, currentCycle.current_index, TRIGGER_SHAPE(syncRatioFrom), TRIGGER_SHAPE(syncRatioTo), TRIGGER_SHAPE(secondSyncRatioFrom), TRIGGER_SHAPE(secondSyncRatioTo)); #else actualSynchGap = gap; - float prevGap = 1.0 * toothed_previous_duration / durationBeforePrevious; print("current gap %f/%f c=%d prev=%d\r\n", gap, prevGap, currentDuration, toothed_previous_duration); #endif /* EFI_PROD_CODE */ } @@ -245,8 +247,10 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no triggerDecoderErrorPin.setValue(isDecodingError); if (isDecodingError) { lastDecodingErrorTime = getTimeNowNt(); + someSortOfTriggerError = true; + totalTriggerErrorCounter++; - if (engineConfiguration->isPrintTriggerSynchDetails) { + if (engineConfiguration->isPrintTriggerSynchDetails || someSortOfTriggerError) { #if EFI_PROD_CODE || defined(__DOXYGEN__) scheduleMsg(logger, "error: synchronizationPoint @ index %d expected %d/%d/%d got %d/%d/%d", currentCycle.current_index, TRIGGER_SHAPE(expectedEventCount[0]), @@ -282,6 +286,13 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no } if (!isValidIndex(PASS_ENGINE_PARAMETER_F)) { warning(OBD_PCM_Processor_Fault, "unexpected eventIndex=%d while size %d", currentCycle.current_index, TRIGGER_SHAPE(size)); + lastDecodingErrorTime = getTimeNowNt(); + someSortOfTriggerError = true; + } + if (someSortOfTriggerError) { + if (getTimeNowNt() - lastDecodingErrorTime > US2NT(US_PER_SECOND_LL)) { + someSortOfTriggerError = false; + } } if (boardConfiguration->sensorChartMode == SC_RPM_ACCEL || boardConfiguration->sensorChartMode == SC_DETAILED_RPM) { diff --git a/firmware/hw_layer/trigger_input.cpp b/firmware/hw_layer/trigger_input.cpp index ad15a4eecf..518786c1de 100644 --- a/firmware/hw_layer/trigger_input.cpp +++ b/firmware/hw_layer/trigger_input.cpp @@ -40,8 +40,6 @@ 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); } @@ -55,7 +53,7 @@ static void shaft_icu_period_callback(ICUDriver *icup) { // 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)) + if (CONFIG(useOnlyFrontForTrigger)) return; hwHandleShaftSignal(signal); } diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index 4586b268e4..7cccc4432f 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -275,5 +275,5 @@ int getRusEfiVersion(void) { return 123; // this is here to make the compiler happy about the unused array if (UNUSED_CCM_SIZE[0] * 0 != 0) return 3211; // this is here to make the compiler happy about the unused array - return 20150923; + return 20150924; }