rusEFI
The most advanced open source ECU
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 ()
 
char * getPinNameByAdcChannel (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 ()
 
bool validateConfigOnStartUpOrBurn ()
 
void commonEarlyInit ()
 
void initRealHardwareEngineController ()
 
int getRusEfiVersion (void)
 

Variables

Engine ___engine CCM_OPTIONAL
 
Engineengine
 
static PeriodicFastController fastController
 
static PeriodicSlowController slowController
 
static EngineStateBlinkingTask engineStateBlinkingTask
 
AdcDevice fastAdc
 
static volatile char UNUSED_RAM_SIZE [RAM_UNUSED_SIZE]
 

Function Documentation

◆ commonEarlyInit()

void commonEarlyInit ( )

Initialize hardware drivers

Definition at line 682 of file engine_controller.cpp.

682  {
683  // Start this early - it will start LED blinking and such
685 
686 #if EFI_SHAFT_POSITION_INPUT
687  // todo: figure out better startup logic
689 #endif /* EFI_SHAFT_POSITION_INPUT */
690 
691  /**
692  * Initialize hardware drivers
693  */
694  initHardware();
695 
697 
698 #if EFI_FILE_LOGGING
699  initMmcCard();
700 #endif /* EFI_FILE_LOGGING */
701 
702 #if EFI_ENGINE_EMULATOR
704 #endif
705 
706 #if EFI_LUA
707  startLua();
708 #endif // EFI_LUA
709 
710 #if EFI_CAN_SERIAL
711  // needs to be called after initCan() inside initHardware()
712  startCanConsole();
713 #endif /* EFI_CAN_SERIAL */
714 
715 #if HW_CHECK_ALWAYS_STIMULATE
716  // we need a special binary for final assembly check. We cannot afford to require too much software or too many steps
717  // to be executed at the place of assembly
718  enableTriggerStimulator(/*incGlobalConfiguration*/false);
719 #endif // HW_CHECK_ALWAYS_STIMULATE
720 }
void initQcBenchControls()
void initEngineEmulator()
void initHardware()
Definition: hardware.cpp:576
void startLua()
Definition: lua.cpp:386
void initMmcCard()
Definition: mmc_card.cpp:640
void startStatusThreads()
void initTriggerCentral()
void enableTriggerStimulator(bool incGlobalConfiguration)
void startCanConsole()

Referenced by runRusEfiWithConfig().

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

418  {
419 #if EFI_PROD_CODE
420  addConsoleAction("sensorinfo", printSensorInfo);
421  addConsoleAction("reset_accel", resetAccel);
422 #endif /* EFI_PROD_CODE */
423 
424 #if EFI_SIMULATOR || EFI_UNIT_TEST
425  printf("commonInitEngineController\n");
426 #endif
427 
428 #if !EFI_UNIT_TEST
430 #endif /* EFI_UNIT_TEST */
431 
432 #if EFI_ENGINE_CONTROL
433  /**
434  * This has to go after 'enginePins.startPins()' in order to
435  * properly detect un-assigned output pins
436  */
438 
440 #endif // EFI_ENGINE_CONTROL
441 
442 #if EFI_SENSOR_CHART
443  initSensorChart();
444 #endif /* EFI_SENSOR_CHART */
445 
446 #if EFI_PROD_CODE || EFI_SIMULATOR
447  initSettings();
448 
449  if (hasFirmwareError()) {
450  return;
451  }
452 #endif
453 
454 #if ! EFI_UNIT_TEST && EFI_ENGINE_CONTROL
455  initBenchTest();
456 #endif /* ! EFI_UNIT_TEST && EFI_ENGINE_CONTROL */
457 
458 #if EFI_ALTERNATOR_CONTROL
460 #endif /* EFI_ALTERNATOR_CONTROL */
461 
462 #if EFI_VVT_PID
464 #endif /* EFI_VVT_PID */
465 
466 #if EFI_MALFUNCTION_INDICATOR
468 #endif /* EFI_MALFUNCTION_INDICATOR */
469 
470 #if !EFI_UNIT_TEST
471  // This is tested independently - don't configure sensors for tests.
472  // This lets us selectively mock them for each test.
473  initNewSensors();
474 #endif /* EFI_UNIT_TEST */
475 
476  initSensors();
477 
479 
480  initScriptImpl();
481 
482  initGpPwm();
483 
484 #if EFI_IDLE_CONTROL
485  startIdleThread();
486 #endif /* EFI_IDLE_CONTROL */
487 
488 #if EFI_TCU
490 #endif
491 
493 
494 #if EFI_ELECTRONIC_THROTTLE_BODY
496 #endif /* EFI_ELECTRONIC_THROTTLE_BODY */
497 
498 #if EFI_MAP_AVERAGING
501  }
502 #endif /* EFI_MAP_AVERAGING */
503 
504 #if EFI_BOOST_CONTROL
505  initBoostCtrl();
506 #endif /* EFI_BOOST_CONTROL */
507 
508 #if EFI_LAUNCH_CONTROL
510 #endif
511 
513 
514 #if EFI_UNIT_TEST
516 #endif /* EFI_UNIT_TEST */
517 
518 #if (EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT) || EFI_SIMULATOR || EFI_UNIT_TEST
519  initAuxValves();
520 #endif /* EFI_ENGINE_CONTROL */
521 
522  initTachometer();
523  initSpeedometer();
524 }
void initAccelEnrichment()
void initIgnitionAdvanceControl()
void initSensors()
Definition: allsensors.cpp:14
void initAlternatorCtrl()
void initAuxValves()
Definition: aux_valves.cpp:54
void initBenchTest()
Definition: bench_test.cpp:646
void initBoostCtrl()
FuelSchedule injectionEvents
Definition: engine.h:258
RpmCalculator rpmCalculator
Definition: engine.h:273
void addFuelEvents()
bool Register()
Definition: sensor.cpp:131
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
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 initMalfunctionIndicator(void)
void initMapAveraging()
engine_configuration_s * engineConfiguration
void initScriptImpl()
Definition: script_impl.cpp:82
void initSensorChart(void)
void initSettings()
Definition: settings.cpp:769
void initSpeedometer()
Definition: speedometer.cpp:25
void initTachometer()
Definition: tachometer.cpp:67
printf("\n")
void initVvtActuators()
Definition: vvt.cpp:182

Referenced by initRealHardwareEngineController().

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

◆ doPeriodicSlowCallback()

static void doPeriodicSlowCallback ( )
static

rusEfi usually runs on hardware which halts execution while writing to internal flash, so we postpone writes to until engine is stopped. Writes in case of self-stimulation are fine.

todo: allow writing if 2nd bank of flash is used

Definition at line 185 of file engine_controller.cpp.

185  {
186 #if EFI_SHAFT_POSITION_INPUT
187  efiAssertVoid(ObdCode::CUSTOM_ERR_6661, getCurrentRemainingStack() > 64, "lowStckOnEv");
188 
190 
192  if (engine->rpmCalculator.isStopped()) {
193  resetAccel();
194  }
195 
198  }
199 #endif /* EFI_SHAFT_POSITION_INPUT */
200 
202 
203 #if EFI_SHAFT_POSITION_INPUT
205  /**
206  * rusEfi usually runs on hardware which halts execution while writing to internal flash, so we
207  * postpone writes to until engine is stopped. Writes in case of self-stimulation are fine.
208  *
209  * todo: allow writing if 2nd bank of flash is used
210  */
211 #if EFI_CONFIGURATION_STORAGE
213 #endif /* EFI_CONFIGURATION_STORAGE */
214  }
215 #else /* if EFI_SHAFT_POSITION_INPUT */
216  #if EFI_CONFIGURATION_STORAGE
218  #endif /* EFI_CONFIGURATION_STORAGE */
219 #endif /* EFI_SHAFT_POSITION_INPUT */
220 
221 #if EFI_TCU
223  if (engine->gearController == NULL) {
227  }
229  }
230 #endif // EFI_TCU
231 
233 }
void updateAccelParameters()
void tryResetWatchdog()
TriggerCentral triggerCentral
Definition: engine.h:286
GearControllerBase * gearController
Definition: engine.h:182
int getGlobalConfigurationVersion(void) const
Definition: engine.cpp:315
LocalVersionHolder versionForConfigurationListeners
Definition: engine.h:221
void periodicSlowCallback()
Definition: engine.cpp:146
virtual void update()
virtual GearControllerMode getMode() const
bool isOld(int globalVersion)
bool isStopped() const override
bool directSelfStimulation
void slowStartStopButtonCallback()
Definition: start_stop.cpp:56
void writeToFlashIfPending()
Definition: flash_main.cpp:95
@ 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 340 of file engine_controller.cpp.

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

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

283  {
284  if (isOutOfBounds(offset))
285  return;
286  uint8_t *ptr = (uint8_t *) (&((char *) engineConfiguration)[offset]);
287  uint8_t value = *ptr;
288  /**
289  * this response is part of rusEfi console API
290  */
291  efiPrintf("byte%s%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, value);
292 }

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

371  {
372  if (isOutOfBounds(offset))
373  return;
374  float *ptr = (float *) (&((char *) engineConfiguration)[offset]);
375  float value = *ptr;
376  /**
377  * this response is part of rusEfi console API
378  */
379  efiPrintf("float%s%d is %.5f", CONSOLE_DATA_PROTOCOL_TAG, offset, value);
380 }

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

351  {
352  if (isOutOfBounds(offset))
353  return;
354  int *ptr = (int *) (&((char *) engineConfiguration)[offset]);
355  int value = *ptr;
356  /**
357  * this response is part of rusEfi console API
358  */
359  efiPrintf("int%s%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, value);
360 }

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

240  {
241 #if HAL_USE_ADC
242  if (!isAdcChannelValid(hwChannel)) {
243  snprintf(buffer, bufferSize, "NONE");
244  } else {
245  const char *name = portname(getAdcChannelPort(msg, hwChannel));
246  snprintf(buffer, bufferSize, "%s%d", name ? name : "null", getAdcChannelPin(hwChannel));
247  }
248 #else
249  snprintf(buffer, bufferSize, "NONE");
250 #endif /* HAL_USE_ADC */
251  return buffer;
252 }
bool isAdcChannelValid(adc_channel_e hwChannel)
Definition: adc_inputs.h:20
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(), printMAPInfo(), and printTpsSenser().

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

◆ getRusEfiVersion()

int getRusEfiVersion ( void  )

See also SIGNATURE_HASH

Definition at line 762 of file engine_controller.cpp.

762  {
763  if (UNUSED_RAM_SIZE[0] != 0)
764  return 123; // this is here to make the compiler happy about the unused array
765  if (UNUSED_CCM_SIZE[0] * 0 != 0)
766  return 3211; // this is here to make the compiler happy about the unused array
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 }
static volatile char UNUSED_RAM_SIZE[RAM_UNUSED_SIZE]

Referenced by firmwareError(), handleGetVersion(), myerror(), 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 272 of file engine_controller.cpp.

272  {
273  if (isOutOfBounds(offset))
274  return;
275  uint16_t *ptr = (uint16_t *) (&((char *) engineConfiguration)[offset]);
276  uint16_t value = *ptr;
277  /**
278  * this response is part of rusEfi console API
279  */
280  efiPrintf("short%s%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, value);
281 }

Referenced by initConfigActions(), and setShort().

Here is the caller graph for this function:

◆ initConfigActions()

static void initConfigActions ( )
static

Definition at line 401 of file engine_controller.cpp.

401  {
403  addConsoleActionII("set_int", (VoidIntInt) setInt);
404  addConsoleActionII("set_short", (VoidIntInt) setShort);
405  addConsoleActionII("set_byte", (VoidIntInt) setByte);
406  addConsoleActionSSS("set_bit", setBit);
407 
408  addConsoleActionI("get_float", getFloat);
409  addConsoleActionI("get_int", getInt);
410  addConsoleActionI("get_short", getShort);
411  addConsoleActionI("get_byte", getByte);
412  addConsoleActionII("get_bit", getBit);
413 }
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 *)
Definition: cli_registry.h:68
void(* VoidIntInt)(int, int)
Definition: cli_registry.h:61
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 109 of file engine_controller.cpp.

109  {
110 #if EFI_ENGINE_CONTROL
111  initFuelMap();
114  for (size_t i=0;i<efi::size(events.elements);i++) {
115  // above-zero value helps distinguish events
116  events.elements[i].sparkCounter = 1;
117  }
118  // above-zero value helps distinguish events
120 #endif // EFI_ENGINE_CONTROL
121 }
IgnitionEventList ignitionEvents
Definition: engine.h:259
EngineState engineState
Definition: engine.h:312
void initFuelMap()
Initialize fuel map data structure.
Definition: fuel_math.cpp:352
void initSpeedDensity()
composite packet size
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 235 of file engine_controller.cpp.

235  {
236  slowController.start();
237  fastController.start();
238 }
static PeriodicFastController fastController
static PeriodicSlowController slowController

Referenced by runRusEfi().

Here is the caller graph for this function:

◆ initRealHardwareEngineController()

void initRealHardwareEngineController ( )

Definition at line 723 of file engine_controller.cpp.

723  {
726 
727 #if EFI_LOGIC_ANALYZER
730  }
731 #endif /* EFI_LOGIC_ANALYZER */
732 
733  if (hasFirmwareError()) {
734  return;
735  }
736 
737  engineStateBlinkingTask.start();
738 
740 }
static EngineStateBlinkingTask engineStateBlinkingTask
void commonInitEngineController()
void initWaveAnalyzer()
void initWarningRunningPins()
void initVrThresholdPwm()
Definition: vr_pwm.cpp:39

Referenced by runRusEfiWithConfig().

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

◆ printSensorInfo()

static void printSensorInfo ( )
static

Definition at line 259 of file engine_controller.cpp.

259  {
260 #if HAL_USE_ADC
261  // Print info about analog mappings
263 #endif // HAL_USE_ADC
264 
265  // Print info about all sensors
267 }
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 175 of file engine_controller.cpp.

175  {
177 #if EFI_ENGINE_CONTROL
178  for (size_t i = 0; i < efi::size(engine->injectionEvents.elements); i++)
179  {
181  }
182 #endif // EFI_ENGINE_CONTROL
183 }
TpsAccelEnrichment tpsAccelEnrichment
Definition: engine.h:283
InjectionEvent elements[MAX_CYLINDER_COUNT]
Definition: fuel_schedule.h:82
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 294 of file engine_controller.cpp.

294  {
295  int offset = atoi(offsetStr);
296  if (absI(offset) == absI(ATOI_ERROR_CODE)) {
297  efiPrintf("invalid offset [%s]", offsetStr);
298  return;
299  }
300  if (isOutOfBounds(offset)) {
301  return;
302  }
303  int bit = atoi(bitStr);
304  if (absI(bit) == absI(ATOI_ERROR_CODE)) {
305  efiPrintf("invalid bit [%s]", bitStr);
306  return;
307  }
308  int value = atoi(valueStr);
309  if (absI(value) == absI(ATOI_ERROR_CODE)) {
310  efiPrintf("invalid value [%s]", valueStr);
311  return;
312  }
313  int *ptr = (int *) (&((char *) engineConfiguration)[offset]);
314  *ptr ^= (-value ^ *ptr) & (1 << bit);
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);
320 }
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 331 of file engine_controller.cpp.

331  {
332  if (isOutOfBounds(offset))
333  return;
334  uint8_t *ptr = (uint8_t *) (&((char *) engineConfiguration)[offset]);
335  *ptr = (uint8_t) value;
336  getByte(offset);
338 }

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

382  {
383  int offset = atoi(offsetStr);
384  if (absI(offset) == absI(ATOI_ERROR_CODE)) {
385  efiPrintf("invalid offset [%s]", offsetStr);
386  return;
387  }
388  if (isOutOfBounds(offset))
389  return;
390  float value = atoff(valueStr);
391  if (std::isnan(value)) {
392  efiPrintf("invalid value [%s]", valueStr);
393  return;
394  }
395  float *ptr = (float *) (&((char *) engineConfiguration)[offset]);
396  *ptr = value;
397  getFloat(offset);
399 }

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

362  {
363  if (isOutOfBounds(offset))
364  return;
365  int *ptr = (int *) (&((char *) engineConfiguration)[offset]);
366  *ptr = value;
367  getInt(offset);
369 }

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

322  {
323  if (isOutOfBounds(offset))
324  return;
325  uint16_t *ptr = (uint16_t *) (&((char *) engineConfiguration)[offset]);
326  *ptr = (uint16_t) value;
327  getShort(offset);
329 }

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

526  {
527  return true;
528 }

Referenced by validateConfigOnStartUpOrBurn().

Here is the caller graph for this function:

◆ validateConfigOnStartUpOrBurn()

bool validateConfigOnStartUpOrBurn ( )

Definition at line 531 of file engine_controller.cpp.

531  {
532  if (!validateBoardConfig()) {
533  return false;
534  }
535  if (engineConfiguration->cylindersCount > MAX_CYLINDER_COUNT) {
536  criticalError("Invalid cylinder count: %d", engineConfiguration->cylindersCount);
537  return false;
538  }
539  if (engineConfiguration->adcVcc > 5.0f || engineConfiguration->adcVcc < 1.0f) {
540  criticalError("Invalid adcVcc: %f", engineConfiguration->adcVcc);
541  return false;
542  }
545  }
546 
548 
549 #if EFI_ENGINE_CONTROL
550  // Fueling
551  {
554 
555  ensureArrayIsAscending("Lambda/AFR load", config->lambdaLoadBins);
556  ensureArrayIsAscending("Lambda/AFR RPM", config->lambdaRpmBins);
557 
558  ensureArrayIsAscending("Fuel CLT mult", config->cltFuelCorrBins);
559  ensureArrayIsAscending("Fuel IAT mult", config->iatFuelCorrBins);
560 
563 
564  ensureArrayIsAscending("Injection phase load", config->injPhaseLoadBins);
565  ensureArrayIsAscending("Injection phase RPM", config->injPhaseRpmBins);
566 
570 
573 
576 
577  ensureArrayIsAscendingOrDefault("TPS TPS RPM correction", config->tpsTspCorrValuesBins);
578 
581  }
582 
583  // Ignition
584  {
586 
591 
592  ensureArrayIsAscending("Ignition CLT corr", config->cltTimingBins);
593 
594  ensureArrayIsAscending("Ignition IAT corr IAT", config->ignitionIatCorrTempBins);
595  ensureArrayIsAscending("Ignition IAT corr Load", config->ignitionIatCorrLoadBins);
596  }
597 
600 #endif // EFI_ENGINE_CONTROL
601 
608 
609 // todo: huh? why does this not work on CI? ensureArrayIsAscendingOrDefault("Dwell Correction Voltage", engineConfiguration->dwellVoltageCorrVoltBins);
610 
611  ensureArrayIsAscending("MAF transfer function", config->mafDecodingBins);
612 
613  // Cranking tables
614  ensureArrayIsAscending("Cranking fuel mult", config->crankingFuelBins);
615  ensureArrayIsAscending("Cranking duration", config->crankingCycleBins);
618 
619  // Idle tables
620  ensureArrayIsAscending("Idle target RPM", config->cltIdleRpmBins);
621  ensureArrayIsAscending("Idle warmup mult", config->cltIdleCorrBins);
626 
627  for (size_t index = 0; index < efi::size(engineConfiguration->vrThreshold); index++) {
628  auto& cfg = engineConfiguration->vrThreshold[index];
629 
630  if (cfg.pin == Gpio::Unassigned) {
631  continue;
632  }
633  ensureArrayIsAscending("VR threshold", cfg.rpmBins);
634  }
635 
636 #if EFI_BOOST_CONTROL
637  // Boost
638  ensureArrayIsAscending("Boost control TPS", config->boostTpsBins);
639  ensureArrayIsAscending("Boost control RPM", config->boostRpmBins);
640 #endif // EFI_BOOST_CONTROL
641 
642 #if EFI_ANTILAG_SYSTEM
643  // ALS
648 #endif // EFI_ANTILAG_SYSTEM
649 
650 #if EFI_ELECTRONIC_THROTTLE_BODY
651  // ETB
654 #endif // EFI_ELECTRONIC_THROTTLE_BODY
655 
656  if (isGdiEngine()) {
660  ensureArrayIsAscending("HPFP target rpm", config->hpfpTargetRpmBins);
661  ensureArrayIsAscending("HPFP target load", config->hpfpTargetLoadBins);
662  }
663 
664  // VVT
666  ensureArrayIsAscending("VVT intake load", config->vvtTable1LoadBins);
667  ensureArrayIsAscending("VVT intake RPM", config->vvtTable1RpmBins);
668  }
669 
670 #if CAM_INPUTS_COUNT != 1
672  ensureArrayIsAscending("VVT exhaust load", config->vvtTable2LoadBins);
673  ensureArrayIsAscending("VVT exhaust RPM", config->vvtTable2RpmBins);
674  }
675 #endif
676 
677  return true;
678 }
@ Unassigned
void ensureArrayIsAscendingOrDefault(const char *msg, const TValue(&values)[TSize])
void ensureArrayIsAscending(const char *msg, const TValue(&values)[TSize])
PUBLIC_API_WEAK bool validateBoardConfig()
bool isGdiEngine()
persistent_config_s * config
bool isBrainPinValid(brain_pin_e brainPin)
scaled_channel< uint16_t, 100, 1 > tractionControlSlipBins[TRACTION_CONTROL_ETB_DROP_SIZE]
uint8_t tractionControlSpeedBins[TRACTION_CONTROL_ETB_DROP_SIZE]
float battLagCorrBins[VBAT_INJECTOR_CURVE_SIZE]
scaled_channel< uint8_t, 2, 1 > hpfpLobeProfileQuantityBins[HPFP_LOBE_PROFILE_SIZE]
scaled_channel< uint8_t, 1, 100 > iacCoastingRpmBins[CLT_CURVE_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, 100 > pedalToTpsRpmBins[PEDAL_TO_TPS_SIZE]
scaled_channel< uint8_t, 1, 50 > hpfpTargetRpmBins[HPFP_TARGET_SIZE]
scaled_channel< uint8_t, 1, 50 > tpsTspCorrValuesBins[TPS_TPS_ACCEL_CLT_CORR_TABLE]
scaled_channel< int8_t, 1, 2 > cltIdleRpmBins[CLT_CURVE_SIZE]
scaled_channel< uint8_t, 1, 100 > boostRpmBins[BOOST_RPM_COUNT]
scaled_channel< uint16_t, 100, 1 > mapEstimateTpsBins[FUEL_LOAD_COUNT]
scaled_channel< uint8_t, 1, 50 > hpfpCompensationRpmBins[HPFP_COMPENSATION_SIZE]
scaled_channel< uint8_t, 1, 50 > idleAdvanceBins[IDLE_ADVANCE_CURVE_SIZE]
scaled_channel< uint16_t, 10, 1 > hpfpTargetLoadBins[HPFP_TARGET_SIZE]
scaled_channel< uint8_t, 1, 5 > ignitionIatCorrLoadBins[8]

Referenced by handleBurnCommand(), and runRusEfiWithConfig().

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

Variable Documentation

◆ CCM_OPTIONAL

volatile char UNUSED_CCM_SIZE [CCM_UNUSED_SIZE] CCM_OPTIONAL

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

Definition at line 100 of file engine_controller.cpp.

◆ engine

Engine* engine

Definition at line 104 of file engine_controller.cpp.

Referenced by WallFuel::adjust(), applyIACposition(), applyNonPersistentConfiguration(), applyPidSettings(), applyPinState(), assertTimeIsLinear(), RpmCalculator::assignRpmValue(), attachMsdSdCard(), auxPlainPinTurnOn(), blipIdle(), boardInitHardware(), brain_pin_markUsed(), HpfpQuantity::calcFuelPercent(), canDashboardHaltech(), canInfo(), RpmCalculator::checkIfSpinning(), TriggerCentral::checkIfTriggerConfigChanged(), EtbController::checkStatus(), TunerStudio::cmdOutputChannels(), commonInitEngineController(), completionCallback(), configureRusefiLuaHooks(), TriggerCentral::decodeMapCam(), AemXSeriesWideband::decodeRusefiDiag(), detectHellenBoardType(), IdleController::determinePhase(), disableTriggerStimulator(), disengageStarterIfNeeded(), doInitElectronicThrottle(), StepperMotorBase::doIteration(), doPeriodicSlowCallback(), emulatorApplyPinState(), enableExternalTriggerStimulator(), enableOrDisable(), enableTriggerStimulator(), etbAutocal(), etbPidReset(), executeTSCommand(), executorStatistics(), extIonCallback(), fastAdcErrorCB(), HpfpLobe::findNextLobe(), finishIdleTestIfNeeded(), fireSparkAndPrepareNextSchedule(), firmwareError(), fuelClosedLoopCorrection(), getAcrState(), getAdvance(), getAdvanceCorrections(), SpeedDensityAirmass::getAirmass(), getAirmassModel(), AngleBasedEvent::getAngleFromNow(), getBaseFuelMass(), getBoardId(), getBrainUsedPin(), getBrakePedalState(), VvtController::getClosedLoop(), BoostController::getClosedLoop(), AlternatorController::getClosedLoop(), IdleController::getClosedLoop(), EtbController::getClosedLoopAutotune(), getClutchDownState(), getClutchUpState(), getCoilDutyCycle(), getCrankingFuel(), getCrankingFuel3(), IdleController::getCrankingTaperFraction(), TriggerCentral::getCurrentEnginePhase(), getCurrentIgnitionMode(), getEngineRotationState(), getEngineState(), getExecutorInterface(), getFuelALSCorrection(), getFuelSchedule(), getIdlePosition(), IdleController::getIdlePosition(), IdleController::getIdleTimingAdjustment(), getIgnitionEvents(), getInjectionMass(), getInjectorDutyCycle(), getInjectorDutyCycleStage2(), ClosedLoopFuelCellImpl::getLambdaError(), getLimpManager(), getLiveData(), SpeedDensityAirmass::getMap(), LambdaMonitor::getMaxAllowedLambda(), getMultiSparkCount(), BoostController::getOpenLoop(), RpmCalculator::getOperationMode(), getOutputValueByName(), getPerCylinderFiringOrderOffset(), PrimeController::getPrimeDuration(), getRunningAdvance(), getRunningFuel(), IdleController::getRunningOpenLoop(), BoostController::getSetpoint(), VvtController::getSetpoint(), EtbController::getSetpointEtb(), EtbController::getSetpointIdleValve(), IgnitionState::getSparkDwell(), DfcoController::getState(), FanController::getState(), IdleController::getTargetRpm(), TpsAccelEnrichment::getTpsEnrichment(), getTriggerCentral(), getTunerStudioOutputChannels(), AirmassVeModelBase::getVe(), getWrappedAdvance(), grabPedalIsUp(), grabPedalIsWideOpen(), handleCommandX14(), handleFuel(), handleGetDataRequest(), handleShaftSignal(), TriggerCentral::handleShaftSignal(), handleTestCommand(), handleVvtCamSignal(), hipThread(), incrementGlobalConfigurationVersion(), Generic4TransmissionController::init(), Gm4l6xTransmissionController::init(), initAlternatorCtrl(), initAuxValves(), initBoostCtrl(), initDataStructures(), initDcMotor(), initElectronicThrottle(), initGearController(), initGpPwm(), initializeIgnitionActions(), initSpeedometer(), initStartStopButton(), initTachometer(), initVrThresholdPwm(), initVvtActuators(), is_F_OrOlder(), LambdaMonitorBase::isCurrentlyGood(), isMegaModuleRevision(), isTriggerErrorNow(), lua_getDigital(), lua_setDebug(), mainTriggerCallback(), mapAveragingAdcCallback(), mapAveragingTriggerCallback(), mountMmc(), myAlloc(), obdOnCanPacketRx(), VvtController::observePlant(), onConfigurationChangeTriggerCallback(), onEcuStartDoSomethingTriggerInputPins(), onFastAdcComplete(), HpfpController::onFastCallback(), WallFuelController::onFastCallback(), KnockControllerBase::onKnockSenseCompleted(), PrimeController::onPrimeStart(), RpmCalculator::onSlowCallback(), IdleController::onSlowCallback(), FanController::onSlowCallback(), FuelPumpController::onSlowCallback(), HarleyAcr::onSlowCallback(), MainRelayController::onSlowCallback(), TripOdometer::onSlowCallback(), IgnitionController::onSlowCallback(), SensorChecker::onSlowCallback(), onStartStopButtonToggle(), onTdcCallback(), PrimaryTriggerDecoder::onTriggerError(), onTriggerEventSparkLogic(), Engine::OnTriggerSynchronization(), InjectionEvent::onTriggerTooth(), overFireSparkAndPrepareNextSchedule(), Engine::periodicFastCallback(), EngineState::periodicFastCallback(), Engine::periodicSlowCallback(), CanWrite::PeriodicTask(), pokeAuxDigital(), populateFrame(), postCanState(), StepperMotorBase::postCurrentPosition(), GearControllerBase::postState(), Engine::preCalculate(), prepareCylinderIgnitionSchedule(), prepareIgnitionSchedule(), prepareOutputSignals(), printConfiguration(), printErrorCounters(), printUid(), processCanRxImu_BoschM5_10_RollX(), processCanRxImu_BoschM5_10_YawY(), processCanRxImu_BoschM5_10_Z(), processLastKnockEvent(), StepDirectionStepper::pulse(), readFromFlash(), readGppwmChannel(), recalculateAuxValveTiming(), CanStreamerState::receiveFrame(), refreshMapAveragingPreCalc(), reportLogicAnalyzerToTS(), resetAccel(), resetLua(), rpmShaftPositionCallback(), runBench(), runOneLua(), runRusEfi(), sayHello(), scheduleByAngle(), TriggerScheduler::scheduleEventsUntilNextTriggerTooth(), HpfpController::scheduleNextCycle(), scheduleOpen(), scheduleSparkEvent(), sendQcBenchAuxDigitalCounters(), sendQcBenchButtonCounters(), sendQcBenchEventCounters(), sendWidebandInfo(), SentDecoderThread(), setAltPFactor(), setBoardConfigOverrides(), setEngineType(), setEtbIdlePosition(), setEtbLuaAdjustment(), setEtbWastegatePosition(), IgnitionOutputPin::setHigh(), StepperMotorBase::setInitialPosition(), IgnitionOutputPin::setLow(), SetNextCompositeEntry(), EtbController::setOutput(), Generic4TransmissionController::setPcState(), setPin(), RpmCalculator::setRpmValue(), RpmCalculator::setSpinningUp(), RpmCalculator::setStopped(), setToothLogReady(), setTpsAccelLen(), setTriggerEmulatorRPM(), setTriggerType(), setValue(), setWholeTimingMapCmd(), shouldCorrect(), shouldUpdateCorrection(), slowAdcErrorCB(), slowStartStopButtonCallback(), startAveraging(), startBoostPin(), AdcDevice::startConversionI(), startDwellByTurningSparkPinHigh(), startIdleBench(), startIdleThread(), startKnockSampling(), startLua(), startPwm(), startSimulatedTriggerSignal(), startTriggerInputPins(), tdcMarkCallback(), THD_FUNCTION(), tle8888PostState(), tle8888startup(), triggerScopeDisable(), triggerScopeGetBuffer(), turnSparkPinHighStartCharging(), turnVvtPidOn(), undoIdleBlipIfNeeded(), InjectionEvent::update(), SimpleTransmissionController::update(), DynoView::update(), updateDevConsoleState(), updateEgtSensors(), updateFlags(), updateFuelCorrections(), updateFuelInfo(), updateFuelResults(), updateFuelSensors(), updateGppwm(), updateIgnition(), updateLambda(), updateMiscSensors(), updatePressures(), updateRawSensors(), updateSdCardLiveFlags(), EngineState::updateSparkSkip(), LimpManager::updateState(), Engine::updateSwitchInputs(), EngineState::updateTChargeK(), updateTempSensors(), updateThrottles(), Engine::updateTriggerWaveform(), updateTriggerWaveformIfNeeded(), updateTunerStudioState(), updateVehicleSpeed(), updateVvtSensors(), updateWarningCodes(), TriggerCentral::updateWaveform(), validateHardwareTimer(), warning(), watchDogBuddyCallback(), writeToFlashNow(), and CanTxMessage::~CanTxMessage().

◆ engineStateBlinkingTask

EngineStateBlinkingTask engineStateBlinkingTask
static

Definition at line 173 of file engine_controller.cpp.

Referenced by initRealHardwareEngineController().

◆ fastAdc

AdcDevice fastAdc
extern

◆ fastController

PeriodicFastController fastController
static

Definition at line 148 of file engine_controller.cpp.

Referenced by initPeriodicEvents().

◆ slowController

PeriodicSlowController slowController
static

Definition at line 149 of file engine_controller.cpp.

Referenced by initPeriodicEvents().

◆ UNUSED_RAM_SIZE

volatile char UNUSED_RAM_SIZE[RAM_UNUSED_SIZE]
static

Definition at line 756 of file engine_controller.cpp.

Referenced by getRusEfiVersion().

Go to the source code of this file.