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)
 
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 ()
 
bool validateConfig ()
 
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 670 of file engine_controller.cpp.

670  {
671  // Start this early - it will start LED blinking and such
673 
674 #if EFI_SHAFT_POSITION_INPUT
675  // todo: figure out better startup logic
677 #endif /* EFI_SHAFT_POSITION_INPUT */
678 
679  /**
680  * Initialize hardware drivers
681  */
682  initHardware();
683 
685 
686 #if EFI_FILE_LOGGING
687  initMmcCard();
688 #endif /* EFI_FILE_LOGGING */
689 
690 #if EFI_ENGINE_EMULATOR
692 #endif
693 
694 #if EFI_LUA
695  startLua();
696 #endif // EFI_LUA
697 
698 #if EFI_CAN_SERIAL
699  // needs to be called after initCan() inside initHardware()
700  startCanConsole();
701 #endif /* EFI_CAN_SERIAL */
702 
703 #if HW_CHECK_ALWAYS_STIMULATE
704  // we need a special binary for final assembly check. We cannot afford to require too much software or too many steps
705  // to be executed at the place of assembly
706  enableTriggerStimulator(/*incGlobalConfiguration*/false);
707 #endif // HW_CHECK_ALWAYS_STIMULATE
708 }
void initQcBenchControls()
void initEngineEmulator()
void initHardware()
Definition: hardware.cpp:577
void startLua()
Definition: lua.cpp:386
void initMmcCard()
Definition: mmc_card.cpp:625
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 422 of file engine_controller.cpp.

422  {
423 #if EFI_PROD_CODE
424  addConsoleAction("sensorinfo", printSensorInfo);
425  addConsoleAction("reset_accel", resetAccel);
426 #endif /* EFI_PROD_CODE */
427 
429 
430 #if EFI_SIMULATOR || EFI_UNIT_TEST
431  printf("commonInitEngineController\n");
432 #endif
433 
434 #if !EFI_UNIT_TEST
436 #endif /* EFI_UNIT_TEST */
437 
438 #if EFI_ENGINE_CONTROL
439  /**
440  * This has to go after 'enginePins.startPins()' in order to
441  * properly detect un-assigned output pins
442  */
444 
446 #endif // EFI_ENGINE_CONTROL
447 
448 #if EFI_SENSOR_CHART
449  initSensorChart();
450 #endif /* EFI_SENSOR_CHART */
451 
452 #if EFI_PROD_CODE || EFI_SIMULATOR
453  initSettings();
454 
455  if (hasFirmwareError()) {
456  return;
457  }
458 #endif
459 
460 #if ! EFI_UNIT_TEST && EFI_ENGINE_CONTROL
461  initBenchTest();
462 #endif /* ! EFI_UNIT_TEST && EFI_ENGINE_CONTROL */
463 
464 #if EFI_ALTERNATOR_CONTROL
466 #endif /* EFI_ALTERNATOR_CONTROL */
467 
468 #if EFI_VVT_PID
470 #endif /* EFI_VVT_PID */
471 
472 #if EFI_MALFUNCTION_INDICATOR
474 #endif /* EFI_MALFUNCTION_INDICATOR */
475 
476 #if !EFI_UNIT_TEST
477  // This is tested independently - don't configure sensors for tests.
478  // This lets us selectively mock them for each test.
479  initNewSensors();
480 #endif /* EFI_UNIT_TEST */
481 
482  initSensors();
483 
485 
486  initScriptImpl();
487 
488  initGpPwm();
489 
490 #if EFI_IDLE_CONTROL
491  startIdleThread();
492 #endif /* EFI_IDLE_CONTROL */
493 
494 #if EFI_TCU
496 #endif
497 
499 
500 #if EFI_ELECTRONIC_THROTTLE_BODY
502 #endif /* EFI_ELECTRONIC_THROTTLE_BODY */
503 
504 #if EFI_MAP_AVERAGING
507  }
508 #endif /* EFI_MAP_AVERAGING */
509 
510 #if EFI_BOOST_CONTROL
511  initBoostCtrl();
512 #endif /* EFI_BOOST_CONTROL */
513 
514 #if EFI_LAUNCH_CONTROL
516 #endif
517 
519 
520 #if EFI_UNIT_TEST
522 #endif /* EFI_UNIT_TEST */
523 
524 #if (EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT) || EFI_SIMULATOR || EFI_UNIT_TEST
525  initAuxValves();
526 #endif /* EFI_ENGINE_CONTROL */
527 
528  initTachometer();
529  initSpeedometer();
530 }
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:650
void initBoostCtrl()
FuelSchedule injectionEvents
Definition: engine.h:247
RpmCalculator rpmCalculator
Definition: engine.h:262
void addFuelEvents()
bool Register()
Definition: sensor.cpp:131
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
void initButtonDebounce()
void initInterpolation()
void initElectronicThrottle()
void prepareOutputSignals()
Engine * engine
static void printSensorInfo()
static void initConfigActions()
static void resetAccel()
void initGearController()
void initGpPwm()
Definition: gppwm.cpp:29
void startIdleThread()
void initNewSensors()
void initLaunchControl()
void initMalfunctionIndicator(void)
void initMapAveraging()
engine_configuration_s * engineConfiguration
void initScriptImpl()
Definition: script_impl.cpp:85
void initSensorChart(void)
void initSettings()
Definition: settings.cpp:846
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 189 of file engine_controller.cpp.

189  {
190 #if EFI_SHAFT_POSITION_INPUT
191  efiAssertVoid(ObdCode::CUSTOM_ERR_6661, getCurrentRemainingStack() > 64, "lowStckOnEv");
192 
194 
196  if (engine->rpmCalculator.isStopped()) {
197  resetAccel();
198  }
199 
202  }
203 #endif /* EFI_SHAFT_POSITION_INPUT */
204 
206 
207 #if EFI_SHAFT_POSITION_INPUT
209  /**
210  * rusEfi usually runs on hardware which halts execution while writing to internal flash, so we
211  * postpone writes to until engine is stopped. Writes in case of self-stimulation are fine.
212  *
213  * todo: allow writing if 2nd bank of flash is used
214  */
215 #if (EFI_STORAGE_INT_FLASH == TRUE) || (EFI_STORAGE_MFS == TRUE)
217 #endif /* (EFI_STORAGE_INT_FLASH == TRUE) || (EFI_STORAGE_MFS == TRUE) */
218  }
219 #else /* if EFI_SHAFT_POSITION_INPUT */
220  #if (EFI_STORAGE_INT_FLASH == TRUE) || (EFI_STORAGE_MFS == TRUE)
222  #endif /* (EFI_STORAGE_INT_FLASH == TRUE) || (EFI_STORAGE_MFS == TRUE) */
223 #endif /* EFI_SHAFT_POSITION_INPUT */
224 
225 #if EFI_TCU
227  if (engine->gearController == NULL) {
231  }
233  }
234 #endif // EFI_TCU
235 
237 }
void updateAccelParameters()
void tryResetWatchdog()
TriggerCentral triggerCentral
Definition: engine.h:275
GearControllerBase * gearController
Definition: engine.h:179
int getGlobalConfigurationVersion(void) const
Definition: engine.cpp:300
LocalVersionHolder versionForConfigurationListeners
Definition: engine.h:220
void periodicSlowCallback()
Definition: engine.cpp:142
virtual void update()
virtual GearControllerMode getMode() const
bool isOld(int globalVersion)
bool isStopped() const override
bool directSelfStimulation
void slowStartStopButtonCallback()
Definition: start_stop.cpp:53
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 344 of file engine_controller.cpp.

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

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

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

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

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

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

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

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 
)

Definition at line 244 of file engine_controller.cpp.

244  {
245 #if HAL_USE_ADC
246  if (!isAdcChannelValid(hwChannel)) {
247  strcpy(buffer, "NONE");
248  } else {
249  strcpy(buffer, portname(getAdcChannelPort(msg, hwChannel)));
250  itoa10(&buffer[2], getAdcChannelPin(hwChannel));
251  }
252 #else
253  strcpy(buffer, "NONE");
254 #endif /* HAL_USE_ADC */
255  return buffer;
256 }
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)
char * itoa10(char *p, int num)
Definition: efilib.cpp:119
static const char * msg
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 VCS_VERSION

Definition at line 755 of file engine_controller.cpp.

755  {
756  if (UNUSED_RAM_SIZE[0] != 0)
757  return 123; // this is here to make the compiler happy about the unused array
758  if (UNUSED_CCM_SIZE[0] * 0 != 0)
759  return 3211; // this is here to make the compiler happy about the unused array
760 #if defined(EFI_BOOTLOADER_INCLUDE_CODE)
761  // make bootloader code happy too
762  if (initBootloader() != 0)
763  return 123;
764 #endif /* EFI_BOOTLOADER_INCLUDE_CODE */
765  return VCS_DATE;
766 }
static volatile char UNUSED_RAM_SIZE[RAM_UNUSED_SIZE]

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

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

Referenced by initConfigActions(), and setShort().

Here is the caller graph for this function:

◆ initConfigActions()

static void initConfigActions ( )
static

Definition at line 405 of file engine_controller.cpp.

405  {
407  addConsoleActionII("set_int", (VoidIntInt) setInt);
408  addConsoleActionII("set_short", (VoidIntInt) setShort);
409  addConsoleActionII("set_byte", (VoidIntInt) setByte);
410  addConsoleActionSSS("set_bit", setBit);
411 
412  addConsoleActionI("get_float", getFloat);
413  addConsoleActionI("get_int", getInt);
414  addConsoleActionI("get_short", getShort);
415  addConsoleActionI("get_byte", getByte);
416  addConsoleActionII("get_bit", getBit);
417 }
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 113 of file engine_controller.cpp.

113  {
114 #if EFI_ENGINE_CONTROL
115  initFuelMap();
118  for (size_t i=0;i<efi::size(events.elements);i++) {
119  // above-zero value helps distinguish events
120  events.elements[i].sparkCounter = 1;
121  }
122  // above-zero value helps distinguish events
124 #endif // EFI_ENGINE_CONTROL
125 }
IgnitionEventList ignitionEvents
Definition: engine.h:248
EngineState engineState
Definition: engine.h:304
void initFuelMap()
Initialize fuel map data structure.
Definition: fuel_math.cpp:346
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 239 of file engine_controller.cpp.

239  {
240  slowController.start();
241  fastController.start();
242 }
static PeriodicFastController fastController
static PeriodicSlowController slowController

Referenced by runRusEfi().

Here is the caller graph for this function:

◆ initRealHardwareEngineController()

void initRealHardwareEngineController ( )

Definition at line 711 of file engine_controller.cpp.

711  {
714 
715 #if EFI_LOGIC_ANALYZER
718  }
719 #endif /* EFI_LOGIC_ANALYZER */
720 
721  if (hasFirmwareError()) {
722  return;
723  }
724 
725  engineStateBlinkingTask.start();
726 
728 
729 #if EFI_PWM_TESTER
730  initPwmTester();
731 #endif /* EFI_PWM_TESTER */
732 
733 }
static EngineStateBlinkingTask engineStateBlinkingTask
void commonInitEngineController()
void initWaveAnalyzer()
void initPwmTester()
Definition: pwm_tester.cpp:70
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 263 of file engine_controller.cpp.

263  {
264 #if HAL_USE_ADC
265  // Print info about analog mappings
267 #endif // HAL_USE_ADC
268 
269  // Print info about all sensors
271 }
static void PrintInfo()
static void showAllSensorInfo()
Definition: sensor.cpp:246

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

179  {
181 #if EFI_ENGINE_CONTROL
182  for (size_t i = 0; i < efi::size(engine->injectionEvents.elements); i++)
183  {
185  }
186 #endif // EFI_ENGINE_CONTROL
187 }
TpsAccelEnrichment tpsAccelEnrichment
Definition: engine.h:272
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 298 of file engine_controller.cpp.

298  {
299  int offset = atoi(offsetStr);
300  if (absI(offset) == absI(ATOI_ERROR_CODE)) {
301  efiPrintf("invalid offset [%s]", offsetStr);
302  return;
303  }
304  if (isOutOfBounds(offset)) {
305  return;
306  }
307  int bit = atoi(bitStr);
308  if (absI(bit) == absI(ATOI_ERROR_CODE)) {
309  efiPrintf("invalid bit [%s]", bitStr);
310  return;
311  }
312  int value = atoi(valueStr);
313  if (absI(value) == absI(ATOI_ERROR_CODE)) {
314  efiPrintf("invalid value [%s]", valueStr);
315  return;
316  }
317  int *ptr = (int *) (&((char *) engineConfiguration)[offset]);
318  *ptr ^= (-value ^ *ptr) & (1 << bit);
319  /**
320  * this response is part of rusEfi console API
321  */
322  efiPrintf("bit%s%d/%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, bit, value);
324 }
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 335 of file engine_controller.cpp.

335  {
336  if (isOutOfBounds(offset))
337  return;
338  uint8_t *ptr = (uint8_t *) (&((char *) engineConfiguration)[offset]);
339  *ptr = (uint8_t) value;
340  getByte(offset);
342 }

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

386  {
387  int offset = atoi(offsetStr);
388  if (absI(offset) == absI(ATOI_ERROR_CODE)) {
389  efiPrintf("invalid offset [%s]", offsetStr);
390  return;
391  }
392  if (isOutOfBounds(offset))
393  return;
394  float value = atoff(valueStr);
395  if (cisnan(value)) {
396  efiPrintf("invalid value [%s]", valueStr);
397  return;
398  }
399  float *ptr = (float *) (&((char *) engineConfiguration)[offset]);
400  *ptr = value;
401  getFloat(offset);
403 }

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

366  {
367  if (isOutOfBounds(offset))
368  return;
369  int *ptr = (int *) (&((char *) engineConfiguration)[offset]);
370  *ptr = value;
371  getInt(offset);
373 }

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

326  {
327  if (isOutOfBounds(offset))
328  return;
329  uint16_t *ptr = (uint16_t *) (&((char *) engineConfiguration)[offset]);
330  *ptr = (uint16_t) value;
331  getShort(offset);
333 }

Referenced by initConfigActions().

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

◆ validateConfig()

bool validateConfig ( )

Definition at line 533 of file engine_controller.cpp.

533  {
534  if (engineConfiguration->cylindersCount > MAX_CYLINDER_COUNT) {
535  criticalError("Invalid cylinder count: %d", engineConfiguration->cylindersCount);
536  return false;
537  }
538 
540 
541 #if EFI_ENGINE_CONTROL
542  // Fueling
543  {
546 
547  ensureArrayIsAscending("Lambda/AFR load", config->lambdaLoadBins);
548  ensureArrayIsAscending("Lambda/AFR RPM", config->lambdaRpmBins);
549 
550  ensureArrayIsAscending("Fuel CLT mult", config->cltFuelCorrBins);
551  ensureArrayIsAscending("Fuel IAT mult", config->iatFuelCorrBins);
552 
553  ensureArrayIsAscending("Injection phase load", config->injPhaseLoadBins);
554  ensureArrayIsAscending("Injection phase RPM", config->injPhaseRpmBins);
555 
559 
562 
565 
566  ensureArrayIsAscendingOrDefault("TPS TPS RPM correction", config->tpsTspCorrValuesBins);
567 
570  }
571 
572  // Ignition
573  {
575 
580 
581  ensureArrayIsAscending("Ignition CLT corr", config->cltTimingBins);
582 
583  ensureArrayIsAscending("Ignition IAT corr IAT", config->ignitionIatCorrTempBins);
584  ensureArrayIsAscending("Ignition IAT corr Load", config->ignitionIatCorrLoadBins);
585  }
586 
589 #endif // EFI_ENGINE_CONTROL
590 
597 
598 // todo: huh? why does this not work on CI? ensureArrayIsAscendingOrDefault("Dwell Correction Voltage", engineConfiguration->dwellVoltageCorrVoltBins);
599 
601 
602  // Cranking tables
603  ensureArrayIsAscending("Cranking fuel mult", config->crankingFuelBins);
604  ensureArrayIsAscending("Cranking duration", config->crankingCycleBins);
606 
607  // Idle tables
608  ensureArrayIsAscending("Idle target RPM", config->cltIdleRpmBins);
609  ensureArrayIsAscending("Idle warmup mult", config->cltIdleCorrBins);
614 
615  for (size_t index = 0; index < efi::size(engineConfiguration->vrThreshold); index++) {
616  auto& cfg = engineConfiguration->vrThreshold[index];
617 
618  if (cfg.pin == Gpio::Unassigned) {
619  continue;
620  }
621  ensureArrayIsAscending("VR Bins", cfg.rpmBins);
622  }
623 
624 #if EFI_BOOST_CONTROL
625  // Boost
626  ensureArrayIsAscending("Boost control TPS", config->boostTpsBins);
627  ensureArrayIsAscending("Boost control RPM", config->boostRpmBins);
628 #endif // EFI_BOOST_CONTROL
629 
630 #if EFI_ANTILAG_SYSTEM
631  // ALS
636 #endif // EFI_ANTILAG_SYSTEM
637 
638 #if EFI_ELECTRONIC_THROTTLE_BODY
639  // ETB
642 #endif // EFI_ELECTRONIC_THROTTLE_BODY
643 
644  if (isGdiEngine()) {
648  ensureArrayIsAscending("HPFP target rpm", config->hpfpTargetRpmBins);
649  ensureArrayIsAscending("HPFP target load", config->hpfpTargetLoadBins);
650  }
651 
652  // VVT
654  ensureArrayIsAscending("VVT intake load", config->vvtTable1LoadBins);
655  ensureArrayIsAscending("VVT intake RPM", config->vvtTable1RpmBins);
656  }
657 
658 #if CAM_INPUTS_COUNT != 1
660  ensureArrayIsAscending("VVT exhaust load", config->vvtTable2LoadBins);
661  ensureArrayIsAscending("VVT exhaust RPM", config->vvtTable2RpmBins);
662  }
663 #endif
664 
665  return true;
666 }
@ Unassigned
void ensureArrayIsAscendingOrDefault(const char *msg, const TValue(&values)[TSize])
void ensureArrayIsAscending(const char *msg, const TValue(&values)[TSize])
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 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 104 of file engine_controller.cpp.

◆ engine

Engine* engine

Definition at line 108 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(), 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(), 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(), FanController::getState(), IdleController::getTargetRpm(), TpsAccelEnrichment::getTpsEnrichment(), getTriggerCentral(), getTunerStudioOutputChannels(), AirmassVeModelBase::getVe(), grabPedalIsUp(), grabPedalIsWideOpen(), handleCommandX14(), handleFuel(), handleGetDataRequest(), handleShaftSignal(), TriggerCentral::handleShaftSignal(), handleTestCommand(), handleVvtCamSignal(), hipThread(), incrementGlobalConfigurationVersion(), Gm4l6xTransmissionController::init(), initAlternatorCtrl(), initAuxValves(), initBoostCtrl(), initDataStructures(), initDcMotor(), initElectronicThrottle(), initGearController(), initGpPwm(), initializeIgnitionActions(), initPwmTester(), initSpeedometer(), initTachometer(), initVrThresholdPwm(), initVvtActuators(), is_F_OrOlder(), LambdaMonitorBase::isCurrentlyGood(), LaunchControlBase::isInsideSwitchCondition(), isMegaModuleRevision(), isTriggerErrorNow(), lua_getDigital(), lua_setDebug(), mainTriggerCallback(), mapAveragingAdcCallback(), mapAveragingTriggerCallback(), mountMmc(), myAlloc(), obdOnCanPacketRx(), VvtController::observePlant(), onConfigurationChangeTriggerCallback(), onEcuStartDoSomethingTriggerInputPins(), onFastAdcComplete(), HpfpController::onFastCallback(), WallFuelController::onFastCallback(), KnockControllerBase::onKnockSenseCompleted(), 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(), postMapState(), GearControllerBase::postState(), Engine::preCalculate(), prepareCylinderIgnitionSchedule(), prepareIgnitionSchedule(), prepareOutputSignals(), printConfiguration(), printErrorCounters(), processCanRxImu_BoschM5_10_RollX(), processCanRxImu_BoschM5_10_YawY(), processCanRxImu_BoschM5_10_Z(), processLastKnockEvent(), StepDirectionStepper::pulse(), 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(), Gm4l6xTransmissionController::setPcState(), setPin(), RpmCalculator::setRpmValue(), RpmCalculator::setSpinningUp(), RpmCalculator::setStopped(), setToothLogReady(), setTpsAccelLen(), setTriggerEmulatorRPM(), setTriggerType(), setValue(), setWholeTimingMapCmd(), setWholeVeCmd(), shouldCorrect(), shouldUpdateCorrection(), slowStartStopButtonCallback(), startAveraging(), startBoostPin(), startDwellByTurningSparkPinHigh(), startIdleBench(), startIdleThread(), startKnockSampling(), startLua(), startPwm(), startPwmTest(), startSimulatedTriggerSignal(), startTriggerInputPins(), tdcMarkCallback(), testCallback(), THD_FUNCTION(), tle8888PostState(), tle8888startup(), toggleTestAndScheduleNext(), triggerScopeDisable(), triggerScopeGetBuffer(), turnSparkPinHighStartCharging(), turnVvtPidOn(), undoIdleBlipIfNeeded(), InjectionEvent::update(), SimpleTransmissionController::update(), Gm4l6xTransmissionController::update(), DynoView::update(), updateDevConsoleState(), updateEgtSensors(), updateFlags(), updateFuelCorrections(), updateFuelInfo(), updateFuelResults(), updateFuelSensors(), updateGppwm(), updateIgnition(), updateLambda(), updateMiscSensors(), updatePressures(), updateRawSensors(), EngineState::updateSparkSkip(), LimpManager::updateState(), Engine::updateSwitchInputs(), EngineState::updateTChargeK(), updateTempSensors(), updateThrottles(), Engine::updateTriggerWaveform(), updateTriggerWaveformIfNeeded(), updateTunerStudioState(), updateVehicleSpeed(), updateVvtSensors(), updateWarningCodes(), TriggerCentral::updateWaveform(), validateConfiguration(), validateHardwareTimer(), warning(), watchDogBuddyCallback(), writeToFlashNow(), and CanTxMessage::~CanTxMessage().

◆ engineStateBlinkingTask

EngineStateBlinkingTask engineStateBlinkingTask
static

Definition at line 177 of file engine_controller.cpp.

Referenced by initRealHardwareEngineController().

◆ fastAdc

AdcDevice fastAdc
extern

◆ fastController

PeriodicFastController fastController
static

Definition at line 152 of file engine_controller.cpp.

Referenced by initPeriodicEvents().

◆ slowController

PeriodicSlowController slowController
static

Definition at line 153 of file engine_controller.cpp.

Referenced by initPeriodicEvents().

◆ UNUSED_RAM_SIZE

volatile char UNUSED_RAM_SIZE[RAM_UNUSED_SIZE]
static

Definition at line 749 of file engine_controller.cpp.

Referenced by getRusEfiVersion().

Go to the source code of this file.