2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file engine_configuration.h
|
|
|
|
* @brief Main engine configuration data structure.
|
|
|
|
*
|
|
|
|
* @date Oct 30, 2013
|
2020-01-07 21:02:40 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
|
|
|
|
2019-12-14 12:33:30 -08:00
|
|
|
#pragma once
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2020-02-26 22:32:26 -08:00
|
|
|
#include "persistent_configuration.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2018-12-24 19:17:13 -08:00
|
|
|
#ifndef DEFAULT_ENGINE_TYPE
|
2022-02-09 16:49:41 -08:00
|
|
|
#define DEFAULT_ENGINE_TYPE MINIMAL_PINS
|
2018-12-24 19:17:13 -08:00
|
|
|
#endif
|
|
|
|
|
2017-06-11 12:27:23 -07:00
|
|
|
#define CLT_MANUAL_IDLE_CORRECTION config->cltIdleCorrBins, config->cltIdleCorr, CLT_CURVE_SIZE
|
|
|
|
#define WARMUP_CLT_EXTRA_FUEL_CURVE config->cltFuelCorrBins, config->cltFuelCorr, CLT_CURVE_SIZE
|
|
|
|
#define IAT_FUEL_CORRECTION_CURVE config->iatFuelCorrBins, config->iatFuelCorr, IAT_CURVE_SIZE
|
|
|
|
#define INJECTOR_LAG_CURVE engineConfiguration->injector.battLagCorrBins, engineConfiguration->injector.battLagCorr, VBAT_INJECTOR_CURVE_SIZE
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
#define MOCK_UNDEFINED -1
|
|
|
|
|
2022-04-02 23:21:37 -07:00
|
|
|
void setCrankOperationMode();
|
|
|
|
void setCamOperationMode();
|
|
|
|
void setTwoStrokeOperationMode();
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
void prepareVoidConfiguration(engine_configuration_s *activeConfiguration);
|
2021-11-16 01:15:29 -08:00
|
|
|
void setTargetRpmCurve(int rpm);
|
|
|
|
void setWholeIgnitionIatCorr(float value);
|
|
|
|
void setFuelTablesLoadBin(float minValue, float maxValue);
|
|
|
|
void setWholeIatCorrTimingTable(float value);
|
|
|
|
void setWholeTimingTable_d(angle_t value);
|
|
|
|
#define setWholeTimingTable(x) setWholeTimingTable_d(x);
|
|
|
|
void setConstantDwell(floatms_t dwellMs);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2017-05-30 10:50:33 -07:00
|
|
|
// needed by bootloader
|
2021-11-16 01:15:29 -08:00
|
|
|
void setDefaultBasePins();
|
2019-07-24 18:24:39 -07:00
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void setDefaultSdCardParameters();
|
2017-05-30 10:50:33 -07:00
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void onBurnRequest();
|
2023-04-19 19:09:48 -07:00
|
|
|
void incrementGlobalConfigurationVersion(const char * msg = "undef");
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2023-02-10 16:09:39 -08:00
|
|
|
void commonFrankensoAnalogInputs();
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-08-08 19:12:51 -07:00
|
|
|
void emptyCallbackWithConfiguration(engine_configuration_s * engine);
|
|
|
|
|
|
|
|
typedef void (*configuration_callback_t)(engine_configuration_s*);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
// because of 'Logging' class parameter these functions are visible only to C++ code but C code
|
2021-11-16 01:15:29 -08:00
|
|
|
void loadConfiguration();
|
2021-11-08 09:23:00 -08:00
|
|
|
/**
|
|
|
|
* boardCallback is invoked after configuration reset but before specific engineType configuration
|
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
void resetConfigurationExt(configuration_callback_t boardCallback, engine_type_e engineType);
|
|
|
|
void resetConfigurationExt(engine_type_e engineType);
|
2021-03-30 04:28:22 -07:00
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void rememberCurrentConfiguration();
|
2019-08-08 19:12:51 -07:00
|
|
|
#endif /* __cplusplus */
|
2020-04-25 21:07:59 -07:00
|
|
|
|
2021-03-31 11:46:50 -07:00
|
|
|
void setBoardDefaultConfiguration(void);
|
|
|
|
void setBoardConfigOverrides(void);
|
2022-01-15 07:36:49 -08:00
|
|
|
void boardOnConfigurationChange(engine_configuration_s *previousConfiguration);
|
2021-07-16 15:13:33 -07:00
|
|
|
|
|
|
|
#if !EFI_UNIT_TEST
|
|
|
|
extern persistent_config_container_s persistentState;
|
2021-11-17 00:53:17 -08:00
|
|
|
static engine_configuration_s * const engineConfiguration =
|
|
|
|
&persistentState.persistentConfiguration.engineConfiguration;
|
|
|
|
static persistent_config_s * const config = &persistentState.persistentConfiguration;
|
|
|
|
#else // EFI_UNIT_TEST
|
2021-11-15 21:23:14 -08:00
|
|
|
extern engine_configuration_s *engineConfiguration;
|
|
|
|
extern persistent_config_s *config;
|
2021-11-17 00:53:17 -08:00
|
|
|
#endif // EFI_UNIT_TEST
|
2021-07-16 15:13:33 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* & is reference in C++ (not C)
|
|
|
|
* Ref is a pointer that:
|
|
|
|
* you access with dot instead of arrow
|
|
|
|
* Cannot be null
|
|
|
|
* This is about EFI_ACTIVE_CONFIGURATION_IN_FLASH
|
|
|
|
*/
|
|
|
|
extern engine_configuration_s & activeConfiguration;
|
|
|
|
|
|
|
|
#if ! EFI_ACTIVE_CONFIGURATION_IN_FLASH
|
|
|
|
// We store a special changeable copy of configuration is RAM, so we can just compare them
|
|
|
|
#define isConfigurationChanged(x) (engineConfiguration->x != activeConfiguration.x)
|
|
|
|
#else
|
|
|
|
// We cannot call prepareVoidConfiguration() for activeConfiguration if it's stored in flash,
|
|
|
|
// so we need to tell the firmware that it's "void" (i.e. zeroed, invalid) by setting a special flag variable,
|
|
|
|
// and then we consider 'x' as changed if it's just non-zero.
|
|
|
|
extern bool isActiveConfigurationVoid;
|
2022-04-28 14:32:39 -07:00
|
|
|
#define isConfigurationChanged(x) ((engineConfiguration->x != activeConfiguration.x) || (isActiveConfigurationVoid && (int)(engineConfiguration->x) != 0))
|
2021-07-16 15:13:33 -07:00
|
|
|
#endif /* EFI_ACTIVE_CONFIGURATION_IN_FLASH */
|
|
|
|
|
|
|
|
#define isPinOrModeChanged(pin, mode) (isConfigurationChanged(pin) || isConfigurationChanged(mode))
|
2022-09-29 20:01:06 -07:00
|
|
|
|
|
|
|
int getBoardMetaOutputsCount();
|
2022-09-29 20:45:46 -07:00
|
|
|
Gpio* getBoardMetaOutputs();
|