dead knock code (#3255)

* more unification

* hip stub

* comment

* guard

* channel idx

* include

* hip

* move in to engine

* hip9011

* dead stuff

* dead

* fsio

* lcd

* more dead
This commit is contained in:
Matthew Kennedy 2021-09-21 17:40:20 -07:00 committed by GitHub
parent 5de27e0b92
commit 8cd132b8a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 5 additions and 138 deletions

View File

@ -193,7 +193,6 @@ void setBoardDefaultConfiguration(void) {
engineConfiguration->triggerSimulatorPinModes[0] = OM_DEFAULT;
// not used
engineConfiguration->externalKnockSenseAdc = EFI_ADC_NONE;
engineConfiguration->displayMode = DM_NONE;
engineConfiguration->HD44780_rs = GPIO_UNASSIGNED;
engineConfiguration->HD44780_e = GPIO_UNASSIGNED;

View File

@ -159,7 +159,6 @@ void setBoardDefaultConfiguration(void) {
//setFsio(0, (GPIOB_1), STARTER_RELAY_LOGIC PASS_CONFIG_PARAMETER_SUFFIX);
/* not used */
engineConfiguration->externalKnockSenseAdc = EFI_ADC_NONE;
engineConfiguration->displayMode = DM_NONE;
engineConfiguration->HD44780_rs = GPIO_UNASSIGNED;
engineConfiguration->HD44780_e = GPIO_UNASSIGNED;
@ -210,9 +209,7 @@ void setBoardDefaultConfiguration(void) {
engineConfiguration->hip9011PrescalerAndSDO = (0x6 << 1); //HIP_16MHZ_PRESCALER;
engineConfiguration->hip9011Gain = 1.0;
engineConfiguration->knockBandCustom = 0.0;
engineConfiguration->knockVThreshold = 4.0;
engineConfiguration->cylinderBore = 96.9;
engineConfiguration->maxKnockSubDeg = 20.0;
/* Cylinder to knock bank mapping */
engineConfiguration->knockBankCyl1 = 0;

View File

@ -90,8 +90,6 @@ void setMazda626EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
// setFsio(0, GPIOE_6, "1" PASS_CONFIG_PARAMETER_SUFFIX);
//#endif
engineConfiguration->externalKnockSenseAdc = EFI_ADC_4;
engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED;
engineConfiguration->camInputs[0] = GPIOA_5;
}

View File

@ -62,8 +62,8 @@ struct TunerStudioOutputChannels {
unsigned int unusedBit10 : 1; // bit 10
unsigned int clutchUpState : 1; // bit 11
unsigned int clutchDownState : 1; // bit 12
unsigned int knockEverIndicator : 1; // bit 13
unsigned int knockNowIndicator : 1; // bit 14
unsigned int unusedb13 : 1; // bit 13
unsigned int unusedb14 : 1; // bit 14
unsigned int brakePedalState : 1; // bit 15. 0 - not pressed, 1 = pressed
unsigned int toothLogReady : 1; // bit 16
unsigned int acSwitchState : 1; // bit 17. 0 - not pressed, 1 = pressed

View File

@ -626,9 +626,6 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
tsOutputChannels->VssAcceleration = getDynoviewAcceleration(PASS_ENGINE_PARAMETER_SIGNATURE);
#endif
//tsOutputChannels->knockCount = engine->knockCount;
//tsOutputChannels->knockLevel = engine->knockVolts;
#if HW_CHECK_MODE
tsOutputChannels->hasCriticalError = 1;
#else
@ -704,9 +701,6 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
tsOutputChannels->recentErrorCodes[i] = engine->engineState.warnings.recentWarnings.get(i);
}
tsOutputChannels->knockNowIndicator = engine->knockCount > 0;
tsOutputChannels->knockEverIndicator = engine->knockEver;
tsOutputChannels->clutchUpState = engine->clutchUpState;
tsOutputChannels->clutchDownState = engine->clutchDownState;
tsOutputChannels->brakePedalState = engine->brakePedalState;

View File

@ -477,38 +477,6 @@ void Engine::setConfig(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
injectEngineReferences();
}
void Engine::printKnockState(void) {
efiPrintf("knock now=%s/ever=%s", boolToString(knockNow), boolToString(knockEver));
}
void Engine::knockLogic(float knockVolts DECLARE_ENGINE_PARAMETER_SUFFIX) {
this->knockVolts = knockVolts;
knockNow = knockVolts > engineConfiguration->knockVThreshold;
/**
* KnockCount is directly proportional to the degrees of ignition
* advance removed
* ex: degrees to subtract = knockCount;
*/
/**
* TODO use knockLevel as a factor for amount of ignition advance
* to remove
* Perhaps allow the user to set a multiplier
* ex: degrees to subtract = knockCount + (knockLevel * X)
* X = user configurable multiplier
*/
if (knockNow) {
knockEver = true;
timeOfLastKnockEvent = getTimeNowUs();
if (knockCount < engineConfiguration->maxKnockSubDeg)
knockCount++;
} else if (knockCount >= 1) {
knockCount--;
} else {
knockCount = 0;
}
}
void Engine::watchdog() {
#if EFI_ENGINE_CONTROL
if (isRunningPwmTest)

View File

@ -289,26 +289,6 @@ public:
FsioState fsioState;
/**
* Are we experiencing knock right now?
*/
bool knockNow = false;
/**
* Have we experienced knock since engine was started?
*/
bool knockEver = false;
/**
* KnockCount is directly proportional to the degrees of ignition
* advance removed
*/
int knockCount = 0;
float knockVolts = 0;
bool knockDebug = false;
efitimeus_t timeOfLastKnockEvent = 0;
/**
* are we running any kind of functional test? this affect
* some areas
@ -391,9 +371,6 @@ public:
// onKnockSenseCompleted is the callback from the knock sense driver to report a sensed knock level
bool onKnockSenseCompleted(uint8_t cylinderIndex, float levelDbv, efitick_t lastKnockTime);
void knockLogic(float knockVolts DECLARE_ENGINE_PARAMETER_SUFFIX);
void printKnockState(void);
AirmassModelBase* mockAirmassModel = nullptr;
LimpManager limpManager;

View File

@ -437,9 +437,6 @@ static void setHip9011FrankensoPinout(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#endif /* EFI_PROD_CODE */
engineConfiguration->hip9011Gain = 1;
engineConfiguration->knockVThreshold = 4;
engineConfiguration->maxKnockSubDeg = 20;
if (!CONFIG(useTpicAdvancedMode)) {
engineConfiguration->hipOutputChannel = EFI_ADC_10; // PC0

View File

@ -233,8 +233,6 @@ FsioResult LECalculator::processElement(const LEElement *element DECLARE_ENGINE_
int sensorIdx = static_cast<int>(SensorType::Aux1) + index;
return Sensor::get(static_cast<SensorType>(sensorIdx));
}
case LE_METHOD_KNOCK:
return ENGINE(knockCount);
case LE_UNDEFINED:
warning(CUSTOM_UNKNOWN_FSIO, "FSIO undefined action");
return unexpected;

View File

@ -40,7 +40,6 @@ typedef enum {
LE_METHOD_VBATT = 109,
LE_METHOD_AC_TOGGLE = 110,
LE_METHOD_TIME_SINCE_AC_TOGGLE = 111,
LE_METHOD_KNOCK = 112,
LE_METHOD_FSIO_TABLE = 113,
LE_METHOD_SELF = 114,
LE_METHOD_MAP = 115,

View File

@ -60,7 +60,6 @@ static LENameOrdinalPair leFsioSetting(LE_METHOD_FSIO_SETTING, FSIO_METHOD_FSIO_
static LENameOrdinalPair leFsioTable(LE_METHOD_FSIO_TABLE, FSIO_METHOD_FSIO_TABLE);
static LENameOrdinalPair leFsioAnalogInput(LE_METHOD_FSIO_ANALOG_INPUT, FSIO_METHOD_FSIO_ANALOG_INPUT);
static LENameOrdinalPair leFsioDigitalInput(LE_METHOD_FSIO_DIGITAL_INPUT, FSIO_METHOD_FSIO_DIGITAL_INPUT);
static LENameOrdinalPair leKnock(LE_METHOD_KNOCK, "knock");
static LENameOrdinalPair leIntakeVVT(LE_METHOD_INTAKE_VVT, "ivvt");
static LENameOrdinalPair leExhaustVVT(LE_METHOD_EXHAUST_VVT, "evvt");
static LENameOrdinalPair leCrankingRpm(LE_METHOD_CRANKING_RPM, "cranking_rpm");

View File

@ -331,7 +331,6 @@ static void printAnalogInfo(void) {
printAnalogChannelInfo("AFR", engineConfiguration->afr.hwChannel);
printAnalogChannelInfo("MAP", engineConfiguration->map.sensor.hwChannel);
printAnalogChannelInfo("BARO", engineConfiguration->baroSensor.hwChannel);
printAnalogChannelInfo("extKno", engineConfiguration->externalKnockSenseAdc);
printAnalogChannelInfo("OilP", engineConfiguration->oilPressure.hwChannel);
@ -498,14 +497,6 @@ static void initConfigActions(void) {
addConsoleActionI("get_byte", getByte);
addConsoleActionII("get_bit", getBit);
}
// todo: move this logic somewhere else?
static void getKnockInfo(void) {
adc_channel_e hwChannel = engineConfiguration->externalKnockSenseAdc;
efiPrintf("externalKnockSenseAdc on ADC", getPinNameByAdcChannel("knock", hwChannel, pinNameBuffer));
engine->printKnockState();
}
#endif /* EFI_UNIT_TEST */
// this method is used by real firmware and simulator and unit test
@ -762,10 +753,6 @@ void initEngineContoller(DECLARE_ENGINE_PARAMETER_SUFFIX) {
initEgoAveraging(PASS_ENGINE_PARAMETER_SIGNATURE);
if (isAdcChannelValid(engineConfiguration->externalKnockSenseAdc)) {
addConsoleAction("knockinfo", getKnockInfo);
}
#if EFI_PROD_CODE
addConsoleAction("reset_accel", resetAccel);
#endif /* EFI_PROD_CODE */

View File

@ -437,14 +437,6 @@ void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp DECLARE
}
}
if (trgEventIndex == 0) {
if (isAdcChannelValid(CONFIG(externalKnockSenseAdc))) {
float externalKnockValue = getVoltageDivided("knock", engineConfiguration->externalKnockSenseAdc PASS_ENGINE_PARAMETER_SUFFIX);
engine->knockLogic(externalKnockValue PASS_ENGINE_PARAMETER_SUFFIX);
}
}
/**
* For fuel we schedule start of injection based on trigger angle, and then inject for
* specified duration of time

View File

@ -64,7 +64,6 @@ static MenuItem miAfr(&miSensors, LL_AFR);
static MenuItem miBaro(&miSensors, LL_BARO);
static MenuItem miMapV(&miSensors, LL_MAF_V);
static MenuItem miMapKgHr(&miSensors, LL_MAF_KG_HR);
static MenuItem miKnock(&miSensors, LL_KNOCK);
static MenuItem miStopEngine(&miBench, "stop engine", scheduleStopEngine);
static MenuItem miTestFan(&miBench, "test fan", fanBench);
@ -195,10 +194,6 @@ static void showLine(lcd_line_e line, int /*screenY*/) {
case LL_VBATT:
lcdPrintf("Battery %.2fv", Sensor::get(SensorType::BatteryVoltage).value_or(0));
return;
case LL_KNOCK:
getPinNameByAdcChannel("hip", engineConfiguration->hipOutputChannel, buffer);
lcdPrintf("Knock %s %.2fv", buffer, engine->knockVolts);
return;
#if EFI_ANALOG_SENSORS
case LL_BARO:

View File

@ -31,7 +31,6 @@ typedef enum {
LL_MAF_KG_HR,
LL_EGO,
LL_BARO,
LL_KNOCK,
LL_FUEL_BASE,
LL_FUEL_TOTAL,

View File

@ -784,8 +784,6 @@ static void enableOrDisable(const char *param, bool isEnabled) {
engineConfiguration->isVerboseAlternator = isEnabled;
} else if (strEqualCaseInsensitive(param, "tpic_advanced_mode")) {
engineConfiguration->useTpicAdvancedMode = isEnabled;
} else if (strEqualCaseInsensitive(param, "knockdebug")) {
engine->knockDebug = isEnabled;
} else if (strEqualCaseInsensitive(param, "altcontrol")) {
engineConfiguration->isAlternatorControlEnabled = isEnabled;
} else if (strEqualCaseInsensitive(param, "sd")) {

View File

@ -500,9 +500,6 @@ static msg_t hipThread(void *arg) {
/* Check for correct cylinder/input */
if (correctCylinder) {
/* report */
engine->knockLogic(knockVolts);
// TODO: convert knock level to dBv
engine->onKnockSenseCompleted(instance.cylinderNumber, knockVolts, instance.knockSampleTimestamp);
@ -619,11 +616,6 @@ static void showHipInfo(void) {
efiPrintf(" PaSDO=0x%x",
instance.prescaler);
efiPrintf(" knockVThreshold=%.2f knockCount=%d maxKnockSubDeg=%.2f",
engineConfiguration->knockVThreshold,
engine->knockCount,
engineConfiguration->maxKnockSubDeg);
efiPrintf(" IntHold %s (mode 0x%x)",
hwPortname(CONFIG(hip9011IntHoldPin)),
CONFIG(hip9011IntHoldPinMode));
@ -662,18 +654,6 @@ static void showHipInfo(void) {
normalizedValueMax[i]);
normalizedValueMax[i] = 0.0;
}
engine->printKnockState();
}
static void setMaxKnockSubDeg(int value) {
engineConfiguration->maxKnockSubDeg = value;
showHipInfo();
}
static void setKnockThresh(float value) {
engineConfiguration->knockVThreshold = value;
showHipInfo();
}
static void setPrescalerAndSDO(int value) {
@ -695,8 +675,6 @@ static void hip_addconsoleActions(void) {
addConsoleActionF("set_gain", setHipGain);
addConsoleActionF("set_band", setHipBand);
addConsoleActionI("set_hip_prescalerandsdo", setPrescalerAndSDO);
addConsoleActionF("set_knock_threshold", setKnockThresh);
addConsoleActionI("set_max_knock_sub_deg", setMaxKnockSubDeg);
}
#endif /* EFI_HIP_9011_DEBUG */

View File

@ -729,7 +729,7 @@ custom spi_device_e 1 bits, U08, @OFFSET@, [0:2], "Off", "SPI1", "SPI2", "SPI3",
float globalFuelCorrection;set global_fuel_correction X;"coef", 1, 0, 0, 1000, 2
float adcVcc;;"volts", 1, 0, 0, 6, 3
float maxKnockSubDeg;maximum total number of degrees to subtract from ignition advance\nwhen knocking;"Deg", 1, 0, 0, 100, 0
float unused552;;"Deg", 1, 0, 0, 100, 0
brain_input_pin_e[CAM_INPUTS_COUNT iterate] camInputs;+Camshaft input could be used either just for engine phase detection if your trigger shape does not include cam sensor as 'primary' channel, or it could be used for Variable Valve timing on one of the camshafts.
uint8_t[CAM_INPUTS_COUNT_padding] camInputsPadding;;
@ -1211,7 +1211,7 @@ bit unused_1484_bit_31
float idleStepperReactionTime;;"ms", 1, 0, 1, 300, 0
float knockVThreshold;;"V", 1, 0, 1, 5, 2
float unused1512;;"", 1, 0, 1, 5, 2
pin_input_mode_e[FSIO_COMMAND_COUNT iterate] fsioInputModes;
uint8_t[10] unusedFsioInputs;;"", 1, 0, 0, 255, 0
@ -1475,7 +1475,7 @@ tle8888_mode_e tle8888mode;
brain_input_pin_e flexSensorPin;+Continental/GM flex fuel sensor, 50-150hz type;
brain_pin_e test557pin
pin_output_mode_e stepperDirectionPinMode;
adc_channel_e externalKnockSenseAdc;
uint8_t unused3103;;"",1,0,0,1,0
output_pin_e stepperEnablePin;
brain_pin_e tle8888_cs;
pin_output_mode_e tle8888_csPinMode;

View File

@ -188,8 +188,6 @@ enable2ndByteCanID = false
needBurn = bits, U32, 0, [9:9], "true", "false";
clutchUpState =bits, U32, 0, [11:11], "true", "false";
clutchDownState =bits, U32, 0, [12:12], "true", "false";
knockEverIndicator=bits, U32, 0, [13:13], "true", "false";
knockNowIndicator=bits, U32, 0, [14:14], "true", "false";
brakePedalIndicator=bits, U32, 0, [15:15], "true", "false";
toothLogReady =bits, U32, 0, [16:16], "true", "false";
acSwitchState =bits, U32, 0, [17:17], "true", "false";
@ -1222,10 +1220,6 @@ gaugeCategory = DynoView
; not implemented
; indicator = { ind_map_error}, "map", "map error", white, black, red, black
indicator = { knockEverIndicator }, "", "Knock recently", white, black, red, black
indicator = { knockNowIndicator }, "no knock", "Knock NOW", white, black, red, black
indicator = { sd_present }, "no SD card", "SD card OK", white, black, green, black
indicator = { sd_logging_internal }, "SD logging", "SD logging", white, black, green, black
indicator = { sd_msd }, "SD USB", "SD USB", white, black, green, black
@ -2419,7 +2413,6 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
field = "TLE 8888 spi", tle8888spiDevice @@if_ts_show_spi
field = "AUX Serial TX", auxSerialTxPin
field = "AUX Serial RX", auxSerialRxPin
field = "External Knock", externalKnockSenseAdc
field = "Start/Stop Button", startStopButtonPin
field = "Upshift Pin", tcuUpshiftButtonPin
field = "Downshift Pin", tcuDownshiftButtonPin
@ -2817,7 +2810,6 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
; Engine->hip9011 Settings
dialog = hipFunction, "HIP9011 Settings (knock decoder)"
field = "Enabled", isHip9011Enabled
field = "Threshold", knockVThreshold, {isHip9011Enabled == 1}
field = "!ECU reboot needed to apply these settings"
field = "IntHold pin (hip9011 input)", hip9011IntHoldPin, {isHip9011Enabled == 1}
field = "IntHold pin (hip9011 input) mode", hip9011IntHoldPinMode, {isHip9011Enabled == 1}