rusefi/firmware/controllers/algo/engine_configuration.cpp

1511 lines
57 KiB
C++
Raw Normal View History

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
2018-01-20 17:55:31 -08:00
* @author Andrey Belomutskiy, (c) 2012-2018
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/>.
*
*/
2018-09-16 19:26:57 -07:00
#include "global.h"
2015-07-10 06:01:56 -07:00
#include "engine_configuration.h"
#include "fsio_impl.h"
#include "allsensors.h"
#include "interpolation.h"
#include "engine_math.h"
#include "speed_density.h"
#include "advance_map.h"
2016-01-01 14:02:49 -08:00
#include "hip9011_lookup.h"
2019-04-12 19:07:03 -07:00
#if EFI_MEMS
2017-08-18 13:18:11 -07:00
#include "accelerometer.h"
#endif
2017-08-16 23:56:25 -07:00
2015-07-10 06:01:56 -07:00
#include "custom_engine.h"
2016-03-26 03:03:24 -07:00
#include "engine_template.h"
2015-07-10 06:01:56 -07:00
#include "acura_rsx.h"
#include "audi_aan.h"
#include "bmw_e34.h"
2016-10-04 12:02:36 -07:00
2015-07-10 06:01:56 -07:00
#include "dodge_neon.h"
2016-10-04 12:02:36 -07:00
#include "dodge_ram.h"
#include "dodge_stratus.h"
2015-07-10 06:01:56 -07:00
#include "ford_aspire.h"
#include "ford_fiesta.h"
#include "ford_1995_inline_6.h"
2016-10-04 12:02:36 -07:00
2015-07-10 06:01:56 -07:00
#include "snow_blower.h"
#include "nissan_primera.h"
#include "honda_accord.h"
#include "GY6_139QMB.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"
#include "mazda_miata_nb.h"
2016-10-04 12:02:36 -07:00
#include "mazda_miata_vvt.h"
2015-07-10 06:01:56 -07:00
#include "mazda_323.h"
#include "mazda_626.h"
2016-10-04 12:02:36 -07:00
2015-07-10 06:01:56 -07:00
#include "saturn_ion.h"
#include "MiniCooperR50.h"
#include "citroenBerlingoTU3JP.h"
#include "rover_v8.h"
#include "mitsubishi.h"
2017-05-06 13:11:45 -07:00
#include "prometheus.h"
2015-07-10 06:01:56 -07:00
#include "subaru.h"
#include "test_engine.h"
#include "sachs.h"
#include "gm_2_2.h"
#include "vw.h"
2015-09-12 12:02:40 -07:00
#include "daihatsu.h"
2015-10-16 13:01:21 -07:00
#include "chevrolet_camaro_4.h"
2015-10-17 10:02:05 -07:00
#include "suzuki_vitara.h"
2015-12-20 17:01:44 -08:00
#include "chevrolet_c20_1973.h"
2015-12-30 13:02:18 -08:00
#include "toyota_jzs147.h"
2016-01-04 02:02:45 -08:00
#include "ford_festiva.h"
2016-01-21 15:03:40 -08:00
#include "lada_kalina.h"
2016-03-26 03:03:24 -07:00
#include "geo_storm.h"
2016-05-04 20:02:32 -07:00
#include "zil130.h"
2016-07-09 16:03:08 -07:00
#include "honda_600.h"
2015-07-10 06:01:56 -07:00
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
#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
#include "hip9011.h"
2018-10-30 04:58:50 -07:00
#endif
2019-04-12 19:07:03 -07:00
#if EFI_PROD_CODE
2017-12-03 12:31:11 -08:00
#include "hardware.h"
#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
2017-12-17 12:41:58 -08:00
#include "trigger_emulator.h"
#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
2017-12-03 12:31:11 -08:00
EXTERN_ENGINE;
2015-07-10 06:01:56 -07:00
//#define TS_DEFAULT_SPEED 115200
#define TS_DEFAULT_SPEED 38400
#define xxxxx 0
static fuel_table_t alphaNfuel = {
{/*0 engineLoad=0.00*/ /*0 800.0*/xxxxx, /*1 1213.0*/xxxxx, /*2 1626.0*/xxxxx, /*3 2040.0*/xxxxx, /*4 2453.0*/xxxxx, /*5 2866.0*/xxxxx, /*6 3280.0*/xxxxx, /*7 3693.0*/xxxxx, /*8 4106.0*/xxxxx, /*9 4520.0*/xxxxx, /*10 4933.0*/xxxxx, /*11 5346.0*/xxxxx, /*12 5760.0*/xxxxx, /*13 6173.0*/xxxxx, /*14 6586.0*/xxxxx, /*15 7000.0*/xxxxx},
{/*1 engineLoad=6.66*/ /*0 800.0*/xxxxx, /*1 1213.0*/xxxxx, /*2 1626.0*/xxxxx, /*3 2040.0*/xxxxx, /*4 2453.0*/xxxxx, /*5 2866.0*/xxxxx, /*6 3280.0*/xxxxx, /*7 3693.0*/xxxxx, /*8 4106.0*/xxxxx, /*9 4520.0*/xxxxx, /*10 4933.0*/xxxxx, /*11 5346.0*/xxxxx, /*12 5760.0*/xxxxx, /*13 6173.0*/xxxxx, /*14 6586.0*/xxxxx, /*15 7000.0*/xxxxx},
{/*2 engineLoad=13.33*/ /*0 800.0*/xxxxx, /*1 1213.0*/xxxxx, /*2 1626.0*/xxxxx, /*3 2040.0*/xxxxx, /*4 2453.0*/xxxxx, /*5 2866.0*/xxxxx, /*6 3280.0*/xxxxx, /*7 3693.0*/xxxxx, /*8 4106.0*/xxxxx, /*9 4520.0*/xxxxx, /*10 4933.0*/xxxxx, /*11 5346.0*/xxxxx, /*12 5760.0*/xxxxx, /*13 6173.0*/xxxxx, /*14 6586.0*/xxxxx, /*15 7000.0*/xxxxx},
{/*3 engineLoad=20.00*/ /*0 800.0*/xxxxx, /*1 1213.0*/xxxxx, /*2 1626.0*/xxxxx, /*3 2040.0*/xxxxx, /*4 2453.0*/xxxxx, /*5 2866.0*/xxxxx, /*6 3280.0*/xxxxx, /*7 3693.0*/xxxxx, /*8 4106.0*/xxxxx, /*9 4520.0*/xxxxx, /*10 4933.0*/xxxxx, /*11 5346.0*/xxxxx, /*12 5760.0*/xxxxx, /*13 6173.0*/xxxxx, /*14 6586.0*/xxxxx, /*15 7000.0*/xxxxx},
{/*4 engineLoad=26.66*/ /*0 800.0*/xxxxx, /*1 1213.0*/xxxxx, /*2 1626.0*/xxxxx, /*3 2040.0*/xxxxx, /*4 2453.0*/xxxxx, /*5 2866.0*/xxxxx, /*6 3280.0*/xxxxx, /*7 3693.0*/xxxxx, /*8 4106.0*/xxxxx, /*9 4520.0*/xxxxx, /*10 4933.0*/xxxxx, /*11 5346.0*/xxxxx, /*12 5760.0*/xxxxx, /*13 6173.0*/xxxxx, /*14 6586.0*/xxxxx, /*15 7000.0*/xxxxx},
{/*5 engineLoad=33.33*/ /*0 800.0*/xxxxx, /*1 1213.0*/xxxxx, /*2 1626.0*/xxxxx, /*3 2040.0*/xxxxx, /*4 2453.0*/xxxxx, /*5 2866.0*/xxxxx, /*6 3280.0*/xxxxx, /*7 3693.0*/xxxxx, /*8 4106.0*/xxxxx, /*9 4520.0*/xxxxx, /*10 4933.0*/xxxxx, /*11 5346.0*/xxxxx, /*12 5760.0*/xxxxx, /*13 6173.0*/xxxxx, /*14 6586.0*/xxxxx, /*15 7000.0*/xxxxx},
{/*6 engineLoad=40.00*/ /*0 800.0*/xxxxx, /*1 1213.0*/xxxxx, /*2 1626.0*/xxxxx, /*3 2040.0*/xxxxx, /*4 2453.0*/xxxxx, /*5 2866.0*/xxxxx, /*6 3280.0*/xxxxx, /*7 3693.0*/xxxxx, /*8 4106.0*/xxxxx, /*9 4520.0*/xxxxx, /*10 4933.0*/xxxxx, /*11 5346.0*/xxxxx, /*12 5760.0*/xxxxx, /*13 6173.0*/xxxxx, /*14 6586.0*/xxxxx, /*15 7000.0*/xxxxx},
{/*7 engineLoad=46.66*/ /*0 800.0*/xxxxx, /*1 1213.0*/xxxxx, /*2 1626.0*/xxxxx, /*3 2040.0*/xxxxx, /*4 2453.0*/xxxxx, /*5 2866.0*/xxxxx, /*6 3280.0*/xxxxx, /*7 3693.0*/xxxxx, /*8 4106.0*/xxxxx, /*9 4520.0*/xxxxx, /*10 4933.0*/xxxxx, /*11 5346.0*/xxxxx, /*12 5760.0*/xxxxx, /*13 6173.0*/xxxxx, /*14 6586.0*/xxxxx, /*15 7000.0*/xxxxx},
{/*8 engineLoad=53.33*/ /*0 800.0*/xxxxx, /*1 1213.0*/xxxxx, /*2 1626.0*/xxxxx, /*3 2040.0*/xxxxx, /*4 2453.0*/xxxxx, /*5 2866.0*/xxxxx, /*6 3280.0*/xxxxx, /*7 3693.0*/xxxxx, /*8 4106.0*/xxxxx, /*9 4520.0*/xxxxx, /*10 4933.0*/xxxxx, /*11 5346.0*/xxxxx, /*12 5760.0*/xxxxx, /*13 6173.0*/xxxxx, /*14 6586.0*/xxxxx, /*15 7000.0*/xxxxx},
{/*9 engineLoad=60.00*/ /*0 800.0*/xxxxx, /*1 1213.0*/xxxxx, /*2 1626.0*/xxxxx, /*3 2040.0*/xxxxx, /*4 2453.0*/xxxxx, /*5 2866.0*/xxxxx, /*6 3280.0*/xxxxx, /*7 3693.0*/xxxxx, /*8 4106.0*/xxxxx, /*9 4520.0*/xxxxx, /*10 4933.0*/xxxxx, /*11 5346.0*/xxxxx, /*12 5760.0*/xxxxx, /*13 6173.0*/xxxxx, /*14 6586.0*/xxxxx, /*15 7000.0*/xxxxx},
{/*10 engineLoad=66.66*/ /*0 800.0*/xxxxx, /*1 1213.0*/xxxxx, /*2 1626.0*/xxxxx, /*3 2040.0*/xxxxx, /*4 2453.0*/xxxxx, /*5 2866.0*/xxxxx, /*6 3280.0*/xxxxx, /*7 3693.0*/xxxxx, /*8 4106.0*/xxxxx, /*9 4520.0*/xxxxx, /*10 4933.0*/xxxxx, /*11 5346.0*/xxxxx, /*12 5760.0*/xxxxx, /*13 6173.0*/xxxxx, /*14 6586.0*/xxxxx, /*15 7000.0*/xxxxx},
{/*11 engineLoad=73.33*/ /*0 800.0*/xxxxx, /*1 1213.0*/xxxxx, /*2 1626.0*/xxxxx, /*3 2040.0*/xxxxx, /*4 2453.0*/xxxxx, /*5 2866.0*/xxxxx, /*6 3280.0*/xxxxx, /*7 3693.0*/xxxxx, /*8 4106.0*/xxxxx, /*9 4520.0*/xxxxx, /*10 4933.0*/xxxxx, /*11 5346.0*/xxxxx, /*12 5760.0*/xxxxx, /*13 6173.0*/xxxxx, /*14 6586.0*/xxxxx, /*15 7000.0*/xxxxx},
{/*12 engineLoad=80.00*/ /*0 800.0*/xxxxx, /*1 1213.0*/xxxxx, /*2 1626.0*/xxxxx, /*3 2040.0*/xxxxx, /*4 2453.0*/xxxxx, /*5 2866.0*/xxxxx, /*6 3280.0*/xxxxx, /*7 3693.0*/xxxxx, /*8 4106.0*/xxxxx, /*9 4520.0*/xxxxx, /*10 4933.0*/xxxxx, /*11 5346.0*/xxxxx, /*12 5760.0*/xxxxx, /*13 6173.0*/xxxxx, /*14 6586.0*/xxxxx, /*15 7000.0*/xxxxx},
{/*13 engineLoad=86.66*/ /*0 800.0*/xxxxx, /*1 1213.0*/xxxxx, /*2 1626.0*/xxxxx, /*3 2040.0*/xxxxx, /*4 2453.0*/xxxxx, /*5 2866.0*/xxxxx, /*6 3280.0*/xxxxx, /*7 3693.0*/xxxxx, /*8 4106.0*/xxxxx, /*9 4520.0*/xxxxx, /*10 4933.0*/xxxxx, /*11 5346.0*/xxxxx, /*12 5760.0*/xxxxx, /*13 6173.0*/xxxxx, /*14 6586.0*/xxxxx, /*15 7000.0*/xxxxx},
{/*14 engineLoad=93.33*/ /*0 800.0*/xxxxx, /*1 1213.0*/xxxxx, /*2 1626.0*/xxxxx, /*3 2040.0*/xxxxx, /*4 2453.0*/xxxxx, /*5 2866.0*/xxxxx, /*6 3280.0*/xxxxx, /*7 3693.0*/xxxxx, /*8 4106.0*/xxxxx, /*9 4520.0*/xxxxx, /*10 4933.0*/xxxxx, /*11 5346.0*/xxxxx, /*12 5760.0*/xxxxx, /*13 6173.0*/xxxxx, /*14 6586.0*/xxxxx, /*15 7000.0*/xxxxx},
{/*15 engineLoad=100.00*/ /*0 800.0*/xxxxx, /*1 1213.0*/xxxxx, /*2 1626.0*/xxxxx, /*3 2040.0*/xxxxx, /*4 2453.0*/xxxxx, /*5 2866.0*/xxxxx, /*6 3280.0*/xxxxx, /*7 3693.0*/xxxxx, /*8 4106.0*/xxxxx, /*9 4520.0*/xxxxx, /*10 4933.0*/xxxxx, /*11 5346.0*/xxxxx, /*12 5760.0*/xxxxx, /*13 6173.0*/xxxxx, /*14 6586.0*/xxxxx, /*15 7000.0*/xxxxx}
};
2016-09-13 17:03:14 -07:00
/**
* Current engine configuration. On firmware start we assign empty configuration, then
* we copy actual configuration after reading settings.
* This is useful to compare old and new configurations in order to apply new settings.
*
* todo: place this field next to 'engineConfiguration'?
*/
#ifdef EFI_ACTIVE_CONFIGURATION_IN_FLASH
engine_configuration_s EFI_ACTIVE_CONFIGURATION_IN_FLASH activeConfiguration;
#else
2016-09-13 17:03:14 -07:00
engine_configuration_s activeConfiguration;
#endif /* EFI_ACTIVE_CONFIGURATION_IN_FLASH */
2016-09-13 17:03:14 -07:00
extern engine_configuration_s *engineConfiguration;
2018-03-04 18:32:48 -08:00
void rememberCurrentConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#ifndef EFI_ACTIVE_CONFIGURATION_IN_FLASH
2016-09-13 17:03:14 -07:00
memcpy(&activeConfiguration, engineConfiguration, sizeof(engine_configuration_s));
#endif /* EFI_ACTIVE_CONFIGURATION_IN_FLASH */
2016-09-13 17:03:14 -07:00
}
2018-03-04 18:32:48 -08:00
extern LoggingWithStorage sharedLogger;
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
*/
2017-05-15 20:28:49 -07:00
void incrementGlobalConfigurationVersion(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
ENGINE(globalConfigurationVersion++);
2018-03-04 18:32:48 -08:00
#if EFI_DEFAILED_LOGGING
scheduleMsg(&sharedLogger, "set globalConfigurationVersion=%d", globalConfigurationVersion);
#endif /* EFI_DEFAILED_LOGGING */
2016-09-15 20:01:48 -07:00
/**
* All these callbacks could be implemented as listeners, but these days I am saving RAM
*/
2019-04-12 19:07:03 -07:00
#if EFI_PROD_CODE
2016-09-13 17:03:14 -07:00
applyNewHardwareSettings();
#endif /* EFI_PROD_CODE */
engine->preCalculate(PASS_ENGINE_PARAMETER_SIGNATURE);
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 */
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 */
2019-04-12 19:07:03 -07:00
#if EFI_IDLE_CONTROL
2017-05-28 10:44:26 -07:00
onConfigurationChangeIdleCallback(&activeConfiguration);
#endif /* EFI_IDLE_CONTROL */
2019-04-12 19:07:03 -07:00
#if EFI_SHAFT_POSITION_INPUT
onConfigurationChangeTriggerCallback(&activeConfiguration PASS_ENGINE_PARAMETER_SUFFIX);
#endif /* EFI_SHAFT_POSITION_INPUT */
2019-04-12 19:07:03 -07:00
#if EFI_EMULATE_POSITION_SENSORS
2017-12-17 12:41:58 -08:00
onConfigurationChangeRpmEmulatorCallback(&activeConfiguration);
#endif /* EFI_EMULATE_POSITION_SENSORS */
2019-04-12 19:07:03 -07:00
#if EFI_FSIO
onConfigurationChangeFsioCallback(&activeConfiguration PASS_ENGINE_PARAMETER_SUFFIX);
#endif /* EFI_FSIO */
2018-03-04 18:32:48 -08:00
rememberCurrentConfiguration(PASS_ENGINE_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
}
/**
* @brief Sets the same dwell time across the whole getRpm() range
*/
void setConstantDwell(floatms_t dwellMs DECLARE_CONFIG_PARAMETER_SUFFIX) {
2015-07-10 06:01:56 -07:00
for (int i = 0; i < DWELL_CURVE_SIZE; i++) {
2017-02-18 12:01:47 -08:00
engineConfiguration->sparkDwellRpmBins[i] = 1000 * i;
2015-07-10 06:01:56 -07:00
}
2018-01-07 08:17:49 -08:00
setLinearCurve(engineConfiguration->sparkDwellValues, DWELL_CURVE_SIZE, dwellMs, dwellMs, 0.01);
2015-07-10 06:01:56 -07:00
}
2016-06-29 22:01:38 -07:00
void setAfrMap(afr_table_t table, float value) {
for (int l = 0; l < FUEL_LOAD_COUNT; l++) {
for (int rpmIndex = 0; rpmIndex < FUEL_RPM_COUNT; rpmIndex++) {
2016-07-01 20:01:22 -07:00
table[l][rpmIndex] = (int)(value * AFR_STORAGE_MULT);
2016-06-29 22:01:38 -07:00
}
}
}
2019-06-10 12:45:18 -07:00
// todo: make this a template
2015-07-10 06:01:56 -07:00
void setMap(fuel_table_t table, float value) {
for (int l = 0; l < FUEL_LOAD_COUNT; l++) {
2016-01-14 20:03:17 -08:00
for (int rpmIndex = 0; rpmIndex < FUEL_RPM_COUNT; rpmIndex++) {
table[l][rpmIndex] = value;
2015-07-10 06:01:56 -07:00
}
}
}
static void setWholeVEMap(float value DECLARE_CONFIG_PARAMETER_SUFFIX) {
2015-07-10 06:01:56 -07:00
setMap(config->veTable, value);
}
void setWholeFuelMap(float value DECLARE_CONFIG_PARAMETER_SUFFIX) {
2015-07-10 06:01:56 -07:00
setMap(config->fuelTable, value);
}
void setWholeIgnitionIatCorr(float value DECLARE_CONFIG_PARAMETER_SUFFIX) {
2019-06-10 12:45:18 -07:00
#if (IGN_LOAD_COUNT == FUEL_LOAD_COUNT) && (IGN_RPM_COUNT == FUEL_RPM_COUNT)
// todo: make setMap a template
2015-10-18 18:02:32 -07:00
setMap(config->ignitionIatCorrTable, value);
2019-06-10 12:45:18 -07:00
#endif
2015-10-18 18:02:32 -07:00
}
void setFuelTablesLoadBin(float minValue, float maxValue DECLARE_CONFIG_PARAMETER_SUFFIX) {
2018-01-07 08:17:49 -08:00
setLinearCurve(config->injPhaseLoadBins, FUEL_LOAD_COUNT, minValue, maxValue, 1);
setLinearCurve(config->veLoadBins, FUEL_LOAD_COUNT, minValue, maxValue, 1);
setLinearCurve(config->afrLoadBins, FUEL_LOAD_COUNT, minValue, maxValue, 1);
2015-07-10 06:01:56 -07:00
}
void setTimingMap(ignition_table_t map, float value) {
for (int l = 0; l < IGN_LOAD_COUNT; l++) {
for (int r = 0; r < IGN_RPM_COUNT; r++) {
map[l][r] = value;
}
}
}
void setWholeIatCorrTimingTable(float value DECLARE_CONFIG_PARAMETER_SUFFIX) {
2015-07-10 06:01:56 -07:00
setTimingMap(config->ignitionIatCorrTable, value);
}
/**
* See also crankingTimingAngle
*/
void setWholeTimingTable_d(angle_t value DECLARE_CONFIG_PARAMETER_SUFFIX) {
2015-07-10 06:01:56 -07:00
setTimingMap(config->ignitionTable, value);
}
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
}
}
static void setDefaultFsioParameters(engine_configuration_s *engineConfiguration) {
board_configuration_s *boardConfiguration = &engineConfiguration->bc;
2017-08-06 16:39:24 -07:00
for (int i = 0; i < AUX_PID_COUNT; i++) {
engineConfiguration->auxPidPins[i] = GPIO_UNASSIGNED;
}
for (int i = 0; i < FSIO_COMMAND_COUNT; i++) {
boardConfiguration->fsioOutputPins[i] = GPIO_UNASSIGNED;
boardConfiguration->fsioDigitalInputs[i] = GPIO_UNASSIGNED;
2017-08-06 16:39:24 -07:00
engineConfiguration->fsioInputModes[i] = PI_DEFAULT;
}
2017-08-06 16:43:01 -07:00
for (int i = 0; i < FSIO_ANALOG_INPUT_COUNT ; i++) {
2017-08-06 16:39:24 -07:00
engineConfiguration->fsioAdc[i] = EFI_ADC_NONE;
}
}
2018-03-04 14:53:52 -08:00
void prepareVoidConfiguration(engine_configuration_s *engineConfiguration) {
efiAssertVoid(OBD_PCM_Processor_Fault, engineConfiguration != NULL, "ec NULL");
2018-03-04 14:53:52 -08:00
memset(engineConfiguration, 0, sizeof(engine_configuration_s));
board_configuration_s *boardConfiguration = &engineConfiguration->bc;
2015-07-10 06:01:56 -07:00
2019-04-21 10:31:55 -07:00
// Now that GPIO_UNASSIGNED == 0 we do not really need explicit zero assignments since memset above does that
boardConfiguration->canTxPin = GPIO_UNASSIGNED;
boardConfiguration->canRxPin = GPIO_UNASSIGNED;
setDefaultFsioParameters(engineConfiguration);
2016-05-11 19:03:18 -07:00
disableLCD(boardConfiguration);
2017-01-28 12:05:25 -08:00
2018-03-04 14:53:52 -08:00
engineConfiguration->camInput = GPIO_UNASSIGNED;
for (int i = 0;i<TRIGGER_INPUT_PIN_COUNT;i++) {
CONFIGB(triggerInputPins)[i] = GPIO_UNASSIGNED;
}
2015-07-10 06:01:56 -07:00
2018-02-25 17:51:34 -08:00
for (int i = 0; i < SERVO_COUNT; i++) {
engineConfiguration->servoOutputPins[i] = GPIO_UNASSIGNED;
}
2017-11-19 08:32:05 -08:00
for (int i = 0; i < AUX_DIGITAL_VALVE_COUNT; i++) {
engineConfiguration->auxValves[i] = GPIO_UNASSIGNED;
}
engineConfiguration->LIS302DLCsPin = GPIO_UNASSIGNED;
2018-01-23 05:34:18 -08:00
engineConfiguration->flexFuelSensor = GPIO_UNASSIGNED;
2018-01-28 11:03:58 -08:00
engineConfiguration->test557pin = GPIO_UNASSIGNED;
2017-11-19 08:32:05 -08:00
boardConfiguration->cdmInputPin = GPIO_UNASSIGNED;
2019-01-04 20:47:39 -08:00
boardConfiguration->joystickCenterPin = GPIO_UNASSIGNED;
boardConfiguration->joystickAPin = GPIO_UNASSIGNED;
boardConfiguration->joystickBPin = GPIO_UNASSIGNED;
boardConfiguration->joystickCPin = GPIO_UNASSIGNED;
boardConfiguration->joystickDPin = GPIO_UNASSIGNED;
2016-12-29 17:02:31 -08:00
boardConfiguration->frequencyReportingMapInputPin = GPIO_UNASSIGNED;
2017-04-18 18:37:31 -07:00
2017-04-11 16:36:26 -07:00
engineConfiguration->sdCardSpiDevice = SPI_NONE;
boardConfiguration->sdCardCsPin = GPIO_UNASSIGNED;
engineConfiguration->accelerometerSpiDevice = SPI_NONE;
boardConfiguration->digitalPotentiometerSpiDevice = SPI_NONE;
boardConfiguration->max31855spiDevice = SPI_NONE;
2017-04-11 16:36:26 -07:00
2019-04-21 11:21:47 -07:00
engineConfiguration->clt.adcChannel = EFI_ADC_NONE;
engineConfiguration->iat.adcChannel = EFI_ADC_NONE;
2017-02-11 23:02:24 -08:00
engineConfiguration->cj125ua = EFI_ADC_NONE;
engineConfiguration->cj125ur = EFI_ADC_NONE;
engineConfiguration->auxTempSensor1.adcChannel = EFI_ADC_NONE;
engineConfiguration->auxTempSensor2.adcChannel = EFI_ADC_NONE;
engineConfiguration->baroSensor.hwChannel = EFI_ADC_NONE;
engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_NONE;
engineConfiguration->oilPressure.hwChannel = EFI_ADC_NONE;
engineConfiguration->vRefAdcChannel = EFI_ADC_NONE;
engineConfiguration->vbattAdcChannel = EFI_ADC_NONE;
engineConfiguration->map.sensor.hwChannel = EFI_ADC_NONE;
engineConfiguration->mafAdcChannel = EFI_ADC_NONE;
engineConfiguration->acSwitchAdc = EFI_ADC_NONE;
engineConfiguration->externalKnockSenseAdc = EFI_ADC_NONE;
engineConfiguration->fuelLevelSensor = EFI_ADC_NONE;
engineConfiguration->hipOutputChannel = EFI_ADC_NONE;
2019-05-04 07:46:48 -07:00
engineConfiguration->afr.hwChannel = EFI_ADC_NONE;
2019-05-25 14:18:16 -07:00
engineConfiguration->high_fuel_pressure_sensor_1 = EFI_ADC_NONE;
engineConfiguration->high_fuel_pressure_sensor_2 = EFI_ADC_NONE;
boardConfiguration->idle.stepperDirectionPin = GPIO_UNASSIGNED;
2017-06-13 07:40:16 -07:00
engineConfiguration->stepperDirectionPinMode = OM_DEFAULT;
boardConfiguration->idle.stepperStepPin = GPIO_UNASSIGNED;
2017-01-28 17:03:19 -08:00
engineConfiguration->stepperEnablePin = GPIO_UNASSIGNED;
engineConfiguration->stepperEnablePinMode = OM_DEFAULT;
2018-03-04 14:53:52 -08:00
engineConfiguration->dizzySparkOutputPin = GPIO_UNASSIGNED;
2016-04-25 20:01:59 -07:00
boardConfiguration->acRelayPin = GPIO_UNASSIGNED;
boardConfiguration->acRelayPinMode = OM_DEFAULT;
2015-07-10 06:01:56 -07:00
2019-04-12 19:07:03 -07:00
#if EFI_ALTERNATOR_CONTROL
2015-07-10 06:01:56 -07:00
setDefaultAlternatorParameters();
#endif /* EFI_ALTERNATOR_CONTROL */
2019-04-12 19:07:03 -07:00
#if EFI_ELECTRONIC_THROTTLE_BODY
2018-12-09 10:50:13 -08:00
setDefaultEtbParameters(PASS_ENGINE_PARAMETER_SIGNATURE);
setDefaultEtbBiasCurve(PASS_ENGINE_PARAMETER_SIGNATURE);
#endif /* EFI_ELECTRONIC_THROTTLE_BODY */
2019-04-12 19:07:03 -07:00
#if EFI_IDLE_CONTROL
2015-10-19 19:02:51 -07:00
setDefaultIdleParameters();
#endif /* EFI_IDLE_CONTROL */
boardConfiguration->wboHeaterPin = GPIO_UNASSIGNED;
boardConfiguration->cj125CsPin = GPIO_UNASSIGNED;
boardConfiguration->hip9011CsPin = GPIO_UNASSIGNED;
boardConfiguration->hip9011IntHoldPin = GPIO_UNASSIGNED;
boardConfiguration->mainRelayPin = GPIO_UNASSIGNED;
boardConfiguration->mainRelayPinMode = OM_DEFAULT;
boardConfiguration->idle.solenoidPin = GPIO_UNASSIGNED;
boardConfiguration->idle.solenoidPinMode = OM_DEFAULT;
boardConfiguration->fuelPumpPin = GPIO_UNASSIGNED;
boardConfiguration->fuelPumpPinMode = OM_DEFAULT;
boardConfiguration->etb1.controlPin1 = GPIO_UNASSIGNED;
boardConfiguration->etb1.controlPin2 = GPIO_UNASSIGNED;
boardConfiguration->etb1.directionPin1 = GPIO_UNASSIGNED;
boardConfiguration->etb1.directionPin2 = GPIO_UNASSIGNED;
boardConfiguration->o2heaterPin = GPIO_UNASSIGNED;
boardConfiguration->tachOutputPin = GPIO_UNASSIGNED;
boardConfiguration->malfunctionIndicatorPin = GPIO_UNASSIGNED;
boardConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT;
boardConfiguration->fanPin = GPIO_UNASSIGNED;
boardConfiguration->fanPinMode = OM_DEFAULT;
boardConfiguration->clutchDownPin = GPIO_UNASSIGNED;
boardConfiguration->clutchDownPinMode = PI_PULLUP;
boardConfiguration->clutchUpPin = GPIO_UNASSIGNED;
boardConfiguration->clutchUpPinMode = PI_PULLUP;
2017-05-15 01:53:04 -07:00
engineConfiguration->brakePedalPin = GPIO_UNASSIGNED;
engineConfiguration->brakePedalPinMode = PI_PULLUP;
2015-07-10 06:01:56 -07:00
boardConfiguration->gps_rx_pin = GPIO_UNASSIGNED;
boardConfiguration->gps_tx_pin = GPIO_UNASSIGNED;
2016-12-27 11:04:04 -08:00
boardConfiguration->vehicleSpeedSensorInputPin = GPIO_UNASSIGNED;
boardConfiguration->triggerErrorPin = GPIO_UNASSIGNED;
2015-07-10 06:01:56 -07:00
for (int i = 0;i < INJECTION_PIN_COUNT;i++) {
boardConfiguration->injectionPins[i] = GPIO_UNASSIGNED;
2015-07-10 06:01:56 -07:00
}
boardConfiguration->injectionPinMode = OM_DEFAULT;
2015-07-10 06:01:56 -07:00
for (int i = 0;i < IGNITION_PIN_COUNT;i++) {
boardConfiguration->ignitionPins[i] = GPIO_UNASSIGNED;
2015-07-10 06:01:56 -07:00
}
boardConfiguration->ignitionPinMode = OM_DEFAULT;
for (int i = 0; i < TRIGGER_SIMULATOR_PIN_COUNT; i++) {
boardConfiguration->triggerSimulatorPins[i] = GPIO_UNASSIGNED;
boardConfiguration->triggerSimulatorPinModes[i] = OM_DEFAULT;
}
for (int i = 0; i < LOGIC_ANALYZER_CHANNEL_COUNT; i++) {
boardConfiguration->logicAnalyzerPins[i] = GPIO_UNASSIGNED;
}
for (int i = 0; i < EGT_CHANNEL_COUNT; i++) {
boardConfiguration->max31855_cs[i] = GPIO_UNASSIGNED;
}
for (int i = 0; i < DIGIPOT_COUNT; i++) {
boardConfiguration->digitalPotentiometerChipSelect[i] = GPIO_UNASSIGNED;
}
boardConfiguration->is_enabled_spi_1 = boardConfiguration->is_enabled_spi_2 = false;
boardConfiguration->is_enabled_spi_3 = boardConfiguration->is_enabled_spi_4 = false;
2015-12-02 17:10:06 -08:00
}
2015-07-10 06:01:56 -07:00
2019-04-28 20:42:49 -07:00
void setDefaultBasePins(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
2019-02-24 06:49:46 -08:00
#ifdef EFI_FATAL_ERROR_PIN
engineConfiguration->fatalErrorPin = EFI_FATAL_ERROR_PIN;
#else
engineConfiguration->fatalErrorPin = GPIOD_14; // red LED on discovery
2019-02-24 06:49:46 -08:00
#endif /* EFI_FATAL_ERROR_PIN */
#ifdef EFI_WARNING_PIN
engineConfiguration->warningLedPin = EFI_WARNING_PIN;
#else
engineConfiguration->warningLedPin = GPIOD_13; // orange LED on discovery
#endif
#ifdef EFI_COMMUNICATION_PIN
engineConfiguration->communicationLedPin = EFI_COMMUNICATION_PIN;
#else
engineConfiguration->communicationLedPin = GPIOD_15; // blue LED on discovery
#endif
#ifdef EFI_RUNNING_PIN
engineConfiguration->runningLedPin = EFI_RUNNING_PIN;
#else
engineConfiguration->runningLedPin = GPIOD_12; // green LED on discovery
#endif
2019-04-12 19:07:03 -07:00
#if EFI_PROD_CODE
// call overrided board-specific serial configuration setup, if needed (for custom boards only)
// needed also by bootloader code
setPinConfigurationOverrides();
#endif /* EFI_PROD_CODE */
2015-07-10 06:01:56 -07:00
}
// needed also by bootloader code
2019-04-28 20:42:49 -07:00
void setDefaultSerialParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
boardConfiguration->useSerialPort = true;
engineConfiguration->binarySerialTxPin = GPIOC_10;
engineConfiguration->binarySerialRxPin = GPIOC_11;
engineConfiguration->consoleSerialTxPin = GPIOC_10;
engineConfiguration->consoleSerialRxPin = GPIOC_11;
boardConfiguration->tunerStudioSerialSpeed = TS_DEFAULT_SPEED;
engineConfiguration->uartConsoleSerialSpeed = 115200;
2019-04-12 19:07:03 -07:00
#if EFI_PROD_CODE
// call overrided board-specific serial configuration setup, if needed (for custom boards only)
setSerialConfigurationOverrides();
#endif /* EFI_PROD_CODE */
}
// needed also by bootloader code
// at the moment bootloader does NOT really need SD card, this is a step towards future bootloader SD card usage
2019-04-28 20:42:49 -07:00
void setDefaultSdCardParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
boardConfiguration->is_enabled_spi_3 = true;
engineConfiguration->sdCardSpiDevice = SPI_DEVICE_3;
boardConfiguration->sdCardCsPin = GPIOD_4;
boardConfiguration->isSdCardEnabled = true;
2019-04-12 19:07:03 -07:00
#if EFI_PROD_CODE
// call overrided board-specific SD card configuration setup, if needed (for custom boards only)
setSdCardConfigurationOverrides();
#endif /* EFI_PROD_CODE */
}
2016-01-23 08:01:32 -08:00
// todo: move injector calibration somewhere else?
// todo: add a enum? if we have enough data?
2017-05-15 20:28:49 -07:00
static void setBosch02880155868(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
2016-01-23 08:01:32 -08:00
// http://www.boschdealer.com/specsheets/0280155868cs.jpg
engineConfiguration->injector.battLagCorrBins[0] = 6;
engineConfiguration->injector.battLagCorr[0] = 3.371;
engineConfiguration->injector.battLagCorrBins[1] = 8;
engineConfiguration->injector.battLagCorr[1] = 1.974;
engineConfiguration->injector.battLagCorrBins[2] = 10;
engineConfiguration->injector.battLagCorr[2] = 1.383;
engineConfiguration->injector.battLagCorrBins[3] = 11;
engineConfiguration->injector.battLagCorr[3] = 1.194;
engineConfiguration->injector.battLagCorrBins[4] = 12;
engineConfiguration->injector.battLagCorr[4] = 1.04;
engineConfiguration->injector.battLagCorrBins[5] = 13;
engineConfiguration->injector.battLagCorr[5] = 0.914;
engineConfiguration->injector.battLagCorrBins[6] = 14;
engineConfiguration->injector.battLagCorr[6] = 0.797;
engineConfiguration->injector.battLagCorrBins[7] = 15;
engineConfiguration->injector.battLagCorr[7] = 0.726;
}
static void setDefaultWarmupIdleCorrection(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
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;
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
}
2017-05-15 20:28:49 -07:00
static void setDefaultWarmupFuelEnrichment(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
initTemperatureCurve(WARMUP_CLT_EXTRA_FUEL_CURVE, 1.0);
setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, -40, 1.50);
setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, -30, 1.50);
setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, -20, 1.42);
setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, -10, 1.36);
setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, 0, 1.28);
setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, 10, 1.19);
setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, 20, 1.12);
setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, 30, 1.10);
setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, 40, 1.06);
setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, 50, 1.06);
setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, 60, 1.03);
setCurveValue(WARMUP_CLT_EXTRA_FUEL_CURVE, 70, 1.01);
2017-05-11 15:58:13 -07:00
}
static void setDefaultFuelCutParameters(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
boardConfiguration->coastingFuelCutEnabled = false;
engineConfiguration->coastingFuelCutRpmLow = 1300;
engineConfiguration->coastingFuelCutRpmHigh = 1500;
engineConfiguration->coastingFuelCutTps = 2;
engineConfiguration->coastingFuelCutMap = 30;
engineConfiguration->coastingFuelCutClt = 30;
}
2017-05-15 20:28:49 -07:00
static void setDefaultCrankingSettings(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
2019-05-25 10:36:29 -07:00
setLinearCurve(engineConfiguration->crankingTpsCoef, CRANKING_CURVE_SIZE, /*from*/1, /*to*/1, 1);
2018-01-07 08:17:49 -08:00
setLinearCurve(engineConfiguration->crankingTpsBins, CRANKING_CURVE_SIZE, 0, 100, 1);
2017-05-11 16:03:31 -07:00
2019-05-25 10:36:29 -07:00
setLinearCurve(config->cltCrankingCorrBins, CLT_CRANKING_CURVE_SIZE, CLT_CURVE_RANGE_FROM, 100, 1);
setLinearCurve(config->cltCrankingCorr, CLT_CRANKING_CURVE_SIZE, 1.0, 1.0, 1);
2019-05-25 10:36:29 -07:00
config->crankingFuelCoef[0] = 2.8; // base cranking fuel adjustment coefficient
2017-05-11 16:03:31 -07:00
config->crankingFuelBins[0] = -20; // temperature in C
config->crankingFuelCoef[1] = 2.2;
2017-05-11 16:03:31 -07:00
config->crankingFuelBins[1] = -10;
config->crankingFuelCoef[2] = 1.8;
2017-05-11 16:03:31 -07:00
config->crankingFuelBins[2] = 5;
config->crankingFuelCoef[3] = 1.5;
2019-04-04 05:26:57 -07:00
config->crankingFuelBins[3] = 30;
config->crankingFuelCoef[4] = 1.0;
2017-05-11 16:03:31 -07:00
config->crankingFuelBins[4] = 35;
config->crankingFuelCoef[5] = 1.0;
2017-05-11 16:03:31 -07:00
config->crankingFuelBins[5] = 50;
config->crankingFuelCoef[6] = 1.0;
2017-05-11 16:03:31 -07:00
config->crankingFuelBins[6] = 65;
config->crankingFuelCoef[7] = 1.0;
2017-05-11 16:03:31 -07:00
config->crankingFuelBins[7] = 90;
config->crankingCycleCoef[0] = 1.5;
config->crankingCycleBins[0] = 4;
config->crankingCycleCoef[1] = 1.35;
config->crankingCycleBins[1] = 8;
config->crankingCycleCoef[2] = 1.05;
config->crankingCycleBins[2] = 12;
config->crankingCycleCoef[3] = 0.75;
config->crankingCycleBins[3] = 16;
config->crankingCycleCoef[4] = 0.5;
config->crankingCycleBins[4] = 74;
config->crankingCycleCoef[5] = 0.5;
config->crankingCycleBins[5] = 75;
config->crankingCycleCoef[6] = 0.5;
config->crankingCycleBins[6] = 76;
config->crankingCycleCoef[7] = 0.5;
config->crankingCycleBins[7] = 77;
engineConfiguration->crankingAdvance[0] = 0;
engineConfiguration->crankingAdvanceBins[0] = 0;
engineConfiguration->crankingAdvance[1] = 0;
engineConfiguration->crankingAdvanceBins[1] = 200;
engineConfiguration->crankingAdvance[2] = 0;
engineConfiguration->crankingAdvanceBins[2] = 400;
engineConfiguration->crankingAdvance[3] = 0;
engineConfiguration->crankingAdvanceBins[3] = 1000;
2017-05-11 16:03:31 -07:00
}
2018-01-07 09:11:49 -08:00
/**
* see also setTargetRpmCurve()
*/
2017-05-15 20:28:49 -07:00
static void setDefaultIdleSpeedTarget(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
2019-05-25 10:36:29 -07:00
setLinearCurve(engineConfiguration->cltIdleRpmBins, CLT_CURVE_SIZE, CLT_CURVE_RANGE_FROM, 140, 10);
2018-01-07 09:11:49 -08:00
2017-06-11 12:06:05 -07:00
setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, -30, 1350);
setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, -20, 1300);
setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, -10, 1200);
setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 0, 1150);
setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 10, 1100);
setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 20, 1050);
setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 30, 1000);
setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 40, 1000);
setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 50, 950);
setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 60, 950);
setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 70, 930);
setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 80, 900);
setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 90, 900);
setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 100, 1000);
setCurveValue(engineConfiguration->cltIdleRpmBins, engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, 110, 1100);
2017-05-11 16:03:31 -07:00
}
2017-05-15 20:28:49 -07:00
static void setDefaultStepperIdleParameters(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
boardConfiguration->idle.stepperDirectionPin = GPIOE_10;
boardConfiguration->idle.stepperStepPin = GPIOE_12;
2017-05-11 16:03:31 -07:00
engineConfiguration->stepperEnablePin = GPIOE_14;
engineConfiguration->idleStepperReactionTime = 10;
engineConfiguration->idleStepperTotalSteps = 150;
}
2017-05-15 20:28:49 -07:00
static void setCanDefaults(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
boardConfiguration->canDeviceMode = CD_USE_CAN2;
boardConfiguration->canTxPin = GPIOB_6;
boardConfiguration->canRxPin = GPIOB_12;
2017-05-11 16:07:15 -07:00
2019-02-10 19:47:49 -08:00
engineConfiguration->canSleepPeriodMs = 50;
2017-05-11 16:07:15 -07:00
engineConfiguration->canReadEnabled = true;
engineConfiguration->canWriteEnabled = true;
engineConfiguration->canNbcType = CAN_BUS_MAZDA_RX8;
}
2018-01-07 09:11:49 -08:00
/**
* see also setDefaultIdleSpeedTarget()
*/
void setTargetRpmCurve(int rpm DECLARE_CONFIG_PARAMETER_SUFFIX) {
2019-05-25 10:36:29 -07:00
setLinearCurve(engineConfiguration->cltIdleRpmBins, CLT_CURVE_SIZE, CLT_CURVE_RANGE_FROM, 90, 10);
2018-01-07 09:11:49 -08:00
setLinearCurve(engineConfiguration->cltIdleRpm, CLT_CURVE_SIZE, rpm, rpm, 10);
2017-12-24 19:05:16 -08:00
}
int getTargetRpmForIdleCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
float clt = engine->sensors.clt;
int targetRpm;
if (cisnan(clt)) {
// error is already reported, let's take first value from the table should be good enough error handing solution
targetRpm = CONFIG(cltIdleRpm)[0];
} else {
targetRpm = interpolate2d("cltRpm", clt, CONFIG(cltIdleRpmBins), CONFIG(cltIdleRpm), CLT_CURVE_SIZE);
}
return targetRpm + engine->fsioState.fsioIdleTargetRPMAdjustment;
}
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.
2015-07-10 06:01:56 -07:00
*/
2017-05-15 20:28:49 -07:00
void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
2019-04-12 19:07:03 -07:00
#if (! EFI_UNIT_TEST)
2015-07-10 06:01:56 -07:00
memset(&persistentState.persistentConfiguration, 0, sizeof(persistentState.persistentConfiguration));
#endif
prepareVoidConfiguration(engineConfiguration);
CONFIGB(mafSensorType) = Bosch0280218037;
2015-07-10 06:01:56 -07:00
setBosch0280218037(config);
2017-05-15 20:28:49 -07:00
setBosch02880155868(PASS_ENGINE_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
2017-08-06 16:47:16 -07:00
for (int i = 0; i < FSIO_COMMAND_COUNT; i++) {
config->fsioFormulas[i][0] = 0;
}
CONFIGB(mapMinBufferLength) = 1;
2017-06-21 23:29:52 -07:00
2017-12-26 21:26:40 -08:00
engineConfiguration->idlePidRpmDeadZone = 50;
2017-07-15 12:36:49 -07:00
engineConfiguration->startOfCrankingPrimingPulse = 0;
2015-07-10 06:01:56 -07:00
engineConfiguration->acCutoffLowRpm = 700;
engineConfiguration->acCutoffHighRpm = 5000;
2016-12-06 20:03:39 -08:00
engineConfiguration->postCrankingTargetClt = 25;
engineConfiguration->postCrankingDurationSec = 2;
2017-06-11 12:17:02 -07:00
initTemperatureCurve(IAT_FUEL_CORRECTION_CURVE, 1);
2015-07-10 06:01:56 -07:00
2015-08-18 21:03:11 -07:00
engineConfiguration->tachPulseDuractionMs = 4;
engineConfiguration->tachPulseTriggerIndex = 4;
2015-07-10 06:01:56 -07:00
engineConfiguration->auxPid[0].minValue = 10;
engineConfiguration->auxPid[0].maxValue = 90;
2017-04-10 11:59:21 -07:00
engineConfiguration->etb.minValue = 0;
engineConfiguration->etb.maxValue = 99;
2017-05-28 11:22:43 -07:00
engineConfiguration->alternatorControl.minValue = 10;
engineConfiguration->alternatorControl.maxValue = 90;
2017-04-10 11:59:21 -07:00
2019-05-25 10:36:29 -07:00
setLinearCurve(engineConfiguration->cltTimingBins, CLT_TIMING_CURVE_SIZE, CLT_CURVE_RANGE_FROM, 120, 1);
2018-01-07 08:17:49 -08:00
setLinearCurve(engineConfiguration->cltTimingExtra, CLT_TIMING_CURVE_SIZE, 0, 0, 1);
2016-10-11 21:01:45 -07:00
2018-01-07 08:17:49 -08:00
setLinearCurve(engineConfiguration->fsioCurve1Bins, FSIO_CURVE_16, 0, 100, 1);
setLinearCurve(engineConfiguration->fsioCurve1, FSIO_CURVE_16, 0, 100, 1);
2017-11-27 18:49:58 -08:00
2018-01-07 08:17:49 -08:00
setLinearCurve(engineConfiguration->fsioCurve2Bins, FSIO_CURVE_16, 0, 100, 1);
setLinearCurve(engineConfiguration->fsioCurve2, FSIO_CURVE_16, 30, 170, 1);
2017-11-27 18:49:58 -08:00
2018-01-07 08:17:49 -08:00
setLinearCurve(engineConfiguration->fsioCurve3Bins, FSIO_CURVE_8, 0, 100, 1);
setLinearCurve(engineConfiguration->fsioCurve4Bins, FSIO_CURVE_8, 0, 100, 1);
2017-11-25 22:17:37 -08:00
setDefaultWarmupIdleCorrection(PASS_CONFIG_PARAMETER_SIGNATURE);
2016-02-14 10:02:00 -08:00
2017-05-15 20:28:49 -07:00
setDefaultWarmupFuelEnrichment(PASS_ENGINE_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
setDefaultFuelCutParameters(PASS_ENGINE_PARAMETER_SIGNATURE);
setMazdaMiataNbTpsTps(PASS_CONFIG_PARAMETER_SIGNATURE);
2017-06-10 21:54:37 -07:00
2019-02-05 20:49:19 -08:00
/**
* 4ms is global default dwell for the whole RPM range
* if you only have one coil and many cylinders or high RPM you would need lower value at higher RPM
*/
setConstantDwell(4 PASS_CONFIG_PARAMETER_SUFFIX);
2019-02-05 21:05:14 -08:00
/**
* Use angle-based duration during cranking
* this is equivalent to 'disable cranking_constant_dwell' console command
*/
engineConfiguration->useConstantDwellDuringCranking = true;
2016-10-28 19:03:00 -07:00
engineConfiguration->ignitionDwellForCrankingMs = 6;
2015-07-10 06:01:56 -07:00
setFuelLoadBin(1.2, 4.4 PASS_CONFIG_PARAMETER_SUFFIX);
setFuelRpmBin(800, 7000 PASS_CONFIG_PARAMETER_SUFFIX);
setTimingLoadBin(1.2, 4.4 PASS_CONFIG_PARAMETER_SUFFIX);
setTimingRpmBin(800, 7000 PASS_CONFIG_PARAMETER_SUFFIX);
2015-07-10 06:01:56 -07:00
2018-01-07 08:17:49 -08:00
setLinearCurve(engineConfiguration->map.samplingAngleBins, MAP_ANGLE_SIZE, 800, 7000, 1);
setLinearCurve(engineConfiguration->map.samplingAngle, MAP_ANGLE_SIZE, 100, 130, 1);
setLinearCurve(engineConfiguration->map.samplingWindowBins, MAP_ANGLE_SIZE, 800, 7000, 1);
setLinearCurve(engineConfiguration->map.samplingWindow, MAP_ANGLE_SIZE, 50, 50, 1);
2015-07-10 06:01:56 -07:00
// set_whole_timing_map 3
setWholeFuelMap(3 PASS_CONFIG_PARAMETER_SUFFIX);
2016-06-29 22:01:38 -07:00
setAfrMap(config->afrTable, 14.7);
2015-07-10 06:01:56 -07:00
2017-05-15 20:28:49 -07:00
setDefaultVETable(PASS_ENGINE_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
2019-06-10 12:45:18 -07:00
#if (IGN_LOAD_COUNT == FUEL_LOAD_COUNT) && (IGN_RPM_COUNT == FUEL_RPM_COUNT)
// todo: make setMap a template
2015-07-10 06:01:56 -07:00
setMap(config->injectionPhase, -180);
2019-06-10 12:45:18 -07:00
#endif
2015-07-10 06:01:56 -07:00
setRpmTableBin(config->injPhaseRpmBins, FUEL_RPM_COUNT);
setFuelTablesLoadBin(10, 160 PASS_CONFIG_PARAMETER_SUFFIX);
2017-05-15 20:28:49 -07:00
setDefaultIatTimingCorrection(PASS_ENGINE_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
2018-01-07 08:17:49 -08:00
setLinearCurve(engineConfiguration->mapAccelTaperBins, FSIO_TABLE_8, 0, 32, 4);
setLinearCurve(engineConfiguration->mapAccelTaperMult, FSIO_TABLE_8, 1, 1, 1);
2016-03-08 21:03:14 -08:00
2018-01-07 08:17:49 -08:00
setLinearCurve(config->tpsTpsAccelFromRpmBins, FSIO_TABLE_8, 0, 100, 10);
setLinearCurve(config->tpsTpsAccelToRpmBins, FSIO_TABLE_8, 0, 100, 10);
2016-03-08 21:03:14 -08:00
2018-01-07 08:17:49 -08:00
setLinearCurve(config->fsioTable1LoadBins, FSIO_TABLE_8, 20, 120, 10);
2016-03-03 21:02:18 -08:00
setRpmTableBin(config->fsioTable1RpmBins, FSIO_TABLE_8);
2018-01-07 08:17:49 -08:00
setLinearCurve(config->fsioTable2LoadBins, FSIO_TABLE_8, 20, 120, 10);
2016-03-03 21:02:18 -08:00
setRpmTableBin(config->fsioTable2RpmBins, FSIO_TABLE_8);
2018-01-07 08:17:49 -08:00
setLinearCurve(config->fsioTable3LoadBins, FSIO_TABLE_8, 20, 120, 10);
2016-07-01 20:01:22 -07:00
setRpmTableBin(config->fsioTable3RpmBins, FSIO_TABLE_8);
2018-01-07 08:17:49 -08:00
setLinearCurve(config->fsioTable4LoadBins, FSIO_TABLE_8, 20, 120, 10);
2016-07-01 20:01:22 -07:00
setRpmTableBin(config->fsioTable4RpmBins, FSIO_TABLE_8);
2016-03-03 21:02:18 -08:00
2017-05-15 20:28:49 -07:00
initEngineNoiseTable(PASS_ENGINE_PARAMETER_SIGNATURE);
2016-01-01 14:02:49 -08:00
2015-07-10 06:01:56 -07:00
setThermistorConfiguration(&engineConfiguration->clt, 0, 9500, 23.8889, 2100, 48.8889, 1000);
engineConfiguration->clt.config.bias_resistor = 1500;
setThermistorConfiguration(&engineConfiguration->iat, 32, 9500, 75, 2100, 120, 1000);
// todo: this value is way off! I am pretty sure temp coeffs are off also
engineConfiguration->iat.config.bias_resistor = 2700;
2019-04-12 19:07:03 -07:00
#if EFI_PROD_CODE
2016-07-22 15:04:12 -07:00
engineConfiguration->warningPeriod = 10;
2016-07-23 11:03:36 -07:00
#else
engineConfiguration->warningPeriod = 0;
2016-12-21 15:01:56 -08:00
#endif /* EFI_PROD_CODE */
2016-07-22 15:04:12 -07:00
2015-07-10 06:01:56 -07:00
engineConfiguration->step1rpm = 3000;
2015-09-30 19:02:34 -07:00
engineConfiguration->step1timing = 10;
engineConfiguration->step1RpmWindow = 500;
engineConfiguration->step1fuelCutEnable = false;
engineConfiguration->step1SparkCutEnable = false;
2015-10-05 17:01:54 -07:00
engineConfiguration->step1RpmWindow = 500;
2015-07-10 06:01:56 -07:00
2016-05-23 12:02:46 -07:00
engineConfiguration->slowAdcAlpha = 0.33333;
2016-01-30 19:03:36 -08:00
engineConfiguration->engineSnifferRpmThreshold = 2500;
engineConfiguration->sensorSnifferRpmThreshold = 2500;
2015-07-10 06:01:56 -07:00
engineConfiguration->rpmHardLimit = 7000;
engineConfiguration->cranking.rpm = 550;
engineConfiguration->cutFuelOnHardLimit = true;
engineConfiguration->cutSparkOnHardLimit = true;
2016-07-01 07:02:58 -07:00
engineConfiguration->tChargeMinRpmMinTps = 0.25;
engineConfiguration->tChargeMinRpmMaxTps = 0.25;
engineConfiguration->tChargeMaxRpmMinTps = 0.25;
engineConfiguration->tChargeMaxRpmMaxTps = 0.9;
engineConfiguration->tChargeMode = TCHARGE_MODE_RPM_TPS;
engineConfiguration->tChargeAirCoefMin = 0.098f;
engineConfiguration->tChargeAirCoefMax = 0.902f;
engineConfiguration->tChargeAirFlowMax = 153.6f;
engineConfiguration->tChargeAirIncrLimit = 1.0f;
engineConfiguration->tChargeAirDecrLimit = 12.5f;
2016-07-01 07:02:58 -07:00
2015-07-10 06:01:56 -07:00
engineConfiguration->noAccelAfterHardLimitPeriodSecs = 3;
2017-05-15 20:28:49 -07:00
setDefaultCrankingSettings(PASS_ENGINE_PARAMETER_SIGNATURE);
2015-11-18 18:02:51 -08:00
2016-02-10 14:01:44 -08:00
engineConfiguration->warmupTargetAfrBins[0] = -12;
engineConfiguration->warmupTargetAfr[0] = 12.3;
engineConfiguration->warmupTargetAfrBins[1] = 0;
engineConfiguration->warmupTargetAfr[1] = 13;
engineConfiguration->warmupTargetAfrBins[2] = 30;
engineConfiguration->warmupTargetAfr[2] = 13.8;
engineConfiguration->warmupTargetAfrBins[3] = 60;
engineConfiguration->warmupTargetAfr[3] = 14.5;
2017-01-22 13:04:09 -08:00
engineConfiguration->fuelClosedLoopCorrectionEnabled = false;
engineConfiguration->fuelClosedLoopCltThreshold = 70;
engineConfiguration->fuelClosedLoopRpmThreshold = 900;
engineConfiguration->fuelClosedLoopTpsThreshold = 80;
boardConfiguration->fuelClosedLoopAfrLowThreshold = 10.3;
2017-01-22 21:06:44 -08:00
engineConfiguration->fuelClosedLoopAfrHighThreshold = 19.8;
engineConfiguration->fuelClosedLoopPid.pFactor = -0.1;
2017-01-22 13:04:09 -08:00
2018-01-07 09:11:49 -08:00
/**
* Idle control defaults
*/
setDefaultIdleSpeedTarget(PASS_ENGINE_PARAMETER_SIGNATURE);
// setTargetRpmCurve(1200 PASS_ENGINE_PARAMETER_SUFFIX);
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;
2019-02-26 18:50:58 -08:00
engineConfiguration->idleRpmPid.minValue = 0.1;
engineConfiguration->idleRpmPid.maxValue = 99;
boardConfiguration->idlePidDeactivationTpsThreshold = 2;
2017-05-28 10:44:26 -07:00
boardConfiguration->idle.solenoidFrequency = 200;
2018-01-07 09:11:49 -08:00
// set idle_position 50
boardConfiguration->manIdlePosition = 50;
2018-01-07 09:11:49 -08:00
engineConfiguration->crankingIACposition = 50;
// engineConfiguration->idleMode = IM_AUTO;
engineConfiguration->idleMode = IM_MANUAL;
2015-07-10 06:01:56 -07:00
boardConfiguration->useStepperIdle = false;
2018-01-07 09:11:49 -08:00
setDefaultStepperIdleParameters(PASS_ENGINE_PARAMETER_SIGNATURE);
/**
* Cranking defaults
*/
engineConfiguration->startUpFuelPumpDuration = 4;
engineConfiguration->cranking.baseFuel = 5;
2015-07-10 06:01:56 -07:00
engineConfiguration->crankingChargeAngle = 70;
2018-01-07 09:11:49 -08:00
2015-07-10 06:01:56 -07:00
engineConfiguration->timingMode = TM_DYNAMIC;
engineConfiguration->fixedModeTiming = 50;
2018-01-07 09:11:49 -08:00
engineConfiguration->analogInputDividerCoefficient = 2;
2015-07-10 06:01:56 -07:00
// performance optimization
boardConfiguration->sensorChartMode = SC_OFF;
2015-07-10 06:01:56 -07:00
2016-07-05 06:01:23 -07:00
engineConfiguration->storageMode = MS_AUTO;
2016-07-20 16:04:27 -07:00
engineConfiguration->specs.firingOrder = FO_1_3_4_2;
2015-07-10 06:01:56 -07:00
engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS;
engineConfiguration->injectionMode = IM_SEQUENTIAL;
engineConfiguration->ignitionMode = IM_ONE_COIL;
engineConfiguration->globalTriggerAngleOffset = 0;
2016-08-28 13:02:34 -07:00
engineConfiguration->extraInjectionOffset = 0;
2015-07-10 06:01:56 -07:00
engineConfiguration->ignitionOffset = 0;
engineConfiguration->overrideCrankingIgnition = true;
engineConfiguration->sensorChartFrequency = 20;
2016-08-28 13:02:34 -07:00
engineConfiguration->fuelAlgorithm = LM_PLAIN_MAF;
2015-07-10 06:01:56 -07:00
engineConfiguration->vbattDividerCoeff = ((float) (15 + 65)) / 15;
2017-04-18 18:37:31 -07:00
engineConfiguration->fanOnTemperature = 95;
2017-04-18 18:59:23 -07:00
engineConfiguration->fanOffTemperature = 91;
2015-07-10 06:01:56 -07:00
engineConfiguration->tpsMin = convertVoltageTo10bitADC(1.250);
engineConfiguration->tpsMax = convertVoltageTo10bitADC(4.538);
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
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
setOperationMode(engineConfiguration, FOUR_STROKE_CAM_SENSOR);
engineConfiguration->specs.cylindersCount = 4;
engineConfiguration->specs.displacement = 2;
/**
* By the way http://users.erols.com/srweiss/tableifc.htm has a LOT of data
*/
engineConfiguration->injector.flow = 200;
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->displayMode = DM_HD44780;
engineConfiguration->logFormat = LF_NATIVE;
engineConfiguration->directSelfStimulation = false;
engineConfiguration->trigger.type = TT_TOOTHED_WHEEL_60_2;
engineConfiguration->HD44780width = 20;
engineConfiguration->HD44780height = 4;
engineConfiguration->cylinderBore = 87.5;
setEgoSensor(ES_14Point7_Free PASS_CONFIG_PARAMETER_SUFFIX);
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
engineConfiguration->isEngineChartEnabled = true;
2016-02-27 20:03:34 -08:00
engineConfiguration->useOnlyRisingEdgeForTrigger = false;
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->primingSquirtDurationMs = 5;
engineConfiguration->isInjectionEnabled = true;
engineConfiguration->isIgnitionEnabled = true;
2016-06-14 19:03:05 -07:00
engineConfiguration->isCylinderCleanupEnabled = false; // this feature is evil if one does not have TPS, better turn off by default
2015-07-10 06:01:56 -07:00
engineConfiguration->secondTriggerChannelEnabled = true;
engineConfiguration->isMapAveragingEnabled = true;
engineConfiguration->isTunerStudioEnabled = true;
engineConfiguration->isWaveAnalyzerEnabled = true;
2017-02-12 18:04:18 -08:00
engineConfiguration->debugMode = DBG_ALTERNATOR_PID;
2016-02-04 20:02:52 -08:00
2015-07-10 06:01:56 -07:00
engineConfiguration->acIdleRpmBump = 200;
engineConfiguration->knockDetectionWindowStart = 35;
engineConfiguration->knockDetectionWindowEnd = 135;
boardConfiguration->fuelLevelEmptyTankVoltage = 0;
boardConfiguration->fuelLevelFullTankVoltage = 5;
2015-07-10 06:01:56 -07:00
/**
* this is RPM. 10000 rpm is only 166Hz, 800 rpm is 13Hz
*/
boardConfiguration->triggerSimulatorFrequency = 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
strcpy(config->timingMultiplier, "1");
strcpy(config->timingAdditive, "0");
2018-08-08 17:56:11 -07:00
engineConfiguration->cj125isUaDivided = true;
2015-07-10 06:01:56 -07:00
engineConfiguration->isAlternatorControlEnabled = true;
engineConfiguration->vehicleSpeedCoef = 1.0f;
boardConfiguration->logicAnalyzerMode[0] = false;
boardConfiguration->logicAnalyzerMode[1] = false;
2015-07-10 06:01:56 -07:00
2016-01-08 08:01:40 -08:00
engineConfiguration->mapErrorDetectionTooLow = 5;
engineConfiguration->mapErrorDetectionTooHigh = 250;
2015-08-30 13:02:00 -07:00
2019-02-10 19:47:49 -08:00
boardConfiguration->idleThreadPeriodMs = 100;
boardConfiguration->consoleLoopPeriodMs = 200;
boardConfiguration->lcdThreadPeriodMs = 300;
boardConfiguration->generalPeriodicThreadPeriodMs = 50;
boardConfiguration->useLcdScreen = true;
2015-07-10 06:01:56 -07:00
2019-01-04 14:18:43 -08:00
engineConfiguration->hip9011Gain = 1;
2015-07-10 06:01:56 -07:00
boardConfiguration->isFastAdcEnabled = true;
boardConfiguration->isEngineControlEnabled = true;
2015-07-10 06:01:56 -07:00
boardConfiguration->isVerboseAlternator = false;
2015-07-10 06:01:56 -07:00
2016-02-08 21:01:43 -08:00
engineConfiguration->warmupAfrPid.offset = 1;
2016-02-10 14:01:44 -08:00
engineConfiguration->warmupAfrThreshold = 60;
2015-07-10 06:01:56 -07:00
2015-12-31 12:01:38 -08:00
engineConfiguration->engineLoadAccelLength = 6;
engineConfiguration->engineLoadAccelEnrichmentThreshold = 5; // kPa
2017-03-05 04:42:18 -08:00
engineConfiguration->engineLoadAccelEnrichmentMultiplier = 0; // todo: improve implementation and re-enable by default
2015-07-10 06:01:56 -07:00
engineConfiguration->tpsAccelLength = 12;
engineConfiguration->tpsAccelEnrichmentThreshold = 40; // TPS % change, per engine cycle
2019-04-12 19:07:03 -07:00
#if EFI_FSIO
2017-12-17 09:02:35 -08:00
/**
* to test:
* set_fsio_setting 1 5000
* set_fsio_output_pin 1 PE3
* set debug_mode 23
* writeconfig
* <reboot ECU>
* fsioinfo
*/
boardConfiguration->fsio_setting[0] = 5000;
2017-12-17 09:02:35 -08:00
// simple warning light as default configuration
// set_fsio_expression 1 "rpm > fsio_setting(1)"
setFsio(0, GPIO_UNASSIGNED, RPM_ABOVE_USER_SETTING_1 PASS_CONFIG_PARAMETER_SUFFIX);
#endif /* EFI_FSIO */
2015-07-10 06:01:56 -07:00
}
/**
* @brief Hardware board-specific default configuration (GPIO pins, ADC channels, SPI configs etc.)
*/
void setDefaultBoardConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
// set initial pin groups
2019-04-28 20:42:49 -07:00
setDefaultBasePins(PASS_CONFIG_PARAMETER_SIGNATURE);
2019-04-28 20:42:49 -07:00
setDefaultSerialParameters(PASS_CONFIG_PARAMETER_SIGNATURE);
setCanDefaults(PASS_ENGINE_PARAMETER_SIGNATURE);
engineConfiguration->map.sensor.hwChannel = EFI_ADC_4;
engineConfiguration->clt.adcChannel = EFI_ADC_6;
engineConfiguration->iat.adcChannel = EFI_ADC_7;
engineConfiguration->afr.hwChannel = EFI_ADC_14;
engineConfiguration->accelerometerSpiDevice = SPI_DEVICE_1;
engineConfiguration->hip9011SpiDevice = SPI_DEVICE_2;
engineConfiguration->cj125SpiDevice = SPI_DEVICE_2;
// boardConfiguration->gps_rx_pin = GPIOB_7;
// boardConfiguration->gps_tx_pin = GPIOB_6;
boardConfiguration->triggerSimulatorPins[0] = GPIOD_1;
boardConfiguration->triggerSimulatorPins[1] = GPIOD_2;
boardConfiguration->triggerInputPins[0] = GPIOC_6;
boardConfiguration->triggerInputPins[1] = GPIOA_5;
//boardConfiguration->logicAnalyzerPins[1] = GPIOE_5; // GPIOE_5 is a popular option (if available)
boardConfiguration->boardTestModeJumperPin = GPIOB_0;
// set this to SPI_DEVICE_3 to enable stimulation
//boardConfiguration->digitalPotentiometerSpiDevice = SPI_DEVICE_3;
boardConfiguration->digitalPotentiometerChipSelect[0] = GPIOD_7;
boardConfiguration->digitalPotentiometerChipSelect[1] = GPIO_UNASSIGNED;
boardConfiguration->digitalPotentiometerChipSelect[2] = GPIOD_5;
boardConfiguration->digitalPotentiometerChipSelect[3] = GPIO_UNASSIGNED;
boardConfiguration->spi1mosiPin = GPIOB_5;
boardConfiguration->spi1misoPin = GPIOB_4;
boardConfiguration->spi1sckPin = GPIOB_3; // please note that this pin is also SWO/SWD - Single Wire debug Output
boardConfiguration->spi2mosiPin = GPIOB_15;
boardConfiguration->spi2misoPin = GPIOB_14;
boardConfiguration->spi2sckPin = GPIOB_13;
boardConfiguration->spi3mosiPin = GPIOB_5;
boardConfiguration->spi3misoPin = GPIOB_4;
boardConfiguration->spi3sckPin = GPIOB_3;
// set optional subsystem configs
#if EFI_MEMS
// this would override some values from above
configureAccelerometerPins(PASS_ENGINE_PARAMETER_SIGNATURE);
#endif /* EFI_MEMS */
#if EFI_HIP_9011
setHip9011FrankensoPinout();
#endif /* EFI_HIP_9011 */
#if EFI_FILE_LOGGING
setDefaultSdCardParameters(PASS_ENGINE_PARAMETER_SIGNATURE);
#endif /* EFI_FILE_LOGGING */
boardConfiguration->is_enabled_spi_1 = false;
boardConfiguration->is_enabled_spi_2 = false;
boardConfiguration->is_enabled_spi_3 = true;
}
2017-05-15 20:28:49 -07:00
void resetConfigurationExt(Logging * logger, engine_type_e engineType DECLARE_ENGINE_PARAMETER_SUFFIX) {
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
*/
2017-05-15 20:28:49 -07:00
setDefaultConfiguration(PASS_ENGINE_PARAMETER_SIGNATURE);
/**
* Let's apply global board defaults too, for most of the boards
*/
if (engineType != MINIMAL_PINS
/* this is a bit nasty */
&& engineType != ETB_BENCH_ENGINE
2019-06-07 15:02:28 -07:00
&& engineType != MICRO_RUS_EFI
&& engineType != TLE8888_BENCH_ENGINE) {
setDefaultBoardConfiguration(PASS_ENGINE_PARAMETER_SIGNATURE);
}
#if EFI_PROD_CODE
// call overrided board-specific configuration setup, if needed (for custom boards only)
setBoardConfigurationOverrides();
#endif
2019-04-12 19:07:03 -07:00
#if EFI_SIMULATOR
2015-07-10 06:01:56 -07:00
engineConfiguration->directSelfStimulation = true;
#endif /* */
engineConfiguration->engineType = engineType;
/**
* And override them with engine-specific defaults
*/
switch (engineType) {
case CUSTOM_ENGINE:
setCustomEngineConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
case MINIMAL_PINS:
// all basic settings are already set in prepareVoidConfiguration(), no need to set anything here
break;
2015-07-10 06:01:56 -07:00
case ACURA_RSX:
setAcuraRSX(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
2019-04-12 19:07:03 -07:00
#if EFI_SUPPORT_DODGE_NEON
2015-07-10 06:01:56 -07:00
case DODGE_NEON_1995:
setDodgeNeon1995EngineConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
2016-09-21 09:03:07 -07:00
case DODGE_NEON_2003_CAM:
setDodgeNeonNGCEngineConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
2016-09-21 10:02:42 -07:00
case DODGE_NEON_2003_CRANK:
setDodgeNeonNGCEngineConfigurationCrankBased(PASS_CONFIG_PARAMETER_SIGNATURE);
2016-09-21 10:02:42 -07:00
break;
2016-01-21 15:03:40 -08:00
case LADA_KALINA:
setLadaKalina(PASS_CONFIG_PARAMETER_SIGNATURE);
2016-01-21 15:03:40 -08:00
break;
2015-07-10 06:01:56 -07:00
#endif /* EFI_SUPPORT_DODGE_NEON */
2019-04-12 19:07:03 -07:00
#if EFI_SUPPORT_FORD_ASPIRE
2015-07-10 06:01:56 -07:00
case FORD_ASPIRE_1996:
setFordAspireEngineConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
#endif /* EFI_SUPPORT_FORD_ASPIRE */
2019-04-12 19:07:03 -07:00
#if EFI_SUPPORT_FORD_FIESTA
2015-07-10 06:01:56 -07:00
case FORD_FIESTA:
2017-05-15 20:28:49 -07:00
setFordFiestaDefaultEngineConfiguration(PASS_ENGINE_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
#endif /* EFI_SUPPORT_FORD_FIESTA */
2019-04-12 19:07:03 -07:00
#if EFI_SUPPORT_NISSAN_PRIMERA
2015-07-10 06:01:56 -07:00
case NISSAN_PRIMERA:
setNissanPrimeraEngineConfiguration(engineConfiguration);
break;
#endif
case HONDA_ACCORD_CD:
setHondaAccordConfigurationThreeWires(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
2016-05-04 20:02:32 -07:00
case ZIL_130:
setZil130(PASS_CONFIG_PARAMETER_SIGNATURE);
2016-05-04 20:02:32 -07:00
break;
2019-01-19 17:27:14 -08:00
case MIATA_NA6_MAP:
setMiataNA6_MAP_Configuration(PASS_CONFIG_PARAMETER_SIGNATURE);
2019-01-19 17:27:14 -08:00
break;
case MIATA_NA6_VAF:
setMiataNA6_VAF_Configuration(PASS_CONFIG_PARAMETER_SIGNATURE);
2016-04-16 15:01:43 -07:00
break;
2019-02-27 05:55:56 -08:00
case ETB_BENCH_ENGINE:
setEtbTestConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE);
2019-02-27 05:55:56 -08:00
break;
2019-06-07 15:02:28 -07:00
case MICRO_RUS_EFI:
2019-04-04 18:34:33 -07:00
case TLE8888_BENCH_ENGINE:
setTle8888TestConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE);
2019-04-04 18:34:33 -07:00
break;
2018-09-06 19:31:23 -07:00
case MAZDA_MIATA_NA8:
setMazdaMiataNA8Configuration(PASS_CONFIG_PARAMETER_SIGNATURE);
2018-09-06 19:31:23 -07:00
break;
2017-03-01 16:41:17 -08:00
case TEST_CIVIC_4_0_BOTH:
setHondaCivic4_0_both(PASS_CONFIG_PARAMETER_SIGNATURE);
2017-03-01 18:38:14 -08:00
break;
case TEST_CIVIC_4_0_RISE:
setHondaCivic4_0_rise(PASS_CONFIG_PARAMETER_SIGNATURE);
2017-03-01 18:38:14 -08:00
break;
2015-07-10 06:01:56 -07:00
case HONDA_ACCORD_CD_TWO_WIRES:
setHondaAccordConfiguration1_24(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
2016-10-15 20:03:28 -07:00
case HONDA_ACCORD_1_24_SHIFTED:
setHondaAccordConfiguration1_24_shifted(PASS_CONFIG_PARAMETER_SIGNATURE);
2016-10-15 20:03:28 -07:00
break;
2017-02-24 15:58:14 -08:00
case FRANKENSO_QA_ENGINE:
setFrankensoBoardTestConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE);
2017-02-24 15:58:14 -08:00
break;
2015-07-10 06:01:56 -07:00
case HONDA_ACCORD_CD_DIP:
setHondaAccordConfigurationDip(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
case MITSU_4G93:
setMitsubishiConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
2019-04-12 19:07:03 -07:00
#if EFI_SUPPORT_1995_FORD_INLINE_6
2015-07-10 06:01:56 -07:00
case FORD_INLINE_6_1995:
setFordInline6(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
#endif /* EFI_SUPPORT_1995_FORD_INLINE_6 */
case GY6_139QMB:
setGy6139qmbDefaultEngineConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
2016-07-09 16:03:08 -07:00
case HONDA_600:
setHonda600(PASS_CONFIG_PARAMETER_SIGNATURE);
2016-07-09 16:03:08 -07:00
break;
2016-11-03 14:03:11 -07:00
case MAZDA_MIATA_NB1:
setMazdaMiataNb1EngineConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
case MAZDA_323:
setMazda323EngineConfiguration(engineConfiguration);
break;
case MAZDA_626:
setMazda626EngineConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
case SATURN_ION_2004:
setSaturnIonEngineConfiguration(engineConfiguration);
break;
2015-10-17 10:02:05 -07:00
case SUZUKI_VITARA:
setSuzukiVitara(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-10-17 10:02:05 -07:00
break;
2015-07-10 06:01:56 -07:00
case MINI_COOPER_R50:
setMiniCooperR50(engineConfiguration);
break;
case FORD_ESCORT_GT:
setFordEscortGt(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
case MIATA_1990:
setMiata1990(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
case MIATA_1994_DEVIATOR:
setMiata1994_d(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
case MIATA_1994_SPAGS:
setMiata1994_s(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
case MIATA_1996:
setMiata1996(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
case CITROEN_TU3JP:
setCitroenBerlingoTU3JPConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
case ROVER_V8:
setRoverv8(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
case SUBARU_2003_WRX:
setSubaru2003Wrx(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
case BMW_E34:
setBmwE34(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
case GM_2_2:
setGm2_2(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
case DODGE_RAM:
setDodgeRam1996(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
2015-09-05 18:03:42 -07:00
case DODGE_STRATUS:
setDodgeStratus(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-09-05 18:03:42 -07:00
break;
2015-07-10 06:01:56 -07:00
case VW_ABA:
setVwAba(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
2017-03-05 18:59:15 -08:00
#if EFI_UNIT_TEST
2017-03-06 14:42:16 -08:00
case TEST_ISSUE_366_BOTH:
setTestEngineIssue366both(PASS_CONFIG_PARAMETER_SIGNATURE);
2017-03-06 14:42:16 -08:00
break;
case TEST_ISSUE_366_RISE:
setTestEngineIssue366rise(PASS_CONFIG_PARAMETER_SIGNATURE);
2017-03-05 18:59:15 -08:00
break;
#else
2017-03-06 14:42:16 -08:00
case TEST_ISSUE_366_BOTH:
case TEST_ISSUE_366_RISE:
2017-03-05 18:59:15 -08:00
#endif
2015-07-10 06:01:56 -07:00
case TEST_ENGINE:
setTestEngineConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
2016-10-04 11:00:58 -07:00
case MAZDA_MIATA_2003:
setMazdaMiata2003EngineConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE);
2016-10-04 12:02:36 -07:00
break;
2017-11-19 14:54:00 -08:00
case MAZDA_MIATA_2003_NA_RAIL:
setMazdaMiata2003EngineConfigurationNaFuelRail(PASS_CONFIG_PARAMETER_SIGNATURE);
2017-04-17 19:10:19 -07:00
break;
2017-12-02 17:59:31 -08:00
case MAZDA_MIATA_2003_BOARD_TEST:
setMazdaMiata2003EngineConfigurationBoardTest(PASS_CONFIG_PARAMETER_SIGNATURE);
2017-12-02 17:59:31 -08:00
break;
2017-05-06 13:11:45 -07:00
case PROMETHEUS_DEFAULTS:
setPrometheusDefaults(PASS_CONFIG_PARAMETER_SIGNATURE);
2017-05-06 13:11:45 -07:00
break;
case SUBARUEJ20G_DEFAULTS:
setSubaruEJ20GDefaults(PASS_CONFIG_PARAMETER_SIGNATURE);
break;
2016-08-20 18:03:09 -07:00
case TEST_ENGINE_VVT:
setTestVVTEngineConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE);
2016-08-20 18:03:09 -07:00
break;
2015-07-10 06:01:56 -07:00
case SACHS:
setSachs(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
break;
2015-09-12 12:02:40 -07:00
case DAIHATSU:
setDaihatsu(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-09-12 12:02:40 -07:00
break;
2015-10-16 13:01:21 -07:00
case CAMARO_4:
setCamaro4(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-10-16 13:01:21 -07:00
break;
2015-12-20 17:01:44 -08:00
case CHEVY_C20_1973:
set1973c20(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-12-20 17:01:44 -08:00
break;
2016-07-13 19:02:35 -07:00
case TOYOTA_2JZ_GTE_VVTi:
setToyota_2jz_vics(PASS_CONFIG_PARAMETER_SIGNATURE);
2016-07-13 20:01:43 -07:00
break;
2015-12-30 13:02:18 -08:00
case TOYOTA_JZS147:
setToyota_jzs147EngineConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE);
2015-12-30 13:02:18 -08:00
break;
2016-03-26 03:03:24 -07:00
case GEO_STORM:
setGeoStormConfiguration(PASS_CONFIG_PARAMETER_SIGNATURE);
2016-03-26 03:03:24 -07:00
break;
2015-09-12 12:02:40 -07:00
2015-07-10 06:01:56 -07:00
default:
2017-01-22 06:03:08 -08:00
warning(CUSTOM_UNEXPECTED_ENGINE_TYPE, "Unexpected engine type: %d", engineType);
2015-07-10 06:01:56 -07:00
}
2017-05-15 20:28:49 -07:00
applyNonPersistentConfiguration(logger PASS_ENGINE_PARAMETER_SUFFIX);
2015-07-10 06:01:56 -07:00
// todo: eliminate triggerShape.operationMode?
2017-03-12 19:48:15 -07:00
if (engineConfiguration->operationMode != TRIGGER_SHAPE(getOperationMode())) {
warning(CUSTOM_ERR_OP_MODE, "operationMode %d/trigger mismatch %d",
2016-11-14 19:02:35 -08:00
engineConfiguration->operationMode,
2017-03-01 19:18:25 -08:00
TRIGGER_SHAPE(getOperationMode()));
2017-03-12 19:48:15 -07:00
}
2015-07-10 06:01:56 -07:00
#if EFI_TUNER_STUDIO
syncTunerStudioCopy();
#endif /* EFI_TUNER_STUDIO */
2015-07-10 06:01:56 -07:00
}
2017-08-31 04:53:41 -07:00
void validateConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (engineConfiguration->adcVcc > 5.0f || engineConfiguration->adcVcc < 1.0f) {
engineConfiguration->adcVcc = 3.0f;
}
}
void applyNonPersistentConfiguration(Logging * logger DECLARE_ENGINE_PARAMETER_SUFFIX) {
2019-04-12 19:07:03 -07:00
#if EFI_PROD_CODE
2019-02-23 09:33:49 -08:00
efiAssertVoid(CUSTOM_APPLY_STACK, getCurrentRemainingStack() > 256, "apply c");
scheduleMsg(logger, "applyNonPersistentConfiguration()");
#endif
assertEngineReference();
2018-02-03 17:43:31 -08:00
2019-04-12 19:07:03 -07:00
#if EFI_ENGINE_CONTROL
2018-12-25 18:05:06 -08:00
ENGINE(initializeTriggerShape(logger PASS_ENGINE_PARAMETER_SUFFIX));
2018-02-03 17:43:31 -08:00
#endif
2019-04-12 19:07:03 -07:00
#if EFI_FSIO
2017-05-15 20:28:49 -07:00
applyFsioConfiguration(PASS_ENGINE_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
#endif
}
2019-04-12 19:07:03 -07:00
#if EFI_ENGINE_CONTROL
2015-07-10 06:01:56 -07:00
2017-05-15 20:28:49 -07:00
void prepareShapes(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
prepareOutputSignals(PASS_ENGINE_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
2017-05-15 20:28:49 -07:00
engine->injectionEvents.addFuelEvents(PASS_ENGINE_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
}
#endif
float getRpmMultiplier(operation_mode_e mode) {
if (mode == FOUR_STROKE_CAM_SENSOR) {
return 0.5;
} else if (mode == FOUR_STROKE_CRANK_SENSOR) {
return 1;
}
return 1;
}
void setOperationMode(engine_configuration_s *engineConfiguration, operation_mode_e mode) {
engineConfiguration->operationMode = mode;
}
operation_mode_e getOperationMode(engine_configuration_s const *engineConfiguration) {
2015-07-10 06:01:56 -07:00
return engineConfiguration->operationMode;
}
void commonFrankensoAnalogInputs(engine_configuration_s *engineConfiguration) {
2015-07-10 06:01:56 -07:00
/**
* VBatt
*/
engineConfiguration->vbattAdcChannel = EFI_ADC_14;
}
void setFrankenso0_1_joystick(engine_configuration_s *engineConfiguration) {
board_configuration_s *boardConfiguration = &engineConfiguration->bc;
boardConfiguration->joystickCenterPin = GPIOC_8;
boardConfiguration->joystickAPin = GPIOD_10;
boardConfiguration->joystickBPin = GPIO_UNASSIGNED;
boardConfiguration->joystickCPin = GPIO_UNASSIGNED;
boardConfiguration->joystickDPin = GPIOD_11;
2015-07-10 06:01:56 -07:00
}
2017-05-07 07:30:05 -07:00
void copyTargetAfrTable(fuel_table_t const source, afr_table_t destination) {
// todo: extract a template!
for (int loadIndex = 0; loadIndex < FUEL_LOAD_COUNT; loadIndex++) {
for (int rpmIndex = 0; rpmIndex < FUEL_RPM_COUNT; rpmIndex++) {
destination[loadIndex][rpmIndex] = AFR_STORAGE_MULT * source[loadIndex][rpmIndex];
}
}
}
2015-07-10 06:01:56 -07:00
void copyFuelTable(fuel_table_t const source, fuel_table_t destination) {
2017-05-07 07:30:05 -07:00
// todo: extract a template!
2016-01-14 20:03:17 -08:00
for (int loadIndex = 0; loadIndex < FUEL_LOAD_COUNT; loadIndex++) {
for (int rpmIndex = 0; rpmIndex < FUEL_RPM_COUNT; rpmIndex++) {
destination[loadIndex][rpmIndex] = source[loadIndex][rpmIndex];
2015-07-10 06:01:56 -07:00
}
}
}
void copyTimingTable(ignition_table_t const source, ignition_table_t destination) {
2017-05-07 07:30:05 -07:00
// todo: extract a template!
2015-07-10 06:01:56 -07:00
for (int k = 0; k < IGN_LOAD_COUNT; k++) {
2016-01-14 20:03:17 -08:00
for (int rpmIndex = 0; rpmIndex < IGN_RPM_COUNT; rpmIndex++) {
destination[k][rpmIndex] = source[k][rpmIndex];
2015-07-10 06:01:56 -07:00
}
}
}