This commit is contained in:
rusefi 2019-01-19 11:28:37 -05:00
parent af7def0cba
commit d671f569c3
4 changed files with 20 additions and 31 deletions

View File

@ -299,8 +299,6 @@ void hipAdcCallback(adcsample_t adcValue) {
hipValueMax = maxF(engine->knockVolts, hipValueMax); hipValueMax = maxF(engine->knockVolts, hipValueMax);
engine->knockLogic(engine->knockVolts); engine->knockLogic(engine->knockVolts);
instance.setAngleWindowWidth();
instance.handleValue(GET_RPM() DEFINE_PARAM_SUFFIX(PASS_HIP_PARAMS)); instance.handleValue(GET_RPM() DEFINE_PARAM_SUFFIX(PASS_HIP_PARAMS));
} }

View File

@ -9,22 +9,7 @@
EXTERN_ENGINE; EXTERN_ENGINE;
HIP9011::HIP9011(Hip9011HardwareInterface *hardware) { HIP9011::HIP9011(Hip9011HardwareInterface *hardware) : rpmLookup() {
needToInit = true;
state = NOT_READY;
/**
* band index is only send to HIP chip on startup
*/
currentBandIndex = 0;
currentGainIndex = -1;
currentIntergratorIndex = -1;
settingUpdateCount = 0;
totalKnockEventsCount = 0;
currentPrescaler = 0;
correctResponsesCount = 0;
invalidHip9011ResponsesCount = 0;
angleWindowWidth = -1;
this->hardware = hardware; this->hardware = hardware;
} }
@ -80,6 +65,12 @@ int HIP9011::getIntegrationIndexByRpm(float rpm) {
void HIP9011::setAngleWindowWidth(DEFINE_HIP_PARAMS) { void HIP9011::setAngleWindowWidth(DEFINE_HIP_PARAMS) {
float angleWindowWidth = GET_CONFIG_VALUE(knockDetectionWindowEnd) - GET_CONFIG_VALUE(knockDetectionWindowStart); float angleWindowWidth = GET_CONFIG_VALUE(knockDetectionWindowEnd) - GET_CONFIG_VALUE(knockDetectionWindowStart);
if (angleWindowWidth < 0) {
#if EFI_PROD_CODE
warning(CUSTOM_ERR_6697, "invalid knock window");
#endif
angleWindowWidth = 0;
}
// float '==' is totally appropriate here // float '==' is totally appropriate here
if (this->angleWindowWidth == angleWindowWidth) if (this->angleWindowWidth == angleWindowWidth)
return; // exit if value has not change return; // exit if value has not change
@ -88,6 +79,8 @@ void HIP9011::setAngleWindowWidth(DEFINE_HIP_PARAMS) {
} }
void HIP9011::handleValue(int rpm DEFINE_PARAM_SUFFIX(DEFINE_HIP_PARAMS)) { void HIP9011::handleValue(int rpm DEFINE_PARAM_SUFFIX(DEFINE_HIP_PARAMS)) {
setAngleWindowWidth(FORWARD_HIP_PARAMS);
int prescalerIndex = GET_CONFIG_VALUE(hip9011PrescalerAndSDO); int prescalerIndex = GET_CONFIG_VALUE(hip9011PrescalerAndSDO);
int integratorIndex = getIntegrationIndexByRpm(rpm); int integratorIndex = getIntegrationIndexByRpm(rpm);
int gainIndex = getHip9011GainIndex(FORWARD_HIP_PARAMS); int gainIndex = getHip9011GainIndex(FORWARD_HIP_PARAMS);

View File

@ -67,17 +67,17 @@ public:
/** /**
* band index is only send to HIP chip on startup * band index is only send to HIP chip on startup
*/ */
int currentBandIndex; int currentBandIndex = 0;
int currentGainIndex; int currentGainIndex = -1;
int correctResponsesCount; int correctResponsesCount = 0;
int invalidHip9011ResponsesCount; int invalidHip9011ResponsesCount = 0;
float angleWindowWidth; float angleWindowWidth = - 1;
int currentIntergratorIndex; int currentIntergratorIndex = -1;
bool needToInit; bool needToInit = true;
int settingUpdateCount; int settingUpdateCount = 0;
int totalKnockEventsCount; int totalKnockEventsCount = 0;
int currentPrescaler; int currentPrescaler = 0;
Hip9011HardwareInterface *hardware; Hip9011HardwareInterface *hardware;
/** /**
* Int/Hold pin is controlled from scheduler call-backs which are set according to current RPM * Int/Hold pin is controlled from scheduler call-backs which are set according to current RPM

View File

@ -60,10 +60,8 @@ TEST(hip9011, configurationCommands) {
HIP9011 instance(&mock); HIP9011 instance(&mock);
instance.prepareHip9011RpmLookup(50);
// want to invoke method with same parameters a few times // want to invoke method with same parameters a few times
#define PARAMETERS 600, /* knockBandCustom*/0, /*cylinderBore*/76, /*hip9011Gain*/1, _8MHZ_PRESCALER, NAN, NAN #define PARAMETERS 600, /* knockBandCustom*/0, /*cylinderBore*/76, /*hip9011Gain*/1, _8MHZ_PRESCALER, 0.0, 50.0
// Not making assumptions on the message send ... // Not making assumptions on the message send ...
EXPECT_CALL(mock, sendSyncCommand(_)).Times(0); EXPECT_CALL(mock, sendSyncCommand(_)).Times(0);