GCC Code Coverage Report


Directory: ./
File: firmware/controllers/algo/defaults/default_base_engine.cpp
Date: 2025-10-24 14:26:41
Coverage Exec Excl Total
Lines: 90.9% 240 0 264
Functions: 90.4% 47 0 52
Branches: 82.1% 23 0 28
Decisions: 90.9% 20 - 22

Line Branch Decision Exec Source
1 #include "pch.h"
2
3 #include "defaults.h"
4 #include "vr_pwm.h"
5 #include "kline.h"
6 #include "engine_configuration_defaults.h"
7 #include <rusefi/manifest.h>
8 #if HW_PROTEUS
9 #include "proteus_meta.h"
10 #endif // HW_PROTEUS
11
12 #if EFI_ALTERNATOR_CONTROL
13 587 static void setDefaultAlternatorParameters() {
14 587 setTable(config->alternatorVoltageTargetTable, 14);
15
16 587 engineConfiguration->alternatorControl.offset = 0;
17 587 engineConfiguration->alternatorControl.pFactor = 30;
18 587 engineConfiguration->alternatorControl.periodMs = 100;
19 587 }
20 #endif // EFI_ALTERNATOR_CONTROL
21
22 588 void setHpfpLobeProfileAngle(int lobes) {
23 #if HPFP_LOBE_PROFILE_SIZE == 16
24 static const float hardCodedHpfpLobeProfileAnglesForThreeLobes[16] = {0.0, 7.5, 16.5, 24.0,
25 32.0 , 40.0, 48.0, 56.0,
26 64.0 , 72.0, 80.0, 88.0,
27 96.0 , 103.5, 112.5, 120.0
28 };
29
30 588 float multiplier = 3.0 / lobes;
31
2/2
✓ Branch 0 taken 9408 times.
✓ Branch 1 taken 588 times.
2/2
✓ Decision 'true' taken 9408 times.
✓ Decision 'false' taken 588 times.
9996 for (size_t i = 0; i < HPFP_LOBE_PROFILE_SIZE; i++) {
32 9408 config->hpfpLobeProfileAngle[i] = multiplier * hardCodedHpfpLobeProfileAnglesForThreeLobes[i];
33 }
34 #endif // HPFP_LOBE_PROFILE_SIZE
35 588 }
36
37 587 static void setDefaultHPFP() {
38 #if ! EFI_UNIT_TEST
39 // unit tests rely on 'hpfpCamLobes' for isGdiEngine() and we need not-GDI by default for unit tests
40 engineConfiguration->hpfpCamLobes = 3;
41 #endif
42
43 // todo: would be nice for unit tests to be happy about these defaults
44 #if EFI_PROD_CODE || EFI_SIMULATOR
45 engineConfiguration->hpfpPumpVolume = 0.290;
46 #endif
47 587 engineConfiguration->hpfpMinAngle = 10;
48 587 engineConfiguration->hpfpActivationAngle = 30;
49 587 engineConfiguration->hpfpTargetDecay = 2000;
50 587 engineConfiguration->hpfpPidP = 0.01;
51 587 engineConfiguration->hpfpPidI = 0.0003;
52 587 engineConfiguration->hpfpPeakPos = 10;
53 587 }
54
55 587 static void setGdiDefaults() {
56 587 setDefaultHPFP();
57
58 587 setRpmTableBin(config->hpfpTargetRpmBins);
59 587 setLinearCurve(config->hpfpTargetLoadBins, 0, 180, 1);
60 587 setTable(config->hpfpTarget, 5000);
61
62 587 setLinearCurve(config->hpfpFuelMassCompensationFuelMass, 0.0, 500, 10);
63 587 setLinearCurve(config->hpfpFuelMassCompensationFuelPressure, 0, 300, 25);
64 587 setTable(config->hpfpFuelMassCompensation, 1.0);
65
66 587 setLinearCurve(config->injectorFlowLinearizationFuelMassBins, 0.0, 500, 10);
67 587 setLinearCurve(config->injectorFlowLinearizationPressureBins, 0, 300, 25);
68 587 }
69
70 1 void setGDIFueling() {
71 #ifdef HW_HELLEN_8CHAN
72 engineConfiguration->externalRusEfiGdiModule = true;
73 #endif
74
75 1 engineConfiguration->injectionMode = IM_SEQUENTIAL;
76 1 engineConfiguration->crankingInjectionMode = IM_SEQUENTIAL;
77 1 engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS;
78
79 1 setGdiWallWetting();
80 // Use high pressure sensor
81 1 engineConfiguration->injectorPressureType = IPT_High;
82 // Automatic compensation of injector flow based on rail pressure
83 1 engineConfiguration->injectorCompensationMode = ICM_SensedRailPressure;
84 // Reference rail pressure is 10 000 kPa = 100 bar
85 1 engineConfiguration->fuelReferencePressure = 10000;
86 //setting "flat" 0.2 ms injector's lag time
87 1 setTable(engineConfiguration->injector.battLagCorrTable, 0.2);
88
89 1 setTable(config->injectionPhase, -200.0f);
90 1 engineConfiguration->injectionTimingMode = InjectionTimingMode::Center;
91 1 engineConfiguration->isPhaseSyncRequiredForIgnition = true;
92 1 }
93
94 /* Cylinder to bank mapping */
95 void setLeftRightBanksNeedBetterName() {
96 for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {
97 // zero-based index
98 engineConfiguration->cylinderBankSelect[i] = i % 2;
99 }
100 }
101
102 587 static void mc33810defaults() {
103 587 engineConfiguration->mc33810Nomi = 5.5;
104 587 engineConfiguration->mc33810maxDwellTimer = mc33810maxDwellTimer_e::DWELL_8MS;
105 587 engineConfiguration->mc33810Maxi = 14;
106 587 }
107
108 584 void setDynoDefaults() {
109 584 config->dynoRpmStep = 100;
110
111 584 config->dynoSaeTemperatureC = 20;
112 584 config->dynoSaeBaro = STD_ATMOSPHERE;
113 584 config->dynoSaeRelativeHumidity = 80;
114
115 584 config->dynoCarWheelDiaInch = 18;
116 584 config->dynoCarWheelTireWidthMm = 235;
117 584 config->dynoCarWheelAspectRatio = 40;
118
119 584 config->dynoCarGearPrimaryReduction = 1;
120 584 config->dynoCarGearRatio = 1.0;
121 584 config->dynoCarGearFinalDrive = 4.2;
122
123 584 config->dynoCarCarMassKg = 1000;
124 584 config->dynoCarCargoMassKg = 95;
125 584 config->dynoCarCoeffOfDrag = 0.29;
126 584 config->dynoCarFrontalAreaM2 = 1.85;
127 584 }
128
129 1172 void defaultsOrFixOnBurn() {
130
2/2
✓ Branch 1 taken 584 times.
✓ Branch 2 taken 588 times.
2/2
✓ Decision 'true' taken 584 times.
✓ Decision 'false' taken 588 times.
1172 if (config->dynoCarCarMassKg == 0) {
131 584 setDynoDefaults();
132 }
133
134
3/4
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 587 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 585 times.
2/2
✓ Decision 'true' taken 587 times.
✓ Decision 'false' taken 585 times.
1172 if (engineConfiguration->mapExpAverageAlpha <= 0 || engineConfiguration->mapExpAverageAlpha > 1) {
135 587 engineConfiguration->mapExpAverageAlpha = 1;
136 }
137
138
3/4
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 587 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 585 times.
2/2
✓ Decision 'true' taken 587 times.
✓ Decision 'false' taken 585 times.
1172 if (engineConfiguration->ppsExpAverageAlpha <= 0 || engineConfiguration->ppsExpAverageAlpha > 1) {
139 587 engineConfiguration->ppsExpAverageAlpha = 1;
140 }
141
3/4
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 587 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 585 times.
2/2
✓ Decision 'true' taken 587 times.
✓ Decision 'false' taken 585 times.
1172 if (engineConfiguration->afrExpAverageAlpha <= 0 || engineConfiguration->afrExpAverageAlpha > 1) {
142 587 engineConfiguration->afrExpAverageAlpha = 1;
143 }
144
145
2/2
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 585 times.
2/2
✓ Decision 'true' taken 587 times.
✓ Decision 'false' taken 585 times.
1172 if (engineConfiguration->alternator_iTermMin == 0) {
146 587 engineConfiguration->alternator_iTermMin = -1000;
147 }
148
2/2
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 585 times.
2/2
✓ Decision 'true' taken 587 times.
✓ Decision 'false' taken 585 times.
1172 if (engineConfiguration->alternator_iTermMax == 0) {
149 587 engineConfiguration->alternator_iTermMax = 1000;
150 }
151
2/2
✓ Branch 1 taken 587 times.
✓ Branch 2 taken 585 times.
2/2
✓ Decision 'true' taken 587 times.
✓ Decision 'false' taken 585 times.
1172 if (engineConfiguration->idleReturnTargetRampDuration <= 0.1){
152 587 engineConfiguration->idleReturnTargetRampDuration = 3;
153 }
154
155
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1170 times.
2/2
✓ Decision 'true' taken 2 times.
✓ Decision 'false' taken 1170 times.
1172 if (engineConfiguration->vvtControlMinRpm < engineConfiguration->cranking.rpm) {
156 2 engineConfiguration->vvtControlMinRpm = engineConfiguration->cranking.rpm;
157 }
158 1172 }
159
160 587 void setDefaultBaseEngine() {
161 // Base Engine Settings
162 587 engineConfiguration->displacement = 2;
163 587 engineConfiguration->knockDetectionUseDoubleFrequency = true;
164 #if MAX_CYLINDER_COUNT >= 4
165 587 setInline4();
166 #else
167 // todo: invoke more complete one cylinder default?
168 engineConfiguration->cylindersCount = 1;
169 #endif
170
171 587 engineConfiguration->isTuningDetectorEnabled = true;
172
173
2/2
✓ Branch 0 taken 2348 times.
✓ Branch 1 taken 587 times.
2/2
✓ Decision 'true' taken 2348 times.
✓ Decision 'false' taken 587 times.
2935 for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {
174 // one knock sensor by default. See also 'setLeftRightBanksNeedBetterName()'
175 // zero-based index
176 2348 engineConfiguration->cylinderBankSelect[i] = 0;
177 }
178
179 587 engineConfiguration->ltft.enabled = true;
180 587 engineConfiguration->ltft.correctionEnabled = true;
181
182 587 engineConfiguration->compressionRatio = 9;
183 587 engineConfiguration->vssFilterReciprocal = VSS_FILTER_MIN;
184 587 engineConfiguration->boardUseCanTerminator = true;
185 587 engineConfiguration->acLowRpmLimit = 500;
186
187 587 engineConfiguration->mafFilterParameter = 1;
188
189 #ifdef EFI_KLINE
190 engineConfiguration->kLinePeriodUs = 300 /* us*/;
191 engineConfiguration->kLineDoHondaSend = true;
192 #endif
193
194 587 setGdiDefaults();
195
196 // it's useful to know what starting point is given tune based on
197 587 engineConfiguration->calibrationBirthday = compilationYear() * 10000 + compilationMonth() * 100 + compilationDay();
198
199 587 engineConfiguration->enableExtendedCanBroadcast = true;
200
201 587 engineConfiguration->fan1ExtraIdle = 2;
202 587 engineConfiguration->fan2ExtraIdle = 2;
203
204 587 engineConfiguration->auxSpeed1Multiplier = 1;
205 587 engineConfiguration->magicNumberAvailableForDevTricks = 1;
206
207 587 engineConfiguration->acrRevolutions = 5;
208 587 engineConfiguration->acPressure.v2 = 5;
209 587 engineConfiguration->acPressure.value2 = 100;
210
211 587 engineConfiguration->lowPressureFuel.v2 = 5;
212 587 engineConfiguration->lowPressureFuel.value2 = 100;
213
214 587 engineConfiguration->wastegatePositionOpenedVoltage = 4.0;
215
216 587 engineConfiguration->fuelLevelAveragingAlpha = engine_configuration_defaults::FUEL_LEVEL_AVERAGING_ALPHA;
217 587 engineConfiguration->fuelLevelUpdatePeriodSec = engine_configuration_defaults::FUEL_LEVEL_UPDATE_PERIOD_SEC;
218 587 engineConfiguration->fuelLevelLowThresholdVoltage = engine_configuration_defaults::FUEL_LEVEL_LOW_THRESHOLD_VOLTAGE;
219 587 engineConfiguration->fuelLevelHighThresholdVoltage = engine_configuration_defaults::FUEL_LEVEL_HIGH_THRESHOLD_VOLTAGE;
220
221 587 engineConfiguration->watchOutForLinearTime = true;
222
223 587 setLinearCurve(engineConfiguration->tractionControlSlipBins, /*from*/0.9, /*to*/1.2, 0.05);
224 587 setLinearCurve(engineConfiguration->tractionControlSpeedBins, /*from*/10, /*to*/120, 5);
225
226 587 engineConfiguration->turbochargerFilter = 0.01f;
227
228 587 mc33810defaults();
229
230 587 setRpmTableBin(config->torqueRpmBins);
231 587 setLinearCurve(config->torqueLoadBins, 0, 100, 1);
232
233 587 engineConfiguration->fuelAlgorithm = engine_load_mode_e::LM_SPEED_DENSITY;
234 // let's have valid default while we still have the field
235 587 engineConfiguration->debugMode = DBG_EXECUTOR;
236
237
238 587 engineConfiguration->primingDelay = 0.5;
239 // this should not be below default rpm! maybe even make them equal?
240 587 engineConfiguration->vvtControlMinRpm = 600;
241
242 // todo: this "2JZ" trigger is very powerful for many low tooth quantity applications
243 // todo: we might be getting closer to a re-name
244 // by the way 2GRFE intake likes position 160 / precision 20
245 // see also https://github.com/rusefi/rusefi/issues/7345
246 //
247 // 2JZ values
248 587 engineConfiguration->camDecoder2jzPosition = 95;
249 587 engineConfiguration->camDecoder2jzPrecision = 40;
250
251 // Limits and Fallbacks
252 587 engineConfiguration->rpmHardLimit = 7000;
253 587 engineConfiguration->rpmHardLimitHyst = 50;
254 587 engineConfiguration->cutFuelOnHardLimit = true;
255 587 engineConfiguration->cutSparkOnHardLimit = true;
256 587 engineConfiguration->etbRevLimitRange = 250;
257
258 587 engineConfiguration->tpsAccelFractionDivisor = 1;
259
260 587 engineConfiguration->rpmSoftLimitWindowSize = 200;
261 587 engineConfiguration->rpmSoftLimitTimingRetard = 4;
262
263 // CLT RPM limit table - just the X axis
264 587 copyArray(config->cltRevLimitRpmBins, { -20, 0, 40, 80 });
265
266 587 engineConfiguration->ALSMinRPM = 400;
267 587 engineConfiguration->ALSMaxRPM = 3200;
268 587 engineConfiguration->ALSMaxDuration = 3;
269 587 engineConfiguration->ALSMaxCLT = 105;
270 // engineConfiguration->alsMinPps = 10;
271 587 engineConfiguration->alsMinTimeBetween = 5;
272 587 engineConfiguration->alsEtbPosition = 30;
273 587 engineConfiguration->ALSMaxTPS = 5;
274
275 587 engineConfiguration->torqueReductionActivationTemperature = 60;
276
277 587 engineConfiguration->knockRetardAggression = 20;
278 587 engineConfiguration->knockRetardReapplyRate = 3;
279 587 engineConfiguration->knockFuelTrim = 0;
280 587 engineConfiguration->knockSuppressMinTps = 10;
281
282 // Trigger
283 587 engineConfiguration->trigger.type = trigger_type_e::TT_TOOTHED_WHEEL_60_2;
284
285 #if EFI_SIMULATOR
286 engineConfiguration->vvtMode[0] = VVT_SINGLE_TOOTH;
287 engineConfiguration->vvtOffsets[0] = 450;
288 engineConfiguration->vvtPins[0] = Gpio::A0; // a random unused pin needed to unblock startSimplePwmExt()
289 #endif // EFI_SIMULATOR
290
291 #if EFI_SIMULATOR
292 // R
293 config->tcuSolenoidTable[0][0] = 99;
294 config->tcuSolenoidTable[0][1] = 1;
295 config->tcuSolenoidTable[0][2] = 2;
296 config->tcuSolenoidTable[0][3] = 3;
297 config->tcuSolenoidTable[0][4] = 4;
298 config->tcuSolenoidTable[0][5] = 5;
299 // P/N
300 config->tcuSolenoidTable[1][0] = 10;
301 config->tcuSolenoidTable[1][1] = 11;
302 config->tcuSolenoidTable[1][2] = 12;
303 config->tcuSolenoidTable[1][3] = 13;
304 config->tcuSolenoidTable[1][4] = 14;
305 config->tcuSolenoidTable[1][5] = 15;
306 config->tcuSolenoidTable[1][6] = 16;
307 config->tcuSolenoidTable[1][7] = 17;
308 config->tcuSolenoidTable[1][8] = 18;
309 config->tcuSolenoidTable[1][9] = 19;
310 // 1
311 config->tcuSolenoidTable[2][0] = 20;
312 config->tcuSolenoidTable[2][1] = 21;
313 config->tcuSolenoidTable[2][2] = 22;
314 // 2
315 config->tcuSolenoidTable[3][0] = 30;
316 config->tcuSolenoidTable[3][1] = 31;
317 config->tcuSolenoidTable[3][3] = 33;
318 // 3
319 config->tcuSolenoidTable[4][0] = 40;
320 config->tcuSolenoidTable[4][1] = 41;
321 config->tcuSolenoidTable[4][4] = 44;
322 // 4
323 config->tcuSolenoidTable[5][0] = 50;
324 config->tcuSolenoidTable[5][1] = 51;
325 config->tcuSolenoidTable[5][5] = 55;
326
327 // [tag:runNotSquareTest] huh why is this not a unit test?!
328 config->scriptTable4[0][0] = 140;
329 config->scriptTable4[0][1] = 141;
330 config->scriptTable4[0][2] = 142;
331 config->scriptTable4[0][3] = 143;
332 config->scriptTable4[0][4] = 144;
333 config->scriptTable4[0][5] = 145;
334
335 config->scriptTable4[1][0] = 240;
336 config->scriptTable4[1][1] = 241;
337 config->scriptTable4[1][2] = 242;
338 config->scriptTable4[1][3] = 243;
339 config->scriptTable4[1][4] = 244;
340 config->scriptTable4[1][5] = 245;
341
342 config->scriptTable4[4][0] = 40;
343 config->scriptTable4[4][2] = 41;
344 config->scriptTable4[4][3] = 42;
345 config->scriptTable4[4][4] = 43;
346 config->scriptTable4[4][5] = 44;
347 config->scriptTable4[4][5] = 45;
348
349 config->scriptTable4[5][0] = 50;
350 config->scriptTable4[5][1] = 51;
351 config->scriptTable4[5][2] = 52;
352 config->scriptTable4[5][3] = 53;
353 config->scriptTable4[5][4] = 54;
354 config->scriptTable4[5][5] = 55;
355
356 #endif // EFI_SIMULATOR
357
358 587 engineConfiguration->globalTriggerAngleOffset = 0;
359
360 // Default this to on - if you want to diagnose, turn it off.
361 587 engineConfiguration->silentTriggerError = true;
362
363 587 engineConfiguration->idleStepperReactionTime = 3;
364 587 engineConfiguration->idleStepperTotalSteps = 200;
365 587 engineConfiguration->stepperForceParkingEveryRestart = true;
366 587 engineConfiguration->iacByTpsTaper = 2;
367
368 587 engineConfiguration->etbSplit = MAX_TPS_PPS_DISCREPANCY;
369
370 // Advanced Trigger
371
372 // Battery and alternator
373 587 engineConfiguration->vbattDividerCoeff = ((float) (15 + 65)) / 15;
374
375 #if EFI_ALTERNATOR_CONTROL
376 587 setDefaultAlternatorParameters();
377 #endif /* EFI_ALTERNATOR_CONTROL */
378
379 // Fuel pump
380 // todo: maybe change to 2s as default?
381 587 engineConfiguration->startUpFuelPumpDuration = 4;
382
383 587 engineConfiguration->kLineBaudRate = KLINE_BAUD_RATE;
384
385 587 engineConfiguration->benchTestOnTime = 4;
386 587 engineConfiguration->benchTestOffTime = 500;
387 587 engineConfiguration->benchTestCount = 3;
388
389
390 // Tachometer
391 // 50% duty cycle is the default for tach signal
392 587 engineConfiguration->tachPulseDurationAsDutyCycle = true;
393 587 engineConfiguration->tachPulseDuractionMs = 0.5;
394 587 engineConfiguration->tachPulsePerRev = 1;
395
396 587 engineConfiguration->etbMinimumPosition = 1;
397 587 engineConfiguration->etbMaximumPosition = 100;
398
399 587 engineConfiguration->tcuInputSpeedSensorTeeth = 1;
400 587 engineConfiguration->issFilterReciprocal = 2;
401
402 //knock
403 #ifdef KNOCK_SPECTROGRAM
404 engineConfiguration->enableKnockSpectrogram = false;
405 engineConfiguration->enableKnockSpectrogramFilter = false;
406 engineConfiguration->knockSpectrumSensitivity = 1.0;
407 engineConfiguration->knockFrequency = 0.0;
408 #endif
409
410 // Check engine light
411 #if EFI_PROD_CODE
412 engineConfiguration->warningPeriod = 10;
413 #else
414 587 engineConfiguration->warningPeriod = 0;
415 #endif /* EFI_PROD_CODE */
416
417 587 setDefaultVrThresholds();
418
419 // Oil pressure protection
420 587 engineConfiguration->minimumOilPressureTimeout = 0.5f;
421 587 setRpmTableBin(config->minimumOilPressureBins);
422 587 setRpmTableBin(config->maximumOilPressureBins);
423
424 18197 engine->engineModules.apply_all([](auto & m) { m.setDefaultConfiguration(); });
425 // we invoke this last so that we can validate even defaults
426 defaultsOrFixOnBurn();
427 }
428
429 1 void setPPSInputs(adc_channel_e pps1, adc_channel_e pps2) {
430 1 engineConfiguration->throttlePedalPositionAdcChannel = pps1;
431 1 engineConfiguration->throttlePedalPositionSecondAdcChannel = pps2;
432 1 }
433
434 void setTPS1Inputs(adc_channel_e tps1, adc_channel_e tps2) {
435 engineConfiguration->tps1_1AdcChannel = tps1;
436 engineConfiguration->tps1_2AdcChannel = tps2;
437 }
438
439 588 void setTPS1Calibration(uint16_t tpsMin, uint16_t tpsMax) {
440 588 engineConfiguration->tpsMin = tpsMin;
441 588 engineConfiguration->tpsMax = tpsMax;
442 588 }
443
444 588 void setTPS1Calibration(uint16_t tpsMin, uint16_t tpsMax, uint16_t tps1SecondaryMin, uint16_t tps1SecondaryMax) {
445 588 setTPS1Calibration(tpsMin, tpsMax);
446
447
448 588 engineConfiguration->tps1SecondaryMin = tps1SecondaryMin;
449 588 engineConfiguration->tps1SecondaryMax = tps1SecondaryMax;
450 588 }
451
452 10 void setCustomMap(float lowValue, float mapLowValueVoltage, float highValue, float mapHighValueVoltage) {
453 10 engineConfiguration->map.sensor.type = MT_CUSTOM;
454 10 engineConfiguration->map.sensor.lowValue = lowValue;
455 10 engineConfiguration->mapLowValueVoltage = mapLowValueVoltage;
456 10 engineConfiguration->map.sensor.highValue = highValue;
457 10 engineConfiguration->mapHighValueVoltage = mapHighValueVoltage;
458 10 }
459
460 590 void setPPSCalibration(float primaryUp, float primaryDown, float secondaryUp, float secondaryDown) {
461 590 engineConfiguration->throttlePedalUpVoltage = primaryUp;
462 590 engineConfiguration->throttlePedalWOTVoltage = primaryDown;
463 590 engineConfiguration->throttlePedalSecondaryUpVoltage = secondaryUp;
464 590 engineConfiguration->throttlePedalSecondaryWOTVoltage = secondaryDown;
465 590 }
466
467 1 void setEtbPID(float p, float i, float d) {
468 1 engineConfiguration->etb.pFactor = p;
469 1 engineConfiguration->etb.iFactor = i;
470 1 engineConfiguration->etb.dFactor = d;
471 1 }
472
473 591 void setInline4() {
474 591 engineConfiguration->cylindersCount = 4;
475 591 engineConfiguration->firingOrder = FO_1_3_4_2;
476 591 }
477
478 void setProteusEtbIO() {
479 #if HW_PROTEUS && EFI_PROD_CODE
480 engineConfiguration->tps1_2AdcChannel = PROTEUS_IN_TPS1_2;
481 setPPSInputs(PROTEUS_IN_PPS, PROTEUS_IN_PPS2);
482 #endif // HW_PROTEUS
483 }
484
485 void setupTLE9201(Gpio controlPin, Gpio direction, Gpio disable, int dcIndex) {
486 // TLE9201 driver
487 // This chip has three control pins:
488 // DIR - sets direction of the motor
489 // PWM - pwm control (enable high, coast low)
490 // DIS - disables motor (enable low)
491
492 // PWM pin
493 engineConfiguration->etbIo[dcIndex].controlPin = controlPin;
494 // DIR pin
495 engineConfiguration->etbIo[dcIndex].directionPin1 = direction;
496 // Disable pin
497 engineConfiguration->etbIo[dcIndex].disablePin = disable;
498
499 // we only have pwm/dir, no dira/dirb
500 engineConfiguration->etb_use_two_wires = false;
501 }
502
503 void setupTLE9201IncludingStepper(Gpio controlPin, Gpio direction, Gpio disable, int dcIndex) {
504 setupTLE9201(controlPin, direction, disable, dcIndex);
505
506 // on SBC style stepper IAC fully-extended valve shaft would give least idle air
507 // fully-retracted valve shaft would give most idle air
508 int stepperIndexWeirdness = 1 - dcIndex;
509 engineConfiguration->stepperDcIo[stepperIndexWeirdness].controlPin = controlPin;
510 engineConfiguration->stepperDcIo[stepperIndexWeirdness].directionPin1 = direction;
511 engineConfiguration->stepperDcIo[stepperIndexWeirdness].directionPin2 = Gpio::Unassigned;
512 engineConfiguration->stepperDcIo[stepperIndexWeirdness].disablePin = disable;
513 }
514