diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 90d4debbb3..ee18d6c7db 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -74,8 +74,6 @@ extern bool main_loop_started; #include "vehicle_speed.h" #include "single_timer_executor.h" #include "periodic_task.h" -extern int vvtEventRiseCounter; -extern int vvtEventFallCounter; extern int icuWidthCallbackCounter; extern int icuWidthPeriodCounter; #endif /* EFI_PROD_CODE */ @@ -773,8 +771,8 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->debugIntField2 = engine->triggerCentral.getHwEventCounter((int)SHAFT_SECONDARY_FALLING); tsOutputChannels->debugIntField3 = engine->triggerCentral.getHwEventCounter((int)SHAFT_3RD_FALLING); #if EFI_PROD_CODE - tsOutputChannels->debugIntField4 = vvtEventRiseCounter; - tsOutputChannels->debugIntField5 = vvtEventFallCounter; + tsOutputChannels->debugIntField4 = engine->triggerCentral.vvtEventRiseCounter; + tsOutputChannels->debugIntField5 = engine->triggerCentral.vvtEventFallCounter; tsOutputChannels->debugFloatField5 = icuWidthCallbackCounter + icuWidthPeriodCounter; #endif /* EFI_PROD_CODE */ diff --git a/firmware/controllers/generated/trigger_generated.h b/firmware/controllers/generated/trigger_generated.h index 6a8fbd2b43..030f704d87 100644 --- a/firmware/controllers/generated/trigger_generated.h +++ b/firmware/controllers/generated/trigger_generated.h @@ -1,4 +1,4 @@ -// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/trigger_state.txt Mon Sep 02 13:51:51 EDT 2019 +// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/trigger_state.txt Mon Sep 02 20:41:37 EDT 2019 // by class com.rusefi.output.CHeaderConsumer // begin #ifndef CONTROLLERS_GENERATED_TRIGGER_GENERATED_H @@ -16,11 +16,19 @@ struct trigger_central_s { * offset 24 */ int vvtCamCounter = (int)0; - /** total size 28*/ + /** + * offset 28 + */ + int vvtEventRiseCounter = (int)0; + /** + * offset 32 + */ + int vvtEventFallCounter = (int)0; + /** total size 36*/ }; typedef struct trigger_central_s trigger_central_s; #endif // end -// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/trigger_state.txt Mon Sep 02 13:51:51 EDT 2019 +// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/trigger_state.txt Mon Sep 02 20:41:37 EDT 2019 diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 6ee6134cf6..ea2a37927d 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -89,6 +89,14 @@ void addTriggerEventListener(ShaftPositionListener listener, const char *name, E } void hwHandleVvtCamSignal(trigger_value_e front DECLARE_ENGINE_PARAMETER_SUFFIX) { + TriggerCentral *tc = &engine->triggerCentral; + if (front == TV_RISE) { + tc->vvtEventRiseCounter++; + } else { + tc->vvtEventFallCounter++; + } + + addEngineSnifferEvent(PROTOCOL_VVT_NAME, front == TV_RISE ? PROTOCOL_ES_UP : PROTOCOL_ES_DOWN); if (CONFIGB(vvtCamSensorUseRise) ^ (front != TV_FALL)) { @@ -102,7 +110,6 @@ void hwHandleVvtCamSignal(trigger_value_e front DECLARE_ENGINE_PARAMETER_SUFFIX) return; } - TriggerCentral *tc = &engine->triggerCentral; tc->vvtCamCounter++; efitick_t nowNt = getTimeNowNt(); @@ -511,9 +518,6 @@ extern bool hwTriggerInputEnabled; extern uint32_t maxSchedulingPrecisionLoss; extern uint32_t *cyccnt; -extern int vvtEventRiseCounter; -extern int vvtEventFallCounter; - void resetMaxValues() { #if EFI_PROD_CODE || EFI_SIMULATOR maxEventCallbackDuration = triggerMaxDuration = 0; @@ -592,7 +596,7 @@ void triggerInfo(void) { if (HAVE_CAM_INPUT()) { scheduleMsg(logger, "VVT input: %s mode %s", hwPortname(engineConfiguration->camInputs[0]), getVvt_mode_e(engineConfiguration->vvtMode)); - scheduleMsg(logger, "VVT event counters: %d/%d", vvtEventRiseCounter, vvtEventFallCounter); + scheduleMsg(logger, "VVT event counters: %d/%d", engine->triggerCentral.vvtEventRiseCounter, engine->triggerCentral.vvtEventFallCounter); } diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 2c68c75fc1..3873404291 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -504,6 +504,8 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no DISPLAY_TEXT(VVT_1); DISPLAY(DISPLAY_CONFIG(CAMINPUTS1)); + DISPLAY(DISPLAY_FIELD(vvtEventRiseCounter)); + DISPLAY(DISPLAY_FIELD(vvtEventFallCounter)); DISPLAY(DISPLAY_FIELD(vvtCamCounter)); if (triggerShape->isSynchronizationNeeded) { diff --git a/firmware/hw_layer/trigger_input.cpp b/firmware/hw_layer/trigger_input.cpp index 2966f5f04e..e624e8f256 100644 --- a/firmware/hw_layer/trigger_input.cpp +++ b/firmware/hw_layer/trigger_input.cpp @@ -36,9 +36,6 @@ EXTERN_ENGINE ; static Logging *logger; -int vvtEventRiseCounter = 0; -int vvtEventFallCounter = 0; - #if EFI_PROD_CODE /* PAL based implementation */ #if (HAL_TRIGGER_USE_PAL == TRUE) && (PAL_USE_CALLBACKS == TRUE) @@ -80,10 +77,8 @@ static void cam_callback(void *arg) { bool rise = (palReadLine(pal_line) == PAL_HIGH); if (rise) { - vvtEventRiseCounter++; hwHandleVvtCamSignal(TV_RISE); } else { - vvtEventFallCounter++; hwHandleVvtCamSignal(TV_FALL); } } @@ -114,13 +109,11 @@ static ICUDriver *primaryCrankDriver; static void cam_icu_width_callback(ICUDriver *icup) { (void)icup; - vvtEventRiseCounter++; hwHandleVvtCamSignal(TV_RISE); } static void cam_icu_period_callback(ICUDriver *icup) { (void)icup; - vvtEventFallCounter++; hwHandleVvtCamSignal(TV_FALL); } diff --git a/firmware/hw_layer/trigger_input_comp.cpp b/firmware/hw_layer/trigger_input_comp.cpp index d3783f609a..2192e3015a 100644 --- a/firmware/hw_layer/trigger_input_comp.cpp +++ b/firmware/hw_layer/trigger_input_comp.cpp @@ -28,9 +28,6 @@ EXTERN_ENGINE ; static Logging *logger; -int vvtEventRiseCounter = 0; -int vvtEventFallCounter = 0; - static void comp_shaft_callback(COMPDriver *comp) { bool isRising = (comp_lld_get_status(comp) & COMP_IRQ_RISING) != 0; int isPrimary = (comp == EFI_COMP_PRIMARY_DEVICE); @@ -56,10 +53,8 @@ static void comp_shaft_callback(COMPDriver *comp) { #if 0 static void comp_cam_callback(COMPDriver *comp) { if (isRising) { - vvtEventRiseCounter++; hwHandleVvtCamSignal(TV_RISE); } else { - vvtEventFallCounter++; hwHandleVvtCamSignal(TV_FALL); } } diff --git a/firmware/integration/trigger_state.txt b/firmware/integration/trigger_state.txt index 0c5074914f..925afa59ec 100644 --- a/firmware/integration/trigger_state.txt +++ b/firmware/integration/trigger_state.txt @@ -6,4 +6,8 @@ struct_no_prefix define_constructor trigger_central_s int vvtCamCounter +int vvtEventRiseCounter +int vvtEventFallCounter + + end_struct diff --git a/java_console/models/src/com/rusefi/config/generated/TriggerState.java b/java_console/models/src/com/rusefi/config/generated/TriggerState.java index 45b2b6adf9..961b7de954 100644 --- a/java_console/models/src/com/rusefi/config/generated/TriggerState.java +++ b/java_console/models/src/com/rusefi/config/generated/TriggerState.java @@ -1,6 +1,6 @@ package com.rusefi.config.generated; -// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/trigger_state.txt Mon Sep 02 13:51:51 EDT 2019 +// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/trigger_state.txt Mon Sep 02 20:41:37 EDT 2019 // by class com.rusefi.output.JavaFieldsConsumer import com.rusefi.config.*; @@ -14,6 +14,8 @@ public class TriggerState { public static final Field HWEVENTCOUNTERS5 = Field.create("HWEVENTCOUNTERS5", 16, FieldType.INT); public static final Field HWEVENTCOUNTERS6 = Field.create("HWEVENTCOUNTERS6", 20, FieldType.INT); public static final Field VVTCAMCOUNTER = Field.create("VVTCAMCOUNTER", 24, FieldType.INT); + public static final Field VVTEVENTRISECOUNTER = Field.create("VVTEVENTRISECOUNTER", 28, FieldType.INT); + public static final Field VVTEVENTFALLCOUNTER = Field.create("VVTEVENTFALLCOUNTER", 32, FieldType.INT); public static final Field[] VALUES = { HWEVENTCOUNTERS1, HWEVENTCOUNTERS2, @@ -22,5 +24,7 @@ public class TriggerState { HWEVENTCOUNTERS5, HWEVENTCOUNTERS6, VVTCAMCOUNTER, + VVTEVENTRISECOUNTER, + VVTEVENTFALLCOUNTER, }; } diff --git a/java_console/ui/src/com/rusefi/ldmp/generated/TriggerDecoderMeta.java b/java_console/ui/src/com/rusefi/ldmp/generated/TriggerDecoderMeta.java index 38fab26b13..b182edb9ca 100644 --- a/java_console/ui/src/com/rusefi/ldmp/generated/TriggerDecoderMeta.java +++ b/java_console/ui/src/com/rusefi/ldmp/generated/TriggerDecoderMeta.java @@ -18,6 +18,8 @@ public class TriggerDecoderMeta { new TextRequest("EOL"), new TextRequest("VVT_1"), new ConfigRequest("CAMINPUTS1"), + new FieldRequest("Trigger", "vvtEventRiseCounter"), + new FieldRequest("Trigger", "vvtEventFallCounter"), new FieldRequest("Trigger", "vvtCamCounter"), }; } \ No newline at end of file