From 12a29232cca053cf5cdc992d0de8519efbc1e52d Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Wed, 31 May 2023 01:41:20 -0400 Subject: [PATCH] tooth_logger.h -> pch (cherry picked from commit ad3ea57276361b6da69eb920dd056a662f6f5c70) --- firmware/ChibiOS | 2 +- firmware/console/binary/tooth_logger.cpp | 2 -- firmware/console/binary/tunerstudio.cpp | 1 - .../engine_cycle/main_trigger_callback.cpp | 1 - .../engine_cycle/rpm_calculator.cpp | 2 -- .../controllers/engine_cycle/spark_logic.cpp | 1 - .../controllers/system/injection_gpio.cpp | 7 +----- .../controllers/trigger/trigger_central.cpp | 22 +++++++++---------- firmware/hw_layer/mmc_card.cpp | 1 - firmware/pch/pch.h | 1 + 10 files changed, 13 insertions(+), 27 deletions(-) diff --git a/firmware/ChibiOS b/firmware/ChibiOS index 284be36d60..30135a2f47 160000 --- a/firmware/ChibiOS +++ b/firmware/ChibiOS @@ -1 +1 @@ -Subproject commit 284be36d608557fb6f9c58786d9da1d6a9283a9c +Subproject commit 30135a2f47677c7cdd24c31b64d7a5218bbca8f3 diff --git a/firmware/console/binary/tooth_logger.cpp b/firmware/console/binary/tooth_logger.cpp index d241ae1b5d..23a50e58b2 100644 --- a/firmware/console/binary/tooth_logger.cpp +++ b/firmware/console/binary/tooth_logger.cpp @@ -10,8 +10,6 @@ #include "pch.h" -#include "tooth_logger.h" - #if EFI_TOOTH_LOGGER /** diff --git a/firmware/console/binary/tunerstudio.cpp b/firmware/console/binary/tunerstudio.cpp index 3bf98fb8f0..1c252dea8a 100644 --- a/firmware/console/binary/tunerstudio.cpp +++ b/firmware/console/binary/tunerstudio.cpp @@ -73,7 +73,6 @@ #include "console_io.h" #include "bluetooth.h" #include "tunerstudio_io.h" -#include "tooth_logger.h" #include "trigger_scope.h" #include "electronic_throttle.h" #include "live_data.h" diff --git a/firmware/controllers/engine_cycle/main_trigger_callback.cpp b/firmware/controllers/engine_cycle/main_trigger_callback.cpp index 9b9fc60352..33fb75b727 100644 --- a/firmware/controllers/engine_cycle/main_trigger_callback.cpp +++ b/firmware/controllers/engine_cycle/main_trigger_callback.cpp @@ -41,7 +41,6 @@ #include "cyclic_buffer.h" #include "fuel_math.h" #include "cdm_ion_sense.h" -#include "tooth_logger.h" #include "local_version_holder.h" #include "event_queue.h" #include "injector_model.h" diff --git a/firmware/controllers/engine_cycle/rpm_calculator.cpp b/firmware/controllers/engine_cycle/rpm_calculator.cpp index 7f482199cc..6e2d8fb7ad 100644 --- a/firmware/controllers/engine_cycle/rpm_calculator.cpp +++ b/firmware/controllers/engine_cycle/rpm_calculator.cpp @@ -15,9 +15,7 @@ #include "pch.h" - #include "trigger_central.h" -#include "tooth_logger.h" #if EFI_SENSOR_CHART #include "sensor_chart.h" diff --git a/firmware/controllers/engine_cycle/spark_logic.cpp b/firmware/controllers/engine_cycle/spark_logic.cpp index 08dcdc230a..aaa42c8aa1 100644 --- a/firmware/controllers/engine_cycle/spark_logic.cpp +++ b/firmware/controllers/engine_cycle/spark_logic.cpp @@ -16,7 +16,6 @@ #include "utlist.h" #include "event_queue.h" -#include "tooth_logger.h" #include "knock_logic.h" diff --git a/firmware/controllers/system/injection_gpio.cpp b/firmware/controllers/system/injection_gpio.cpp index 41116254e7..c5bc30e2db 100644 --- a/firmware/controllers/system/injection_gpio.cpp +++ b/firmware/controllers/system/injection_gpio.cpp @@ -2,12 +2,7 @@ * injection_gpio.cpp */ -#include "injection_gpio.h" -#include "engine_state.h" -#include "tooth_logger.h" -#include "tunerstudio_outputs.h" -#include "engine_configuration.h" -#include "efi_gpio.h" +#include "pch.h" extern bool printFuelDebug; diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 12fec6d830..2d3c2e4a5d 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -12,7 +12,6 @@ #include "trigger_decoder.h" #include "main_trigger_callback.h" #include "listener_array.h" -#include "tooth_logger.h" #include "hip9011.h" #include "logic_analyzer.h" @@ -20,7 +19,6 @@ #include "trigger_simulator.h" #include "trigger_emulator_algo.h" -#include "tooth_logger.h" #include "map_averaging.h" #include "main_trigger_callback.h" #include "status_loop.h" @@ -491,7 +489,7 @@ void handleShaftSignal(int signalIndex, bool isRising, efitick_t timestamp) { #endif /* EFI_TOOTH_LOGGER */ - // for effective noise filtering, we need both signal edges, + // for effective noise filtering, we need both signal edges, // so we pass them to handleShaftSignal() and defer this test if (!engineConfiguration->useNoiselessTriggerDecoder) { if (!isUsefulSignal(signal, getTriggerCentral()->triggerShape)) { @@ -558,9 +556,9 @@ static void reportEventToWaveChart(trigger_event_e ckpSignalType, int triggerEve } /** - * This is used to filter noise spikes (interference) in trigger signal. See + * This is used to filter noise spikes (interference) in trigger signal. See * The basic idea is to use not just edges, but the average amount of time the signal stays in '0' or '1'. - * So we update 'accumulated periods' to track where the signal is. + * So we update 'accumulated periods' to track where the signal is. * And then compare between the current period and previous, with some tolerance (allowing for the wheel speed change). * @return true if the signal is passed through. */ @@ -574,18 +572,18 @@ bool TriggerNoiseFilter::noiseFilter(efitick_t nowNt, TriggerWheel ti = triggerIdx[signal]; // falling is opposite to rising, and vise versa trigger_event_e os = opposite[signal]; - + // todo: currently only primary channel is filtered, because there are some weird trigger types on other channels if (ti != TriggerWheel::T_PRIMARY) return true; - + // update period accumulator: for rising signal, we update '0' accumulator, and for falling - '1' if (lastSignalTimes[signal] != -1) accumSignalPeriods[signal] += nowNt - lastSignalTimes[signal]; // save current time for this trigger channel lastSignalTimes[signal] = nowNt; - - // now we want to compare current accumulated period to the stored one + + // now we want to compare current accumulated period to the stored one efitick_t currentPeriod = accumSignalPeriods[signal]; // the trick is to compare between different efitick_t allowedPeriod = accumSignalPrevPeriods[os]; @@ -593,18 +591,18 @@ bool TriggerNoiseFilter::noiseFilter(efitick_t nowNt, // but first check if we're expecting a gap bool isGapExpected = TRIGGER_WAVEFORM(isSynchronizationNeeded) && triggerState->getShaftSynchronized() && (triggerState->currentCycle.eventCount[(int)ti] + 1) == TRIGGER_WAVEFORM(getExpectedEventCount(ti)); - + if (isGapExpected) { // usually we need to extend the period for gaps, based on the trigger info allowedPeriod *= TRIGGER_WAVEFORM(syncRatioAvg); } - + // also we need some margin for rapidly changing trigger-wheel speed, // that's why we expect the period to be no less than 2/3 of the previous period (this is just an empirical 'magic' coef.) efitick_t minAllowedPeriod = 2 * allowedPeriod / 3; // but no longer than 5/4 of the previous 'normal' period efitick_t maxAllowedPeriod = 5 * allowedPeriod / 4; - + // above all, check if the signal comes not too early if (currentPeriod >= minAllowedPeriod) { // now we store this period as a reference for the next time, diff --git a/firmware/hw_layer/mmc_card.cpp b/firmware/hw_layer/mmc_card.cpp index eac0d19fd7..9f273e6261 100644 --- a/firmware/hw_layer/mmc_card.cpp +++ b/firmware/hw_layer/mmc_card.cpp @@ -19,7 +19,6 @@ #include "buffered_writer.h" #include "status_loop.h" #include "binary_logging.h" -#include "tooth_logger.h" static bool fs_ready = false; diff --git a/firmware/pch/pch.h b/firmware/pch/pch.h index 70d48142a4..ccd1b9f60c 100644 --- a/firmware/pch/pch.h +++ b/firmware/pch/pch.h @@ -36,6 +36,7 @@ #include "perf_trace.h" #include "hardware.h" #include "thread_priority.h" +#include "tooth_logger.h" #if EFI_UNIT_TEST #include