Saab CDM knock signal integration #647
This commit is contained in:
parent
8a7319449f
commit
d80c1f0b1e
|
@ -14,6 +14,8 @@
|
|||
|
||||
#define EFI_FSIO TRUE
|
||||
|
||||
#define EFI_CDM_INTEGRATION TRUE
|
||||
|
||||
#define EFI_TEXT_LOGGING TRUE
|
||||
|
||||
#define EFI_PWM_TESTER FALSE
|
||||
|
|
|
@ -311,6 +311,8 @@ void prepareVoidConfiguration(engine_configuration_s *engineConfiguration) {
|
|||
engineConfiguration->flexFuelSensor = GPIO_UNASSIGNED;
|
||||
engineConfiguration->test557pin = GPIO_UNASSIGNED;
|
||||
|
||||
boardConfiguration->cdmInputPin = GPIO_UNASSIGNED;
|
||||
|
||||
boardConfiguration->joystickCenterPin = GPIO_UNASSIGNED;
|
||||
boardConfiguration->joystickAPin = GPIO_UNASSIGNED;
|
||||
boardConfiguration->joystickBPin = GPIO_UNASSIGNED;
|
||||
|
|
|
@ -8,6 +8,32 @@
|
|||
*/
|
||||
|
||||
#include "cdm_ion_sense.h"
|
||||
#include "engine.h"
|
||||
|
||||
CdmState::CdmState() {
|
||||
currentRevolution = 0;
|
||||
currentValue = 0;
|
||||
accumulator = 0;
|
||||
}
|
||||
|
||||
int CdmState::getValue() {
|
||||
return currentValue;
|
||||
}
|
||||
|
||||
void CdmState::onNewSignal(int currentRevolution) {
|
||||
if (this->currentRevolution == currentRevolution) {
|
||||
accumulator++;
|
||||
} else {
|
||||
this->currentRevolution = currentRevolution;
|
||||
currentValue = accumulator;
|
||||
accumulator = 1;
|
||||
}
|
||||
}
|
||||
|
||||
#if EFI_CDM_INTEGRATION
|
||||
#include "digital_input_exti.h"
|
||||
|
||||
EXTERN_ENGINE;
|
||||
|
||||
#if EFI_TUNER_STUDIO
|
||||
void ionPostState(TunerStudioOutputChannels *tsOutputChannels) {
|
||||
|
@ -15,4 +41,34 @@ void ionPostState(TunerStudioOutputChannels *tsOutputChannels) {
|
|||
}
|
||||
#endif
|
||||
|
||||
static CdmState instance;
|
||||
|
||||
|
||||
static void extIonCallback(EXTDriver *extp, expchannel_t channel) {
|
||||
UNUSED(extp);
|
||||
|
||||
int currentRevolution = engine->triggerCentral.triggerState.getTotalRevolutionCounter();
|
||||
|
||||
instance.onNewSignal(currentRevolution);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void cdmIonInit(void) {
|
||||
// todo: allow 'GPIOA_0' once we migrate to new mandatory configuration
|
||||
if (boardConfiguration->cdmInputPin == GPIOA_0 || boardConfiguration->cdmInputPin == GPIO_UNASSIGNED) {
|
||||
return;
|
||||
}
|
||||
int pin = (int)boardConfiguration->cdmInputPin;
|
||||
if (pin <= 0 || pin > (int)GPIO_UNASSIGNED) {
|
||||
// todo: remove this protection once we migrate to new mandatory configuration
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
enableExti(boardConfiguration->cdmInputPin, EXT_CH_MODE_RISING_EDGE, extIonCallback);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif /* EFI_CDM_INTEGRATION */
|
||||
|
|
|
@ -10,9 +10,27 @@
|
|||
|
||||
#include "global.h"
|
||||
|
||||
class CdmState {
|
||||
public:
|
||||
CdmState();
|
||||
int currentRevolution;
|
||||
/**
|
||||
* accumulated value for engine cycle which is not over yet
|
||||
*/
|
||||
int accumulator;
|
||||
/**
|
||||
* event counter for previous complete engine cycle
|
||||
*/
|
||||
int currentValue;
|
||||
void onNewSignal(int currentRevolution);
|
||||
int getValue();
|
||||
};
|
||||
|
||||
#if EFI_TUNER_STUDIO
|
||||
#include "tunerstudio_configuration.h"
|
||||
void ionPostState(TunerStudioOutputChannels *tsOutputChannels);
|
||||
#endif
|
||||
|
||||
void cdmIonInit(void);
|
||||
|
||||
#endif /* HW_LAYER_CDM_ION_SENSE_H_ */
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "settings.h"
|
||||
#include "algo.h"
|
||||
#include "joystick.h"
|
||||
#include "cdm_ion_sense.h"
|
||||
#include "trigger_central.h"
|
||||
#include "svnversion.h"
|
||||
#include "engine_configuration.h"
|
||||
|
@ -490,6 +491,10 @@ void initHardware(Logging *l) {
|
|||
initVehicleSpeed(sharedLogger);
|
||||
#endif
|
||||
|
||||
#if EFI_CDM_INTEGRATION
|
||||
cdmIonInit();
|
||||
#endif
|
||||
|
||||
#if HAL_USE_EXT || defined(__DOXYGEN__)
|
||||
initJoystick(sharedLogger);
|
||||
#endif
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#define EFI_PRINTF_FUEL_DETAILS TRUE
|
||||
|
||||
#define EFI_CDM_INTEGRATION FALSE
|
||||
|
||||
#define EFI_BLUETOOTH_SETUP FALSE
|
||||
|
||||
#define EFI_GPIO_HARDWARE FALSE
|
||||
|
|
|
@ -5,6 +5,7 @@ TEST_SRC_CPP = test_util.cpp \
|
|||
test_basic_math/test_find_index.cpp \
|
||||
test_basic_math/test_interpolation_3d.cpp \
|
||||
test_cj125.cpp \
|
||||
test_ion.cpp \
|
||||
test_hip9011.cpp \
|
||||
test_data_structures/test_engine_math.cpp \
|
||||
test_startOfCrankingPrimingPulse.cpp \
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
/*
|
||||
* test_c125.h
|
||||
*
|
||||
* Created on: Jan 3, 2019
|
||||
* @author Andrey Belomutskiy, (c) 2012-2019
|
||||
*/
|
||||
|
||||
#ifndef TEST_C125_H_
|
||||
#define TEST_C125_H_
|
||||
|
||||
#endif /* TEST_C125_H_ */
|
|
@ -5,7 +5,6 @@
|
|||
* @author Andrey Belomutskiy, (c) 2012-2019
|
||||
*/
|
||||
|
||||
#include "test_c125.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
TEST(testCJ125, todo) {
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* test_ion.cpp
|
||||
*
|
||||
* Created on: Jan 4, 2019
|
||||
* Author: user
|
||||
*/
|
||||
|
||||
#ifndef TEST_ION_CPP_
|
||||
#define TEST_ION_CPP_
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "cdm_ion_sense.h"
|
||||
|
||||
TEST(ion, signalCounter) {
|
||||
CdmState state;
|
||||
|
||||
EXPECT_EQ(0, state.getValue());
|
||||
|
||||
state.onNewSignal(2);
|
||||
state.onNewSignal(2);
|
||||
state.onNewSignal(2);
|
||||
|
||||
// value is still '0' until we signal end of engine cycle
|
||||
EXPECT_EQ(0, state.getValue());
|
||||
|
||||
// this signals start of new cycle
|
||||
state.onNewSignal(4);
|
||||
EXPECT_EQ(3, state.getValue());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif /* TEST_ION_CPP_ */
|
Loading…
Reference in New Issue