2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file engine_configuration.cpp
|
|
|
|
* @brief Utility method related to the engine configuration data structure.
|
|
|
|
*
|
|
|
|
* @date Nov 22, 2013
|
2020-01-07 21:02:40 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2015-07-10 06:01:56 -07:00
|
|
|
*
|
|
|
|
* This file is part of rusEfi - see http://rusefi.com
|
|
|
|
*
|
|
|
|
* rusEfi is free software; you can redistribute it and/or modify it under the terms of
|
|
|
|
* the GNU General Public License as published by the Free Software Foundation; either
|
|
|
|
* version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* rusEfi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
|
|
|
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with this program.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-07-25 22:05:17 -07:00
|
|
|
#include "pch.h"
|
|
|
|
|
2022-09-07 12:56:45 -07:00
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
#include "speed_density.h"
|
|
|
|
#include "advance_map.h"
|
2021-03-25 15:16:26 -07:00
|
|
|
#include "flash_main.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2022-01-03 00:35:26 -08:00
|
|
|
#include "bench_test.h"
|
2021-01-22 21:00:34 -08:00
|
|
|
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_MEMS
|
2017-08-18 13:18:11 -07:00
|
|
|
#include "accelerometer.h"
|
2019-04-02 20:19:21 -07:00
|
|
|
#endif
|
2017-08-16 23:56:25 -07:00
|
|
|
|
2021-06-02 14:50:07 -07:00
|
|
|
#include "defaults.h"
|
2021-10-02 09:50:06 -07:00
|
|
|
|
2019-11-14 20:58:04 -08:00
|
|
|
#include "bmw_m73.h"
|
2021-10-02 09:50:06 -07:00
|
|
|
#include "bmw_n73.h"
|
2016-10-04 12:02:36 -07:00
|
|
|
|
2021-10-02 09:50:06 -07:00
|
|
|
#include "citroenBerlingoTU3JP.h"
|
|
|
|
#include "custom_engine.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
#include "dodge_neon.h"
|
2016-10-04 12:02:36 -07:00
|
|
|
#include "dodge_ram.h"
|
|
|
|
|
2021-10-02 09:50:06 -07:00
|
|
|
#include "engine_template.h"
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
#include "ford_aspire.h"
|
|
|
|
#include "ford_1995_inline_6.h"
|
2016-10-04 12:02:36 -07:00
|
|
|
|
2021-10-02 09:50:06 -07:00
|
|
|
#include "honda_k_dbc.h"
|
|
|
|
#include "honda_600.h"
|
2021-10-11 12:04:27 -07:00
|
|
|
#include "hyundai.h"
|
2021-10-02 09:50:06 -07:00
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
#include "GY6_139QMB.h"
|
2016-10-04 12:02:36 -07:00
|
|
|
|
2021-10-02 09:50:06 -07:00
|
|
|
#include "nissan_primera.h"
|
|
|
|
#include "nissan_vq.h"
|
|
|
|
|
2016-10-04 12:02:36 -07:00
|
|
|
#include "mazda_miata.h"
|
|
|
|
#include "mazda_miata_1_6.h"
|
2018-09-06 19:41:05 -07:00
|
|
|
#include "mazda_miata_na8.h"
|
2016-10-04 12:02:36 -07:00
|
|
|
#include "mazda_miata_vvt.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
#include "mazda_626.h"
|
2020-12-14 21:09:35 -08:00
|
|
|
#include "m111.h"
|
2021-09-17 21:17:52 -07:00
|
|
|
#include "mercedes.h"
|
2021-10-02 09:50:06 -07:00
|
|
|
|
2022-10-27 17:49:06 -07:00
|
|
|
#include "gm_ls_4.h"
|
2023-03-26 08:35:32 -07:00
|
|
|
#include "gm_sbc.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
#include "subaru.h"
|
|
|
|
#include "test_engine.h"
|
|
|
|
#include "sachs.h"
|
|
|
|
#include "vw.h"
|
2019-12-26 18:33:12 -08:00
|
|
|
#include "vw_b6.h"
|
2015-10-16 13:01:21 -07:00
|
|
|
#include "chevrolet_camaro_4.h"
|
2015-12-30 13:02:18 -08:00
|
|
|
#include "toyota_jzs147.h"
|
2023-06-18 06:41:02 -07:00
|
|
|
#include "toyota_1NZ_FE.h"
|
|
|
|
#include "mitsubishi_3A92.h"
|
2023-06-18 07:07:50 -07:00
|
|
|
#include "mitsubishi_4G93.h"
|
2016-01-04 02:02:45 -08:00
|
|
|
#include "ford_festiva.h"
|
2020-02-02 00:56:21 -08:00
|
|
|
#include "boost_control.h"
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_IDLE_CONTROL
|
2017-12-03 12:31:11 -08:00
|
|
|
#include "idle_thread.h"
|
2018-10-30 04:58:50 -07:00
|
|
|
#endif /* EFI_IDLE_CONTROL */
|
|
|
|
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_ALTERNATOR_CONTROL
|
2019-03-31 13:56:13 -07:00
|
|
|
#include "alternator_controller.h"
|
2018-10-30 04:58:50 -07:00
|
|
|
#endif
|
|
|
|
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_ELECTRONIC_THROTTLE_BODY
|
2018-10-30 04:58:50 -07:00
|
|
|
#include "electronic_throttle.h"
|
|
|
|
#endif
|
|
|
|
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_HIP_9011
|
2019-04-09 16:12:35 -07:00
|
|
|
#include "hip9011.h"
|
2018-10-30 04:58:50 -07:00
|
|
|
#endif
|
|
|
|
|
2021-07-14 22:28:44 -07:00
|
|
|
#include "hardware.h"
|
|
|
|
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_PROD_CODE
|
2017-12-03 12:31:11 -08:00
|
|
|
#include "board.h"
|
|
|
|
#endif /* EFI_PROD_CODE */
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_EMULATE_POSITION_SENSORS
|
2020-04-24 11:00:06 -07:00
|
|
|
#include "trigger_emulator_algo.h"
|
2017-12-17 12:41:58 -08:00
|
|
|
#endif /* EFI_EMULATE_POSITION_SENSORS */
|
|
|
|
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_TUNER_STUDIO
|
2015-07-10 06:01:56 -07:00
|
|
|
#include "tunerstudio.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//#define TS_DEFAULT_SPEED 115200
|
|
|
|
#define TS_DEFAULT_SPEED 38400
|
|
|
|
|
2016-09-13 17:03:14 -07:00
|
|
|
/**
|
|
|
|
* Current engine configuration. On firmware start we assign empty configuration, then
|
2022-12-20 05:48:28 -08:00
|
|
|
* we copy actual configuration after reading settings from flash.
|
2022-12-20 05:48:51 -08:00
|
|
|
* This is useful to compare old/current (activeConfiguration) and new/future (engineConfiguration) configurations in order to apply new settings.
|
2016-09-13 17:03:14 -07:00
|
|
|
*
|
|
|
|
* todo: place this field next to 'engineConfiguration'?
|
|
|
|
*/
|
2023-04-19 17:29:33 -07:00
|
|
|
static bool hasRememberedConfiguration = false;
|
2020-12-16 19:53:26 -08:00
|
|
|
#if EFI_ACTIVE_CONFIGURATION_IN_FLASH
|
2020-04-25 13:32:32 -07:00
|
|
|
#include "flash_int.h"
|
2020-02-04 18:36:38 -08:00
|
|
|
engine_configuration_s & activeConfiguration = reinterpret_cast<persistent_config_container_s*>(getFlashAddrFirstCopy())->persistentConfiguration.engineConfiguration;
|
2019-11-24 21:02:53 -08:00
|
|
|
// we cannot use this activeConfiguration until we call rememberCurrentConfiguration()
|
|
|
|
bool isActiveConfigurationVoid = true;
|
2019-04-15 05:40:12 -07:00
|
|
|
#else
|
2019-10-31 13:06:34 -07:00
|
|
|
static engine_configuration_s activeConfigurationLocalStorage;
|
|
|
|
engine_configuration_s & activeConfiguration = activeConfigurationLocalStorage;
|
2019-04-15 05:40:12 -07:00
|
|
|
#endif /* EFI_ACTIVE_CONFIGURATION_IN_FLASH */
|
2016-09-13 17:03:14 -07:00
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void rememberCurrentConfiguration() {
|
2020-12-16 19:00:42 -08:00
|
|
|
#if ! EFI_ACTIVE_CONFIGURATION_IN_FLASH
|
2016-09-13 17:03:14 -07:00
|
|
|
memcpy(&activeConfiguration, engineConfiguration, sizeof(engine_configuration_s));
|
2019-11-24 21:02:53 -08:00
|
|
|
#else
|
|
|
|
isActiveConfigurationVoid = false;
|
2019-04-15 05:40:12 -07:00
|
|
|
#endif /* EFI_ACTIVE_CONFIGURATION_IN_FLASH */
|
2023-04-19 17:29:33 -07:00
|
|
|
hasRememberedConfiguration = true;
|
2016-09-13 17:03:14 -07:00
|
|
|
}
|
|
|
|
|
2020-07-05 08:16:07 -07:00
|
|
|
static void wipeString(char *string, int size) {
|
|
|
|
// we have to reset bytes after \0 symbol in order to calculate correct tune CRC from MSQ file
|
|
|
|
for (int i = strlen(string) + 1; i < size; i++) {
|
|
|
|
string[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
static void wipeStrings() {
|
2020-07-05 08:16:07 -07:00
|
|
|
wipeString(engineConfiguration->engineMake, sizeof(vehicle_info_t));
|
|
|
|
wipeString(engineConfiguration->engineCode, sizeof(vehicle_info_t));
|
|
|
|
wipeString(engineConfiguration->vehicleName, sizeof(vehicle_info_t));
|
2020-07-05 10:34:51 -07:00
|
|
|
}
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void onBurnRequest() {
|
|
|
|
wipeStrings();
|
2020-07-05 08:16:07 -07:00
|
|
|
|
2023-04-19 19:09:48 -07:00
|
|
|
incrementGlobalConfigurationVersion("burn");
|
2020-07-05 08:16:07 -07:00
|
|
|
}
|
|
|
|
|
2022-01-09 22:47:06 -08:00
|
|
|
// Weak link a stub so that every board doesn't have to implement this function
|
2022-01-31 15:37:42 -08:00
|
|
|
__attribute__((weak)) void boardOnConfigurationChange(engine_configuration_s* /*previousConfiguration*/) { }
|
2022-01-09 22:47:06 -08:00
|
|
|
|
2016-09-13 17:03:14 -07:00
|
|
|
/**
|
|
|
|
* this is the top-level method which should be called in case of any changes to engine configuration
|
|
|
|
* online tuning of most values in the maps does not count as configuration change, but 'Burn' command does
|
2019-10-30 17:51:20 -07:00
|
|
|
*
|
|
|
|
* this method is NOT currently invoked on ECU start - actual user input has to happen!
|
2020-06-04 17:43:52 -07:00
|
|
|
* See preCalculate which is invoked BOTH on start and configuration change
|
2016-09-13 17:03:14 -07:00
|
|
|
*/
|
2023-04-19 19:09:48 -07:00
|
|
|
void incrementGlobalConfigurationVersion(const char * msg) {
|
2023-04-19 17:29:33 -07:00
|
|
|
if (!hasRememberedConfiguration) {
|
2023-04-28 21:13:13 -07:00
|
|
|
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "too early to invoke incrementGlobalConfigurationVersion %s", msg);
|
2023-04-19 17:29:33 -07:00
|
|
|
}
|
2021-11-17 10:45:10 -08:00
|
|
|
engine->globalConfigurationVersion++;
|
2018-03-04 18:32:48 -08:00
|
|
|
#if EFI_DEFAILED_LOGGING
|
2021-04-19 05:11:59 -07:00
|
|
|
efiPrintf("set globalConfigurationVersion=%d", globalConfigurationVersion);
|
2018-03-04 18:32:48 -08:00
|
|
|
#endif /* EFI_DEFAILED_LOGGING */
|
2021-07-14 22:28:44 -07:00
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
applyNewHardwareSettings();
|
2021-07-14 22:28:44 -07:00
|
|
|
|
2022-01-09 22:47:06 -08:00
|
|
|
boardOnConfigurationChange(&activeConfiguration);
|
|
|
|
|
2016-09-15 20:01:48 -07:00
|
|
|
/**
|
|
|
|
* All these callbacks could be implemented as listeners, but these days I am saving RAM
|
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
engine->preCalculate();
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_ALTERNATOR_CONTROL
|
2016-09-15 20:01:48 -07:00
|
|
|
onConfigurationChangeAlternatorCallback(&activeConfiguration);
|
2017-03-20 19:22:06 -07:00
|
|
|
#endif /* EFI_ALTERNATOR_CONTROL */
|
2020-02-02 00:56:21 -08:00
|
|
|
|
|
|
|
#if EFI_BOOST_CONTROL
|
|
|
|
onConfigurationChangeBoostCallback(&activeConfiguration);
|
|
|
|
#endif
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_ELECTRONIC_THROTTLE_BODY
|
2017-05-27 20:01:41 -07:00
|
|
|
onConfigurationChangeElectronicThrottleCallback(&activeConfiguration);
|
|
|
|
#endif /* EFI_ELECTRONIC_THROTTLE_BODY */
|
|
|
|
|
2022-01-03 00:35:26 -08:00
|
|
|
#if EFI_ENGINE_CONTROL && EFI_PROD_CODE
|
|
|
|
onConfigurationChangeBenchTest();
|
|
|
|
#endif
|
|
|
|
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_SHAFT_POSITION_INPUT
|
2021-11-16 01:15:29 -08:00
|
|
|
onConfigurationChangeTriggerCallback();
|
2017-06-26 11:31:10 -07:00
|
|
|
#endif /* EFI_SHAFT_POSITION_INPUT */
|
2021-06-25 08:50:23 -07:00
|
|
|
#if EFI_EMULATE_POSITION_SENSORS && ! EFI_UNIT_TEST
|
2017-12-17 12:41:58 -08:00
|
|
|
onConfigurationChangeRpmEmulatorCallback(&activeConfiguration);
|
|
|
|
#endif /* EFI_EMULATE_POSITION_SENSORS */
|
2018-02-03 08:42:50 -08:00
|
|
|
|
2021-11-17 10:45:10 -08:00
|
|
|
engine->engineModules.apply_all([](auto & m) {
|
2021-11-17 09:13:19 -08:00
|
|
|
m.onConfigurationChange(&activeConfiguration);
|
|
|
|
});
|
2021-11-16 01:15:29 -08:00
|
|
|
rememberCurrentConfiguration();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Sets the same dwell time across the whole getRpm() range
|
2019-11-05 20:17:44 -08:00
|
|
|
* set dwell X
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
void setConstantDwell(floatms_t dwellMs) {
|
2015-07-10 06:01:56 -07:00
|
|
|
for (int i = 0; i < DWELL_CURVE_SIZE; i++) {
|
2022-05-01 20:43:43 -07:00
|
|
|
config->sparkDwellRpmBins[i] = 1000 * i;
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
2022-05-01 20:43:43 -07:00
|
|
|
setArrayValues(config->sparkDwellValues, dwellMs);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void setWholeIgnitionIatCorr(float value) {
|
2021-05-04 07:03:41 -07:00
|
|
|
setTable(config->ignitionIatCorrTable, value);
|
2015-10-18 18:02:32 -07:00
|
|
|
}
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void setFuelTablesLoadBin(float minValue, float maxValue) {
|
2019-11-22 20:27:24 -08:00
|
|
|
setLinearCurve(config->injPhaseLoadBins, minValue, maxValue, 1);
|
|
|
|
setLinearCurve(config->veLoadBins, minValue, maxValue, 1);
|
2020-10-26 15:15:17 -07:00
|
|
|
setLinearCurve(config->lambdaLoadBins, minValue, maxValue, 1);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void setWholeIatCorrTimingTable(float value) {
|
2021-05-09 11:37:16 -07:00
|
|
|
setTable(config->ignitionIatCorrTable, value);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* See also crankingTimingAngle
|
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
void setWholeTimingTable_d(angle_t value) {
|
2021-05-09 11:37:16 -07:00
|
|
|
setTable(config->ignitionTable, value);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2017-06-11 12:13:03 -07:00
|
|
|
static void initTemperatureCurve(float *bins, float *values, int size, float defaultValue) {
|
2015-07-10 06:01:56 -07:00
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
bins[i] = -40 + i * 10;
|
2016-02-15 16:02:15 -08:00
|
|
|
values[i] = defaultValue; // this correction is a multiplier
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-04 14:53:52 -08:00
|
|
|
void prepareVoidConfiguration(engine_configuration_s *engineConfiguration) {
|
2023-04-11 17:01:34 -07:00
|
|
|
efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, engineConfiguration != NULL, "ec NULL");
|
2021-05-20 17:00:32 -07:00
|
|
|
efi::clear(engineConfiguration);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->clutchDownPinMode = PI_PULLUP;
|
2019-11-30 07:24:37 -08:00
|
|
|
engineConfiguration->clutchUpPinMode = PI_PULLUP;
|
2017-05-15 01:53:04 -07:00
|
|
|
engineConfiguration->brakePedalPinMode = PI_PULLUP;
|
2015-12-02 17:10:06 -08:00
|
|
|
}
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void setDefaultBasePins() {
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_PROD_CODE
|
2017-12-24 10:45:03 -08:00
|
|
|
// call overrided board-specific serial configuration setup, if needed (for custom boards only)
|
|
|
|
// needed also by bootloader code
|
|
|
|
setPinConfigurationOverrides();
|
2019-04-21 11:00:19 -07:00
|
|
|
#endif /* EFI_PROD_CODE */
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-07-24 18:24:39 -07:00
|
|
|
// set UART pads configuration based on the board
|
2017-05-30 10:50:33 -07:00
|
|
|
// needed also by bootloader code
|
2023-02-19 11:53:14 -08:00
|
|
|
#ifdef TS_SECONDARY_UxART_PORT
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->binarySerialTxPin = Gpio::C10;
|
|
|
|
engineConfiguration->binarySerialRxPin = Gpio::C11;
|
2023-02-19 11:53:14 -08:00
|
|
|
#endif // TS_SECONDARY_UxART_PORT
|
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->tunerStudioSerialSpeed = TS_DEFAULT_SPEED;
|
2017-05-30 10:50:33 -07:00
|
|
|
engineConfiguration->uartConsoleSerialSpeed = 115200;
|
|
|
|
}
|
|
|
|
|
|
|
|
// needed also by bootloader code
|
2019-04-21 11:00:19 -07:00
|
|
|
// at the moment bootloader does NOT really need SD card, this is a step towards future bootloader SD card usage
|
2021-11-16 01:15:29 -08:00
|
|
|
void setDefaultSdCardParameters() {
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->isSdCardEnabled = true;
|
2017-05-30 10:50:33 -07:00
|
|
|
}
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
static void setDefaultWarmupIdleCorrection() {
|
2019-06-13 06:05:22 -07:00
|
|
|
initTemperatureCurve(CLT_MANUAL_IDLE_CORRECTION, 1.0);
|
2017-05-11 15:58:13 -07:00
|
|
|
|
2017-05-11 19:58:06 -07:00
|
|
|
float baseIdle = 30;
|
|
|
|
|
2019-06-13 06:05:22 -07:00
|
|
|
setCurveValue(CLT_MANUAL_IDLE_CORRECTION, -40, 1.5);
|
|
|
|
setCurveValue(CLT_MANUAL_IDLE_CORRECTION, -30, 1.5);
|
|
|
|
setCurveValue(CLT_MANUAL_IDLE_CORRECTION, -20, 40.0 / baseIdle);
|
|
|
|
setCurveValue(CLT_MANUAL_IDLE_CORRECTION, -10, 40.0 / baseIdle);
|
|
|
|
setCurveValue(CLT_MANUAL_IDLE_CORRECTION, 0, 40.0 / baseIdle);
|
|
|
|
setCurveValue(CLT_MANUAL_IDLE_CORRECTION, 10, 40.0 / baseIdle);
|
|
|
|
setCurveValue(CLT_MANUAL_IDLE_CORRECTION, 20, 40.0 / baseIdle);
|
|
|
|
setCurveValue(CLT_MANUAL_IDLE_CORRECTION, 30, 40.0 / baseIdle);
|
|
|
|
setCurveValue(CLT_MANUAL_IDLE_CORRECTION, 40, 40.0 / baseIdle);
|
|
|
|
setCurveValue(CLT_MANUAL_IDLE_CORRECTION, 50, 37.0 / baseIdle);
|
|
|
|
setCurveValue(CLT_MANUAL_IDLE_CORRECTION, 60, 35.0 / baseIdle);
|
|
|
|
setCurveValue(CLT_MANUAL_IDLE_CORRECTION, 70, 33.0 / baseIdle);
|
2017-05-11 15:58:13 -07:00
|
|
|
}
|
|
|
|
|
2018-01-07 09:11:49 -08:00
|
|
|
/**
|
|
|
|
* see also setTargetRpmCurve()
|
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
static void setDefaultIdleSpeedTarget() {
|
2022-06-29 15:48:30 -07:00
|
|
|
copyArray(config->cltIdleRpmBins, { -30, - 20, -10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 , 110, 120 });
|
|
|
|
copyArray(config->cltIdleRpm, { 1350, 1350, 1300, 1200, 1150, 1100, 1050, 1000, 1000, 950, 950, 930, 900, 900, 1000, 1100 });
|
2017-05-11 16:03:31 -07:00
|
|
|
}
|
|
|
|
|
2018-01-07 09:11:49 -08:00
|
|
|
/**
|
|
|
|
* see also setDefaultIdleSpeedTarget()
|
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
void setTargetRpmCurve(int rpm) {
|
2022-05-01 20:43:43 -07:00
|
|
|
setLinearCurve(config->cltIdleRpmBins, CLT_CURVE_RANGE_FROM, 140, 10);
|
|
|
|
setLinearCurve(config->cltIdleRpm, rpm, rpm, 10);
|
2017-12-24 19:05:16 -08:00
|
|
|
}
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void setDefaultGppwmParameters() {
|
2020-04-26 11:06:28 -07:00
|
|
|
// Same config for all channels
|
2021-11-17 00:54:21 -08:00
|
|
|
for (size_t i = 0; i < efi::size(engineConfiguration->gppwm); i++) {
|
|
|
|
auto& cfg = engineConfiguration->gppwm[i];
|
2022-10-13 17:30:30 -07:00
|
|
|
chsnprintf(engineConfiguration->gpPwmNote[i], sizeof(engineConfiguration->gpPwmNote[0]), "GPPWM%d", i);
|
2020-04-26 11:06:28 -07:00
|
|
|
|
2023-02-06 04:53:31 -08:00
|
|
|
// Set default axes
|
|
|
|
cfg.loadAxis = GPPWM_Zero;
|
|
|
|
cfg.rpmAxis = GPPWM_Rpm;
|
|
|
|
|
2022-04-28 14:32:39 -07:00
|
|
|
cfg.pin = Gpio::Unassigned;
|
2020-04-26 11:06:28 -07:00
|
|
|
cfg.dutyIfError = 0;
|
|
|
|
cfg.onAboveDuty = 60;
|
|
|
|
cfg.offBelowDuty = 50;
|
|
|
|
cfg.pwmFrequency = 250;
|
|
|
|
|
|
|
|
for (size_t j = 0; j < efi::size(cfg.loadBins); j++) {
|
|
|
|
uint8_t z = j * 100 / (efi::size(cfg.loadBins) - 1);
|
|
|
|
cfg.loadBins[j] = z;
|
|
|
|
|
|
|
|
// Fill some values in the table
|
|
|
|
for (size_t k = 0; k < efi::size(cfg.rpmBins); k++) {
|
|
|
|
cfg.table[j][k] = z;
|
|
|
|
}
|
2020-09-07 12:55:43 -07:00
|
|
|
|
2020-04-26 11:06:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t j = 0; j < efi::size(cfg.rpmBins); j++) {
|
2021-12-22 05:09:41 -08:00
|
|
|
cfg.rpmBins[j] = 1000 * j;
|
2020-04-26 11:06:28 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
static void setDefaultEngineNoiseTable() {
|
2022-12-13 13:47:35 -08:00
|
|
|
setRpmTableBin(engineConfiguration->knockNoiseRpmBins);
|
2021-03-30 07:56:25 -07:00
|
|
|
|
2021-08-09 14:07:38 -07:00
|
|
|
engineConfiguration->knockSamplingDuration = 45;
|
|
|
|
|
2022-04-18 05:03:16 -07:00
|
|
|
setArrayValues(engineConfiguration->knockBaseNoise, -20);
|
2021-03-30 07:56:25 -07:00
|
|
|
}
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @brief Global default engine configuration
|
2015-09-26 06:01:32 -07:00
|
|
|
* This method sets the global engine configuration defaults. These default values are then
|
|
|
|
* overridden by engine-specific defaults and the settings are saved in flash memory.
|
|
|
|
*
|
|
|
|
* This method is invoked only when new configuration is needed:
|
|
|
|
* * recently re-flashed chip
|
|
|
|
* * flash version of configuration failed CRC check or appears to be older then FLASH_DATA_VERSION
|
|
|
|
* * 'rewriteconfig' command
|
2017-01-06 07:04:41 -08:00
|
|
|
* * 'set engine_type X' command
|
2015-12-21 17:02:32 -08:00
|
|
|
*
|
|
|
|
* This method should only change the state of the configuration data structure but should NOT change the state of
|
|
|
|
* anything else.
|
2019-07-24 18:15:18 -07:00
|
|
|
*
|
|
|
|
* This method should NOT be setting any default pinout
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
static void setDefaultEngineConfiguration() {
|
2023-05-24 07:00:58 -07:00
|
|
|
#if EFI_ENGINE_CONTROL
|
2019-04-12 19:07:03 -07:00
|
|
|
#if (! EFI_UNIT_TEST)
|
2021-05-20 17:00:32 -07:00
|
|
|
efi::clear(persistentState.persistentConfiguration);
|
2015-07-10 06:01:56 -07:00
|
|
|
#endif
|
|
|
|
prepareVoidConfiguration(engineConfiguration);
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
setDefaultBaseEngine();
|
|
|
|
setDefaultFuel();
|
|
|
|
setDefaultIgnition();
|
|
|
|
setDefaultCranking();
|
2019-07-24 18:15:18 -07:00
|
|
|
|
2021-10-29 09:16:19 -07:00
|
|
|
// VVT closed loop, totally random values!
|
|
|
|
engineConfiguration->auxPid[0].pFactor = 2;
|
|
|
|
engineConfiguration->auxPid[0].iFactor = 0.005;
|
|
|
|
engineConfiguration->auxPid[0].dFactor = 0;
|
|
|
|
engineConfiguration->auxPid[0].offset = 33;
|
|
|
|
engineConfiguration->auxPid[0].minValue = 10;
|
|
|
|
engineConfiguration->auxPid[0].maxValue = 90;
|
|
|
|
|
2021-10-31 12:25:43 -07:00
|
|
|
engineConfiguration->vvtOutputFrequency[0] = 300; // VVT solenoid control
|
2021-10-29 09:16:19 -07:00
|
|
|
|
2021-11-24 20:32:55 -08:00
|
|
|
engineConfiguration->isCylinderCleanupEnabled = true;
|
|
|
|
|
2021-10-29 09:16:19 -07:00
|
|
|
engineConfiguration->auxPid[1].minValue = 10;
|
2021-11-19 22:38:39 -08:00
|
|
|
engineConfiguration->auxPid[1].maxValue = 90;
|
2021-10-29 09:16:19 -07:00
|
|
|
|
2021-11-04 16:35:58 -07:00
|
|
|
engineConfiguration->turboSpeedSensorMultiplier = 1;
|
2021-10-29 09:16:19 -07:00
|
|
|
|
2019-08-29 20:50:20 -07:00
|
|
|
#if EFI_IDLE_CONTROL
|
2021-11-16 01:15:29 -08:00
|
|
|
setDefaultIdleParameters();
|
2019-08-29 20:50:20 -07:00
|
|
|
#endif /* EFI_IDLE_CONTROL */
|
|
|
|
|
2019-07-24 18:15:18 -07:00
|
|
|
#if EFI_ELECTRONIC_THROTTLE_BODY
|
2021-11-16 01:15:29 -08:00
|
|
|
setDefaultEtbParameters();
|
|
|
|
setDefaultEtbBiasCurve();
|
2019-07-24 18:15:18 -07:00
|
|
|
#endif /* EFI_ELECTRONIC_THROTTLE_BODY */
|
2020-02-02 00:56:21 -08:00
|
|
|
#if EFI_BOOST_CONTROL
|
2021-11-16 01:15:29 -08:00
|
|
|
setDefaultBoostParameters();
|
2020-02-02 00:56:21 -08:00
|
|
|
#endif
|
2019-07-24 18:15:18 -07:00
|
|
|
|
2020-09-01 19:24:25 -07:00
|
|
|
// OBD-II default rate is 500kbps
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->canBaudRate = B500KBPS;
|
2022-02-09 21:53:44 -08:00
|
|
|
engineConfiguration->can2BaudRate = B500KBPS;
|
2020-09-01 19:24:25 -07:00
|
|
|
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->mafSensorType = Bosch0280218037;
|
2015-07-10 06:01:56 -07:00
|
|
|
setBosch0280218037(config);
|
|
|
|
|
2019-07-24 18:24:39 -07:00
|
|
|
engineConfiguration->canSleepPeriodMs = 50;
|
|
|
|
engineConfiguration->canReadEnabled = true;
|
|
|
|
engineConfiguration->canWriteEnabled = true;
|
|
|
|
|
2020-03-19 06:22:16 -07:00
|
|
|
// Don't enable, but set default address
|
2020-03-29 18:15:06 -07:00
|
|
|
engineConfiguration->verboseCanBaseAddress = CAN_DEFAULT_BASE;
|
2020-03-19 06:22:16 -07:00
|
|
|
|
2022-11-27 05:10:05 -08:00
|
|
|
engineConfiguration->sdCardLogFrequency = 50;
|
2019-09-20 17:18:22 -07:00
|
|
|
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->mapMinBufferLength = 1;
|
2022-04-10 16:11:34 -07:00
|
|
|
engineConfiguration->vvtActivationDelayMs = 6000;
|
2021-06-02 14:50:07 -07:00
|
|
|
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->startCrankingDuration = 3;
|
2020-03-24 21:58:59 -07:00
|
|
|
|
2021-07-04 06:22:42 -07:00
|
|
|
engineConfiguration->maxAcRpm = 5000;
|
|
|
|
engineConfiguration->maxAcClt = 100;
|
|
|
|
engineConfiguration->maxAcTps = 75;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2017-06-11 12:17:02 -07:00
|
|
|
initTemperatureCurve(IAT_FUEL_CORRECTION_CURVE, 1);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2017-05-28 19:32:32 -07:00
|
|
|
engineConfiguration->auxPid[0].minValue = 10;
|
|
|
|
engineConfiguration->auxPid[0].maxValue = 90;
|
2017-04-10 11:59:21 -07:00
|
|
|
|
2022-04-10 16:11:34 -07:00
|
|
|
engineConfiguration->alternatorControl.minValue = 0;
|
2017-05-28 19:32:32 -07:00
|
|
|
engineConfiguration->alternatorControl.maxValue = 90;
|
2017-04-10 11:59:21 -07:00
|
|
|
|
2022-05-01 20:43:43 -07:00
|
|
|
setLinearCurve(config->scriptCurve1Bins, 0, 100, 1);
|
|
|
|
setLinearCurve(config->scriptCurve1, 0, 100, 1);
|
2017-11-27 18:49:58 -08:00
|
|
|
|
2023-06-06 16:26:21 -07:00
|
|
|
setLinearCurve(config->scriptCurve2Bins, 0, 100, /*precision*/1);
|
2022-05-01 20:43:43 -07:00
|
|
|
setLinearCurve(config->scriptCurve2, 30, 170, 1);
|
2017-11-27 18:49:58 -08:00
|
|
|
|
2022-05-01 20:43:43 -07:00
|
|
|
setLinearCurve(config->scriptCurve3Bins, 0, 100, 1);
|
|
|
|
setLinearCurve(config->scriptCurve4Bins, 0, 100, 1);
|
|
|
|
setLinearCurve(config->scriptCurve5Bins, 0, 100, 1);
|
|
|
|
setLinearCurve(config->scriptCurve6Bins, 0, 100, 1);
|
2017-11-25 22:17:37 -08:00
|
|
|
|
2023-06-06 16:26:21 -07:00
|
|
|
setLinearCurve(config->alsIgnRetardLoadBins, 2, 10, /*precision*/1);
|
2022-12-21 18:29:01 -08:00
|
|
|
setRpmTableBin(config->alsIgnRetardrpmBins);
|
2023-06-06 16:26:21 -07:00
|
|
|
setLinearCurve(config->alsFuelAdjustmentLoadBins, 2, 10, /*precision*/1);
|
2022-12-22 11:38:40 -08:00
|
|
|
setRpmTableBin(config->alsFuelAdjustmentrpmBins);
|
2023-06-06 16:26:21 -07:00
|
|
|
setLinearCurve(engineConfiguration->fuelLevelBins, 0, 5);
|
2022-12-21 18:29:01 -08:00
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
setDefaultWarmupIdleCorrection();
|
2016-02-14 10:02:00 -08:00
|
|
|
|
2019-11-22 20:27:24 -08:00
|
|
|
setLinearCurve(engineConfiguration->map.samplingAngleBins, 800, 7000, 1);
|
|
|
|
setLinearCurve(engineConfiguration->map.samplingAngle, 100, 130, 1);
|
|
|
|
setLinearCurve(engineConfiguration->map.samplingWindowBins, 800, 7000, 1);
|
|
|
|
setLinearCurve(engineConfiguration->map.samplingWindow, 50, 50, 1);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-02-10 09:41:38 -08:00
|
|
|
setLinearCurve(config->vvtTable1LoadBins, 20, 120, 10);
|
2022-12-13 13:47:35 -08:00
|
|
|
setRpmTableBin(config->vvtTable1RpmBins);
|
2021-02-10 09:41:38 -08:00
|
|
|
setLinearCurve(config->vvtTable2LoadBins, 20, 120, 10);
|
2022-12-13 13:47:35 -08:00
|
|
|
setRpmTableBin(config->vvtTable2RpmBins);
|
2021-11-14 07:39:47 -08:00
|
|
|
setLinearCurve(config->scriptTable1LoadBins, 20, 120, 10);
|
2022-12-13 13:47:35 -08:00
|
|
|
setRpmTableBin(config->scriptTable1RpmBins);
|
2021-11-14 07:39:47 -08:00
|
|
|
setLinearCurve(config->scriptTable2LoadBins, 20, 120, 10);
|
2022-12-13 13:47:35 -08:00
|
|
|
setRpmTableBin(config->scriptTable2RpmBins);
|
2021-11-14 07:39:47 -08:00
|
|
|
setLinearCurve(config->scriptTable3LoadBins, 20, 120, 10);
|
2022-12-13 13:47:35 -08:00
|
|
|
setRpmTableBin(config->scriptTable3RpmBins);
|
2021-11-14 07:39:47 -08:00
|
|
|
setLinearCurve(config->scriptTable4LoadBins, 20, 120, 10);
|
2022-12-13 13:47:35 -08:00
|
|
|
setRpmTableBin(config->scriptTable4RpmBins);
|
2016-03-03 21:02:18 -08:00
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
setDefaultEngineNoiseTable();
|
2016-01-01 14:02:49 -08:00
|
|
|
|
2023-06-12 16:33:05 -07:00
|
|
|
// is this same old setCommonNTCSensor?
|
2019-10-02 18:00:10 -07:00
|
|
|
engineConfiguration->clt.config = {0, 23.8889, 48.8889, 9500, 2100, 1000, 1500};
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2023-06-12 16:59:12 -07:00
|
|
|
setCommonNTCSensor(&engineConfiguration->iat, 2700);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-11-15 18:13:01 -08:00
|
|
|
// wow unit tests have much cooler setDefaultLaunchParameters method
|
2020-02-02 07:44:31 -08:00
|
|
|
engineConfiguration->launchRpm = 3000;
|
2021-11-15 18:13:01 -08:00
|
|
|
// engineConfiguration->launchTimingRetard = 10;
|
2020-02-02 07:44:31 -08:00
|
|
|
engineConfiguration->launchTimingRpmRange = 500;
|
2021-11-15 18:13:01 -08:00
|
|
|
engineConfiguration->launchSpeedThreshold = 30;
|
2020-02-02 07:44:31 -08:00
|
|
|
engineConfiguration->hardCutRpmRange = 500;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2016-01-30 19:03:36 -08:00
|
|
|
engineConfiguration->engineSnifferRpmThreshold = 2500;
|
|
|
|
engineConfiguration->sensorSnifferRpmThreshold = 2500;
|
2016-07-01 07:02:58 -07:00
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
engineConfiguration->noAccelAfterHardLimitPeriodSecs = 3;
|
|
|
|
|
2018-01-07 09:11:49 -08:00
|
|
|
/**
|
|
|
|
* Idle control defaults
|
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
setDefaultIdleSpeedTarget();
|
|
|
|
// setTargetRpmCurve(1200);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2017-06-04 17:13:37 -07:00
|
|
|
engineConfiguration->idleRpmPid.pFactor = 0.05;
|
|
|
|
engineConfiguration->idleRpmPid.iFactor = 0.002;
|
|
|
|
|
2023-05-05 17:39:16 -07:00
|
|
|
engineConfiguration->idleRpmPid.minValue = -20;
|
|
|
|
engineConfiguration->idleRpmPid.maxValue = 20;
|
2021-07-24 08:56:29 -07:00
|
|
|
/**
|
|
|
|
* between variation between different sensor and weather and fabrication tolerance
|
|
|
|
* five percent looks like a safer default
|
|
|
|
*/
|
|
|
|
engineConfiguration->idlePidDeactivationTpsThreshold = 5;
|
2017-05-28 10:44:26 -07:00
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->idle.solenoidFrequency = 200;
|
2018-01-07 09:11:49 -08:00
|
|
|
// set idle_position 50
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->manIdlePosition = 50;
|
2018-01-07 09:11:49 -08:00
|
|
|
// engineConfiguration->idleMode = IM_AUTO;
|
|
|
|
engineConfiguration->idleMode = IM_MANUAL;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->useStepperIdle = false;
|
2018-01-07 09:11:49 -08:00
|
|
|
|
2022-08-29 05:15:04 -07:00
|
|
|
setLinearCurve(config->iacCoastingRpmBins, 0, 8000, 1);
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
setDefaultGppwmParameters();
|
2020-04-26 11:06:28 -07:00
|
|
|
|
2019-06-17 09:18:55 -07:00
|
|
|
#if !EFI_UNIT_TEST
|
2018-01-07 09:11:49 -08:00
|
|
|
engineConfiguration->analogInputDividerCoefficient = 2;
|
2019-06-17 09:18:55 -07:00
|
|
|
#endif
|
2018-01-07 09:11:49 -08:00
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
// performance optimization
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->sensorChartMode = SC_OFF;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2022-11-26 11:13:14 -08:00
|
|
|
setTPS1Calibration(convertVoltageTo10bitADC(0),
|
|
|
|
convertVoltageTo10bitADC(5),
|
|
|
|
convertVoltageTo10bitADC(5),
|
|
|
|
convertVoltageTo10bitADC(0));
|
|
|
|
|
2020-05-10 13:13:15 -07:00
|
|
|
engineConfiguration->tps2Min = convertVoltageTo10bitADC(0);
|
|
|
|
engineConfiguration->tps2Max = convertVoltageTo10bitADC(5);
|
2022-11-26 11:13:14 -08:00
|
|
|
engineConfiguration->tps2SecondaryMin = convertVoltageTo10bitADC(5);
|
|
|
|
engineConfiguration->tps2SecondaryMax = convertVoltageTo10bitADC(0);
|
|
|
|
|
2020-11-14 15:05:27 -08:00
|
|
|
engineConfiguration->idlePositionMin = PACK_MULT_VOLTAGE * 0;
|
|
|
|
engineConfiguration->idlePositionMax = PACK_MULT_VOLTAGE * 5;
|
|
|
|
engineConfiguration->wastegatePositionMin = PACK_MULT_VOLTAGE * 0;
|
|
|
|
engineConfiguration->wastegatePositionMax = PACK_MULT_VOLTAGE * 5;
|
2016-01-08 08:01:40 -08:00
|
|
|
engineConfiguration->tpsErrorDetectionTooLow = -10; // -10% open
|
|
|
|
engineConfiguration->tpsErrorDetectionTooHigh = 110; // 110% open
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2017-11-15 11:30:13 -08:00
|
|
|
engineConfiguration->oilPressure.v1 = 0.5f;
|
|
|
|
engineConfiguration->oilPressure.v2 = 4.5f;
|
|
|
|
engineConfiguration->oilPressure.value1 = 0;
|
|
|
|
engineConfiguration->oilPressure.value2 = 689.476f; // 100psi = 689.476kPa
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2016-06-25 13:02:01 -07:00
|
|
|
engineConfiguration->mapLowValueVoltage = 0;
|
|
|
|
// todo: start using this for custom MAP
|
|
|
|
engineConfiguration->mapHighValueVoltage = 5;
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
engineConfiguration->cylinderBore = 87.5;
|
|
|
|
|
2022-01-02 23:13:47 -08:00
|
|
|
setBoschHDEV_5_injectors();
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
setEgoSensor(ES_14Point7_Free);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
engineConfiguration->globalFuelCorrection = 1;
|
2017-06-12 05:41:32 -07:00
|
|
|
engineConfiguration->adcVcc = 3.0;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
engineConfiguration->map.sensor.type = MT_MPX4250;
|
|
|
|
|
|
|
|
engineConfiguration->baroSensor.type = MT_CUSTOM;
|
2016-06-25 16:03:02 -07:00
|
|
|
engineConfiguration->baroSensor.lowValue = 0;
|
|
|
|
engineConfiguration->baroSensor.highValue = 500;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_PROD_CODE
|
2015-07-10 06:01:56 -07:00
|
|
|
engineConfiguration->engineChartSize = 300;
|
|
|
|
#else
|
|
|
|
// need more events for automated test
|
|
|
|
engineConfiguration->engineChartSize = 400;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
engineConfiguration->isMapAveragingEnabled = true;
|
|
|
|
engineConfiguration->isWaveAnalyzerEnabled = true;
|
|
|
|
|
2023-06-18 20:05:16 -07:00
|
|
|
engineConfiguration->acIdleRpmBump = 50;
|
|
|
|
engineConfiguration->acDelay = 0.5;
|
2023-06-19 07:12:18 -07:00
|
|
|
engineConfiguration->acIdleExtraOffset = 15;
|
2021-05-08 15:43:55 -07:00
|
|
|
|
|
|
|
/* these two are used for HIP9011 only
|
|
|
|
* Currently this is offset from fire event, not TDC */
|
|
|
|
/* TODO: convert to offset from TDC */
|
|
|
|
engineConfiguration->knockDetectionWindowStart = 15.0 + 5.0;
|
|
|
|
engineConfiguration->knockDetectionWindowEnd = 15.0 + 45.0;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2023-03-27 01:13:04 -07:00
|
|
|
engineConfiguration->triggerSimulatorRpm = 1200;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2016-07-02 15:02:12 -07:00
|
|
|
engineConfiguration->alternatorPwmFrequency = 300;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-08-01 19:27:23 -07:00
|
|
|
engineConfiguration->isAlternatorControlEnabled = false;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2023-03-16 07:37:27 -07:00
|
|
|
engineConfiguration->driveWheelRevPerKm = 1000;
|
2023-03-15 19:38:15 -07:00
|
|
|
engineConfiguration->finalGearRatio = 1;
|
2021-11-27 05:49:07 -08:00
|
|
|
engineConfiguration->vssGearRatio = 3.73;
|
|
|
|
engineConfiguration->vssToothCount = 21;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2016-01-08 08:01:40 -08:00
|
|
|
engineConfiguration->mapErrorDetectionTooLow = 5;
|
2022-04-03 15:48:23 -07:00
|
|
|
// todo: default limits should be hard-coded for each sensor type
|
|
|
|
// https://github.com/rusefi/rusefi/issues/4030
|
|
|
|
engineConfiguration->mapErrorDetectionTooHigh = 410;
|
2015-08-30 13:02:00 -07:00
|
|
|
|
2023-03-13 13:25:45 -07:00
|
|
|
setLinearCurve(config->throttleEstimateEffectiveAreaBins, 0, 100);
|
|
|
|
|
2019-01-04 14:18:43 -08:00
|
|
|
engineConfiguration->hip9011Gain = 1;
|
2020-02-24 16:08:02 -08:00
|
|
|
#endif // EFI_ENGINE_CONTROL
|
2022-12-20 11:48:24 -08:00
|
|
|
#include "default_script.lua"
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2021-03-25 15:16:26 -07:00
|
|
|
#ifdef CONFIG_RESET_SWITCH_PORT
|
|
|
|
// this pin is not configurable at runtime so that we have a reliable way to reset configuration
|
|
|
|
#define SHOULD_IGNORE_FLASH() (palReadPad(CONFIG_RESET_SWITCH_PORT, CONFIG_RESET_SWITCH_PIN) == 0)
|
|
|
|
#else
|
|
|
|
#define SHOULD_IGNORE_FLASH() (false)
|
|
|
|
#endif // CONFIG_RESET_SWITCH_PORT
|
|
|
|
|
|
|
|
// by default, do not ignore config from flash! use it!
|
|
|
|
#ifndef IGNORE_FLASH_CONFIGURATION
|
|
|
|
#define IGNORE_FLASH_CONFIGURATION false
|
|
|
|
#endif
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void loadConfiguration() {
|
2021-03-25 15:16:26 -07:00
|
|
|
#ifdef CONFIG_RESET_SWITCH_PORT
|
|
|
|
// initialize the reset pin if necessary
|
|
|
|
palSetPadMode(CONFIG_RESET_SWITCH_PORT, CONFIG_RESET_SWITCH_PIN, PAL_MODE_INPUT_PULLUP);
|
|
|
|
#endif /* CONFIG_RESET_SWITCH_PORT */
|
|
|
|
|
2021-03-30 04:28:22 -07:00
|
|
|
#if ! EFI_ACTIVE_CONFIGURATION_IN_FLASH
|
|
|
|
// Clear the active configuration so that registered output pins (etc) detect the change on startup and init properly
|
|
|
|
prepareVoidConfiguration(&activeConfiguration);
|
|
|
|
#endif /* EFI_ACTIVE_CONFIGURATION_IN_FLASH */
|
|
|
|
|
2021-03-25 15:16:26 -07:00
|
|
|
#if EFI_INTERNAL_FLASH
|
|
|
|
if (SHOULD_IGNORE_FLASH() || IGNORE_FLASH_CONFIGURATION) {
|
2023-06-18 08:05:44 -07:00
|
|
|
engineConfiguration->engineType = DEFAULT_ENGINE_TYPE;
|
2021-11-16 01:15:29 -08:00
|
|
|
resetConfigurationExt(engineConfiguration->engineType);
|
2021-03-25 15:16:26 -07:00
|
|
|
writeToFlashNow();
|
|
|
|
} else {
|
|
|
|
// this call reads configuration from flash memory or sets default configuration
|
|
|
|
// if flash state does not look right.
|
|
|
|
readFromFlash();
|
|
|
|
}
|
|
|
|
#else // not EFI_INTERNAL_FLASH
|
|
|
|
// This board doesn't load configuration, initialize the default
|
2023-06-18 08:05:44 -07:00
|
|
|
engineConfiguration->engineType = DEFAULT_ENGINE_TYPE;
|
2021-11-16 01:15:29 -08:00
|
|
|
resetConfigurationExt(engineConfiguration->engineType);
|
2021-03-25 15:16:26 -07:00
|
|
|
#endif /* EFI_INTERNAL_FLASH */
|
2021-03-31 11:46:50 -07:00
|
|
|
|
|
|
|
// Force any board configuration options that humans shouldn't be able to change
|
|
|
|
setBoardConfigOverrides();
|
2021-03-25 15:16:26 -07:00
|
|
|
}
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void resetConfigurationExt(configuration_callback_t boardCallback, engine_type_e engineType) {
|
2016-11-03 14:03:11 -07:00
|
|
|
enginePins.reset(); // that's mostly important for functional tests
|
2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* Let's apply global defaults first
|
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
setDefaultEngineConfiguration();
|
2019-07-24 19:00:48 -07:00
|
|
|
|
|
|
|
// set initial pin groups
|
2021-11-16 01:15:29 -08:00
|
|
|
setDefaultBasePins();
|
2019-07-24 19:00:48 -07:00
|
|
|
|
2020-09-21 09:29:01 -07:00
|
|
|
if (boardCallback != nullptr) {
|
|
|
|
boardCallback(engineConfiguration);
|
|
|
|
}
|
2019-08-08 18:27:57 -07:00
|
|
|
|
2019-04-16 07:27:34 -07:00
|
|
|
#if EFI_PROD_CODE
|
|
|
|
// call overrided board-specific configuration setup, if needed (for custom boards only)
|
2021-03-22 11:15:09 -07:00
|
|
|
setBoardDefaultConfiguration();
|
2021-03-31 11:46:50 -07:00
|
|
|
setBoardConfigOverrides();
|
2019-04-16 07:27:34 -07:00
|
|
|
#endif
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
engineConfiguration->engineType = engineType;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* And override them with engine-specific defaults
|
|
|
|
*/
|
|
|
|
switch (engineType) {
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::MINIMAL_PINS:
|
2020-02-24 16:08:02 -08:00
|
|
|
// all basic settings are already set in prepareVoidConfiguration(), no need to set anything here
|
2021-03-22 11:15:09 -07:00
|
|
|
// nothing to do - we do it all in setBoardDefaultConfiguration
|
2020-02-24 16:08:02 -08:00
|
|
|
break;
|
|
|
|
#if EFI_UNIT_TEST
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::TEST_ISSUE_366_BOTH:
|
2021-11-16 01:15:29 -08:00
|
|
|
setTestEngineIssue366both();
|
2020-02-24 16:08:02 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::TEST_ISSUE_366_RISE:
|
2021-11-16 01:15:29 -08:00
|
|
|
setTestEngineIssue366rise();
|
2020-02-24 16:08:02 -08:00
|
|
|
break;
|
|
|
|
#endif // EFI_UNIT_TEST
|
2020-12-22 18:54:40 -08:00
|
|
|
#if HW_MICRO_RUSEFI
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::MRE_VW_B6:
|
2022-05-20 22:44:19 -07:00
|
|
|
setMreVwPassatB6();
|
2021-12-29 17:23:51 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::MRE_M111:
|
2023-03-16 08:15:13 -07:00
|
|
|
setMreM111EngineConfiguration();
|
2015-07-10 06:01:56 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::MRE_SECONDARY_CAN:
|
2021-11-16 01:15:29 -08:00
|
|
|
mreSecondaryCan();
|
2021-10-27 16:54:45 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::MRE_SUBARU_EJ18:
|
2021-11-16 01:15:29 -08:00
|
|
|
setSubaruEJ18_MRE();
|
2020-02-18 14:53:56 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::MRE_BOARD_NEW_TEST:
|
2021-11-16 01:15:29 -08:00
|
|
|
mreBoardNewTest();
|
2019-11-14 20:58:04 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::BMW_M73_MRE:
|
|
|
|
case engine_type_e::BMW_M73_MRE_SLAVE:
|
2021-11-16 01:15:29 -08:00
|
|
|
setEngineBMW_M73_microRusEfi();
|
2020-03-11 21:16:32 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::MRE_MIATA_94_MAP:
|
2021-11-16 01:15:29 -08:00
|
|
|
setMiata94_MAP_MRE();
|
2020-11-28 19:49:28 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::MRE_MIATA_NA6_MAP:
|
2021-11-16 01:15:29 -08:00
|
|
|
setMiataNA6_MAP_MRE();
|
2020-07-29 18:38:34 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::MRE_BODY_CONTROL:
|
2021-11-16 01:15:29 -08:00
|
|
|
mreBCM();
|
2020-08-29 11:29:34 -07:00
|
|
|
break;
|
2020-12-22 18:54:40 -08:00
|
|
|
#endif // HW_MICRO_RUSEFI
|
|
|
|
#if HW_PROTEUS
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::PROTEUS_M111:
|
2023-03-27 15:46:17 -07:00
|
|
|
setProteusM111EngineConfiguration();
|
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::WASTEGATE_PROTEUS_TEST:
|
2023-02-13 14:46:12 -08:00
|
|
|
proteusDcWastegateTest();
|
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::PROTEUS_HYUNDAI_PB:
|
2023-04-20 13:52:49 -07:00
|
|
|
setProteusHyundaiPb();
|
2023-04-19 17:58:26 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::PROTEUS_NISSAN_VQ35:
|
2023-03-26 09:47:04 -07:00
|
|
|
setProteusNissanVQ();
|
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::PROTEUS_GM_LS_4:
|
2022-10-27 16:53:28 -07:00
|
|
|
setProteusGmLs4();
|
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::PROTEUS_VW_B6:
|
2022-05-20 23:25:43 -07:00
|
|
|
setProteusVwPassatB6();
|
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::PROTEUS_QC_TEST_BOARD:
|
2021-11-16 01:15:29 -08:00
|
|
|
proteusBoardTest();
|
2020-12-26 07:41:33 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::PROTEUS_LUA_DEMO:
|
2021-11-16 01:15:29 -08:00
|
|
|
proteusLuaDemo();
|
2021-11-08 14:31:17 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::PROTEUS_HARLEY:
|
2021-11-16 01:15:29 -08:00
|
|
|
proteusHarley();
|
2021-11-13 01:24:53 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::PROTEUS_BMW_M73:
|
2021-11-16 01:15:29 -08:00
|
|
|
setEngineBMW_M73_Proteus();
|
2020-12-22 18:54:40 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::MIATA_PROTEUS_TCU:
|
2021-11-16 01:15:29 -08:00
|
|
|
setMiataNB2_Proteus_TCU();
|
2020-12-22 18:54:40 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::PROTEUS_HONDA_K:
|
2021-11-16 01:15:29 -08:00
|
|
|
setProteusHondaElement2003();
|
2021-10-02 09:50:06 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::PROTEUS_HONDA_OBD2A:
|
2021-11-16 01:15:29 -08:00
|
|
|
setProteusHondaOBD2A();
|
2021-10-12 15:24:45 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::PROTEUS_E65_6H_MAN_IN_THE_MIDDLE:
|
2022-02-09 14:28:57 -08:00
|
|
|
setEngineProteusGearboxManInTheMiddle();
|
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::PROTEUS_N73:
|
|
|
|
case engine_type_e::PROTEUS_MIATA_NB2:
|
2023-04-29 12:07:43 -07:00
|
|
|
setMiataNB2_Proteus();
|
2020-12-22 18:54:40 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::PROTEUS_SBC:
|
2023-03-26 08:26:38 -07:00
|
|
|
setProteusSbc();
|
|
|
|
break;
|
2021-02-03 11:34:48 -08:00
|
|
|
#ifdef HARDWARE_CI
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::PROTEUS_ANALOG_PWM_TEST:
|
2021-11-16 01:15:29 -08:00
|
|
|
setProteusAnalogPwmTest();
|
2021-02-03 11:34:48 -08:00
|
|
|
break;
|
|
|
|
#endif // HARDWARE_CI
|
2020-12-22 18:54:40 -08:00
|
|
|
#endif // HW_PROTEUS
|
2020-12-31 22:10:28 -08:00
|
|
|
#if HW_HELLEN
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::HELLEN_128_MERCEDES_4_CYL:
|
2021-11-16 01:15:29 -08:00
|
|
|
setHellenMercedes128_4_cyl();
|
2021-09-18 18:27:17 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::HELLEN_128_MERCEDES_6_CYL:
|
2021-11-16 01:15:29 -08:00
|
|
|
setHellenMercedes128_6_cyl();
|
2021-09-17 21:17:52 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::HELLEN_128_MERCEDES_8_CYL:
|
2021-11-16 01:15:29 -08:00
|
|
|
setHellenMercedes128_8_cyl();
|
2021-09-17 21:17:52 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::HELLEN_NB2:
|
2021-11-16 01:15:29 -08:00
|
|
|
setMiataNB2_Hellen72();
|
2021-01-21 22:47:01 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::HELLEN_NB2_36:
|
2021-11-16 01:15:29 -08:00
|
|
|
setMiataNB2_Hellen72_36();
|
2021-08-09 23:34:59 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::HELLEN_NA8_96:
|
2022-06-23 11:30:41 -07:00
|
|
|
setHellenMiata96();
|
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::HELLEN_NB1:
|
2021-11-16 01:15:29 -08:00
|
|
|
setHellenNB1();
|
2021-10-02 20:20:30 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::HELLEN_121_NISSAN_4_CYL:
|
2021-11-16 01:15:29 -08:00
|
|
|
setHellen121nissanQR();
|
2021-08-08 04:04:18 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::HELLEN_121_NISSAN_6_CYL:
|
2021-11-16 01:15:29 -08:00
|
|
|
setHellen121nissanVQ();
|
2021-07-02 13:26:23 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::HELLEN_121_VAG_5_CYL:
|
2021-11-16 01:15:29 -08:00
|
|
|
setHellen121Vag_5_cyl();
|
2021-07-08 13:35:58 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::HELLEN_121_VAG_V6_CYL:
|
2021-11-16 01:15:29 -08:00
|
|
|
setHellen121Vag_v6_cyl();
|
2021-07-08 17:42:35 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::HELLEN_121_VAG_VR6_CYL:
|
2021-11-16 01:15:29 -08:00
|
|
|
setHellen121Vag_vr6_cyl();
|
2021-07-08 13:35:58 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::HELLEN_121_VAG_8_CYL:
|
2021-11-16 01:15:29 -08:00
|
|
|
setHellen121Vag_8_cyl();
|
2021-07-08 13:35:58 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::HELLEN_121_VAG_4_CYL:
|
|
|
|
case engine_type_e::HELLEN_154_VAG:
|
2021-10-11 11:22:35 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::HELLEN_154_HYUNDAI_COUPE_BK1:
|
2021-11-16 01:15:29 -08:00
|
|
|
setGenesisCoupeBK1();
|
2021-10-11 11:22:35 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::HELLEN_154_HYUNDAI_COUPE_BK2:
|
2021-11-16 01:15:29 -08:00
|
|
|
setGenesisCoupeBK2();
|
2021-07-08 22:53:09 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::HELLEN_NA6:
|
2021-11-16 01:15:29 -08:00
|
|
|
setHellenNA6();
|
2021-08-24 13:01:49 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::HELLEN_NA94:
|
2021-11-16 01:15:29 -08:00
|
|
|
setHellenNA94();
|
2021-04-18 07:42:50 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::ALPHAX_8CHAN_SBC:
|
2023-03-26 08:26:38 -07:00
|
|
|
set8chanSbc();
|
|
|
|
break;
|
2020-12-31 22:10:28 -08:00
|
|
|
#endif // HW_HELLEN
|
2020-12-22 18:54:40 -08:00
|
|
|
#if HW_FRANKENSO
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::DEFAULT_FRANKENSO:
|
2021-11-16 01:15:29 -08:00
|
|
|
setFrankensoConfiguration();
|
2020-12-22 18:54:40 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::DISCOVERY_PDM:
|
|
|
|
case engine_type_e::TEST_ENGINE:
|
2023-01-17 08:50:10 -08:00
|
|
|
setTestCamEngineConfiguration();
|
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::TEST_CRANK_ENGINE:
|
2023-01-17 08:50:10 -08:00
|
|
|
setTestCrankEngineConfiguration();
|
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::FRANKENSO_QA_ENGINE:
|
2021-11-16 01:15:29 -08:00
|
|
|
setFrankensoBoardTestConfiguration();
|
2020-12-22 18:54:40 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::FRANKENSO_BMW_M73_F:
|
2021-11-16 01:15:29 -08:00
|
|
|
setBMW_M73_TwoCoilUnitTest();
|
2020-12-22 18:54:40 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::BMW_M73_M:
|
2021-11-16 01:15:29 -08:00
|
|
|
setEngineBMW_M73_Manhattan();
|
2020-12-22 18:54:40 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::DODGE_NEON_1995:
|
2021-11-16 01:15:29 -08:00
|
|
|
setDodgeNeon1995EngineConfiguration();
|
2020-12-22 18:54:40 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::DODGE_NEON_2003_CRANK:
|
2021-11-16 01:15:29 -08:00
|
|
|
setDodgeNeonNGCEngineConfiguration();
|
2016-09-21 10:02:42 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::FORD_ASPIRE_1996:
|
2021-11-16 01:15:29 -08:00
|
|
|
setFordAspireEngineConfiguration();
|
2015-07-10 06:01:56 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::NISSAN_PRIMERA:
|
2021-11-16 01:15:29 -08:00
|
|
|
setNissanPrimeraEngineConfiguration();
|
2020-11-26 18:21:25 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::FRANKENSO_MIATA_NA6_MAP:
|
2021-11-16 01:15:29 -08:00
|
|
|
setMiataNA6_MAP_Frankenso();
|
2019-01-19 17:27:14 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::ETB_BENCH_ENGINE:
|
2021-11-16 01:15:29 -08:00
|
|
|
setEtbTestConfiguration();
|
2019-02-27 05:55:56 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::L9779_BENCH_ENGINE:
|
2022-02-06 10:55:16 -08:00
|
|
|
setL9779TestConfiguration();
|
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::EEPROM_BENCH_ENGINE:
|
2022-02-06 15:13:35 -08:00
|
|
|
#if EFI_PROD_CODE
|
|
|
|
setEepromTestConfiguration();
|
|
|
|
#endif
|
2022-02-06 10:59:08 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::TLE8888_BENCH_ENGINE:
|
2021-11-16 01:15:29 -08:00
|
|
|
setTle8888TestConfiguration();
|
2019-04-04 18:34:33 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::FRANKENSO_MAZDA_MIATA_NA8:
|
2022-06-23 11:30:41 -07:00
|
|
|
setFrankensoMazdaMiataNA8Configuration();
|
2018-09-06 19:31:23 -07:00
|
|
|
break;
|
2023-06-18 06:41:02 -07:00
|
|
|
case engine_type_e::MITSUBISHI_3A92:
|
|
|
|
setMitsubishi3A92();
|
|
|
|
break;
|
|
|
|
case engine_type_e::TOYOTA_1NZ_FE:
|
|
|
|
setToyota1NZFE();
|
|
|
|
break;
|
|
|
|
case engine_type_e::MITSUBISHI_4G93:
|
2023-06-18 07:07:50 -07:00
|
|
|
setMitsubishi4G93();
|
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::FORD_INLINE_6_1995:
|
2021-11-16 01:15:29 -08:00
|
|
|
setFordInline6();
|
2015-07-10 06:01:56 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::GY6_139QMB:
|
2021-11-16 01:15:29 -08:00
|
|
|
setGy6139qmbDefaultEngineConfiguration();
|
2015-07-10 06:01:56 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::HONDA_600:
|
2021-11-16 01:15:29 -08:00
|
|
|
setHonda600();
|
2016-07-09 16:03:08 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::FORD_ESCORT_GT:
|
2021-11-16 01:15:29 -08:00
|
|
|
setFordEscortGt();
|
2015-07-10 06:01:56 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::MIATA_1996:
|
2021-11-16 01:15:29 -08:00
|
|
|
setFrankensteinMiata1996();
|
2015-07-10 06:01:56 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::CITROEN_TU3JP:
|
2021-11-16 01:15:29 -08:00
|
|
|
setCitroenBerlingoTU3JPConfiguration();
|
2015-07-10 06:01:56 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::SUBARU_2003_WRX:
|
2021-11-16 01:15:29 -08:00
|
|
|
setSubaru2003Wrx();
|
2015-07-10 06:01:56 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::DODGE_RAM:
|
2021-11-16 01:15:29 -08:00
|
|
|
setDodgeRam1996();
|
2015-07-10 06:01:56 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::VW_ABA:
|
2021-11-16 01:15:29 -08:00
|
|
|
setVwAba();
|
2015-07-10 06:01:56 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::FRANKENSO_MAZDA_MIATA_2003:
|
2021-11-16 01:15:29 -08:00
|
|
|
setMazdaMiata2003EngineConfiguration();
|
2016-10-04 12:02:36 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::MAZDA_MIATA_2003_NA_RAIL:
|
2021-11-16 01:15:29 -08:00
|
|
|
setMazdaMiata2003EngineConfigurationNaFuelRail();
|
2017-04-17 19:10:19 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::MAZDA_MIATA_2003_BOARD_TEST:
|
2021-11-16 01:15:29 -08:00
|
|
|
setMazdaMiata2003EngineConfigurationBoardTest();
|
2017-12-02 17:59:31 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::TEST_ENGINE_VVT:
|
2021-11-16 01:15:29 -08:00
|
|
|
setTestVVTEngineConfiguration();
|
2016-08-20 18:03:09 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::TEST_DC_WASTEGATE_DISCOVERY:
|
2023-01-17 01:14:44 -08:00
|
|
|
setTestDcWastegateConfiguration();
|
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::SACHS:
|
2021-11-16 01:15:29 -08:00
|
|
|
setSachs();
|
2015-07-10 06:01:56 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::CAMARO_4:
|
2021-11-16 01:15:29 -08:00
|
|
|
setCamaro4();
|
2015-10-16 13:01:21 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::TOYOTA_2JZ_GTE_VVTi:
|
2021-11-16 01:15:29 -08:00
|
|
|
setToyota_2jz_vics();
|
2016-07-13 20:01:43 -07:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::TEST_33816:
|
2021-11-16 01:15:29 -08:00
|
|
|
setTest33816EngineConfiguration();
|
2020-02-25 18:35:21 -08:00
|
|
|
break;
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::TEST_100:
|
|
|
|
case engine_type_e::TEST_101:
|
|
|
|
case engine_type_e::TEST_102:
|
|
|
|
case engine_type_e::TEST_ROTARY:
|
2021-11-16 01:15:29 -08:00
|
|
|
setRotary();
|
2021-07-21 16:55:14 -07:00
|
|
|
break;
|
2020-12-22 18:54:40 -08:00
|
|
|
#endif // HW_FRANKENSO
|
2021-02-06 10:50:34 -08:00
|
|
|
#ifdef HW_SUBARU_EG33
|
2023-05-31 22:31:46 -07:00
|
|
|
case engine_type_e::SUBARUEG33_DEFAULTS:
|
2021-11-16 01:15:29 -08:00
|
|
|
setSubaruEG33Defaults();
|
2021-02-06 10:50:34 -08:00
|
|
|
break;
|
|
|
|
#endif //HW_SUBARU_EG33
|
2015-07-10 06:01:56 -07:00
|
|
|
default:
|
2023-04-11 17:01:34 -07:00
|
|
|
firmwareError(ObdCode::CUSTOM_UNEXPECTED_ENGINE_TYPE, "Unexpected engine type: %d", engineType);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
2021-11-16 01:15:29 -08:00
|
|
|
applyNonPersistentConfiguration();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2019-08-08 19:12:51 -07:00
|
|
|
void emptyCallbackWithConfiguration(engine_configuration_s * engineConfiguration) {
|
2019-11-05 17:07:55 -08:00
|
|
|
UNUSED(engineConfiguration);
|
2019-08-08 18:27:57 -07:00
|
|
|
}
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void resetConfigurationExt(engine_type_e engineType) {
|
|
|
|
resetConfigurationExt(&emptyCallbackWithConfiguration, engineType);
|
2019-08-08 18:27:57 -07:00
|
|
|
}
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void validateConfiguration() {
|
2017-08-31 04:53:41 -07:00
|
|
|
if (engineConfiguration->adcVcc > 5.0f || engineConfiguration->adcVcc < 1.0f) {
|
|
|
|
engineConfiguration->adcVcc = 3.0f;
|
|
|
|
}
|
2021-11-16 01:15:29 -08:00
|
|
|
engine->preCalculate();
|
2017-08-31 04:53:41 -07:00
|
|
|
}
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void applyNonPersistentConfiguration() {
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_PROD_CODE
|
2023-06-24 23:08:53 -07:00
|
|
|
efiAssertVoid(ObdCode::CUSTOM_APPLY_STACK, hasLotsOfRemainingStack(), "apply c");
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("applyNonPersistentConfiguration()");
|
2018-02-03 08:42:50 -08:00
|
|
|
#endif
|
|
|
|
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_ENGINE_CONTROL
|
2022-04-02 16:27:18 -07:00
|
|
|
engine->updateTriggerWaveform();
|
2020-05-22 15:07:19 -07:00
|
|
|
#endif // EFI_ENGINE_CONTROL
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2022-04-02 23:21:37 -07:00
|
|
|
void setTwoStrokeOperationMode() {
|
|
|
|
engineConfiguration->twoStroke = true;
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2022-04-02 23:21:37 -07:00
|
|
|
void setCamOperationMode() {
|
2022-04-02 21:43:28 -07:00
|
|
|
engineConfiguration->skippedWheelOnCam = true;
|
|
|
|
}
|
|
|
|
|
2022-04-02 23:21:37 -07:00
|
|
|
void setCrankOperationMode() {
|
2022-04-02 21:43:28 -07:00
|
|
|
engineConfiguration->skippedWheelOnCam = false;
|
2022-04-02 21:34:18 -07:00
|
|
|
}
|
|
|
|
|
2023-02-10 16:09:39 -08:00
|
|
|
void commonFrankensoAnalogInputs() {
|
2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* VBatt
|
|
|
|
*/
|
|
|
|
engineConfiguration->vbattAdcChannel = EFI_ADC_14;
|
|
|
|
}
|
|
|
|
|
2021-03-31 11:46:50 -07:00
|
|
|
// These symbols are weak so that a board_configuration.cpp file can override them
|
2022-01-11 19:26:24 -08:00
|
|
|
__attribute__((weak)) void setBoardDefaultConfiguration() { }
|
|
|
|
__attribute__((weak)) void setBoardConfigOverrides() { }
|
2022-09-29 17:54:13 -07:00
|
|
|
|
2023-05-12 15:13:27 -07:00
|
|
|
__attribute__((weak)) void onBoardStandBy() { }
|
|
|
|
|
2022-09-29 20:01:06 -07:00
|
|
|
__attribute__((weak)) int getBoardMetaOutputsCount() { return 0; }
|
2022-09-29 20:45:46 -07:00
|
|
|
__attribute__((weak)) Gpio* getBoardMetaOutputs() { return nullptr; }
|