From 0e12622371ca551b9c55d28506a44ea943b00397 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Mon, 20 Feb 2023 22:37:14 -0800 Subject: [PATCH] cdm ion --- firmware/config/stm32f4ems/efifeatures.h | 4 - firmware/console/status_loop.cpp | 6 -- .../engine_cycle/main_trigger_callback.cpp | 1 - .../controllers/trigger/trigger_central.cpp | 7 -- firmware/hw_layer/cdm_ion_sense.cpp | 83 ------------------- firmware/hw_layer/cdm_ion_sense.h | 39 --------- firmware/hw_layer/hardware.cpp | 5 -- firmware/hw_layer/hw_layer.mk | 1 - firmware/integration/rusefi_config.txt | 1 - firmware/tunerstudio/rusefi.input | 1 - simulator/simulator/efifeatures.h | 2 - unit_tests/tests/test_ion.cpp | 34 -------- unit_tests/tests/tests.mk | 1 - 13 files changed, 185 deletions(-) delete mode 100644 firmware/hw_layer/cdm_ion_sense.cpp delete mode 100644 firmware/hw_layer/cdm_ion_sense.h delete mode 100644 unit_tests/tests/test_ion.cpp diff --git a/firmware/config/stm32f4ems/efifeatures.h b/firmware/config/stm32f4ems/efifeatures.h index 4bb5b1eea5..2f27cfed4d 100644 --- a/firmware/config/stm32f4ems/efifeatures.h +++ b/firmware/config/stm32f4ems/efifeatures.h @@ -27,10 +27,6 @@ #define EFI_DYNO_VIEW TRUE -#ifndef EFI_CDM_INTEGRATION -#define EFI_CDM_INTEGRATION FALSE -#endif - #ifndef EFI_TOOTH_LOGGER #define EFI_TOOTH_LOGGER TRUE #endif diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 0362b1628d..c317e40f5e 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -47,7 +47,6 @@ #include "svnversion.h" #include "can_hw.h" #include "periodic_thread_controller.h" -#include "cdm_ion_sense.h" #include "binary_logging.h" #include "buffered_writer.h" #include "dynoview.h" @@ -807,11 +806,6 @@ DcHardware *getdcHardware(); } break; - case DBG_ION: -#if EFI_CDM_INTEGRATION - ionPostState(tsOutputChannels); -#endif /* EFI_CDM_INTEGRATION */ - break; case DBG_TLE8888: #if (BOARD_TLE8888_COUNT > 0) tle8888PostState(); diff --git a/firmware/controllers/engine_cycle/main_trigger_callback.cpp b/firmware/controllers/engine_cycle/main_trigger_callback.cpp index 1bb2060126..461112b1df 100644 --- a/firmware/controllers/engine_cycle/main_trigger_callback.cpp +++ b/firmware/controllers/engine_cycle/main_trigger_callback.cpp @@ -40,7 +40,6 @@ #include "advance_map.h" #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" diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 68c88abdc8..1495a05450 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -806,13 +806,6 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta wrapAngle(expectNextPhase, "nextEnginePhase", CUSTOM_ERR_6555); expectedNextPhase = expectNextPhase; -#if EFI_CDM_INTEGRATION - if (trgEventIndex == 0 && isBrainPinValid(engineConfiguration->cdmInputPin)) { - int cdmKnockValue = getCurrentCdmValue(getTriggerCentral()->triggerState.getCrankSynchronizationCounter()); - engine->knockLogic(cdmKnockValue); - } -#endif /* EFI_CDM_INTEGRATION */ - if (engine->rpmCalculator.getCachedRpm() > 0 && triggerIndexForListeners == 0) { engine->tpsAccelEnrichment.onEngineCycleTps(); } diff --git a/firmware/hw_layer/cdm_ion_sense.cpp b/firmware/hw_layer/cdm_ion_sense.cpp deleted file mode 100644 index 67ec408509..0000000000 --- a/firmware/hw_layer/cdm_ion_sense.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * @file cdm_ion_sense.cpp - * - * Saab Ion Sensing Module integration - * - * See https://github.com/rusefi/rusefi/wiki/Saab_Trionic_8_Combustion-Detection-Module_on_Mazda_Miata_running_rusEfi - * - * Created on: Dec 31, 2018 - * @author Andrey Belomutskiy, (c) 2012-2020 - */ - -#include "pch.h" - -#include "cdm_ion_sense.h" - -CdmState::CdmState() { - accumilatingAtRevolution = 0; - currentValue = 0; - accumulatingCurrentValue = 0; -} - -int CdmState::getValue(int currentRevolution) { - applyAccumulatedData(currentRevolution); - if (currentRevolution == currentValueAtIndex + 1) { - // returning total result of previous engine cycle - return currentValue; - } - // we are here if previous engine cycle had no knock events - return 0; -} - -void CdmState::applyAccumulatedData(int currentRevolution) { - if (currentRevolution > accumilatingAtRevolution) { - currentValue = accumulatingCurrentValue; - currentValueAtIndex = accumilatingAtRevolution; - } -} - -void CdmState::onNewSignal(int currentRevolution) { - if (this->accumilatingAtRevolution == currentRevolution) { - accumulatingCurrentValue++; - } else { - applyAccumulatedData(currentRevolution); - // start new accumulation - accumilatingAtRevolution = currentRevolution; - accumulatingCurrentValue = 1; - } -} - -// above logic compiles unconditionally so that unit tests are happy, but without an instance linker would have nothing to link -#if EFI_CDM_INTEGRATION - -#include "digital_input_exti.h" - -static CdmState instance; - -int getCurrentCdmValue(int currentRevolution) { - return instance.getValue(currentRevolution); -} - -#if EFI_TUNER_STUDIO -void ionPostState(TunerStudioOutputChannels *tsOutputChannels) { - tsOutputChannels->debugIntField1 = instance.totalCdmEvents; -} -#endif /* EFI_TUNER_STUDIO */ - -static void extIonCallback(void *arg) { - UNUSED(arg); - instance.totalCdmEvents++; - - int currentRevolution = engine->triggerCentral.triggerState.getCrankSynchronizationCounter(); - instance.onNewSignal(currentRevolution); -} - -void cdmIonInit(void) { - if (!isBrainPinValid(engineConfiguration->cdmInputPin)) { - return; - } - - efiExtiEnablePin("ion", engineConfiguration->cdmInputPin, PAL_EVENT_MODE_RISING_EDGE, extIonCallback, NULL); -} - -#endif /* EFI_CDM_INTEGRATION */ diff --git a/firmware/hw_layer/cdm_ion_sense.h b/firmware/hw_layer/cdm_ion_sense.h deleted file mode 100644 index b13c2e5564..0000000000 --- a/firmware/hw_layer/cdm_ion_sense.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * @file cdm_ion_sense.h - * - * @date Dec 31, 2018 - * @author Andrey Belomutskiy, (c) 2012-2020 - */ - -#pragma once - -#include "global.h" -#include "tunerstudio_outputs.h" - -class CdmState { -public: - CdmState(); - int totalCdmEvents = 0; - - int accumilatingAtRevolution = -1; - /** - * accumulated value for engine cycle which is not over yet - */ - int accumulatingCurrentValue; - /** - * event counter for previous complete engine cycle - */ - int currentValue = 0; - int currentValueAtIndex = -1; - void onNewSignal(int currentRevolution); - void applyAccumulatedData(int currentRevolution); - int getValue(int currentRevolution); -}; - -#if EFI_TUNER_STUDIO -void ionPostState(TunerStudioOutputChannels *tsOutputChannels); -#endif - -void cdmIonInit(void); -int getCurrentCdmValue(int currentRevolution); - diff --git a/firmware/hw_layer/hardware.cpp b/firmware/hw_layer/hardware.cpp index ee10062298..0f5a04f16a 100644 --- a/firmware/hw_layer/hardware.cpp +++ b/firmware/hw_layer/hardware.cpp @@ -39,7 +39,6 @@ #include "mcp3208.h" #include "histogram.h" #include "sent.h" -#include "cdm_ion_sense.h" #include "trigger_central.h" #include "svnversion.h" #include "vvt.h" @@ -544,10 +543,6 @@ void initHardware() { initCanVssSupport(); #endif // EFI_CAN_SUPPORT -#if EFI_CDM_INTEGRATION - cdmIonInit(); -#endif // EFI_CDM_INTEGRATION - #if EFI_SENT_SUPPORT initSent(); #endif diff --git a/firmware/hw_layer/hw_layer.mk b/firmware/hw_layer/hw_layer.mk index 74dbd19659..f5fb51d13a 100644 --- a/firmware/hw_layer/hw_layer.mk +++ b/firmware/hw_layer/hw_layer.mk @@ -26,7 +26,6 @@ HW_LAYER_EMS_CPP = \ $(PROJECT_DIR)/hw_layer/stepper_dual_hbridge.cpp \ $(PROJECT_DIR)/hw_layer/io_pins.cpp \ $(PROJECT_DIR)/hw_layer/rtc_helper.cpp \ - $(PROJECT_DIR)/hw_layer/cdm_ion_sense.cpp \ $(PROJECT_DIR)/hw_layer/debounce.cpp \ $(PROJECT_DIR)/hw_layer/adc/mcp3208.cpp diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 1346f547a6..5446b1d3b0 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -842,7 +842,6 @@ custom script_setting_t 4 scalar, F32, @OFFSET@, "", 1, 0, 0, 18000, 2 Gpio spi3misoPin; Gpio spi3sckPin; - Gpio cdmInputPin;Saab Combustion Detection Module knock signal input pin\nalso known as Saab Ion Sensing Module; uart_device_e consoleUartDevice; diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index e7b8bc7abc..0ecf631ef5 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -2783,7 +2783,6 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_ field = "SPI3 MISO", spi3misoPin, {is_enabled_spi_3 == 1} @@if_ts_show_spi field = "SPI3 SCK", spi3sckPin, {is_enabled_spi_3 == 1} @@if_ts_show_spi field = "LIS302DLCsPin", LIS302DLCsPin - field = "Saab CDM knock", cdmInputPin field = "DRV8860 CS", drv8860_cs field = "DRV8860 CS Mode", drv8860_csPinMode field = "DRV8860 MISO pin", drv8860_miso diff --git a/simulator/simulator/efifeatures.h b/simulator/simulator/efifeatures.h index ac296019fa..4f5d681931 100644 --- a/simulator/simulator/efifeatures.h +++ b/simulator/simulator/efifeatures.h @@ -44,8 +44,6 @@ #define EFI_USB_SERIAL FALSE -#define EFI_CDM_INTEGRATION FALSE - #define EFI_MC33816 FALSE #define EFI_HPFP TRUE diff --git a/unit_tests/tests/test_ion.cpp b/unit_tests/tests/test_ion.cpp deleted file mode 100644 index 7afc03a696..0000000000 --- a/unit_tests/tests/test_ion.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * @file test_ion.cpp - * - * @date Jan 4, 2019 - * @author Andrey Belomutskiy, (c) 2012-2020 - */ - -#include "gtest/gtest.h" -#include "cdm_ion_sense.h" - -TEST(ion, signalCounter) { - CdmState state; - - EXPECT_EQ(0, state.getValue(0)); - - state.onNewSignal(/* currentRevolution= */ 2); - state.onNewSignal(/* currentRevolution= */ 2); - state.onNewSignal(/* currentRevolution= */ 2); - - // value is still '0' until we signal end of engine cycle - EXPECT_EQ(0, state.getValue(/* currentRevolution= */2)); - - // this invocation would flush current accumulation - EXPECT_EQ(3, state.getValue(/* currentRevolution= */3)); - - state.onNewSignal(/* currentRevolution= */3); - // returning previous full cycle value - EXPECT_EQ(3, state.getValue(3)); - - - EXPECT_EQ(1, state.getValue(/* currentRevolution= */4)); - EXPECT_EQ(0, state.getValue(/* currentRevolution= */5)); -} - diff --git a/unit_tests/tests/tests.mk b/unit_tests/tests/tests.mk index 70442939d4..d1812d8f9c 100644 --- a/unit_tests/tests/tests.mk +++ b/unit_tests/tests/tests.mk @@ -53,7 +53,6 @@ TESTS_SRC_CPP = \ tests/test_util.cpp \ tests/test_start_stop.cpp \ tests/test_hardware_reinit.cpp \ - tests/test_ion.cpp \ tests/test_engine_math.cpp \ tests/test_fasterEngineSpinningUp.cpp \ tests/test_dwell_corner_case_issue_796.cpp \