rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
engine_configuration.h
Go to the documentation of this file.
1/**
2 * @file engine_configuration.h
3 * @brief Main engine configuration data structure.
4 *
5 * @date Oct 30, 2013
6 * @author Andrey Belomutskiy, (c) 2012-2020
7 */
8
9#pragma once
10
12
13#ifndef DEFAULT_ENGINE_TYPE
14#define DEFAULT_ENGINE_TYPE engine_type_e::MINIMAL_PINS
15#endif
16
17#define WARMUP_CLT_EXTRA_FUEL_CURVE config->cltFuelCorrBins, config->cltFuelCorr, CLT_CURVE_SIZE
18#define IAT_FUEL_CORRECTION_CURVE config->iatFuelCorrBins, config->iatFuelCorr, IAT_CURVE_SIZE
19
20#define MOCK_UNDEFINED -1
21
22// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90826 Weak symbol does not work reliably on windows
23// https://sourceware.org/bugzilla/show_bug.cgi?id=9687 Weak symbols not working on mingw32
24// DEPRECATED see PUBLIC_API_WEAK
25#if !defined(IS_WINDOWS_COMPILER) || !IS_WINDOWS_COMPILER
26#define PUBLIC_API_WEAK_SOMETHING_WEIRD __attribute__((weak))
27#else
28#define PUBLIC_API_WEAK_SOMETHING_WEIRD
29#endif
30
33
35void setTargetRpmCurve(float rpm);
36void setFuelTablesLoadBin(float minValue, float maxValue);
37void setWholeIatCorrTimingTable(float value);
39void setConstantDwell(floatms_t dwellMs);
40
41// needed by bootloader
43
45
46void onBurnRequest();
47void incrementGlobalConfigurationVersion(const char * msg = "undef");
48
50
52
54
55#ifdef __cplusplus
56// because of 'Logging' class parameter these functions are visible only to C++ code but C code
58/**
59 * boardCallback is invoked after configuration reset but before specific engineType configuration
60 */
63
65#endif /* __cplusplus */
66
69void onBoardStandBy();
71// fun fact: the red LED for critical error is defined via LED_CRITICAL_ERROR_BRAIN_PIN
73// technical debt: only used to blink from bootloader?
75
76int hackHellenBoardId(int detectedId);
77void applyEngineType(engine_type_e engineType);
78
79#if !EFI_UNIT_TEST
83#else // EFI_UNIT_TEST
86#endif // EFI_UNIT_TEST
87
88/**
89 * & is reference in C++ (not C)
90 * Ref is a pointer that:
91 * you access with dot instead of arrow
92 * Cannot be null
93 * This is about EFI_ACTIVE_CONFIGURATION_IN_FLASH
94 */
96
97#if ! EFI_ACTIVE_CONFIGURATION_IN_FLASH
98// We store a special changeable copy of configuration is RAM, so we can just compare them
99#define isConfigurationChanged(x) (engineConfiguration->x != activeConfiguration.x)
100#else
101// We cannot call prepareVoidConfiguration() for activeConfiguration if it's stored in flash,
102// so we need to tell the firmware that it's "void" (i.e. zeroed, invalid) by setting a special flag variable,
103// and then we consider 'x' as changed if it's just non-zero.
104extern bool isActiveConfigurationVoid;
105#define isConfigurationChanged(x) ((engineConfiguration->x != activeConfiguration.x) || (isActiveConfigurationVoid && (int)(engineConfiguration->x) != 0))
106#endif /* EFI_ACTIVE_CONFIGURATION_IN_FLASH */
107
108#define isPinOrModeChanged(pin, mode) (isConfigurationChanged(pin) || isConfigurationChanged(mode))
109
110// total number of outputs: low side + high side
static EngineAccessor engine
Definition engine.h:413
void setConstantDwell(floatms_t dwellMs)
Sets the same dwell time across the whole getRpm() range set dwell X.
void setBoardDefaultConfiguration()
Board-specific configuration defaults.
Gpio getWarningLedPin()
void onBurnRequest()
void setCamOperationMode()
void commonFrankensoAnalogInputs()
void setDefaultBasePins()
void incrementGlobalConfigurationVersion(const char *msg="undef")
int getBoardMetaLowSideOutputsCount()
void resetConfigurationExt(configuration_callback_t boardCallback, engine_type_e engineType)
int getBoardMetaDcOutputsCount()
void onBoardStandBy()
Gpio getCommsLedPin()
void setTargetRpmCurve(float rpm)
void setDefaultSdCardParameters()
static constexpr persistent_config_s * config
void setCrankOperationMode()
void loadConfiguration()
int getBoardMetaOutputsCount()
void setWholeIatCorrTimingTable(float value)
engine_configuration_s & activeConfiguration
Gpio getRunningLedPin()
void rememberCurrentConfiguration()
void applyEngineType(engine_type_e engineType)
void setBoardConfigOverrides()
void(* configuration_callback_t)(engine_configuration_s *)
void setWholeTimingTable(angle_t value)
void emptyCallbackWithConfiguration(engine_configuration_s *engine)
static constexpr engine_configuration_s * engineConfiguration
persistent_config_container_s persistentState
bool isActiveConfigurationVoid
void setFuelTablesLoadBin(float minValue, float maxValue)
int hackHellenBoardId(int detectedId)
Gpio * getBoardMetaOutputs()
void prepareVoidConfiguration(engine_configuration_s *activeConfiguration)
engine_type_e
float floatms_t
float angle_t