75 #if EFI_LOGIC_ANALYZER
83 #if defined(EFI_BOOTLOADER_INCLUDE_CODE)
84 #include "bootloader/bootloader.h"
114 #if EFI_ENGINE_CONTROL
120 events.elements[i].sparkCounter = 1;
137 return FAST_CALLBACK_PERIOD_MS;
148 return SLOW_CALLBACK_PERIOD_MS;
161 #if EFI_SHAFT_POSITION_INPUT
164 bool is_running =
false;
181 #if EFI_ENGINE_CONTROL
190 #if EFI_SHAFT_POSITION_INPUT
207 #if EFI_SHAFT_POSITION_INPUT
215 #if (EFI_STORAGE_INT_FLASH == TRUE) || (EFI_STORAGE_MFS == TRUE)
220 #if (EFI_STORAGE_INT_FLASH == TRUE) || (EFI_STORAGE_MFS == TRUE)
274 #define isOutOfBounds(offset) ((offset<0) || (offset) >= (int) sizeof(engine_configuration_s))
277 if (isOutOfBounds(offset))
280 uint16_t value = *ptr;
284 efiPrintf(
"short%s%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, value);
288 if (isOutOfBounds(offset))
291 uint8_t value = *ptr;
295 efiPrintf(
"byte%s%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, value);
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);
304 if (isOutOfBounds(offset)) {
307 int bit = atoi(bitStr);
308 if (absI(bit) == absI(ATOI_ERROR_CODE)) {
309 efiPrintf(
"invalid bit [%s]", bitStr);
312 int value = atoi(valueStr);
313 if (absI(value) == absI(ATOI_ERROR_CODE)) {
314 efiPrintf(
"invalid value [%s]", valueStr);
318 *ptr ^= (-value ^ *ptr) & (1 << bit);
322 efiPrintf(
"bit%s%d/%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, bit, value);
326 static void setShort(
const int offset,
const int value) {
327 if (isOutOfBounds(offset))
330 *ptr = (uint16_t) value;
335 static void setByte(
const int offset,
const int value) {
336 if (isOutOfBounds(offset))
339 *ptr = (uint8_t) value;
344 static void getBit(
int offset,
int bit) {
345 if (isOutOfBounds(offset))
348 int value = (*ptr >> bit) & 1;
352 efiPrintf(
"bit%s%d/%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, bit, value);
356 if (isOutOfBounds(offset))
363 efiPrintf(
"int%s%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, value);
366 static void setInt(
const int offset,
const int value) {
367 if (isOutOfBounds(offset))
376 if (isOutOfBounds(offset))
383 efiPrintf(
"float%s%d is %.5f", CONSOLE_DATA_PROTOCOL_TAG, offset, value);
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);
392 if (isOutOfBounds(offset))
394 float value = atoff(valueStr);
396 efiPrintf(
"invalid value [%s]", valueStr);
430 #if EFI_SIMULATOR || EFI_UNIT_TEST
431 printf(
"commonInitEngineController\n");
438 #if EFI_ENGINE_CONTROL
452 #if EFI_PROD_CODE || EFI_SIMULATOR
455 if (hasFirmwareError()) {
460 #if ! EFI_UNIT_TEST && EFI_ENGINE_CONTROL
464 #if EFI_ALTERNATOR_CONTROL
472 #if EFI_MALFUNCTION_INDICATOR
500 #if EFI_ELECTRONIC_THROTTLE_BODY
504 #if EFI_MAP_AVERAGING
510 #if EFI_BOOST_CONTROL
514 #if EFI_LAUNCH_CONTROL
524 #if (EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT) || EFI_SIMULATOR || EFI_UNIT_TEST
541 #if EFI_ENGINE_CONTROL
624 #if EFI_BOOST_CONTROL
630 #if EFI_ANTILAG_SYSTEM
638 #if EFI_ELECTRONIC_THROTTLE_BODY
658 #if CAM_INPUTS_COUNT != 1
674 #if EFI_SHAFT_POSITION_INPUT
690 #if EFI_ENGINE_EMULATOR
703 #if HW_CHECK_ALWAYS_STIMULATE
715 #if EFI_LOGIC_ANALYZER
721 if (hasFirmwareError()) {
743 #ifndef RAM_UNUSED_SIZE
744 #define RAM_UNUSED_SIZE 30000
746 #ifndef CCM_UNUSED_SIZE
747 #define CCM_UNUSED_SIZE 512
750 static volatile char UNUSED_CCM_SIZE[CCM_UNUSED_SIZE]
CCM_OPTIONAL;
758 if (UNUSED_CCM_SIZE[0] * 0 != 0)
760 #if defined(EFI_BOOTLOADER_INCLUDE_CODE)
762 if (initBootloader() != 0)
void initAccelEnrichment()
void updateAccelParameters()
void initIgnitionAdvanceControl()
void initAlternatorCtrl()
Utility methods related to bench testing.
void initQcBenchControls()
TriggerCentral triggerCentral
GearControllerBase * gearController
FuelSchedule injectionEvents
IgnitionEventList ignitionEvents
void periodicFastCallback()
int getGlobalConfigurationVersion(void) const
LocalVersionHolder versionForConfigurationListeners
void periodicSlowCallback()
RpmCalculator rpmCalculator
TpsAccelEnrichment tpsAccelEnrichment
InjectionEvent elements[MAX_CYLINDER_COUNT]
virtual GearControllerMode getMode() const
bool isOld(int globalVersion)
void setValue(const char *msg, int logicValue, bool isForce=false)
virtual int getPeriodMs()=0
virtual void PeriodicTask()=0
bool isStopped() const override
bool isCranking() const override
static void showAllSensorInfo()
bool directSelfStimulation
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 *)
void(* VoidIntInt)(int, int)
int getAdcChannelPin(adc_channel_e hwChannel)
ioportid_t getAdcChannelPort(const char *msg, adc_channel_e hwChannel)
void initButtonDebounce()
const char * portname(ioportid_t GPIOx)
void ensureArrayIsAscendingOrDefault(const char *msg, const TValue(&values)[TSize])
void ensureArrayIsAscending(const char *msg, const TValue(&values)[TSize])
char * itoa10(char *p, int num)
void initElectronicThrottle()
void prepareOutputSignals()
void incrementGlobalConfigurationVersion(const char *msg)
static PeriodicFastController fastController
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)
static void initConfigActions()
static void getByte(int offset)
void initPeriodicEvents()
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()
int getRusEfiVersion(void)
void slowStartStopButtonCallback()
void initEngineEmulator()
void writeToFlashIfPending()
void initFuelMap()
Initialize fuel map data structure.
void initGearController()
Idle Valve Control thread.
This data structure holds current malfunction codes.
void initMalfunctionIndicator(void)
We can blink out OBD-II error codes using Malfunction Indicator Light (MIL)
persistent_config_s * config
engine_configuration_s * engineConfiguration
bool isBrainPinValid(brain_pin_e brainPin)
void initSensorChart(void)
void startStatusThreads()
void initWarningRunningPins()
vr_threshold_s vrThreshold[VR_THRESHOLD_COUNT]
bool isMapAveragingEnabled
bool isWaveAnalyzerEnabled
scaled_channel< uint16_t, 100, 1 > tractionControlSlipBins[TRACTION_CONTROL_ETB_DROP_SIZE]
GearControllerMode gearControllerMode
brain_input_pin_e camInputs[CAM_INPUTS_COUNT]
uint8_t tractionControlSpeedBins[TRACTION_CONTROL_ETB_DROP_SIZE]
uint32_t globalSparkCounter
float battLagCorrBins[VBAT_INJECTOR_CURVE_SIZE]
scaled_channel< uint8_t, 2, 1 > hpfpLobeProfileQuantityBins[HPFP_LOBE_PROFILE_SIZE]
uint16_t injectorStagingRpmBins[INJ_STAGING_COUNT]
uint16_t vvtTable1LoadBins[SCRIPT_TABLE_8]
uint16_t ignTrimRpmBins[TRIM_SIZE]
scaled_channel< uint8_t, 1, 100 > iacCoastingRpmBins[CLT_CURVE_SIZE]
uint16_t vvtTable1RpmBins[SCRIPT_TABLE_8]
uint16_t injectorStagingLoadBins[INJ_STAGING_COUNT]
int8_t ignitionIatCorrTempBins[8]
uint8_t pedalToTpsPedalBins[PEDAL_TO_TPS_SIZE]
uint16_t mapEstimateRpmBins[FUEL_RPM_COUNT]
uint16_t veRpmBins[FUEL_RPM_COUNT]
uint16_t vvtTable2LoadBins[SCRIPT_TABLE_8]
scaled_channel< uint8_t, 1, 10 > idleVeRpmBins[IDLE_VE_SIZE]
float crankingFuelBins[CRANKING_CURVE_SIZE]
float mafDecodingBins[MAF_DECODING_COUNT]
scaled_channel< uint16_t, 1000, 1 > fuelLevelBins[FUEL_LEVEL_TABLE_COUNT]
scaled_channel< uint8_t, 1, 100 > pedalToTpsRpmBins[PEDAL_TO_TPS_SIZE]
uint8_t boostTpsBins[BOOST_LOAD_COUNT]
uint8_t idleVeLoadBins[IDLE_VE_SIZE]
uint16_t sparkDwellRpmBins[DWELL_CURVE_SIZE]
uint16_t ignitionLoadBins[IGN_LOAD_COUNT]
uint16_t vvtTable2RpmBins[SCRIPT_TABLE_8]
uint8_t hpfpDeadtimeVoltsBins[HPFP_DEADTIME_SIZE]
uint16_t alsIgnRetardLoadBins[4]
uint16_t lambdaRpmBins[FUEL_RPM_COUNT]
uint16_t ignTrimLoadBins[TRIM_SIZE]
scaled_channel< uint8_t, 1, 50 > hpfpTargetRpmBins[HPFP_TARGET_SIZE]
float scriptCurve6Bins[SCRIPT_CURVE_8]
float cltFuelCorrBins[CLT_CURVE_SIZE]
uint16_t fuelTrimRpmBins[TRIM_SIZE]
float scriptCurve4Bins[SCRIPT_CURVE_8]
scaled_channel< uint8_t, 1, 50 > tpsTspCorrValuesBins[TPS_TPS_ACCEL_CLT_CORR_TABLE]
scaled_channel< int8_t, 1, 2 > cltIdleRpmBins[CLT_CURVE_SIZE]
uint16_t alsIgnRetardrpmBins[4]
uint16_t injPhaseRpmBins[FUEL_RPM_COUNT]
float scriptCurve5Bins[SCRIPT_CURVE_8]
float cltTimingBins[CLT_TIMING_CURVE_SIZE]
scaled_channel< uint8_t, 1, 100 > boostRpmBins[BOOST_RPM_COUNT]
float tpsTpsAccelFromRpmBins[TPS_TPS_ACCEL_TABLE]
uint16_t alsFuelAdjustmentLoadBins[4]
uint16_t ignitionRpmBins[IGN_RPM_COUNT]
float scriptCurve2Bins[SCRIPT_CURVE_16]
float cltIdleCorrBins[CLT_CURVE_SIZE]
uint16_t veLoadBins[FUEL_LOAD_COUNT]
float scriptCurve3Bins[SCRIPT_CURVE_8]
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]
float scriptCurve1Bins[SCRIPT_CURVE_16]
uint16_t injPhaseLoadBins[FUEL_LOAD_COUNT]
float iatFuelCorrBins[IAT_CURVE_SIZE]
float crankingCycleBins[CRANKING_CURVE_SIZE]
uint16_t fuelTrimLoadBins[TRIM_SIZE]
float tpsTpsAccelToRpmBins[TPS_TPS_ACCEL_TABLE]
uint16_t alsFuelAdjustmentrpmBins[4]
scaled_channel< uint16_t, 10, 1 > hpfpTargetLoadBins[HPFP_TARGET_SIZE]
scaled_channel< uint8_t, 1, 5 > ignitionIatCorrLoadBins[8]
float crankingTpsBins[CRANKING_CURVE_SIZE]
uint16_t lambdaLoadBins[FUEL_LOAD_COUNT]
static std::vector< CompositeEvent > events
void initTriggerCentral()
void enableTriggerStimulator(bool incGlobalConfiguration)
static BigBufferHandle buffer
void initVrThresholdPwm()