From c80a37503e05ad8f1cdcf24c16d23fa5acf8f965 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Wed, 1 Dec 2021 14:17:16 -0500 Subject: [PATCH] trigger_adc helping simulator --- firmware/hw_layer/digital_input/trigger/trigger_input.h | 3 ++- .../hw_layer/digital_input/trigger/trigger_input_adc.cpp | 5 +++++ unit_tests/global.h | 2 -- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/firmware/hw_layer/digital_input/trigger/trigger_input.h b/firmware/hw_layer/digital_input/trigger/trigger_input.h index 5512f64844..6b5f061925 100644 --- a/firmware/hw_layer/digital_input/trigger/trigger_input.h +++ b/firmware/hw_layer/digital_input/trigger/trigger_input.h @@ -10,7 +10,6 @@ #include "trigger_structure.h" #include "trigger_central.h" -#include "trigger_input.h" #define TRIGGER_BAIL_IF_DISABLED \ if (!engine->hwTriggerInputEnabled) { \ @@ -36,6 +35,8 @@ void startTriggerDebugPins(); #if HAL_USE_ADC typedef adcsample_t triggerAdcSample_t; +#else +typedef uint16_t triggerAdcSample_t; #endif /* HAL_USE_ADC */ // This detector has 2 modes for low-RPM (ADC) and fast-RPM (EXTI) diff --git a/firmware/hw_layer/digital_input/trigger/trigger_input_adc.cpp b/firmware/hw_layer/digital_input/trigger/trigger_input_adc.cpp index 2a61eed52f..56540dcb2c 100644 --- a/firmware/hw_layer/digital_input/trigger/trigger_input_adc.cpp +++ b/firmware/hw_layer/digital_input/trigger/trigger_input_adc.cpp @@ -153,6 +153,8 @@ void onTriggerChanged(efitick_t stamp, bool isPrimary, bool isRising) { void TriggerAdcDetector::init() { +#if ! EFI_SIMULATOR + // todo: move some of these to config // we need to make at least minNumAdcMeasurementsPerTooth for 1 tooth (i.e. between two consequent events) @@ -176,6 +178,7 @@ void TriggerAdcDetector::init() { adcMaxThreshold = adcDefaultThreshold - adcDeltaThreshold; reset(); +#endif // EFI_SIMULATOR } void TriggerAdcDetector::reset() { @@ -226,6 +229,7 @@ void TriggerAdcDetector::digitalCallback(efitick_t stamp, bool isPrimary, bool r } void TriggerAdcDetector::analogCallback(efitick_t stamp, triggerAdcSample_t value) { +#if ! EFI_SIMULATOR if (curAdcMode != TRIGGER_ADC_ADC) { return; } @@ -353,5 +357,6 @@ void TriggerAdcDetector::analogCallback(efitick_t stamp, triggerAdcSample_t valu prevValue = transition; prevStamp = stamp; +#endif // EFI_SIMULATOR } diff --git a/unit_tests/global.h b/unit_tests/global.h index 74875e7334..24919250e3 100644 --- a/unit_tests/global.h +++ b/unit_tests/global.h @@ -18,8 +18,6 @@ typedef uint32_t iomode_t; typedef uint32_t ioportid_t; typedef uint32_t ioportmask_t; -typedef uint16_t triggerAdcSample_t; - #define DL_OUTPUT_BUFFER 200 // just a stub implementation for unit tests