rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions | Variables
engine_controller.cpp File Reference

Detailed Description

Controllers package entry point code.

Date
Feb 7, 2013
Author
Andrey Belomutskiy, (c) 2012-2020

This file is part of rusEfi - see http://rusefi.com

rusEfi is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

rusEfi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file engine_controller.cpp.

Functions

void initDataStructures ()
 
static void doPeriodicSlowCallback ()
 
static void resetAccel ()
 
void initPeriodicEvents ()
 
chargetPinNameByAdcChannel (const char *msg, adc_channel_e hwChannel, char *buffer, size_t bufferSize)
 
static void printSensorInfo ()
 
static void getShort (int offset)
 
static void getByte (int offset)
 
static void setBit (const char *offsetStr, const char *bitStr, const char *valueStr)
 
static void setShort (const int offset, const int value)
 
static void setByte (const int offset, const int value)
 
static void getBit (int offset, int bit)
 
static void getInt (int offset)
 
static void setInt (const int offset, const int value)
 
static void getFloat (int offset)
 
static void setFloat (const char *offsetStr, const char *valueStr)
 
static void initConfigActions ()
 
void commonInitEngineController ()
 
PUBLIC_API_WEAK bool validateBoardConfig ()
 
static bool validateGdi ()
 
bool validateConfigOnStartUpOrBurn ()
 
void commonEarlyInit ()
 
void initRealHardwareEngineController ()
 
int getRusEfiVersion ()
 

Variables

Engine ___engine CCM_OPTIONAL
 
Engineengine
 
static PeriodicFastController fastController
 
static PeriodicSlowController slowController
 
static EngineStateBlinkingTask engineStateBlinkingTask
 

Function Documentation

◆ commonEarlyInit()

void commonEarlyInit ( )

Initialize hardware drivers

Definition at line 710 of file engine_controller.cpp.

710 {
711 // Start this early - it will start LED blinking and such
713
714#if EFI_SHAFT_POSITION_INPUT
715 // todo: figure out better startup logic
717#endif /* EFI_SHAFT_POSITION_INPUT */
718
719 /**
720 * Initialize hardware drivers
721 */
722 initHardware();
723
725
726#if EFI_FILE_LOGGING
727 initMmcCard();
728#endif /* EFI_FILE_LOGGING */
729
730#if EFI_ENGINE_EMULATOR
732#endif
733
734#if EFI_LUA
735 startLua();
736#endif // EFI_LUA
737
738#if EFI_CAN_SERIAL
739 // needs to be called after initCan() inside initHardware()
741#endif /* EFI_CAN_SERIAL */
742
743}
void initQcBenchControls()
void initEngineEmulator()
void initHardware()
Definition hardware.cpp:540
void startLua()
Definition lua.cpp:281
void initMmcCard()
void startStatusThreads()
void initTriggerCentral()
void startCanConsole()

Referenced by initEfiWithConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ commonInitEngineController()

void commonInitEngineController ( )

This has to go after 'enginePins.startPins()' in order to properly detect un-assigned output pins

Definition at line 386 of file engine_controller.cpp.

386 {
387#if EFI_PROD_CODE
388 addConsoleAction("sensorinfo", printSensorInfo);
389 addConsoleAction("reset_accel", resetAccel);
390#endif /* EFI_PROD_CODE */
391
392#if EFI_SIMULATOR || EFI_UNIT_TEST
393 printf("commonInitEngineController\n");
394#endif
395
396#if !EFI_UNIT_TEST
398#endif /* EFI_UNIT_TEST */
399
400#if EFI_ENGINE_CONTROL
401 /**
402 * This has to go after 'enginePins.startPins()' in order to
403 * properly detect un-assigned output pins
404 */
406
408#endif // EFI_ENGINE_CONTROL
409
410
411#if EFI_PROD_CODE || EFI_SIMULATOR
412 initSettings();
413
414 if (hasFirmwareError()) {
415 return;
416 }
417#endif
418
419#if ! EFI_UNIT_TEST && EFI_ENGINE_CONTROL
421#endif /* ! EFI_UNIT_TEST && EFI_ENGINE_CONTROL */
422
423#if EFI_ALTERNATOR_CONTROL
425#endif /* EFI_ALTERNATOR_CONTROL */
426
427#if EFI_VVT_PID
429#endif /* EFI_VVT_PID */
430
431#if EFI_MALFUNCTION_INDICATOR
433#endif /* EFI_MALFUNCTION_INDICATOR */
434
435#if !EFI_UNIT_TEST
436 // This is tested independently - don't configure sensors for tests.
437 // This lets us selectively mock them for each test.
439#endif /* EFI_UNIT_TEST */
440
441 initSensors();
442
444
446
447 initGpPwm();
448
449#if EFI_IDLE_CONTROL
451#endif /* EFI_IDLE_CONTROL */
452
453#if EFI_TCU
455#endif
456
458
459#if EFI_ELECTRONIC_THROTTLE_BODY
461#endif /* EFI_ELECTRONIC_THROTTLE_BODY */
462
463#if EFI_MAP_AVERAGING && defined (MODULE_MAP_AVERAGING)
464 engine->module<MapAveragingModule>()->init();
465#else
466 efiPrintf("No MapAveraging support!");
467#endif /* EFI_MAP_AVERAGING */
468
469#if EFI_BOOST_CONTROL
471#endif /* EFI_BOOST_CONTROL */
472
473#if EFI_LAUNCH_CONTROL
475#endif
476
478
479#if EFI_UNIT_TEST
481#endif /* EFI_UNIT_TEST */
482
483#if EFI_AUX_VALVES
485#endif /* EFI_AUX_VALVES */
486
487#ifdef MODULE_TACHOMETER
488 engine->module<TachometerModule>()->init();
489#endif
490
492
493 initStft();
494#if EFI_LTFT_CONTROL
495 initLtft();
496#endif
497}
void initAccelEnrichment()
void initIgnitionAdvanceControl()
void initSensors()
void initAlternatorCtrl()
void initAuxValves()
void initBenchTest()
void initBoostCtrl()
FuelSchedule injectionEvents
Definition engine.h:288
RpmCalculator rpmCalculator
Definition engine.h:306
constexpr auto & module()
Definition engine.h:200
bool Register()
Definition sensor.cpp:131
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
void initStft(void)
void initButtonDebounce()
void initElectronicThrottle()
void prepareOutputSignals()
Engine * engine
static void printSensorInfo()
static void initConfigActions()
static void resetAccel()
void initGearController()
void initGpPwm()
Definition gppwm.cpp:31
void startIdleThread()
void initNewSensors()
void initLaunchControl()
void initLtft()
void initMalfunctionIndicator(void)
void initScriptImpl()
void initSettings()
Definition settings.cpp:637
void initSpeedometer()
printf("\n")
void initVvtActuators()
Definition vvt.cpp:190

Referenced by initRealHardwareEngineController().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ doPeriodicSlowCallback()

static void doPeriodicSlowCallback ( )
static

Definition at line 179 of file engine_controller.cpp.

179 {
180#if EFI_SHAFT_POSITION_INPUT
181 efiAssertVoid(ObdCode::CUSTOM_ERR_6661, getCurrentRemainingStack() > 64, "lowStckOnEv");
182
184
187 resetAccel();
188 }
189#endif /* EFI_SHAFT_POSITION_INPUT */
190
192
193#if EFI_TCU
195 if (engine->gearController == NULL) {
199 }
201 }
202#endif // EFI_TCU
203
205}
void tryResetWatchdog()
GearControllerBase * gearController
Definition engine.h:210
void periodicSlowCallback()
Definition engine.cpp:159
virtual void update()
virtual GearControllerMode getMode() const
bool isStopped() const override
static constexpr engine_configuration_s * engineConfiguration
void slowStartStopButtonCallback()
@ CUSTOM_ERR_6661
Here is the call graph for this function:

◆ getBit()

static void getBit ( int  offset,
int  bit 
)
static

this response is part of rusEfi console API

Definition at line 308 of file engine_controller.cpp.

308 {
309 if (isOutOfBounds(offset))
310 return;
311 int *ptr = (int *) (&((char *) engineConfiguration)[offset]);
312 int value = (*ptr >> bit) & 1;
313 /**
314 * this response is part of rusEfi console API
315 */
316 efiPrintf("bit%s%d/%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, bit, value);
317}
uint16_t offset
Definition tunerstudio.h:0

Referenced by initConfigActions().

Here is the caller graph for this function:

◆ getByte()

static void getByte ( int  offset)
static

this response is part of rusEfi console API

Definition at line 251 of file engine_controller.cpp.

251 {
252 if (isOutOfBounds(offset))
253 return;
254 uint8_t *ptr = (uint8_t *) (&((char *) engineConfiguration)[offset]);
255 uint8_t value = *ptr;
256 /**
257 * this response is part of rusEfi console API
258 */
259 efiPrintf("byte%s%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, value);
260}

Referenced by initConfigActions(), and setByte().

Here is the caller graph for this function:

◆ getFloat()

static void getFloat ( int  offset)
static

this response is part of rusEfi console API

Definition at line 339 of file engine_controller.cpp.

339 {
340 if (isOutOfBounds(offset))
341 return;
342 float *ptr = (float *) (&((char *) engineConfiguration)[offset]);
343 float value = *ptr;
344 /**
345 * this response is part of rusEfi console API
346 */
347 efiPrintf("float%s%d is %.5f", CONSOLE_DATA_PROTOCOL_TAG, offset, value);
348}

Referenced by initConfigActions(), and setFloat().

Here is the caller graph for this function:

◆ getInt()

static void getInt ( int  offset)
static

this response is part of rusEfi console API

Definition at line 319 of file engine_controller.cpp.

319 {
320 if (isOutOfBounds(offset))
321 return;
322 int *ptr = (int *) (&((char *) engineConfiguration)[offset]);
323 int value = *ptr;
324 /**
325 * this response is part of rusEfi console API
326 */
327 efiPrintf("int%s%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, value);
328}

Referenced by initConfigActions(), and setInt().

Here is the caller graph for this function:

◆ getPinNameByAdcChannel()

char * getPinNameByAdcChannel ( const char msg,
adc_channel_e  hwChannel,
char buffer,
size_t  bufferSize 
)

Definition at line 212 of file engine_controller.cpp.

212 {
213#if HAL_USE_ADC
214 if (!isAdcChannelValid(hwChannel)) {
215 snprintf(buffer, bufferSize, "NONE");
216 } else {
217 const char *name = portname(getAdcChannelPort(msg, hwChannel));
218 snprintf(buffer, bufferSize, "%s%d", name ? name : "null", getAdcChannelPin(hwChannel));
219 }
220#else
221 snprintf(buffer, bufferSize, "NONE");
222#endif /* HAL_USE_ADC */
223 return buffer;
224}
bool isAdcChannelValid(adc_channel_e hwChannel)
Definition adc_inputs.h:23
int getAdcChannelPin(adc_channel_e hwChannel)
ioportid_t getAdcChannelPort(const char *msg, adc_channel_e hwChannel)
const char * portname(ioportid_t GPIOx)
static BigBufferHandle buffer

Referenced by AdcSubscription::PrintInfo(), and printMAPInfo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRusEfiVersion()

int getRusEfiVersion ( )

See also SIGNATURE_HASH

Definition at line 768 of file engine_controller.cpp.

768 {
769#if defined(EFI_BOOTLOADER_INCLUDE_CODE)
770 // make bootloader code happy too
771 if (initBootloader() != 0)
772 return 123;
773#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
774 return VCS_DATE;
775}

Referenced by errorHandlerInit(), errorHandlerWriteReportFile(), firmwareErrorV(), handleGetVersion(), printVersionForConsole(), readFromFlash(), sayHello(), and updateTunerStudioState().

Here is the caller graph for this function:

◆ getShort()

static void getShort ( int  offset)
static

this response is part of rusEfi console API

Definition at line 240 of file engine_controller.cpp.

240 {
241 if (isOutOfBounds(offset))
242 return;
243 uint16_t *ptr = (uint16_t *) (&((char *) engineConfiguration)[offset]);
244 uint16_t value = *ptr;
245 /**
246 * this response is part of rusEfi console API
247 */
248 efiPrintf("short%s%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, value);
249}

Referenced by initConfigActions(), and setShort().

Here is the caller graph for this function:

◆ initConfigActions()

static void initConfigActions ( )
static

Definition at line 369 of file engine_controller.cpp.

369 {
372 addConsoleActionII("set_short", (VoidIntInt) setShort);
374 addConsoleActionSSS("set_bit", setBit);
375
376 addConsoleActionI("get_float", getFloat);
377 addConsoleActionI("get_int", getInt);
378 addConsoleActionI("get_short", getShort);
379 addConsoleActionI("get_byte", getByte);
380 addConsoleActionII("get_bit", getBit);
381}
void addConsoleActionII(const char *token, VoidIntInt callback)
Register a console command with two Integer parameters.
void addConsoleActionSS(const char *token, VoidCharPtrCharPtr callback)
void addConsoleActionSSS(const char *token, VoidCharPtrCharPtrCharPtr callback)
void addConsoleActionI(const char *token, VoidInt callback)
Register a console command with one Integer parameter.
void(* VoidCharPtrCharPtr)(const char *, const char *)
void(* VoidIntInt)(int, int)
static void setFloat(const char *offsetStr, const char *valueStr)
static void getShort(int offset)
static void getFloat(int offset)
static void setByte(const int offset, const int value)
static void setInt(const int offset, const int value)
static void getByte(int offset)
static void getBit(int offset, int bit)
static void setShort(const int offset, const int value)
static void getInt(int offset)
static void setBit(const char *offsetStr, const char *bitStr, const char *valueStr)

Referenced by commonInitEngineController().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initDataStructures()

void initDataStructures ( )

Definition at line 102 of file engine_controller.cpp.

102 {
103#if EFI_ENGINE_CONTROL
104 initFuelMap();
107 for (size_t i=0;i<efi::size(events.elements);i++) {
108 // above-zero value helps distinguish events
110 }
111 // above-zero value helps distinguish events
113#endif // EFI_ENGINE_CONTROL
114}
IgnitionEventList ignitionEvents
Definition engine.h:289
EngineState engineState
Definition engine.h:344
uint32_t sparkCounter
IgnitionEvent elements[MAX_CYLINDER_COUNT]
void initFuelMap()
Initialize fuel map data structure.
void initSpeedDensity()
static std::vector< CompositeEvent > events

Referenced by runRusEfi().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initPeriodicEvents()

void initPeriodicEvents ( )

Definition at line 207 of file engine_controller.cpp.

207 {
208 slowController.start();
209 fastController.start();
210}
static PeriodicFastController fastController
static PeriodicSlowController slowController

Referenced by runRusEfi().

Here is the caller graph for this function:

◆ initRealHardwareEngineController()

void initRealHardwareEngineController ( )

Definition at line 746 of file engine_controller.cpp.

746 {
749
750#if EFI_LOGIC_ANALYZER
753 }
754#endif /* EFI_LOGIC_ANALYZER */
755
756 if (hasFirmwareError()) {
757 return;
758 }
759
761
763}
static EngineStateBlinkingTask engineStateBlinkingTask
void commonInitEngineController()
void initWaveAnalyzer()
void initWarningRunningPins()
void initVrThresholdPwm()
Definition vr_pwm.cpp:39

Referenced by initEfiWithConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ printSensorInfo()

static void printSensorInfo ( )
static

Definition at line 227 of file engine_controller.cpp.

227 {
228#if HAL_USE_ADC
229 // Print info about analog mappings
231#endif // HAL_USE_ADC
232
233 // Print info about all sensors
235}
static void PrintInfo()
static void showAllSensorInfo()
Definition sensor.cpp:237

Referenced by commonInitEngineController().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetAccel()

static void resetAccel ( )
static

Definition at line 168 of file engine_controller.cpp.

168 {
169 engine->module<TpsAccelEnrichment>()->resetAE();
170
171#if EFI_ENGINE_CONTROL
172 for (size_t i = 0; i < efi::size(engine->injectionEvents.elements); i++)
173 {
175 }
176#endif // EFI_ENGINE_CONTROL
177}
InjectionEvent elements[MAX_CYLINDER_COUNT]
WallFuel & getWallFuel()
void resetWF()
Definition wall_fuel.cpp:10

Referenced by commonInitEngineController(), and doPeriodicSlowCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setBit()

static void setBit ( const char offsetStr,
const char bitStr,
const char valueStr 
)
static

this response is part of rusEfi console API

Definition at line 262 of file engine_controller.cpp.

262 {
263 int offset = atoi(offsetStr);
264 if (absI(offset) == absI(ATOI_ERROR_CODE)) {
265 efiPrintf("invalid offset [%s]", offsetStr);
266 return;
267 }
268 if (isOutOfBounds(offset)) {
269 return;
270 }
271 int bit = atoi(bitStr);
272 if (absI(bit) == absI(ATOI_ERROR_CODE)) {
273 efiPrintf("invalid bit [%s]", bitStr);
274 return;
275 }
276 int value = atoi(valueStr);
277 if (absI(value) == absI(ATOI_ERROR_CODE)) {
278 efiPrintf("invalid value [%s]", valueStr);
279 return;
280 }
281 int *ptr = (int *) (&((char *) engineConfiguration)[offset]);
282 *ptr ^= (-value ^ *ptr) & (1 << bit);
283 /**
284 * this response is part of rusEfi console API
285 */
286 efiPrintf("bit%s%d/%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, bit, value);
288}
void incrementGlobalConfigurationVersion(const char *msg)

Referenced by initConfigActions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setByte()

static void setByte ( const int  offset,
const int  value 
)
static

Definition at line 299 of file engine_controller.cpp.

299 {
300 if (isOutOfBounds(offset))
301 return;
302 uint8_t *ptr = (uint8_t *) (&((char *) engineConfiguration)[offset]);
303 *ptr = (uint8_t) value;
306}

Referenced by initConfigActions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFloat()

static void setFloat ( const char offsetStr,
const char valueStr 
)
static

Definition at line 350 of file engine_controller.cpp.

350 {
351 int offset = atoi(offsetStr);
352 if (absI(offset) == absI(ATOI_ERROR_CODE)) {
353 efiPrintf("invalid offset [%s]", offsetStr);
354 return;
355 }
356 if (isOutOfBounds(offset))
357 return;
358 float value = atoff(valueStr);
359 if (std::isnan(value)) {
360 efiPrintf("invalid value [%s]", valueStr);
361 return;
362 }
363 float *ptr = (float *) (&((char *) engineConfiguration)[offset]);
364 *ptr = value;
367}

Referenced by initConfigActions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setInt()

static void setInt ( const int  offset,
const int  value 
)
static

Definition at line 330 of file engine_controller.cpp.

330 {
331 if (isOutOfBounds(offset))
332 return;
333 int *ptr = (int *) (&((char *) engineConfiguration)[offset]);
334 *ptr = value;
335 getInt(offset);
337}

Referenced by initConfigActions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setShort()

static void setShort ( const int  offset,
const int  value 
)
static

Definition at line 290 of file engine_controller.cpp.

290 {
291 if (isOutOfBounds(offset))
292 return;
293 uint16_t *ptr = (uint16_t *) (&((char *) engineConfiguration)[offset]);
294 *ptr = (uint16_t) value;
297}

Referenced by initConfigActions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ validateBoardConfig()

PUBLIC_API_WEAK bool validateBoardConfig ( )

Definition at line 499 of file engine_controller.cpp.

499 {
500 return true;
501}

Referenced by validateConfigOnStartUpOrBurn().

Here is the caller graph for this function:

◆ validateConfigOnStartUpOrBurn()

bool validateConfigOnStartUpOrBurn ( )

Definition at line 519 of file engine_controller.cpp.

519 {
520 if (!validateBoardConfig()) {
521 return false;
522 }
523#if defined(HW_HELLEN_UAEFI)
524 // todo: make this board-specific validation callback!
526#endif
527 if (!validateGdi()) {
528 return false;
529 }
531 criticalError("Broken ETB min/max %d %d",
534 return false;
535 }
536
538 if (engineConfiguration->cylindersCount > MAX_CYLINDER_COUNT) {
539 criticalError("Invalid cylinder count: %d", engineConfiguration->cylindersCount);
540 return false;
541 }
542#if EFI_PROD_CODE && (BOARD_MC33810_COUNT > 0)
543 float maxConfiguredCorr = config->dwellVoltageCorrValues[0];
544 for (size_t i = 0;i<efi::size(config->dwellVoltageCorrValues);i++) {
545 maxConfiguredCorr = std::max(maxConfiguredCorr, (float)config->dwellVoltageCorrValues[i]);
546 }
547 float maxConfiguredDwell = config->sparkDwellValues[0];
548 for (size_t i = 0;i<efi::size(config->sparkDwellValues);i++) {
549 maxConfiguredDwell = std::max(maxConfiguredDwell, (float)config->sparkDwellValues[i]);
550 }
552 if (maxConfiguredCorr * maxConfiguredDwell > maxAllowedDwell) {
553 criticalError("Dwell=%.2f/corr=%.2f while 33810 limit %d", maxConfiguredDwell, maxConfiguredCorr, maxAllowedDwell);
554 }
555
556#endif // EFI_PROD_CODE && (BOARD_MC33810_COUNT > 0)
557 if (engineConfiguration->adcVcc > 5.0f || engineConfiguration->adcVcc < 1.0f) {
558 criticalError("Invalid adcVcc: %f", engineConfiguration->adcVcc);
559 return false;
560 }
561
564
565#if EFI_ENGINE_CONTROL
566 // Fueling
567 {
570
571 ensureArrayIsAscending("Lambda/AFR load", config->lambdaLoadBins);
572 ensureArrayIsAscending("Lambda/AFR RPM", config->lambdaRpmBins);
573
576
579
580 ensureArrayIsAscending("Injection phase load", config->injPhaseLoadBins);
581 ensureArrayIsAscending("Injection phase RPM", config->injPhaseRpmBins);
582
584
587
590
593
595
598 }
599
600 // Ignition
601 {
603
608
609 ensureArrayIsAscending("Ignition CLT corr CLT", config->ignitionCltCorrTempBins);
610 ensureArrayIsAscending("Ignition CLT corr Load", config->ignitionCltCorrLoadBins);
611
612 ensureArrayIsAscending("Ignition IAT corr IAT", config->ignitionIatCorrTempBins);
613 ensureArrayIsAscending("Ignition IAT corr Load", config->ignitionIatCorrLoadBins);
614 }
615
618#endif // EFI_ENGINE_CONTROL
619
626
627// todo: huh? why does this not work on CI? ensureArrayIsAscendingOrDefault("Dwell Correction Voltage", engineConfiguration->dwellVoltageCorrVoltBins);
628
629 ensureArrayIsAscending("MAF transfer function", config->mafDecodingBins);
630
631 // Cranking tables
632 ensureArrayIsAscending("Cranking fuel mult", config->crankingFuelBins);
633 ensureArrayIsAscending("Cranking duration", config->crankingCycleBins);
636
637 // Idle tables
638 ensureArrayIsAscending("Idle target RPM", config->cltIdleRpmBins);
639 ensureArrayIsAscending("Idle warmup mult CLT", config->cltIdleCorrBins);
640 ensureArrayIsAscending("Idle warmup mult RPM", config->rpmIdleCorrBins);
645
646 for (size_t index = 0; index < efi::size(engineConfiguration->vrThreshold); index++) {
647 auto& cfg = engineConfiguration->vrThreshold[index];
648
649 if (cfg.pin == Gpio::Unassigned) {
650 continue;
651 }
652 ensureArrayIsAscending("VR threshold", cfg.rpmBins);
653 }
654
655#if EFI_BOOST_CONTROL
656 // Boost
657 ensureArrayIsAscending("Boost control Load [open loop]", config->boostOpenLoopLoadBins);
658 ensureArrayIsAscending("Boost control Load [closed loop]", config->boostClosedLoopLoadBins);
659 ensureArrayIsAscending("Boost control RPM [open+closed loop]", config->boostRpmBins);
660#endif // EFI_BOOST_CONTROL
661
662#if EFI_ANTILAG_SYSTEM
663 // ALS
668#endif // EFI_ANTILAG_SYSTEM
669
670#if EFI_ELECTRONIC_THROTTLE_BODY
671 // ETB
674#endif // EFI_ELECTRONIC_THROTTLE_BODY
675
676 if (isGdiEngine()) {
682
683 ensureArrayIsAscending("HPFP fuel mass compensation fuel pressure", config->hpfpFuelMassCompensationFuelPressure);
684 ensureArrayIsAscending("HPFP fuel mass compensation fuel mass", config->hpfpFuelMassCompensationFuelMass);
685
686 }
687
688 // VVT
692 }
693
694#if CAM_INPUTS_COUNT != 1
696 ensureArrayIsAscending("VVT exhaust load", config->vvtTable2LoadBins);
698 }
699#endif
700
702 ensureArrayIsAscending("Oil pressure protection", config->minimumOilPressureBins);
703 }
704
705 return true;
706}
@ Unassigned
void defaultsOrFixOnBurn()
void ensureArrayIsAscendingOrDefault(const char *msg, const TValue(&values)[TSize])
void ensureArrayIsAscending(const char *msg, const TValue(&values)[TSize])
void pickEtbOrStepper()
static constexpr persistent_config_s * config
PUBLIC_API_WEAK bool validateBoardConfig()
static bool validateGdi()
bool isGdiEngine()
int getMc33810maxDwellTimer(mc33810maxDwellTimer_e value)
Definition mc33810.cpp:1003
bool isBrainPinValid(brain_pin_e brainPin)
uint8_t tractionControlSpeedBins[TRACTION_CONTROL_ETB_DROP_SPEED_SIZE]
scaled_channel< uint16_t, 100, 1 > tractionControlSlipBins[TRACTION_CONTROL_ETB_DROP_SLIP_SIZE]
scaled_channel< int16_t, 100, 1 > battLagCorrBattBins[VBAT_INJECTOR_CURVE_SIZE]
scaled_channel< uint32_t, 10, 1 > battLagCorrPressBins[VBAT_INJECTOR_CURVE_PRESSURE_SIZE]
scaled_channel< uint8_t, 2, 1 > hpfpLobeProfileQuantityBins[HPFP_LOBE_PROFILE_SIZE]
scaled_channel< int16_t, 1, 1 > cltIdleRpmBins[CLT_CURVE_SIZE]
scaled_channel< uint8_t, 1, 100 > iacCoastingRpmBins[CLT_CURVE_SIZE]
scaled_channel< uint16_t, 10, 1 > hpfpFuelMassCompensationFuelPressure[HPFP_FUEL_MASS_COMPENSATION_SIZE]
scaled_channel< uint8_t, 1, 50 > hpfpCompensationRpmBins[HPFP_COMPENSATION_RPM_SIZE]
scaled_channel< uint16_t, 1000, 1 > fuelLevelBins[FUEL_LEVEL_TABLE_COUNT]
scaled_channel< uint8_t, 1, 10 > idleVeRpmBins[IDLE_VE_SIZE_RPM]
scaled_channel< uint8_t, 1, 50 > hpfpTargetRpmBins[HPFP_TARGET_SIZE]
scaled_channel< uint8_t, 50, 1 > dwellVoltageCorrValues[DWELL_CURVE_SIZE]
scaled_channel< uint8_t, 1, 50 > tpsTspCorrValuesBins[TPS_TPS_ACCEL_CLT_CORR_TABLE]
scaled_channel< uint16_t, 100, 1 > mapEstimateTpsBins[MAP_EST_LOAD_COUNT]
scaled_channel< uint8_t, 1, 5 > ignitionCltCorrLoadBins[CLT_TIMING_LOAD_AXIS_SIZE]
scaled_channel< int16_t, 1, 1 > ignitionCltCorrTempBins[CLT_TIMING_TEMP_AXIS_SIZE]
scaled_channel< uint8_t, 1, 100 > boostRpmBins[BOOST_RPM_COUNT]
scaled_channel< uint8_t, 1, 100 > rpmIdleCorrBins[CLT_IDLE_TABLE_RPM_SIZE]
scaled_channel< uint8_t, 1, 100 > pedalToTpsRpmBins[PEDAL_TO_TPS_RPM_SIZE]
scaled_channel< uint8_t, 1, 50 > idleAdvanceBins[IDLE_ADVANCE_CURVE_SIZE]
scaled_channel< uint8_t, 1, 5 > ignitionIatCorrLoadBins[IAT_IGN_CORR_LOAD_COUNT]
scaled_channel< uint16_t, 100, 1 > hpfpFuelMassCompensationFuelMass[HPFP_FUEL_MASS_COMPENSATION_SIZE]
scaled_channel< uint16_t, 10, 1 > hpfpTargetLoadBins[HPFP_TARGET_SIZE]
scaled_channel< uint8_t, 1, 100 > minimumOilPressureBins[8]
scaled_channel< uint16_t, 100, 1 > sparkDwellValues[DWELL_CURVE_SIZE]

Referenced by handleBurnCommand(), and initEfiWithConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ validateGdi()

static bool validateGdi ( )
static

Definition at line 503 of file engine_controller.cpp.

503 {
504 auto lobes = engineConfiguration->hpfpCamLobes;
505 if (!lobes) {
506 return true;
507 }
508 int expectedLastLobeProfileAngle = 360 / lobes;
509 float actualLastAngle = config->hpfpLobeProfileAngle[efi::size(config->hpfpLobeProfileAngle) - 1];
510 if (expectedLastLobeProfileAngle != actualLastAngle) {
511 criticalError("Last HPFP angle expected %d got %f", expectedLastLobeProfileAngle, actualLastAngle);
512 return false;
513 }
514
515 return true;
516}
scaled_channel< uint8_t, 2, 1 > hpfpLobeProfileAngle[HPFP_LOBE_PROFILE_SIZE]

Referenced by validateConfigOnStartUpOrBurn().

Here is the caller graph for this function:

Variable Documentation

◆ CCM_OPTIONAL

Engine ___engine CCM_OPTIONAL

Would love to pass reference to configuration object into constructor but C++ does allow attributes after parenthesized initializer

Definition at line 92 of file engine_controller.cpp.

◆ engine

Engine* engine

◆ engineStateBlinkingTask

EngineStateBlinkingTask engineStateBlinkingTask
static

Definition at line 166 of file engine_controller.cpp.

Referenced by initRealHardwareEngineController().

◆ fastController

PeriodicFastController fastController
static

Definition at line 141 of file engine_controller.cpp.

Referenced by initPeriodicEvents().

◆ slowController

PeriodicSlowController slowController
static

Definition at line 142 of file engine_controller.cpp.

Referenced by initPeriodicEvents().

Go to the source code of this file.