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 708 of file engine_controller.cpp.

708 {
709 // Start this early - it will start LED blinking and such
711
712#if EFI_SHAFT_POSITION_INPUT
713 // todo: figure out better startup logic
715#endif /* EFI_SHAFT_POSITION_INPUT */
716
717 /**
718 * Initialize hardware drivers
719 */
720 initHardware();
721
723
724#if EFI_FILE_LOGGING
725 initMmcCard();
726#endif /* EFI_FILE_LOGGING */
727
728#if EFI_ENGINE_EMULATOR
730#endif
731
732#if EFI_LUA
733 startLua();
734#endif // EFI_LUA
735
736#if EFI_CAN_SERIAL
737 // needs to be called after initCan() inside initHardware()
739#endif /* EFI_CAN_SERIAL */
740
741}
void initQcBenchControls()
void initEngineEmulator()
void initHardware()
Definition hardware.cpp:538
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 388 of file engine_controller.cpp.

388 {
389#if EFI_PROD_CODE
390 addConsoleAction("sensorinfo", printSensorInfo);
391 addConsoleAction("reset_accel", resetAccel);
392#endif /* EFI_PROD_CODE */
393
394#if EFI_SIMULATOR || EFI_UNIT_TEST
395 printf("commonInitEngineController\n");
396#endif
397
398#if !EFI_UNIT_TEST
400#endif /* EFI_UNIT_TEST */
401
402#if EFI_ENGINE_CONTROL
403 /**
404 * This has to go after 'enginePins.startPins()' in order to
405 * properly detect un-assigned output pins
406 */
408
410#endif // EFI_ENGINE_CONTROL
411
412
413#if EFI_PROD_CODE || EFI_SIMULATOR
414 initSettings();
415
416 if (hasFirmwareError()) {
417 return;
418 }
419#endif
420
421#if ! EFI_UNIT_TEST && EFI_ENGINE_CONTROL
423#endif /* ! EFI_UNIT_TEST && EFI_ENGINE_CONTROL */
424
425#if EFI_ALTERNATOR_CONTROL
427#endif /* EFI_ALTERNATOR_CONTROL */
428
429#if EFI_VVT_PID
431#endif /* EFI_VVT_PID */
432
433#if EFI_MALFUNCTION_INDICATOR
435#endif /* EFI_MALFUNCTION_INDICATOR */
436
437#if !EFI_UNIT_TEST
438 // This is tested independently - don't configure sensors for tests.
439 // This lets us selectively mock them for each test.
441#endif /* EFI_UNIT_TEST */
442
443 initSensors();
444
446
448
449 initGpPwm();
450
451#if EFI_IDLE_CONTROL
453#endif /* EFI_IDLE_CONTROL */
454
455#if EFI_TCU
457#endif
458
460
461#if EFI_ELECTRONIC_THROTTLE_BODY
463#endif /* EFI_ELECTRONIC_THROTTLE_BODY */
464
465#if EFI_MAP_AVERAGING && defined (MODULE_MAP_AVERAGING)
466 engine->module<MapAveragingModule>()->init();
467#else
468 efiPrintf("No MapAveraging support!");
469#endif /* EFI_MAP_AVERAGING */
470
471#if EFI_BOOST_CONTROL
473#endif /* EFI_BOOST_CONTROL */
474
475#if EFI_LAUNCH_CONTROL
477#endif
478
480
481#if EFI_UNIT_TEST
483#endif /* EFI_UNIT_TEST */
484
485#if EFI_AUX_VALVES
487#endif /* EFI_AUX_VALVES */
488
489#ifdef MODULE_TACHOMETER
490 engine->module<TachometerModule>()->init();
491#endif
492
494
495 initStft();
496#if EFI_LTFT_CONTROL
497 initLtft();
498#endif
499}
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:633
void initSpeedometer()
printf("\n")
void initVvtActuators()
Definition vvt.cpp:192

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 181 of file engine_controller.cpp.

181 {
182#if EFI_SHAFT_POSITION_INPUT
183 efiAssertVoid(ObdCode::CUSTOM_ERR_6661, getCurrentRemainingStack() > 64, "lowStckOnEv");
184
186
189 resetAccel();
190 }
191#endif /* EFI_SHAFT_POSITION_INPUT */
192
194
195#if EFI_TCU
197 if (engine->gearController == NULL) {
201 }
203 }
204#endif // EFI_TCU
205
207}
void tryResetWatchdog()
GearControllerBase * gearController
Definition engine.h:210
void periodicSlowCallback()
Definition engine.cpp:150
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 310 of file engine_controller.cpp.

310 {
311 if (isOutOfBounds(offset))
312 return;
313 int *ptr = (int *) (&((char *) engineConfiguration)[offset]);
314 int value = (*ptr >> bit) & 1;
315 /**
316 * this response is part of rusEfi console API
317 */
318 efiPrintf("bit%s%d/%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, bit, value);
319}
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 253 of file engine_controller.cpp.

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

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 341 of file engine_controller.cpp.

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

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 321 of file engine_controller.cpp.

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

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 214 of file engine_controller.cpp.

214 {
215#if HAL_USE_ADC
216 if (!isAdcChannelValid(hwChannel)) {
217 snprintf(buffer, bufferSize, "NONE");
218 } else {
219 const char *name = portname(getAdcChannelPort(msg, hwChannel));
220 snprintf(buffer, bufferSize, "%s%d", name ? name : "null", getAdcChannelPin(hwChannel));
221 }
222#else
223 snprintf(buffer, bufferSize, "NONE");
224#endif /* HAL_USE_ADC */
225 return buffer;
226}
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 766 of file engine_controller.cpp.

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

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 242 of file engine_controller.cpp.

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

Referenced by initConfigActions(), and setShort().

Here is the caller graph for this function:

◆ initConfigActions()

static void initConfigActions ( )
static

Definition at line 371 of file engine_controller.cpp.

371 {
374 addConsoleActionII("set_short", (VoidIntInt) setShort);
376 addConsoleActionSSS("set_bit", setBit);
377
378 addConsoleActionI("get_float", getFloat);
379 addConsoleActionI("get_int", getInt);
380 addConsoleActionI("get_short", getShort);
381 addConsoleActionI("get_byte", getByte);
382 addConsoleActionII("get_bit", getBit);
383}
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 104 of file engine_controller.cpp.

104 {
105#if EFI_ENGINE_CONTROL
106 initFuelMap();
109 for (size_t i=0;i<efi::size(events.elements);i++) {
110 // above-zero value helps distinguish events
112 }
113 // above-zero value helps distinguish events
115#endif // EFI_ENGINE_CONTROL
116}
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 209 of file engine_controller.cpp.

209 {
210 slowController.start();
211 fastController.start();
212}
static PeriodicFastController fastController
static PeriodicSlowController slowController

Referenced by runRusEfi().

Here is the caller graph for this function:

◆ initRealHardwareEngineController()

void initRealHardwareEngineController ( )

Definition at line 744 of file engine_controller.cpp.

744 {
747
748#if EFI_LOGIC_ANALYZER
751 }
752#endif /* EFI_LOGIC_ANALYZER */
753
754 if (hasFirmwareError()) {
755 return;
756 }
757
759
761}
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 229 of file engine_controller.cpp.

229 {
230#if HAL_USE_ADC
231 // Print info about analog mappings
233#endif // HAL_USE_ADC
234
235 // Print info about all sensors
237}
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 170 of file engine_controller.cpp.

170 {
171 engine->module<TpsAccelEnrichment>()->resetAE();
172
173#if EFI_ENGINE_CONTROL
174 for (size_t i = 0; i < efi::size(engine->injectionEvents.elements); i++)
175 {
177 }
178#endif // EFI_ENGINE_CONTROL
179}
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 264 of file engine_controller.cpp.

264 {
265 int offset = atoi(offsetStr);
266 if (absI(offset) == absI(ATOI_ERROR_CODE)) {
267 efiPrintf("invalid offset [%s]", offsetStr);
268 return;
269 }
270 if (isOutOfBounds(offset)) {
271 return;
272 }
273 int bit = atoi(bitStr);
274 if (absI(bit) == absI(ATOI_ERROR_CODE)) {
275 efiPrintf("invalid bit [%s]", bitStr);
276 return;
277 }
278 int value = atoi(valueStr);
279 if (absI(value) == absI(ATOI_ERROR_CODE)) {
280 efiPrintf("invalid value [%s]", valueStr);
281 return;
282 }
283 int *ptr = (int *) (&((char *) engineConfiguration)[offset]);
284 *ptr ^= (-value ^ *ptr) & (1 << bit);
285 /**
286 * this response is part of rusEfi console API
287 */
288 efiPrintf("bit%s%d/%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, bit, value);
290}
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 301 of file engine_controller.cpp.

301 {
302 if (isOutOfBounds(offset))
303 return;
304 uint8_t *ptr = (uint8_t *) (&((char *) engineConfiguration)[offset]);
305 *ptr = (uint8_t) value;
308}

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 352 of file engine_controller.cpp.

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

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 332 of file engine_controller.cpp.

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

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 292 of file engine_controller.cpp.

292 {
293 if (isOutOfBounds(offset))
294 return;
295 uint16_t *ptr = (uint16_t *) (&((char *) engineConfiguration)[offset]);
296 *ptr = (uint16_t) value;
299}

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 501 of file engine_controller.cpp.

501 {
502 return true;
503}

Referenced by validateConfigOnStartUpOrBurn().

Here is the caller graph for this function:

◆ validateConfigOnStartUpOrBurn()

bool validateConfigOnStartUpOrBurn ( )

Definition at line 521 of file engine_controller.cpp.

521 {
522 if (!validateBoardConfig()) {
523 return false;
524 }
525 if (!validateGdi()) {
526 return false;
527 }
529 criticalError("Broken ETB min/max %d %d",
532 return false;
533 }
534
536 if (engineConfiguration->cylindersCount > MAX_CYLINDER_COUNT) {
537 criticalError("Invalid cylinder count: %d", engineConfiguration->cylindersCount);
538 return false;
539 }
540#if EFI_PROD_CODE && (BOARD_MC33810_COUNT > 0)
541 float maxConfiguredCorr = config->dwellVoltageCorrValues[0];
542 for (size_t i = 0;i<efi::size(config->dwellVoltageCorrValues);i++) {
543 maxConfiguredCorr = std::max(maxConfiguredCorr, (float)config->dwellVoltageCorrValues[i]);
544 }
545 float maxConfiguredDwell = config->sparkDwellValues[0];
546 for (size_t i = 0;i<efi::size(config->sparkDwellValues);i++) {
547 maxConfiguredDwell = std::max(maxConfiguredDwell, (float)config->sparkDwellValues[i]);
548 }
550 if (maxConfiguredCorr * maxConfiguredDwell > maxAllowedDwell) {
551 criticalError("Dwell=%.2f/corr=%.2f while 33810 limit %d", maxConfiguredDwell, maxConfiguredCorr, maxAllowedDwell);
552 }
553
554#endif // EFI_PROD_CODE && (BOARD_MC33810_COUNT > 0)
555 if (engineConfiguration->adcVcc > 5.0f || engineConfiguration->adcVcc < 1.0f) {
556 criticalError("Invalid adcVcc: %f", engineConfiguration->adcVcc);
557 return false;
558 }
559
562
563#if EFI_ENGINE_CONTROL
564 // Fueling
565 {
568
569 ensureArrayIsAscending("Lambda/AFR load", config->lambdaLoadBins);
570 ensureArrayIsAscending("Lambda/AFR RPM", config->lambdaRpmBins);
571
574
577
578 ensureArrayIsAscending("Injection phase load", config->injPhaseLoadBins);
579 ensureArrayIsAscending("Injection phase RPM", config->injPhaseRpmBins);
580
582
585
588
591
593
596 }
597
598 // Ignition
599 {
601
606
607 ensureArrayIsAscending("Ignition CLT corr CLT", config->ignitionCltCorrTempBins);
608 ensureArrayIsAscending("Ignition CLT corr Load", config->ignitionCltCorrLoadBins);
609
610 ensureArrayIsAscending("Ignition IAT corr IAT", config->ignitionIatCorrTempBins);
611 ensureArrayIsAscending("Ignition IAT corr Load", config->ignitionIatCorrLoadBins);
612 }
613
616#endif // EFI_ENGINE_CONTROL
617
624
625// todo: huh? why does this not work on CI? ensureArrayIsAscendingOrDefault("Dwell Correction Voltage", engineConfiguration->dwellVoltageCorrVoltBins);
626
627 ensureArrayIsAscending("MAF transfer function", config->mafDecodingBins);
628
629 // Cranking tables
630 ensureArrayIsAscending("Cranking fuel mult", config->crankingFuelBins);
631 ensureArrayIsAscending("Cranking duration", config->crankingCycleBins);
634
635 // Idle tables
636 ensureArrayIsAscending("Idle target RPM", config->cltIdleRpmBins);
637 ensureArrayIsAscending("Idle warmup mult CLT", config->cltIdleCorrBins);
638 ensureArrayIsAscending("Idle warmup mult RPM", config->rpmIdleCorrBins);
643
644 for (size_t index = 0; index < efi::size(engineConfiguration->vrThreshold); index++) {
645 auto& cfg = engineConfiguration->vrThreshold[index];
646
647 if (cfg.pin == Gpio::Unassigned) {
648 continue;
649 }
650 ensureArrayIsAscending("VR threshold", cfg.rpmBins);
651 }
652
653#if EFI_BOOST_CONTROL
654 // Boost
655 ensureArrayIsAscending("Boost control Load [open loop]", config->boostOpenLoopLoadBins);
656 ensureArrayIsAscending("Boost control Load [closed loop]", config->boostClosedLoopLoadBins);
657 ensureArrayIsAscending("Boost control RPM [open+closed loop]", config->boostRpmBins);
658#endif // EFI_BOOST_CONTROL
659
660#if EFI_ANTILAG_SYSTEM
661 // ALS
666#endif // EFI_ANTILAG_SYSTEM
667
668#if EFI_ELECTRONIC_THROTTLE_BODY
669 // ETB
672#endif // EFI_ELECTRONIC_THROTTLE_BODY
673
674 if (isGdiEngine()) {
680
681 ensureArrayIsAscending("HPFP fuel mass compensation fuel pressure", config->hpfpFuelMassCompensationFuelPressure);
682 ensureArrayIsAscending("HPFP fuel mass compensation fuel mass", config->hpfpFuelMassCompensationFuelMass);
683
684 }
685
686 // VVT
690 }
691
692#if CAM_INPUTS_COUNT != 1
694 ensureArrayIsAscending("VVT exhaust load", config->vvtTable2LoadBins);
696 }
697#endif
698
700 ensureArrayIsAscending("Oil pressure protection", config->minimumOilPressureBins);
701 }
702
703 return true;
704}
@ Unassigned
void defaultsOrFixOnBurn()
void ensureArrayIsAscendingOrDefault(const char *msg, const TValue(&values)[TSize])
void ensureArrayIsAscending(const char *msg, const TValue(&values)[TSize])
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, 10 > idleVeRpmBins[IDLE_VE_SIZE]
scaled_channel< uint16_t, 1000, 1 > fuelLevelBins[FUEL_LEVEL_TABLE_COUNT]
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, 100 > boostRpmBins[BOOST_RPM_COUNT]
scaled_channel< int16_t, 1, 1 > ignitionCltCorrTempBins[CLT_TIMING_CURVE_SIZE]
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 > hpfpCompensationRpmBins[HPFP_COMPENSATION_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]
scaled_channel< uint8_t, 1, 5 > ignitionCltCorrLoadBins[CLT_TIMING_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 505 of file engine_controller.cpp.

505 {
506 auto lobes = engineConfiguration->hpfpCamLobes;
507 if (!lobes) {
508 return true;
509 }
510 int expectedLastLobeProfileAngle = 360 / lobes;
511 float actualLastAngle = config->hpfpLobeProfileAngle[efi::size(config->hpfpLobeProfileAngle) - 1];
512 if (expectedLastLobeProfileAngle != actualLastAngle) {
513 criticalError("Last HPFP angle expected %d got %f", expectedLastLobeProfileAngle, actualLastAngle);
514 return false;
515 }
516
517 return true;
518}
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 94 of file engine_controller.cpp.

◆ engine

Engine* engine

◆ engineStateBlinkingTask

EngineStateBlinkingTask engineStateBlinkingTask
static

Definition at line 168 of file engine_controller.cpp.

Referenced by initRealHardwareEngineController().

◆ fastController

PeriodicFastController fastController
static

Definition at line 143 of file engine_controller.cpp.

Referenced by initPeriodicEvents().

◆ slowController

PeriodicSlowController slowController
static

Definition at line 144 of file engine_controller.cpp.

Referenced by initPeriodicEvents().

Go to the source code of this file.