GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 91.1% 245 / 0 / 269
Functions: 90.4% 47 / 0 / 52
Branches: 82.1% 23 / 0 / 28
Decisions: 90.9% 20 / - / 22

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