75 #if EFI_LOGIC_ANALYZER
79 #if defined(EFI_BOOTLOADER_INCLUDE_CODE)
80 #include "bootloader/bootloader.h"
106 #if EFI_ENGINE_CONTROL
112 events.elements[i].sparkCounter = 1;
129 return FAST_CALLBACK_PERIOD_MS;
140 return SLOW_CALLBACK_PERIOD_MS;
153 #if EFI_SHAFT_POSITION_INPUT
156 bool is_running =
false;
174 #if EFI_ENGINE_CONTROL
183 #if EFI_SHAFT_POSITION_INPUT
196 #if EFI_SHAFT_POSITION_INPUT
204 #if EFI_CONFIGURATION_STORAGE
209 #if EFI_CONFIGURATION_STORAGE
236 snprintf(
buffer, bufferSize,
"NONE");
242 snprintf(
buffer, bufferSize,
"NONE");
259 #define isOutOfBounds(offset) ((offset<0) || (offset) >= (int) sizeof(engine_configuration_s))
262 if (isOutOfBounds(offset))
265 uint16_t value = *ptr;
269 efiPrintf(
"short%s%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, value);
273 if (isOutOfBounds(offset))
276 uint8_t value = *ptr;
280 efiPrintf(
"byte%s%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, value);
283 static void setBit(
const char *offsetStr,
const char *bitStr,
const char *valueStr) {
284 int offset = atoi(offsetStr);
285 if (absI(offset) == absI(ATOI_ERROR_CODE)) {
286 efiPrintf(
"invalid offset [%s]", offsetStr);
289 if (isOutOfBounds(offset)) {
292 int bit = atoi(bitStr);
293 if (absI(bit) == absI(ATOI_ERROR_CODE)) {
294 efiPrintf(
"invalid bit [%s]", bitStr);
297 int value = atoi(valueStr);
298 if (absI(value) == absI(ATOI_ERROR_CODE)) {
299 efiPrintf(
"invalid value [%s]", valueStr);
303 *ptr ^= (-value ^ *ptr) & (1 << bit);
307 efiPrintf(
"bit%s%d/%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, bit, value);
311 static void setShort(
const int offset,
const int value) {
312 if (isOutOfBounds(offset))
315 *ptr = (uint16_t) value;
320 static void setByte(
const int offset,
const int value) {
321 if (isOutOfBounds(offset))
324 *ptr = (uint8_t) value;
329 static void getBit(
int offset,
int bit) {
330 if (isOutOfBounds(offset))
333 int value = (*ptr >> bit) & 1;
337 efiPrintf(
"bit%s%d/%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, bit, value);
341 if (isOutOfBounds(offset))
348 efiPrintf(
"int%s%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, value);
351 static void setInt(
const int offset,
const int value) {
352 if (isOutOfBounds(offset))
361 if (isOutOfBounds(offset))
368 efiPrintf(
"float%s%d is %.5f", CONSOLE_DATA_PROTOCOL_TAG, offset, value);
371 static void setFloat(
const char *offsetStr,
const char *valueStr) {
372 int offset = atoi(offsetStr);
373 if (absI(offset) == absI(ATOI_ERROR_CODE)) {
374 efiPrintf(
"invalid offset [%s]", offsetStr);
377 if (isOutOfBounds(offset))
379 float value = atoff(valueStr);
380 if (std::isnan(value)) {
381 efiPrintf(
"invalid value [%s]", valueStr);
413 #if EFI_SIMULATOR || EFI_UNIT_TEST
414 printf(
"commonInitEngineController\n");
421 #if EFI_ENGINE_CONTROL
435 #if EFI_PROD_CODE || EFI_SIMULATOR
438 if (hasFirmwareError()) {
443 #if ! EFI_UNIT_TEST && EFI_ENGINE_CONTROL
447 #if EFI_ALTERNATOR_CONTROL
455 #if EFI_MALFUNCTION_INDICATOR
483 #if EFI_ELECTRONIC_THROTTLE_BODY
487 #if EFI_MAP_AVERAGING
493 #if EFI_BOOST_CONTROL
497 #if EFI_LAUNCH_CONTROL
538 #if EFI_ENGINE_CONTROL
625 #if EFI_BOOST_CONTROL
631 #if EFI_ANTILAG_SYSTEM
639 #if EFI_ELECTRONIC_THROTTLE_BODY
659 #if CAM_INPUTS_COUNT != 1
679 #if EFI_SHAFT_POSITION_INPUT
695 #if EFI_ENGINE_EMULATOR
708 #if HW_CHECK_ALWAYS_STIMULATE
720 #if EFI_LOGIC_ANALYZER
726 if (hasFirmwareError()) {
743 #ifndef RAM_UNUSED_SIZE
744 #define RAM_UNUSED_SIZE 17400
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 initIgnitionAdvanceControl()
void initAlternatorCtrl()
Utility methods related to bench testing.
void initQcBenchControls()
TriggerCentral triggerCentral
GearControllerBase * gearController
FuelSchedule injectionEvents
IgnitionEventList ignitionEvents
void periodicFastCallback()
void periodicSlowCallback()
RpmCalculator rpmCalculator
constexpr auto & module()
InjectionEvent elements[MAX_CYLINDER_COUNT]
virtual GearControllerMode getMode() const
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])
void initElectronicThrottle()
void prepareOutputSignals()
void incrementGlobalConfigurationVersion(const char *msg)
bool validateConfigOnStartUpOrBurn()
static PeriodicFastController fastController
static void setFloat(const char *offsetStr, const char *valueStr)
PUBLIC_API_WEAK bool validateBoardConfig()
static void getShort(int offset)
static void printSensorInfo()
Engine ___engine CCM_OPTIONAL
static volatile char UNUSED_RAM_SIZE[RAM_UNUSED_SIZE]
static void getFloat(int offset)
static PeriodicSlowController slowController
static void setByte(const int offset, const int value)
static EngineStateBlinkingTask engineStateBlinkingTask
char * getPinNameByAdcChannel(const char *msg, adc_channel_e hwChannel, char *buffer, size_t bufferSize)
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()
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 enableOilPressureProtect
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]
scaled_channel< uint8_t, 1, 100 > iacCoastingRpmBins[CLT_CURVE_SIZE]
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 ignTrimRpmBins[IGN_TRIM_SIZE]
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 idleVeLoadBins[IDLE_VE_SIZE]
uint16_t sparkDwellRpmBins[DWELL_CURVE_SIZE]
uint16_t ignitionLoadBins[IGN_LOAD_COUNT]
uint16_t fuelTrimRpmBins[FUEL_TRIM_SIZE]
uint8_t hpfpDeadtimeVoltsBins[HPFP_DEADTIME_SIZE]
uint16_t alsIgnRetardLoadBins[4]
uint16_t lambdaRpmBins[FUEL_RPM_COUNT]
scaled_channel< uint8_t, 1, 50 > hpfpTargetRpmBins[HPFP_TARGET_SIZE]
float scriptCurve6Bins[SCRIPT_CURVE_8]
float cltFuelCorrBins[CLT_CURVE_SIZE]
uint16_t vvtTable1RpmBins[VVT_TABLE_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 vvtTable1LoadBins[VVT_TABLE_SIZE]
uint16_t alsIgnRetardrpmBins[4]
uint16_t vvtTable2RpmBins[VVT_TABLE_SIZE]
uint16_t injPhaseRpmBins[FUEL_RPM_COUNT]
float scriptCurve5Bins[SCRIPT_CURVE_8]
float cltTimingBins[CLT_TIMING_CURVE_SIZE]
uint8_t boostLoadBins[BOOST_LOAD_COUNT]
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 fuelTrimLoadBins[FUEL_TRIM_SIZE]
uint16_t veLoadBins[FUEL_LOAD_COUNT]
float cltBoostCorrBins[BOOST_CURVE_SIZE]
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]
float iatBoostCorrBins[BOOST_CURVE_SIZE]
uint16_t injPhaseLoadBins[FUEL_LOAD_COUNT]
int16_t crankingCycleFuelCltBins[CRANKING_CYCLE_CLT_SIZE]
float iatFuelCorrBins[IAT_CURVE_SIZE]
uint16_t vvtTable2LoadBins[VVT_TABLE_SIZE]
float crankingCycleBins[CRANKING_CURVE_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, 100 > minimumOilPressureBins[8]
scaled_channel< uint8_t, 1, 5 > ignitionIatCorrLoadBins[8]
float crankingTpsBins[CRANKING_CURVE_SIZE]
uint16_t ignTrimLoadBins[IGN_TRIM_SIZE]
uint16_t lambdaLoadBins[FUEL_LOAD_COUNT]
static std::vector< CompositeEvent > events
void initTriggerCentral()
void enableTriggerStimulator(bool incGlobalConfiguration)
static BigBufferHandle buffer
void initVrThresholdPwm()