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