rusEFI
The most advanced open source ECU
engine_controller.cpp
Go to the documentation of this file.
1 /**
2  * @file engine_controller.cpp
3  * @brief Controllers package entry point code
4  *
5  *
6  *
7  * @date Feb 7, 2013
8  * @author Andrey Belomutskiy, (c) 2012-2020
9  *
10  * This file is part of rusEfi - see http://rusefi.com
11  *
12  * rusEfi is free software; you can redistribute it and/or modify it under the terms of
13  * the GNU General Public License as published by the Free Software Foundation; either
14  * version 3 of the License, or (at your option) any later version.
15  *
16  * rusEfi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
17  * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along with this program.
21  * If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #include "pch.h"
25 
26 
27 #include "trigger_central.h"
28 #include "script_impl.h"
29 #include "idle_thread.h"
30 #include "hardware.h"
31 #include "advance_map.h"
32 #include "main_trigger_callback.h"
33 #include "flash_main.h"
34 #include "bench_test.h"
35 #include "mmc_card.h"
36 #include "electronic_throttle.h"
37 #include "trigger_emulator_algo.h"
38 #include "map_averaging.h"
40 #include "malfunction_central.h"
41 #include "malfunction_indicator.h"
42 #include "speed_density.h"
43 #include "local_version_holder.h"
44 #include "alternator_controller.h"
45 #include "can_bench_test.h"
46 #include "engine_emulator.h"
47 #include "fuel_math.h"
48 #include "spark_logic.h"
49 #include "status_loop.h"
50 #include "aux_valves.h"
51 #include "accelerometer.h"
52 #include "vvt.h"
53 #include "boost_control.h"
54 #include "launch_control.h"
55 #include "tachometer.h"
56 #include "speedometer.h"
57 #include "gppwm.h"
58 #include "date_stamp.h"
59 #include "rusefi_lua.h"
60 #include "buttonshift.h"
61 #include "start_stop.h"
62 #include "dynoview.h"
63 #include "vr_pwm.h"
64 #include "adc_subscription.h"
65 #include "gc_generic.h"
66 
67 #if EFI_SENSOR_CHART
68 #include "sensor_chart.h"
69 #endif /* EFI_SENSOR_CHART */
70 
71 #if EFI_TUNER_STUDIO
72 #include "tunerstudio.h"
73 #endif /* EFI_TUNER_STUDIO */
74 
75 #if EFI_LOGIC_ANALYZER
76 #include "logic_analyzer.h"
77 #endif /* EFI_LOGIC_ANALYZER */
78 
79 #if HAL_USE_ADC
80 #include "AdcConfiguration.h"
81 #endif /* HAL_USE_ADC */
82 
83 #if defined(EFI_BOOTLOADER_INCLUDE_CODE)
84 #include "bootloader/bootloader.h"
85 #endif /* EFI_BOOTLOADER_INCLUDE_CODE */
86 
87 #include "periodic_task.h"
88 
89 
90 #if ! EFI_UNIT_TEST
91 #include "init.h"
92 #include "mpu_util.h"
93 #endif /* EFI_UNIT_TEST */
94 
95 #if EFI_PROD_CODE
96 #include "pwm_tester.h"
97 #endif /* EFI_PROD_CODE */
98 
99 #if !EFI_UNIT_TEST
100 
101 /**
102  * Would love to pass reference to configuration object into constructor but C++ does allow attributes after parenthesized initializer
103  */
105 
106 #else // EFI_UNIT_TEST
107 
109 
110 #endif /* EFI_UNIT_TEST */
111 
112 
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 }
126 
127 #if !EFI_UNIT_TEST
128 
129 static void doPeriodicSlowCallback();
130 
131 class PeriodicFastController : public PeriodicTimerController {
132  void PeriodicTask() override {
134  }
135 
136  int getPeriodMs() override {
137  return FAST_CALLBACK_PERIOD_MS;
138  }
139 };
140 
141 class PeriodicSlowController : public PeriodicTimerController {
142  void PeriodicTask() override {
144  }
145 
146  int getPeriodMs() override {
147  // no reason to have this configurable, looks like everyone is happy with 20Hz
148  return SLOW_CALLBACK_PERIOD_MS;
149  }
150 };
151 
152 static PeriodicFastController fastController;
153 static PeriodicSlowController slowController;
154 
155 class EngineStateBlinkingTask : public PeriodicTimerController {
156  int getPeriodMs() override {
157  return 50;
158  }
159 
160  void PeriodicTask() override {
161 #if EFI_SHAFT_POSITION_INPUT
162  bool is_running = engine->rpmCalculator.isRunning();
163 #else
164  bool is_running = false;
165 #endif /* EFI_SHAFT_POSITION_INPUT */
166 
167  if (is_running) {
168  // blink in running mode
170  } else {
171  int is_cranking = engine->rpmCalculator.isCranking();
172  enginePins.runningLedPin.setValue(is_cranking);
173  }
174  }
175 };
176 
177 static EngineStateBlinkingTask engineStateBlinkingTask;
178 
179 static void resetAccel() {
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 }
188 
189 static void doPeriodicSlowCallback() {
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 }
238 
240  slowController.start();
241  fastController.start();
242 }
243 
244 char * getPinNameByAdcChannel(const char *msg, adc_channel_e hwChannel, char *buffer) {
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 }
257 
258 #if HAL_USE_ADC
259 extern AdcDevice fastAdc;
260 #endif /* HAL_USE_ADC */
261 
262 #if EFI_PROD_CODE
263 static void printSensorInfo() {
264 #if HAL_USE_ADC
265  // Print info about analog mappings
267 #endif // HAL_USE_ADC
268 
269  // Print info about all sensors
271 }
272 #endif // EFI_PROD_CODE
273 
274 #define isOutOfBounds(offset) ((offset<0) || (offset) >= (int) sizeof(engine_configuration_s))
275 
276 static void getShort(int offset) {
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 }
286 
287 static void getByte(int offset) {
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 }
297 
298 static void setBit(const char *offsetStr, const char *bitStr, const char *valueStr) {
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 }
325 
326 static void setShort(const int offset, const int value) {
327  if (isOutOfBounds(offset))
328  return;
329  uint16_t *ptr = (uint16_t *) (&((char *) engineConfiguration)[offset]);
330  *ptr = (uint16_t) value;
331  getShort(offset);
333 }
334 
335 static void setByte(const int offset, const int value) {
336  if (isOutOfBounds(offset))
337  return;
338  uint8_t *ptr = (uint8_t *) (&((char *) engineConfiguration)[offset]);
339  *ptr = (uint8_t) value;
340  getByte(offset);
342 }
343 
344 static void getBit(int offset, int bit) {
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 }
354 
355 static void getInt(int offset) {
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 }
365 
366 static void setInt(const int offset, const int value) {
367  if (isOutOfBounds(offset))
368  return;
369  int *ptr = (int *) (&((char *) engineConfiguration)[offset]);
370  *ptr = value;
371  getInt(offset);
373 }
374 
375 static void getFloat(int offset) {
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 }
385 
386 static void setFloat(const char *offsetStr, const char *valueStr) {
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 }
404 
405 static void initConfigActions() {
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 }
418 #endif /* EFI_UNIT_TEST */
419 
420 // one-time start-up
421 // this method is used by real firmware and simulator and unit test
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 }
531 
532 // Returns false if there's an obvious problem with the loaded configuration
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 }
667 
668 #if !EFI_UNIT_TEST
669 
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 }
709 
710 // one-time start-up
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 }
734 
735 /**
736  * these two variables are here only to let us know how much RAM is available, also these
737  * help to notice when RAM usage goes up - if a code change adds to RAM usage these variables would fail
738  * linking process which is the way to raise the alarm
739  *
740  * You get "cannot move location counter backwards" linker error when you run out of RAM. When you run out of RAM you shall reduce these
741  * UNUSED_SIZE constants.
742  */
743 #ifndef RAM_UNUSED_SIZE
744 #define RAM_UNUSED_SIZE 30000
745 #endif
746 #ifndef CCM_UNUSED_SIZE
747 #define CCM_UNUSED_SIZE 512
748 #endif
749 static volatile char UNUSED_RAM_SIZE[RAM_UNUSED_SIZE];
750 static volatile char UNUSED_CCM_SIZE[CCM_UNUSED_SIZE] CCM_OPTIONAL;
751 
752 /**
753  * See also VCS_VERSION
754  */
755 int getRusEfiVersion(void) {
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 }
767 #endif /* EFI_UNIT_TEST */
void initAccelEnrichment()
void updateAccelParameters()
bool isAdcChannelValid(adc_channel_e hwChannel)
Definition: adc_inputs.h:20
void initIgnitionAdvanceControl()
void initSensors()
Definition: allsensors.cpp:14
void initAlternatorCtrl()
alternator controller
void tryResetWatchdog()
void initAuxValves()
Definition: aux_valves.cpp:54
void initBenchTest()
Definition: bench_test.cpp:650
Utility methods related to bench testing.
void initBoostCtrl()
void initQcBenchControls()
static void PrintInfo()
Definition: engine.h:89
TriggerCentral triggerCentral
Definition: engine.h:281
GearControllerBase * gearController
Definition: engine.h:179
FuelSchedule injectionEvents
Definition: engine.h:253
IgnitionEventList ignitionEvents
Definition: engine.h:254
void periodicFastCallback()
Definition: engine.cpp:557
int getGlobalConfigurationVersion(void) const
Definition: engine.cpp:300
LocalVersionHolder versionForConfigurationListeners
Definition: engine.h:220
EngineState engineState
Definition: engine.h:310
void periodicSlowCallback()
Definition: engine.cpp:142
RpmCalculator rpmCalculator
Definition: engine.h:268
TpsAccelEnrichment tpsAccelEnrichment
Definition: engine.h:278
OutputPin runningLedPin
Definition: efi_gpio.h:103
InjectionEvent elements[MAX_CYLINDER_COUNT]
Definition: fuel_schedule.h:82
void addFuelEvents()
virtual void update()
virtual GearControllerMode getMode() const
WallFuel & getWallFuel()
bool isOld(int globalVersion)
void setValue(const char *msg, int logicValue, bool isForce=false)
Definition: efi_gpio.cpp:583
void toggle()
Definition: efi_gpio.cpp:548
virtual int getPeriodMs()=0
virtual void PeriodicTask()=0
bool isStopped() const override
bool isRunning() const
bool isCranking() const override
bool Register()
Definition: sensor.cpp:131
static void showAllSensorInfo()
Definition: sensor.cpp:246
bool directSelfStimulation
void resetWF()
Definition: wall_fuel.cpp:10
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
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
@ Unassigned
int getAdcChannelPin(adc_channel_e hwChannel)
ioportid_t getAdcChannelPort(const char *msg, adc_channel_e hwChannel)
void initButtonDebounce()
EnginePins enginePins
Definition: efi_gpio.cpp:24
const char * portname(ioportid_t GPIOx)
void initInterpolation()
void ensureArrayIsAscendingOrDefault(const char *msg, const TValue(&values)[TSize])
void ensureArrayIsAscending(const char *msg, const TValue(&values)[TSize])
char * itoa10(char *p, int num)
Definition: efilib.cpp:119
void initElectronicThrottle()
void prepareOutputSignals()
Engine ___engine
void incrementGlobalConfigurationVersion(const char *msg)
static PeriodicFastController fastController
Engine * engine
static void setFloat(const char *offsetStr, const char *valueStr)
static void getShort(int offset)
static void printSensorInfo()
Engine ___engine CCM_OPTIONAL
static volatile char UNUSED_RAM_SIZE[RAM_UNUSED_SIZE]
char * getPinNameByAdcChannel(const char *msg, adc_channel_e hwChannel, char *buffer)
static void getFloat(int offset)
static PeriodicSlowController slowController
static void setByte(const int offset, const int value)
static EngineStateBlinkingTask engineStateBlinkingTask
static void setInt(const int offset, const int value)
void commonEarlyInit()
static void initConfigActions()
static void getByte(int offset)
void initPeriodicEvents()
bool validateConfig()
static void doPeriodicSlowCallback()
void initDataStructures()
static void getBit(int offset, int bit)
static void setShort(const int offset, const int value)
static void getInt(int offset)
void initRealHardwareEngineController()
static void setBit(const char *offsetStr, const char *bitStr, const char *valueStr)
void commonInitEngineController()
static void resetAccel()
AdcDevice fastAdc
int getRusEfiVersion(void)
void slowStartStopButtonCallback()
Definition: start_stop.cpp:53
void initEngineEmulator()
void writeToFlashIfPending()
Definition: flash_main.cpp:95
void initFuelMap()
Initialize fuel map data structure.
Definition: fuel_math.cpp:346
void initGearController()
void initGpPwm()
Definition: gppwm.cpp:29
void initHardware()
Definition: hardware.cpp:577
bool isGdiEngine()
Idle Valve Control thread.
void startIdleThread()
void initNewSensors()
void initLaunchControl()
void initWaveAnalyzer()
void startLua()
Definition: lua.cpp:386
Main logic header.
This data structure holds current malfunction codes.
void initMalfunctionIndicator(void)
We can blink out OBD-II error codes using Malfunction Indicator Light (MIL)
void initMapAveraging()
void initMmcCard()
Definition: mmc_card.cpp:625
@ CUSTOM_ERR_6661
persistent_config_s * config
engine_configuration_s * engineConfiguration
bool isBrainPinValid(brain_pin_e brainPin)
void initPwmTester()
Definition: pwm_tester.cpp:70
adc_channel_e
void initScriptImpl()
Definition: script_impl.cpp:85
void initSensorChart(void)
void initSettings()
Definition: settings.cpp:840
void initSpeedDensity()
void initSpeedometer()
Definition: speedometer.cpp:25
void startStatusThreads()
void initWarningRunningPins()
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]
void initTachometer()
Definition: tachometer.cpp:67
composite packet size
static std::vector< CompositeEvent > events
void initTriggerCentral()
void enableTriggerStimulator(bool incGlobalConfiguration)
static BigBufferHandle buffer
void startCanConsole()
printf("\n")
void initVrThresholdPwm()
Definition: vr_pwm.cpp:39
void initVvtActuators()
Definition: vvt.cpp:182