mirror of https://github.com/FOME-Tech/fome-fw.git
cdm ion
This commit is contained in:
parent
e1af81e1d7
commit
0e12622371
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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 */
|
|
@ -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);
|
||||
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -44,8 +44,6 @@
|
|||
|
||||
#define EFI_USB_SERIAL FALSE
|
||||
|
||||
#define EFI_CDM_INTEGRATION FALSE
|
||||
|
||||
#define EFI_MC33816 FALSE
|
||||
#define EFI_HPFP TRUE
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
@ -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 \
|
||||
|
|
Loading…
Reference in New Issue