2021-07-25 22:05:17 -07:00
|
|
|
#include "pch.h"
|
|
|
|
|
2021-06-02 14:50:07 -07:00
|
|
|
#include "defaults.h"
|
2022-05-17 14:54:11 -07:00
|
|
|
#include "vr_pwm.h"
|
2023-03-03 18:27:48 -08:00
|
|
|
#include "kline.h"
|
2024-03-06 19:47:11 -08:00
|
|
|
#include <rusefi/manifest.h>
|
2023-07-19 10:58:43 -07:00
|
|
|
#if HW_PROTEUS
|
|
|
|
#include "proteus_meta.h"
|
|
|
|
#endif // HW_PROTEUS
|
2021-06-02 14:50:07 -07:00
|
|
|
|
2023-11-04 06:09:10 -07:00
|
|
|
#if EFI_ALTERNATOR_CONTROL
|
2021-11-16 01:15:29 -08:00
|
|
|
static void setDefaultAlternatorParameters() {
|
2024-07-15 13:41:29 -07:00
|
|
|
setTable(config->alternatorVoltageTargetTable, 14);
|
2021-06-02 14:50:07 -07:00
|
|
|
|
|
|
|
engineConfiguration->alternatorControl.offset = 0;
|
|
|
|
engineConfiguration->alternatorControl.pFactor = 30;
|
|
|
|
engineConfiguration->alternatorControl.periodMs = 100;
|
|
|
|
}
|
2023-11-04 06:09:10 -07:00
|
|
|
#endif // EFI_ALTERNATOR_CONTROL
|
2021-06-02 14:50:07 -07:00
|
|
|
|
2023-06-10 09:46:39 -07:00
|
|
|
void setGDIFueling() {
|
2024-02-25 21:27:43 -08:00
|
|
|
setGdiWallWetting();
|
2023-06-10 09:46:39 -07:00
|
|
|
// Use high pressure sensor
|
|
|
|
engineConfiguration->injectorPressureType = IPT_High;
|
|
|
|
// Automatic compensation of injector flow based on rail pressure
|
|
|
|
engineConfiguration->injectorCompensationMode = ICM_SensedRailPressure;
|
|
|
|
// Reference rail pressure is 10 000 kPa = 100 bar
|
|
|
|
engineConfiguration->fuelReferencePressure = 10000;
|
|
|
|
//setting "flat" 0.2 ms injector's lag time
|
|
|
|
setArrayValues(engineConfiguration->injector.battLagCorr, 0.2);
|
2023-06-12 16:39:46 -07:00
|
|
|
|
|
|
|
setTable(config->injectionPhase, -200.0f);
|
|
|
|
engineConfiguration->injectionTimingMode = InjectionTimingMode::Center;
|
2023-09-25 12:52:16 -07:00
|
|
|
engineConfiguration->isPhaseSyncRequiredForIgnition = true;
|
2023-06-10 09:46:39 -07:00
|
|
|
}
|
|
|
|
|
2022-10-25 18:54:26 -07:00
|
|
|
/* Cylinder to bank mapping */
|
|
|
|
void setLeftRightBanksNeedBetterName() {
|
2023-03-27 00:58:18 -07:00
|
|
|
for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {
|
2024-05-13 13:18:49 -07:00
|
|
|
// zero-based index
|
2022-10-25 18:54:26 -07:00
|
|
|
engineConfiguration->cylinderBankSelect[i] = i % 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-24 21:41:13 -07:00
|
|
|
static void setDefaultHPFP() {
|
2023-09-25 09:13:46 -07:00
|
|
|
#if ! EFI_UNIT_TEST
|
|
|
|
// unit tests rely on 'hpfpCamLobes' for isGdiEngine() and we need not-GDI by default for unit tests
|
2023-08-29 13:46:04 -07:00
|
|
|
engineConfiguration->hpfpCamLobes = 3;
|
2023-09-25 09:13:46 -07:00
|
|
|
#endif
|
|
|
|
|
2023-04-24 21:55:47 -07:00
|
|
|
// todo: would be nice for unit tests to be happy about these defaults
|
2024-02-24 21:05:23 -08:00
|
|
|
#if EFI_PROD_CODE || EFI_SIMULATOR
|
2023-04-24 21:41:13 -07:00
|
|
|
engineConfiguration->hpfpPumpVolume = 0.290;
|
2023-08-29 13:53:49 -07:00
|
|
|
#endif
|
2023-04-24 21:41:13 -07:00
|
|
|
engineConfiguration->hpfpMinAngle = 10;
|
|
|
|
engineConfiguration->hpfpActivationAngle = 30;
|
|
|
|
engineConfiguration->hpfpTargetDecay = 2000;
|
|
|
|
engineConfiguration->hpfpPidP = 0.01;
|
|
|
|
engineConfiguration->hpfpPidI = 0.0003;
|
|
|
|
engineConfiguration->hpfpPeakPos = 10;
|
|
|
|
}
|
|
|
|
|
2024-05-26 10:53:19 -07:00
|
|
|
static void mc33810defaults() {
|
|
|
|
engineConfiguration->mc33810Nomi = 5.5;
|
|
|
|
engineConfiguration->mc33810Maxi = 14;
|
|
|
|
}
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void setDefaultBaseEngine() {
|
2021-06-02 14:50:07 -07:00
|
|
|
// Base Engine Settings
|
2023-03-27 00:58:18 -07:00
|
|
|
engineConfiguration->displacement = 2;
|
2024-08-04 11:02:58 -07:00
|
|
|
engineConfiguration->knockDetectionUseDoubleFrequency = true;
|
2023-07-23 23:41:45 -07:00
|
|
|
setInline4();
|
2021-06-02 14:50:07 -07:00
|
|
|
|
2024-03-19 18:58:22 -07:00
|
|
|
for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {
|
|
|
|
// one knock sensor by default. See also 'setLeftRightBanksNeedBetterName()'
|
2024-05-13 13:18:49 -07:00
|
|
|
// zero-based index
|
|
|
|
engineConfiguration->cylinderBankSelect[i] = 0;
|
2024-03-19 18:58:22 -07:00
|
|
|
}
|
|
|
|
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->compressionRatio = 9;
|
2023-03-30 07:01:51 -07:00
|
|
|
engineConfiguration->vssFilterReciprocal = VSS_FILTER_MIN;
|
2023-05-09 16:33:47 -07:00
|
|
|
engineConfiguration->boardUseCanTerminator = true;
|
2024-06-09 12:09:07 -07:00
|
|
|
engineConfiguration->acLowRpmLimit = 500;
|
2021-06-02 14:50:07 -07:00
|
|
|
|
2024-05-25 19:40:12 -07:00
|
|
|
#ifdef EFI_KLINE
|
|
|
|
engineConfiguration->kLinePeriodUs = 300 /* us*/;
|
|
|
|
engineConfiguration->kLineDoHondaSend = true;
|
|
|
|
#endif
|
|
|
|
|
2024-01-19 13:41:32 -08:00
|
|
|
setDefaultHPFP();
|
2023-04-24 21:41:13 -07:00
|
|
|
|
2024-03-06 19:47:11 -08:00
|
|
|
// it's useful to know what starting point is given tune based on
|
|
|
|
engineConfiguration->calibrationBirthday = compilationYear() * 10000 + compilationMonth() * 100 + compilationDay();
|
|
|
|
|
2024-01-19 13:41:32 -08:00
|
|
|
engineConfiguration->enableExtendedCanBroadcast = true;
|
2023-11-25 16:24:46 -08:00
|
|
|
|
2024-01-19 13:41:32 -08:00
|
|
|
engineConfiguration->fan1ExtraIdle = 2;
|
|
|
|
engineConfiguration->fan2ExtraIdle = 2;
|
|
|
|
|
2024-02-02 06:48:51 -08:00
|
|
|
engineConfiguration->auxSpeed1Multiplier = 1;
|
2024-03-17 18:05:11 -07:00
|
|
|
engineConfiguration->magicNumberAvailableForDevTricks = 1;
|
2024-02-02 06:48:51 -08:00
|
|
|
|
2024-01-19 13:41:32 -08:00
|
|
|
engineConfiguration->acrRevolutions = 5;
|
2023-11-11 14:36:42 -08:00
|
|
|
|
2023-11-17 12:59:04 -08:00
|
|
|
engineConfiguration->watchOutForLinearTime = true;
|
|
|
|
|
2024-05-16 09:39:09 -07:00
|
|
|
setLinearCurve(engineConfiguration->tractionControlSlipBins, /*from*/0.9, /*to*/1.2, 0.05);
|
2023-12-31 11:37:23 -08:00
|
|
|
setLinearCurve(engineConfiguration->tractionControlSpeedBins, /*from*/10, /*to*/120, 5);
|
|
|
|
|
2022-09-19 09:06:00 -07:00
|
|
|
engineConfiguration->turbochargerFilter = 0.01f;
|
|
|
|
|
2024-05-26 10:53:19 -07:00
|
|
|
mc33810defaults();
|
|
|
|
|
2021-06-03 11:40:19 -07:00
|
|
|
engineConfiguration->fuelAlgorithm = LM_SPEED_DENSITY;
|
2022-01-21 12:22:11 -08:00
|
|
|
// let's have valid default while we still have the field
|
2024-06-14 22:13:18 -07:00
|
|
|
engineConfiguration->debugMode = DBG_EXECUTOR;
|
2021-06-03 11:40:19 -07:00
|
|
|
|
2023-05-05 12:27:02 -07:00
|
|
|
engineConfiguration->boostCutPressure = 300;
|
|
|
|
engineConfiguration->boostCutPressureHyst = 20;
|
2023-12-29 09:29:15 -08:00
|
|
|
engineConfiguration->boostControlMinRpm = 2000;
|
|
|
|
engineConfiguration->boostControlMinTps = 30;
|
|
|
|
engineConfiguration->boostControlMinMap = 110;
|
2023-05-05 12:27:02 -07:00
|
|
|
|
2023-06-18 20:02:38 -07:00
|
|
|
engineConfiguration->primingDelay = 0.5;
|
2023-06-19 07:47:26 -07:00
|
|
|
engineConfiguration->vvtControlMinRpm = 500.0;
|
2023-06-18 20:02:38 -07:00
|
|
|
|
2023-09-10 07:34:06 -07:00
|
|
|
engineConfiguration->camDecoder2jzPosition = 95;
|
2023-10-08 12:07:50 -07:00
|
|
|
engineConfiguration->camDecoder2jzPrecision = 40;
|
2023-09-09 21:22:38 -07:00
|
|
|
|
2021-06-02 14:50:07 -07:00
|
|
|
// Limits and Fallbacks
|
|
|
|
engineConfiguration->rpmHardLimit = 7000;
|
2023-04-29 07:43:53 -07:00
|
|
|
engineConfiguration->rpmHardLimitHyst = 50;
|
2021-06-02 14:50:07 -07:00
|
|
|
engineConfiguration->cutFuelOnHardLimit = true;
|
|
|
|
engineConfiguration->cutSparkOnHardLimit = true;
|
2023-11-17 18:45:49 -08:00
|
|
|
engineConfiguration->etbRevLimitRange = 250;
|
2023-04-22 08:57:07 -07:00
|
|
|
|
2024-03-15 10:07:16 -07:00
|
|
|
engineConfiguration->tpsAccelFractionDivisor = 1;
|
|
|
|
|
2024-03-15 09:39:24 -07:00
|
|
|
engineConfiguration->rpmSoftLimitWindowSize = 200;
|
|
|
|
engineConfiguration->rpmSoftLimitTimingRetard = 4;
|
|
|
|
|
2023-11-17 20:09:27 -08:00
|
|
|
// CLT RPM limit table - just the X axis
|
2024-03-17 12:06:14 -07:00
|
|
|
copyArray(config->cltRevLimitRpmBins, { -20, 0, 40, 80 });
|
2023-11-17 20:09:27 -08:00
|
|
|
|
2022-12-16 20:51:50 -08:00
|
|
|
engineConfiguration->ALSMinRPM = 400;
|
|
|
|
engineConfiguration->ALSMaxRPM = 3200;
|
2023-02-06 15:05:38 -08:00
|
|
|
engineConfiguration->ALSMaxDuration = 3.5;
|
2022-12-16 20:51:50 -08:00
|
|
|
engineConfiguration->ALSMaxCLT = 105;
|
|
|
|
// engineConfiguration->alsMinPps = 10;
|
2022-12-14 19:25:06 -08:00
|
|
|
engineConfiguration->alsMinTimeBetween = 5;
|
|
|
|
engineConfiguration->alsEtbPosition = 30;
|
2022-12-31 11:47:48 -08:00
|
|
|
engineConfiguration->ALSMaxTPS = 5;
|
2022-12-14 19:25:06 -08:00
|
|
|
|
2024-02-25 06:41:43 -08:00
|
|
|
engineConfiguration->knockRetardAggression = 20;
|
|
|
|
engineConfiguration->knockRetardReapplyRate = 3;
|
2024-10-21 09:02:54 -07:00
|
|
|
engineConfiguration->knockFuelTrim = 0;
|
|
|
|
engineConfiguration->knockSuppressMinTps = 10;
|
2024-02-25 06:41:43 -08:00
|
|
|
|
2021-06-02 14:50:07 -07:00
|
|
|
// Trigger
|
2023-05-31 22:56:40 -07:00
|
|
|
engineConfiguration->trigger.type = trigger_type_e::TT_TOOTHED_WHEEL_60_2;
|
2022-04-03 03:58:25 -07:00
|
|
|
|
2023-10-25 15:05:48 -07:00
|
|
|
#if EFI_SIMULATOR
|
|
|
|
engineConfiguration->vvtMode[0] = VVT_SINGLE_TOOTH;
|
2023-11-02 18:57:01 -07:00
|
|
|
engineConfiguration->vvtOffsets[0] = 450;
|
2024-06-16 11:41:21 -07:00
|
|
|
engineConfiguration->vvtPins[0] = Gpio::A0; // a random unused pin needed to unblock startSimplePwmExt()
|
2023-10-25 15:05:48 -07:00
|
|
|
#endif // EFI_SIMULATOR
|
|
|
|
|
2023-10-25 15:08:05 -07:00
|
|
|
#if EFI_SIMULATOR
|
|
|
|
// R
|
2023-10-25 15:56:34 -07:00
|
|
|
config->tcuSolenoidTable[0][0] = 99;
|
2023-10-25 15:08:05 -07:00
|
|
|
config->tcuSolenoidTable[0][1] = 1;
|
2023-10-25 15:56:34 -07:00
|
|
|
config->tcuSolenoidTable[0][2] = 2;
|
|
|
|
config->tcuSolenoidTable[0][3] = 3;
|
|
|
|
config->tcuSolenoidTable[0][4] = 4;
|
|
|
|
config->tcuSolenoidTable[0][5] = 5;
|
2023-10-25 15:08:05 -07:00
|
|
|
// P/N
|
2023-10-25 15:56:34 -07:00
|
|
|
config->tcuSolenoidTable[1][0] = 10;
|
|
|
|
config->tcuSolenoidTable[1][1] = 11;
|
|
|
|
config->tcuSolenoidTable[1][2] = 12;
|
|
|
|
config->tcuSolenoidTable[1][3] = 13;
|
|
|
|
config->tcuSolenoidTable[1][4] = 14;
|
|
|
|
config->tcuSolenoidTable[1][5] = 15;
|
|
|
|
config->tcuSolenoidTable[1][6] = 16;
|
|
|
|
config->tcuSolenoidTable[1][7] = 17;
|
|
|
|
config->tcuSolenoidTable[1][8] = 18;
|
|
|
|
config->tcuSolenoidTable[1][9] = 19;
|
2023-10-25 15:08:05 -07:00
|
|
|
// 1
|
2023-10-25 15:56:34 -07:00
|
|
|
config->tcuSolenoidTable[2][0] = 20;
|
|
|
|
config->tcuSolenoidTable[2][1] = 21;
|
|
|
|
config->tcuSolenoidTable[2][2] = 22;
|
2023-10-25 15:08:05 -07:00
|
|
|
// 2
|
2023-10-25 15:56:34 -07:00
|
|
|
config->tcuSolenoidTable[3][0] = 30;
|
|
|
|
config->tcuSolenoidTable[3][1] = 31;
|
|
|
|
config->tcuSolenoidTable[3][3] = 33;
|
2023-10-25 15:08:05 -07:00
|
|
|
// 3
|
2023-10-25 15:56:34 -07:00
|
|
|
config->tcuSolenoidTable[4][0] = 40;
|
|
|
|
config->tcuSolenoidTable[4][1] = 41;
|
|
|
|
config->tcuSolenoidTable[4][4] = 44;
|
2023-10-25 15:08:05 -07:00
|
|
|
// 4
|
2023-10-25 15:56:34 -07:00
|
|
|
config->tcuSolenoidTable[5][0] = 50;
|
2023-10-25 19:44:48 -07:00
|
|
|
config->tcuSolenoidTable[5][1] = 51;
|
2023-10-25 15:56:34 -07:00
|
|
|
config->tcuSolenoidTable[5][5] = 55;
|
2023-10-25 15:08:05 -07:00
|
|
|
|
2023-10-25 19:44:48 -07:00
|
|
|
config->scriptTable4[0][0] = 140;
|
|
|
|
config->scriptTable4[0][1] = 141;
|
2023-10-25 20:50:28 -07:00
|
|
|
config->scriptTable4[0][2] = 142;
|
|
|
|
config->scriptTable4[0][3] = 143;
|
|
|
|
config->scriptTable4[0][4] = 144;
|
2023-10-25 19:44:48 -07:00
|
|
|
config->scriptTable4[0][5] = 145;
|
|
|
|
|
|
|
|
config->scriptTable4[1][0] = 240;
|
|
|
|
config->scriptTable4[1][1] = 241;
|
2023-10-25 20:50:28 -07:00
|
|
|
config->scriptTable4[1][2] = 242;
|
|
|
|
config->scriptTable4[1][3] = 243;
|
|
|
|
config->scriptTable4[1][4] = 244;
|
2023-10-25 19:44:48 -07:00
|
|
|
config->scriptTable4[1][5] = 245;
|
|
|
|
|
|
|
|
config->scriptTable4[4][0] = 40;
|
2023-10-25 20:50:28 -07:00
|
|
|
config->scriptTable4[4][2] = 41;
|
|
|
|
config->scriptTable4[4][3] = 42;
|
|
|
|
config->scriptTable4[4][4] = 43;
|
|
|
|
config->scriptTable4[4][5] = 44;
|
2023-10-25 19:44:48 -07:00
|
|
|
config->scriptTable4[4][5] = 45;
|
|
|
|
|
|
|
|
config->scriptTable4[5][0] = 50;
|
|
|
|
config->scriptTable4[5][1] = 51;
|
2023-10-25 20:50:28 -07:00
|
|
|
config->scriptTable4[5][2] = 52;
|
|
|
|
config->scriptTable4[5][3] = 53;
|
|
|
|
config->scriptTable4[5][4] = 54;
|
2023-10-25 19:44:48 -07:00
|
|
|
config->scriptTable4[5][5] = 55;
|
|
|
|
|
2023-10-25 15:08:05 -07:00
|
|
|
#endif // EFI_SIMULATOR
|
|
|
|
|
2021-06-02 14:50:07 -07:00
|
|
|
engineConfiguration->globalTriggerAngleOffset = 0;
|
|
|
|
|
|
|
|
// Default this to on - if you want to diagnose, turn it off.
|
|
|
|
engineConfiguration->silentTriggerError = true;
|
|
|
|
|
2023-03-27 18:33:49 -07:00
|
|
|
engineConfiguration->idleStepperReactionTime = 3;
|
|
|
|
engineConfiguration->idleStepperTotalSteps = 200;
|
2023-03-27 19:01:20 -07:00
|
|
|
engineConfiguration->stepperForceParkingEveryRestart = true;
|
2023-06-14 21:57:28 -07:00
|
|
|
engineConfiguration->iacByTpsTaper = 2;
|
2023-03-27 18:33:49 -07:00
|
|
|
|
2023-10-30 19:13:29 -07:00
|
|
|
engineConfiguration->etbSplit = MAX_TPS_PPS_DISCREPANCY;
|
|
|
|
|
2021-06-02 14:50:07 -07:00
|
|
|
// Advanced Trigger
|
|
|
|
|
|
|
|
// Battery and alternator
|
|
|
|
engineConfiguration->vbattDividerCoeff = ((float) (15 + 65)) / 15;
|
|
|
|
|
|
|
|
#if EFI_ALTERNATOR_CONTROL
|
2021-11-16 01:15:29 -08:00
|
|
|
setDefaultAlternatorParameters();
|
2021-06-02 14:50:07 -07:00
|
|
|
#endif /* EFI_ALTERNATOR_CONTROL */
|
|
|
|
|
|
|
|
// Fuel pump
|
2024-03-15 09:39:24 -07:00
|
|
|
// todo: maybe change to 2s as default?
|
2021-06-02 14:50:07 -07:00
|
|
|
engineConfiguration->startUpFuelPumpDuration = 4;
|
|
|
|
|
2023-03-03 18:27:48 -08:00
|
|
|
engineConfiguration->kLineBaudRate = KLINE_BAUD_RATE;
|
|
|
|
|
2022-05-22 06:42:58 -07:00
|
|
|
engineConfiguration->benchTestOnTime = 4;
|
|
|
|
engineConfiguration->benchTestOffTime = 500;
|
|
|
|
engineConfiguration->benchTestCount = 3;
|
|
|
|
|
2021-06-13 05:06:45 -07:00
|
|
|
// Fans
|
2024-03-17 13:10:39 -07:00
|
|
|
engineConfiguration->fanOnTemperature = 92;
|
|
|
|
engineConfiguration->fanOffTemperature = 88;
|
2021-06-13 05:06:45 -07:00
|
|
|
engineConfiguration->fan2OnTemperature = 95;
|
|
|
|
engineConfiguration->fan2OffTemperature = 91;
|
2021-06-02 14:50:07 -07:00
|
|
|
|
|
|
|
// Tachometer
|
|
|
|
// 50% duty cycle is the default for tach signal
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->tachPulseDurationAsDutyCycle = true;
|
|
|
|
engineConfiguration->tachPulseDuractionMs = 0.5;
|
|
|
|
engineConfiguration->tachPulsePerRev = 1;
|
2021-06-02 14:50:07 -07:00
|
|
|
|
2022-05-02 02:24:50 -07:00
|
|
|
engineConfiguration->etbMinimumPosition = 1;
|
|
|
|
engineConfiguration->etbMaximumPosition = 100;
|
2022-04-25 14:20:56 -07:00
|
|
|
|
|
|
|
engineConfiguration->tcuInputSpeedSensorTeeth = 1;
|
2022-04-25 14:42:19 -07:00
|
|
|
engineConfiguration->issFilterReciprocal = 2;
|
2022-04-25 14:20:56 -07:00
|
|
|
|
2024-05-04 03:27:32 -07:00
|
|
|
//knock
|
2024-05-04 04:28:00 -07:00
|
|
|
#ifdef KNOCK_SPECTROGRAM
|
2024-05-04 03:27:32 -07:00
|
|
|
engineConfiguration->enableKnockSpectrogram = false;
|
2024-10-21 09:02:12 -07:00
|
|
|
engineConfiguration->enableKnockSpectrogramFilter = false;
|
|
|
|
engineConfiguration->knockSpectrumSensitivity = 1.0;
|
|
|
|
engineConfiguration->knockFrequency = 0.0;
|
2024-05-04 03:27:32 -07:00
|
|
|
#endif
|
|
|
|
|
2021-06-02 14:50:07 -07:00
|
|
|
// Check engine light
|
|
|
|
#if EFI_PROD_CODE
|
|
|
|
engineConfiguration->warningPeriod = 10;
|
|
|
|
#else
|
|
|
|
engineConfiguration->warningPeriod = 0;
|
|
|
|
#endif /* EFI_PROD_CODE */
|
2022-05-17 14:54:11 -07:00
|
|
|
|
|
|
|
setDefaultVrThresholds();
|
|
|
|
|
2024-08-06 13:10:10 -07:00
|
|
|
// Oil pressure protection
|
|
|
|
engineConfiguration->minimumOilPressureTimeout = 0.5f;
|
|
|
|
setLinearCurve(config->minimumOilPressureBins, 0, 7000);
|
2021-06-02 14:50:07 -07:00
|
|
|
}
|
2022-10-29 20:04:24 -07:00
|
|
|
|
|
|
|
void setPPSInputs(adc_channel_e pps1, adc_channel_e pps2) {
|
|
|
|
engineConfiguration->throttlePedalPositionAdcChannel = pps1;
|
|
|
|
engineConfiguration->throttlePedalPositionSecondAdcChannel = pps2;
|
2022-10-29 20:55:14 -07:00
|
|
|
}
|
|
|
|
|
2022-10-29 21:17:42 -07:00
|
|
|
void setTPS1Inputs(adc_channel_e tps1, adc_channel_e tps2) {
|
|
|
|
engineConfiguration->tps1_1AdcChannel = tps1;
|
|
|
|
engineConfiguration->tps1_2AdcChannel = tps2;
|
|
|
|
}
|
|
|
|
|
2023-03-03 07:35:06 -08:00
|
|
|
void setTPS1Calibration(uint16_t tpsMin, uint16_t tpsMax) {
|
2022-11-04 09:37:28 -07:00
|
|
|
engineConfiguration->tpsMin = tpsMin;
|
|
|
|
engineConfiguration->tpsMax = tpsMax;
|
2023-03-03 07:35:06 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void setTPS1Calibration(uint16_t tpsMin, uint16_t tpsMax, uint16_t tps1SecondaryMin, uint16_t tps1SecondaryMax) {
|
|
|
|
setTPS1Calibration(tpsMin, tpsMax);
|
|
|
|
|
2022-11-04 09:37:28 -07:00
|
|
|
|
|
|
|
engineConfiguration->tps1SecondaryMin = tps1SecondaryMin;
|
|
|
|
engineConfiguration->tps1SecondaryMax = tps1SecondaryMax;
|
|
|
|
}
|
|
|
|
|
2023-11-07 22:15:33 -08:00
|
|
|
void setCustomMap(float lowValue, float mapLowValueVoltage, float highValue, float mapHighValueVoltage) {
|
|
|
|
engineConfiguration->map.sensor.type = MT_CUSTOM;
|
|
|
|
engineConfiguration->map.sensor.lowValue = lowValue;
|
|
|
|
engineConfiguration->mapLowValueVoltage = mapLowValueVoltage;
|
|
|
|
engineConfiguration->map.sensor.highValue = highValue;
|
|
|
|
engineConfiguration->mapHighValueVoltage = mapHighValueVoltage;
|
|
|
|
}
|
|
|
|
|
2022-10-29 20:55:14 -07:00
|
|
|
void setPPSCalibration(float primaryUp, float primaryDown, float secondaryUp, float secondaryDown) {
|
|
|
|
engineConfiguration->throttlePedalUpVoltage = primaryUp;
|
|
|
|
engineConfiguration->throttlePedalWOTVoltage = primaryDown;
|
|
|
|
engineConfiguration->throttlePedalSecondaryUpVoltage = secondaryUp;
|
|
|
|
engineConfiguration->throttlePedalSecondaryWOTVoltage = secondaryDown;
|
|
|
|
}
|
2022-11-04 10:27:40 -07:00
|
|
|
|
|
|
|
void setEtbPID(float p, float i, float d) {
|
|
|
|
engineConfiguration->etb.pFactor = p;
|
|
|
|
engineConfiguration->etb.iFactor = i;
|
|
|
|
engineConfiguration->etb.dFactor = d;
|
|
|
|
}
|
2023-07-12 08:34:25 -07:00
|
|
|
|
|
|
|
void setInline4() {
|
|
|
|
engineConfiguration->cylindersCount = 4;
|
|
|
|
engineConfiguration->firingOrder = FO_1_3_4_2;
|
|
|
|
}
|
2023-07-19 10:36:19 -07:00
|
|
|
|
|
|
|
void setProteusEtbIO() {
|
2023-07-19 10:50:51 -07:00
|
|
|
#if HW_PROTEUS && EFI_PROD_CODE
|
2023-07-19 10:36:19 -07:00
|
|
|
engineConfiguration->tps1_2AdcChannel = PROTEUS_IN_TPS1_2;
|
|
|
|
setPPSInputs(PROTEUS_IN_PPS, PROTEUS_IN_PPS2);
|
|
|
|
#endif // HW_PROTEUS
|
|
|
|
}
|
2024-08-14 08:34:34 -07:00
|
|
|
|
|
|
|
void setupTLE9201(Gpio controlPin, Gpio direction, Gpio disable, int dcIndex) {
|
|
|
|
// TLE9201 driver
|
|
|
|
// This chip has three control pins:
|
|
|
|
// DIR - sets direction of the motor
|
|
|
|
// PWM - pwm control (enable high, coast low)
|
|
|
|
// DIS - disables motor (enable low)
|
|
|
|
|
|
|
|
// PWM pin
|
|
|
|
engineConfiguration->etbIo[dcIndex].controlPin = controlPin;
|
|
|
|
// DIR pin
|
|
|
|
engineConfiguration->etbIo[dcIndex].directionPin1 = direction;
|
|
|
|
// Disable pin
|
|
|
|
engineConfiguration->etbIo[dcIndex].disablePin = disable;
|
|
|
|
|
|
|
|
// we only have pwm/dir, no dira/dirb
|
|
|
|
engineConfiguration->etb_use_two_wires = false;
|
|
|
|
}
|
2024-08-22 16:11:10 -07:00
|
|
|
|
|
|
|
void setupTLE9201IncludingStepper(Gpio controlPin, Gpio direction, Gpio disable, int dcIndex) {
|
|
|
|
setupTLE9201(controlPin, direction, disable, dcIndex);
|
|
|
|
|
|
|
|
// on SBC style stepper IAC fully-extended valve shaft would give least idle air
|
|
|
|
// fully-retracted valve shaft would give most idle air
|
|
|
|
int stepperIndexWeirdness = 1 - dcIndex;
|
|
|
|
engineConfiguration->stepperDcIo[stepperIndexWeirdness].controlPin = controlPin;
|
|
|
|
engineConfiguration->stepperDcIo[stepperIndexWeirdness].directionPin1 = direction;
|
|
|
|
engineConfiguration->stepperDcIo[stepperIndexWeirdness].directionPin2 = Gpio::Unassigned;
|
|
|
|
engineConfiguration->stepperDcIo[stepperIndexWeirdness].disablePin = disable;
|
|
|
|
}
|