2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file settings.cpp
|
|
|
|
* @brief This file is about configuring engine via the human-readable protocol
|
|
|
|
*
|
|
|
|
* @date Dec 30, 2012
|
2020-01-13 18:57:43 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
|
|
|
|
2021-07-25 22:05:17 -07:00
|
|
|
#include "pch.h"
|
2021-07-14 21:34:22 -07:00
|
|
|
|
2022-11-23 03:01:34 -08:00
|
|
|
#if ! EFI_UNIT_TEST
|
2022-09-07 12:56:45 -07:00
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
#include "eficonsole.h"
|
|
|
|
#include "trigger_decoder.h"
|
|
|
|
#include "console_io.h"
|
2017-01-06 13:03:41 -08:00
|
|
|
#include "idle_thread.h"
|
2019-03-31 13:56:13 -07:00
|
|
|
#include "alternator_controller.h"
|
2020-04-24 11:00:06 -07:00
|
|
|
#include "trigger_emulator_algo.h"
|
2022-05-15 12:31:35 -07:00
|
|
|
#include "value_lookup.h"
|
2022-11-23 12:53:16 -08:00
|
|
|
#if EFI_RTC
|
|
|
|
#include "rtc_helper.h"
|
|
|
|
#endif // EFI_RTC
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_PROD_CODE
|
2017-01-11 18:04:22 -08:00
|
|
|
#include "can_hw.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
#include "rusefi.h"
|
|
|
|
#include "hardware.h"
|
2022-11-23 03:01:34 -08:00
|
|
|
#endif // EFI_PROD_CODE
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-11-19 23:18:17 -08:00
|
|
|
#if EFI_ELECTRONIC_THROTTLE_BODY
|
|
|
|
#include "electronic_throttle.h"
|
2022-11-23 03:01:34 -08:00
|
|
|
#endif // EFI_ELECTRONIC_THROTTLE_BODY
|
2019-11-19 23:18:17 -08:00
|
|
|
|
2023-11-03 10:08:35 -07:00
|
|
|
#if (EFI_STORAGE_INT_FLASH == TRUE) || (EFI_STORAGE_MFS == TRUE)
|
2015-07-10 06:01:56 -07:00
|
|
|
#include "flash_main.h"
|
2023-11-03 10:08:35 -07:00
|
|
|
#endif /* (EFI_STORAGE_INT_FLASH == TRUE) || (EFI_STORAGE_MFS == TRUE) */
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_ENGINE_SNIFFER
|
2015-07-15 18:01:45 -07:00
|
|
|
#include "engine_sniffer.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
extern int waveChartUsedSize;
|
|
|
|
extern WaveChart waveChart;
|
2022-11-23 03:01:34 -08:00
|
|
|
#endif // EFI_ENGINE_SNIFFER
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2023-11-01 10:02:20 -07:00
|
|
|
void printSpiState() {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("spi 1=%s/2=%s/3=%s/4=%s",
|
2020-01-06 05:44:23 -08:00
|
|
|
boolToString(engineConfiguration->is_enabled_spi_1),
|
|
|
|
boolToString(engineConfiguration->is_enabled_spi_2),
|
|
|
|
boolToString(engineConfiguration->is_enabled_spi_3),
|
|
|
|
boolToString(engineConfiguration->is_enabled_spi_4));
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2023-11-01 10:02:20 -07:00
|
|
|
static void printOutputs() {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("injectionPins: mode %s", getPin_output_mode_e(engineConfiguration->injectionPinMode));
|
2023-04-28 18:01:08 -07:00
|
|
|
for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {
|
2019-12-11 14:48:55 -08:00
|
|
|
brain_pin_e brainPin = engineConfiguration->injectionPins[i];
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("injection #%d @ %s", (1 + i), hwPortname(brainPin));
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("ignitionPins: mode %s", getPin_output_mode_e(engineConfiguration->ignitionPinMode));
|
2023-04-28 18:01:08 -07:00
|
|
|
for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {
|
2019-12-11 14:48:55 -08:00
|
|
|
brain_pin_e brainPin = engineConfiguration->ignitionPins[i];
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("ignition #%d @ %s", (1 + i), hwPortname(brainPin));
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("idlePin: mode %s @ %s freq=%d", getPin_output_mode_e(engineConfiguration->idle.solenoidPinMode),
|
2019-12-11 14:48:55 -08:00
|
|
|
hwPortname(engineConfiguration->idle.solenoidPin), engineConfiguration->idle.solenoidFrequency);
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("malfunctionIndicator: %s mode=%s", hwPortname(engineConfiguration->malfunctionIndicatorPin),
|
2019-12-11 14:48:55 -08:00
|
|
|
getPin_output_mode_e(engineConfiguration->malfunctionIndicatorPinMode));
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("fuelPumpPin: mode %s @ %s", getPin_output_mode_e(engineConfiguration->fuelPumpPinMode),
|
2019-12-11 14:48:55 -08:00
|
|
|
hwPortname(engineConfiguration->fuelPumpPin));
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("fanPin: mode %s @ %s", getPin_output_mode_e(engineConfiguration->fanPinMode),
|
2019-12-11 14:48:55 -08:00
|
|
|
hwPortname(engineConfiguration->fanPin));
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("mainRelay: mode %s @ %s", getPin_output_mode_e(engineConfiguration->mainRelayPinMode),
|
2019-12-11 14:48:55 -08:00
|
|
|
hwPortname(engineConfiguration->mainRelayPin));
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("starterRelay: mode %s @ %s", getPin_output_mode_e(engineConfiguration->starterRelayDisablePinMode),
|
2020-03-18 13:32:03 -07:00
|
|
|
hwPortname(engineConfiguration->starterRelayDisablePin));
|
2019-11-25 17:08:01 -08:00
|
|
|
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("alternator field: mode %s @ %s",
|
2019-12-11 14:48:55 -08:00
|
|
|
getPin_output_mode_e(engineConfiguration->alternatorControlPinMode),
|
|
|
|
hwPortname(engineConfiguration->alternatorControlPin));
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Prints current engine configuration to human-readable console.
|
|
|
|
*/
|
2023-11-01 10:02:20 -07:00
|
|
|
void printConfiguration() {
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-10-20 07:38:01 -07:00
|
|
|
efiPrintf("Template %s/%d trigger %s/%s/%d", getEngine_type_e(engineConfiguration->engineType),
|
2015-07-10 06:01:56 -07:00
|
|
|
engineConfiguration->engineType, getTrigger_type_e(engineConfiguration->trigger.type),
|
2016-08-28 13:02:34 -07:00
|
|
|
getEngine_load_mode_e(engineConfiguration->fuelAlgorithm), engineConfiguration->fuelAlgorithm);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("configurationVersion=%d", engine->getGlobalConfigurationVersion());
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("rpmHardLimit: %d/operationMode=%d", engineConfiguration->rpmHardLimit,
|
2022-09-13 22:34:52 -07:00
|
|
|
getEngineRotationState()->getOperationMode());
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("globalTriggerAngleOffset=%.2f", engineConfiguration->globalTriggerAngleOffset);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("=== cranking ===");
|
|
|
|
efiPrintf("crankingRpm: %d", engineConfiguration->cranking.rpm);
|
|
|
|
efiPrintf("cranking injection %s", getInjection_mode_e(engineConfiguration->crankingInjectionMode));
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-06-13 04:52:07 -07:00
|
|
|
efiPrintf("cranking timing %.2f", engineConfiguration->crankingTimingAngle);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("=== ignition ===");
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("ignitionMode: %s/enabled=%s", getIgnition_mode_e(engineConfiguration->ignitionMode),
|
2015-07-10 06:01:56 -07:00
|
|
|
boolToString(engineConfiguration->isIgnitionEnabled));
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("timingMode: %s", getTiming_mode_e(engineConfiguration->timingMode));
|
2015-07-10 06:01:56 -07:00
|
|
|
if (engineConfiguration->timingMode == TM_FIXED) {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("fixedModeTiming: %d", (int) engineConfiguration->fixedModeTiming);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("=== injection ===");
|
2022-05-15 07:13:47 -07:00
|
|
|
efiPrintf("injection %s enabled=%s", getInjection_mode_e(engineConfiguration->injectionMode),
|
|
|
|
boolToString(engineConfiguration->isInjectionEnabled));
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2023-11-01 10:02:20 -07:00
|
|
|
printOutputs();
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("map_avg=%s/wa=%s",
|
2016-12-27 21:02:03 -08:00
|
|
|
boolToString(engineConfiguration->isMapAveragingEnabled),
|
2020-09-29 03:34:39 -07:00
|
|
|
boolToString(engineConfiguration->isWaveAnalyzerEnabled));
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("isManualSpinningMode=%s/isCylinderCleanupEnabled=%s",
|
2015-07-10 06:01:56 -07:00
|
|
|
boolToString(engineConfiguration->isManualSpinningMode),
|
|
|
|
boolToString(engineConfiguration->isCylinderCleanupEnabled));
|
|
|
|
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("clutchUp@%s: %s", hwPortname(engineConfiguration->clutchUpPin),
|
2022-08-25 19:24:35 -07:00
|
|
|
boolToString(engine->engineState.clutchUpState));
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("clutchDown@%s: %s", hwPortname(engineConfiguration->clutchDownPin),
|
2022-06-28 23:37:24 -07:00
|
|
|
boolToString(engine->engineState.clutchDownState));
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("digitalPotentiometerSpiDevice %d", engineConfiguration->digitalPotentiometerSpiDevice);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
for (int i = 0; i < DIGIPOT_COUNT; i++) {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("digitalPotentiometer CS%d %s", i,
|
2019-12-11 14:48:55 -08:00
|
|
|
hwPortname(engineConfiguration->digitalPotentiometerChipSelect[i]));
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2022-11-23 03:01:34 -08:00
|
|
|
#if EFI_PROD_CODE
|
2023-11-01 10:02:20 -07:00
|
|
|
printSpiState();
|
2022-11-23 03:01:34 -08:00
|
|
|
#endif // EFI_PROD_CODE
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2023-11-05 12:55:46 -08:00
|
|
|
#if EFI_ENGINE_CONTROL
|
2021-11-16 01:15:29 -08:00
|
|
|
static void doPrintConfiguration() {
|
2023-11-01 10:02:20 -07:00
|
|
|
printConfiguration();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void setFixedModeTiming(int value) {
|
|
|
|
engineConfiguration->fixedModeTiming = value;
|
2017-05-12 10:47:09 -07:00
|
|
|
doPrintConfiguration();
|
2021-11-16 01:15:29 -08:00
|
|
|
incrementGlobalConfigurationVersion();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void setTimingMode(int value) {
|
|
|
|
engineConfiguration->timingMode = (timing_mode_e) value;
|
2017-05-12 10:47:09 -07:00
|
|
|
doPrintConfiguration();
|
2021-11-16 01:15:29 -08:00
|
|
|
incrementGlobalConfigurationVersion();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void setIdleSolenoidFrequency(int value) {
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->idle.solenoidFrequency = value;
|
2021-11-16 01:15:29 -08:00
|
|
|
incrementGlobalConfigurationVersion();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void setSensorChartMode(int value) {
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->sensorChartMode = (sensor_chart_e) value;
|
2017-05-12 10:47:09 -07:00
|
|
|
doPrintConfiguration();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
2023-11-05 12:55:46 -08:00
|
|
|
#endif // EFI_ENGINE_CONTROL
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2020-03-29 22:13:02 -07:00
|
|
|
static void printTpsSenser(const char *msg, SensorType sensor, int16_t min, int16_t max, adc_channel_e channel) {
|
|
|
|
auto tps = Sensor::get(sensor);
|
|
|
|
auto raw = Sensor::getRaw(sensor);
|
2020-02-07 01:05:16 -08:00
|
|
|
|
|
|
|
if (!tps.Valid) {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("TPS not valid");
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
2020-05-20 22:08:07 -07:00
|
|
|
|
|
|
|
char pinNameBuffer[16];
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("tps min (closed) %d/max (full) %d v=%.2f @%s", min, max,
|
2020-03-29 22:13:02 -07:00
|
|
|
raw, getPinNameByAdcChannel(msg, channel, pinNameBuffer));
|
|
|
|
|
|
|
|
|
2022-07-30 14:08:48 -07:00
|
|
|
efiPrintf("current 10bit=%d value=%.2f", convertVoltageTo10bitADC(raw), tps.value_or(0));
|
2020-03-29 22:13:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void printTPSInfo(void) {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("pedal up %f / down %f",
|
2020-04-02 05:04:12 -07:00
|
|
|
engineConfiguration->throttlePedalUpVoltage,
|
|
|
|
engineConfiguration->throttlePedalWOTVoltage);
|
2019-09-02 19:58:36 -07:00
|
|
|
|
2020-11-06 12:30:11 -08:00
|
|
|
auto pps = Sensor::get(SensorType::AcceleratorPedal);
|
|
|
|
|
|
|
|
if (!pps.Valid) {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("PPS not valid");
|
2020-11-06 12:30:11 -08:00
|
|
|
}
|
|
|
|
|
2020-03-29 22:13:02 -07:00
|
|
|
printTpsSenser("TPS", SensorType::Tps1, engineConfiguration->tpsMin, engineConfiguration->tpsMax, engineConfiguration->tps1_1AdcChannel);
|
|
|
|
printTpsSenser("TPS2", SensorType::Tps2, engineConfiguration->tps2Min, engineConfiguration->tps2Max, engineConfiguration->tps2_1AdcChannel);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2023-11-05 12:55:46 -08:00
|
|
|
#if EFI_ENGINE_CONTROL
|
2015-07-10 06:01:56 -07:00
|
|
|
static void setCrankingRpm(int value) {
|
|
|
|
engineConfiguration->cranking.rpm = value;
|
2017-05-12 10:47:09 -07:00
|
|
|
doPrintConfiguration();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* this method is used in console - it also prints current configuration
|
|
|
|
*/
|
|
|
|
static void setAlgorithmInt(int value) {
|
|
|
|
setAlgorithm((engine_load_mode_e) value);
|
2017-05-12 10:47:09 -07:00
|
|
|
doPrintConfiguration();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void setFiringOrder(int value) {
|
2023-04-28 18:01:08 -07:00
|
|
|
engineConfiguration->firingOrder = (firing_order_e) value;
|
2017-05-12 10:47:09 -07:00
|
|
|
doPrintConfiguration();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void setRpmHardLimit(int value) {
|
|
|
|
engineConfiguration->rpmHardLimit = value;
|
2017-05-12 10:47:09 -07:00
|
|
|
doPrintConfiguration();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2017-05-07 15:37:22 -07:00
|
|
|
static void setCrankingIACExtra(float percent) {
|
2017-05-16 19:13:40 -07:00
|
|
|
engineConfiguration->crankingIACposition = percent;
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("cranking_iac %.2f", percent);
|
2017-05-07 15:37:22 -07:00
|
|
|
}
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
static void setCrankingFuel(float timeMs) {
|
|
|
|
engineConfiguration->cranking.baseFuel = timeMs;
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("cranking_fuel %.2f", timeMs);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void setGlobalTriggerAngleOffset(float value) {
|
2016-06-06 17:02:51 -07:00
|
|
|
if (cisnan(value)) {
|
2023-04-11 17:01:34 -07:00
|
|
|
warning(ObdCode::CUSTOM_ERR_SGTP_ARGUMENT, "Invalid argument");
|
2016-06-06 17:02:51 -07:00
|
|
|
return;
|
|
|
|
}
|
2015-07-10 06:01:56 -07:00
|
|
|
engineConfiguration->globalTriggerAngleOffset = value;
|
2021-11-16 01:15:29 -08:00
|
|
|
incrementGlobalConfigurationVersion();
|
2017-05-12 10:47:09 -07:00
|
|
|
doPrintConfiguration();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void setCrankingTimingAngle(float value) {
|
|
|
|
engineConfiguration->crankingTimingAngle = value;
|
2021-11-16 01:15:29 -08:00
|
|
|
incrementGlobalConfigurationVersion();
|
2017-05-12 10:47:09 -07:00
|
|
|
doPrintConfiguration();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void setCrankingInjectionMode(int value) {
|
|
|
|
engineConfiguration->crankingInjectionMode = (injection_mode_e) value;
|
2021-11-16 01:15:29 -08:00
|
|
|
incrementGlobalConfigurationVersion();
|
2017-05-12 10:47:09 -07:00
|
|
|
doPrintConfiguration();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void setInjectionMode(int value) {
|
|
|
|
engineConfiguration->injectionMode = (injection_mode_e) value;
|
2021-11-16 01:15:29 -08:00
|
|
|
incrementGlobalConfigurationVersion();
|
2017-05-12 10:47:09 -07:00
|
|
|
doPrintConfiguration();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void setIgnitionMode(int value) {
|
2023-05-23 22:23:39 -07:00
|
|
|
#if EFI_ENGINE_CONTROL
|
2015-07-10 06:01:56 -07:00
|
|
|
engineConfiguration->ignitionMode = (ignition_mode_e) value;
|
2021-11-16 01:15:29 -08:00
|
|
|
incrementGlobalConfigurationVersion();
|
|
|
|
prepareOutputSignals();
|
2017-05-12 10:47:09 -07:00
|
|
|
doPrintConfiguration();
|
2023-05-23 22:23:39 -07:00
|
|
|
#endif // EFI_ENGINE_CONTROL
|
2015-12-18 14:02:31 -08:00
|
|
|
}
|
|
|
|
|
2023-05-23 22:38:15 -07:00
|
|
|
static void setIndividualCoilsIgnition() {
|
|
|
|
setIgnitionMode((int)IM_INDIVIDUAL_COILS);
|
|
|
|
}
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
static void setTriggerType(int value) {
|
|
|
|
engineConfiguration->trigger.type = (trigger_type_e) value;
|
2021-11-16 01:15:29 -08:00
|
|
|
incrementGlobalConfigurationVersion();
|
2017-05-12 10:47:09 -07:00
|
|
|
doPrintConfiguration();
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("Do you need to also invoke set operation_mode X?");
|
2019-12-21 20:27:54 -08:00
|
|
|
engine->resetEngineSnifferIfInTestMode();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2017-05-13 04:48:42 -07:00
|
|
|
static void setDebugMode(int value) {
|
|
|
|
engineConfiguration->debugMode = (debug_mode_e) value;
|
|
|
|
}
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
static void setWholeTimingMap(float value) {
|
2022-12-31 11:47:29 -08:00
|
|
|
setTable(config->ignitionTable, value);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void setWholePhaseMapCmd(float value) {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("Setting whole injection phase map to %.2f", value);
|
2021-05-04 07:03:41 -07:00
|
|
|
setTable(config->injectionPhase, value);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void setWholeTimingMapCmd(float value) {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("Setting whole timing advance map to %.2f", value);
|
2015-07-10 06:01:56 -07:00
|
|
|
setWholeTimingMap(value);
|
2019-12-21 20:27:54 -08:00
|
|
|
engine->resetEngineSnifferIfInTestMode();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void setWholeVeCmd(float value) {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("Setting whole VE map to %.2f", value);
|
2016-08-28 13:02:34 -07:00
|
|
|
if (engineConfiguration->fuelAlgorithm != LM_SPEED_DENSITY) {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("WARNING: setting VE map not in SD mode is pointless");
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
2021-05-04 07:03:41 -07:00
|
|
|
setTable(config->veTable, value);
|
2019-12-21 20:27:54 -08:00
|
|
|
engine->resetEngineSnifferIfInTestMode();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
2023-11-05 12:55:46 -08:00
|
|
|
#endif // EFI_ENGINE_CONTROL
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
#if EFI_PROD_CODE
|
|
|
|
|
2021-07-17 10:42:10 -07:00
|
|
|
static brain_pin_e parseBrainPinWithErrorMessage(const char *pinName) {
|
|
|
|
brain_pin_e pin = parseBrainPin(pinName);
|
2022-04-28 14:32:39 -07:00
|
|
|
if (pin == Gpio::Invalid) {
|
2021-07-17 10:42:10 -07:00
|
|
|
efiPrintf("invalid pin name [%s]", pinName);
|
|
|
|
}
|
|
|
|
return pin;
|
|
|
|
}
|
|
|
|
|
2019-07-25 18:39:39 -07:00
|
|
|
/**
|
|
|
|
* For example:
|
|
|
|
* set_ignition_pin 1 PD7
|
|
|
|
* todo: this method counts index from 1 while at least 'set_trigger_input_pin' counts from 0.
|
|
|
|
* todo: make things consistent
|
|
|
|
*/
|
2015-07-10 06:01:56 -07:00
|
|
|
static void setIgnitionPin(const char *indexStr, const char *pinName) {
|
|
|
|
int index = atoi(indexStr) - 1; // convert from human index into software index
|
2021-07-06 17:14:08 -07:00
|
|
|
if (index < 0 || index >= MAX_CYLINDER_COUNT)
|
2015-07-10 06:01:56 -07:00
|
|
|
return;
|
2021-07-17 10:42:10 -07:00
|
|
|
brain_pin_e pin = parseBrainPinWithErrorMessage(pinName);
|
2022-04-28 14:32:39 -07:00
|
|
|
if (pin == Gpio::Invalid) {
|
2015-07-10 06:01:56 -07:00
|
|
|
return;
|
|
|
|
}
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("setting ignition pin[%d] to %s please save&restart", index, hwPortname(pin));
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->ignitionPins[index] = pin;
|
2021-11-16 01:15:29 -08:00
|
|
|
incrementGlobalConfigurationVersion();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2020-11-25 16:52:22 -08:00
|
|
|
// this method is useful for desperate time debugging
|
2022-11-01 18:44:22 -07:00
|
|
|
// readpin PA0
|
2021-08-21 21:00:20 -07:00
|
|
|
void readPin(const char *pinName) {
|
2021-07-17 10:42:10 -07:00
|
|
|
brain_pin_e pin = parseBrainPinWithErrorMessage(pinName);
|
2022-04-28 14:32:39 -07:00
|
|
|
if (pin == Gpio::Invalid) {
|
2020-11-25 16:52:22 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
int physicalValue = palReadPad(getHwPort("read", pin), getHwPin("read", pin));
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("pin %s value %d", hwPortname(pin), physicalValue);
|
2020-11-25 16:52:22 -08:00
|
|
|
}
|
|
|
|
|
2021-07-17 10:42:10 -07:00
|
|
|
// this method is useful for desperate time debugging or hardware validation
|
|
|
|
static void benchSetPinValue(const char *pinName, int bit) {
|
|
|
|
brain_pin_e pin = parseBrainPinWithErrorMessage(pinName);
|
2022-04-28 14:32:39 -07:00
|
|
|
if (pin == Gpio::Invalid) {
|
2021-07-17 10:42:10 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
palWritePad(getHwPort("write", pin), getHwPin("write", pin), bit);
|
|
|
|
efiPrintf("pin %s set value", hwPortname(pin));
|
|
|
|
readPin(pinName);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void benchClearPin(const char *pinName) {
|
|
|
|
benchSetPinValue(pinName, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void benchSetPin(const char *pinName) {
|
|
|
|
benchSetPinValue(pinName, 1);
|
|
|
|
}
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
static void setIndividualPin(const char *pinName, brain_pin_e *targetPin, const char *name) {
|
2021-07-17 10:42:10 -07:00
|
|
|
brain_pin_e pin = parseBrainPinWithErrorMessage(pinName);
|
2022-04-28 14:32:39 -07:00
|
|
|
if (pin == Gpio::Invalid) {
|
2015-07-10 06:01:56 -07:00
|
|
|
return;
|
|
|
|
}
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("setting %s pin to %s please save&restart", name, hwPortname(pin));
|
2015-07-10 06:01:56 -07:00
|
|
|
*targetPin = pin;
|
2021-11-16 01:15:29 -08:00
|
|
|
incrementGlobalConfigurationVersion();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2020-08-08 15:28:43 -07:00
|
|
|
// set vss_pin
|
|
|
|
static void setVssPin(const char *pinName) {
|
|
|
|
setIndividualPin(pinName, &engineConfiguration->vehicleSpeedSensorInputPin, "VSS");
|
|
|
|
}
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
// set_idle_pin none
|
|
|
|
static void setIdlePin(const char *pinName) {
|
2019-12-11 14:48:55 -08:00
|
|
|
setIndividualPin(pinName, &engineConfiguration->idle.solenoidPin, "idle");
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void setMainRelayPin(const char *pinName) {
|
2019-12-11 14:48:55 -08:00
|
|
|
setIndividualPin(pinName, &engineConfiguration->mainRelayPin, "main relay");
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2020-04-10 17:31:58 -07:00
|
|
|
static void setTriggerSyncPin(const char *pinName) {
|
|
|
|
setIndividualPin(pinName, &engineConfiguration->debugTriggerSync, "trigger sync");
|
|
|
|
}
|
|
|
|
|
2019-11-25 17:08:01 -08:00
|
|
|
static void setStarterRelayPin(const char *pinName) {
|
2020-03-18 13:32:03 -07:00
|
|
|
setIndividualPin(pinName, &engineConfiguration->starterRelayDisablePin, "starter disable relay");
|
2019-11-25 17:08:01 -08:00
|
|
|
}
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
static void setAlternatorPin(const char *pinName) {
|
2019-12-11 14:48:55 -08:00
|
|
|
setIndividualPin(pinName, &engineConfiguration->alternatorControlPin, "alternator");
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2019-09-15 08:32:38 -07:00
|
|
|
static void setACRelayPin(const char *pinName) {
|
2019-12-11 14:48:55 -08:00
|
|
|
setIndividualPin(pinName, &engineConfiguration->acRelayPin, "A/C");
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void setFuelPumpPin(const char *pinName) {
|
2019-12-11 14:48:55 -08:00
|
|
|
setIndividualPin(pinName, &engineConfiguration->fuelPumpPin, "fuelPump");
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void setInjectionPin(const char *indexStr, const char *pinName) {
|
|
|
|
int index = atoi(indexStr) - 1; // convert from human index into software index
|
2021-07-06 17:14:08 -07:00
|
|
|
if (index < 0 || index >= MAX_CYLINDER_COUNT)
|
2015-07-10 06:01:56 -07:00
|
|
|
return;
|
2021-07-17 10:42:10 -07:00
|
|
|
brain_pin_e pin = parseBrainPinWithErrorMessage(pinName);
|
2022-04-28 14:32:39 -07:00
|
|
|
if (pin == Gpio::Invalid) {
|
2015-07-10 06:01:56 -07:00
|
|
|
return;
|
|
|
|
}
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("setting injection pin[%d] to %s please save&restart", index, hwPortname(pin));
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->injectionPins[index] = pin;
|
2021-11-16 01:15:29 -08:00
|
|
|
incrementGlobalConfigurationVersion();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2019-07-25 18:39:39 -07:00
|
|
|
/**
|
|
|
|
* For example:
|
|
|
|
* set_trigger_input_pin 0 PA5
|
|
|
|
* todo: this method counts index from 0 while at least 'set_ignition_pin' counts from 1.
|
|
|
|
* todo: make things consistent
|
|
|
|
*/
|
2015-07-10 06:01:56 -07:00
|
|
|
static void setTriggerInputPin(const char *indexStr, const char *pinName) {
|
|
|
|
int index = atoi(indexStr);
|
|
|
|
if (index < 0 || index > 2)
|
|
|
|
return;
|
2021-07-17 10:42:10 -07:00
|
|
|
brain_pin_e pin = parseBrainPinWithErrorMessage(pinName);
|
2022-04-28 14:32:39 -07:00
|
|
|
if (pin == Gpio::Invalid) {
|
2015-07-10 06:01:56 -07:00
|
|
|
return;
|
|
|
|
}
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("setting trigger pin[%d] to %s please save&restart", index, hwPortname(pin));
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->triggerInputPins[index] = pin;
|
2021-11-16 01:15:29 -08:00
|
|
|
incrementGlobalConfigurationVersion();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void setTriggerSimulatorPin(const char *indexStr, const char *pinName) {
|
|
|
|
int index = atoi(indexStr);
|
2020-12-06 16:29:37 -08:00
|
|
|
if (index < 0 || index >= TRIGGER_SIMULATOR_PIN_COUNT)
|
2015-07-10 06:01:56 -07:00
|
|
|
return;
|
2021-07-17 10:42:10 -07:00
|
|
|
brain_pin_e pin = parseBrainPinWithErrorMessage(pinName);
|
2022-04-28 14:32:39 -07:00
|
|
|
if (pin == Gpio::Invalid) {
|
2015-07-10 06:01:56 -07:00
|
|
|
return;
|
|
|
|
}
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("setting trigger simulator pin[%d] to %s please save&restart", index, hwPortname(pin));
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->triggerSimulatorPins[index] = pin;
|
2021-11-16 01:15:29 -08:00
|
|
|
incrementGlobalConfigurationVersion();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2019-04-12 19:07:03 -07:00
|
|
|
#if HAL_USE_ADC
|
2020-05-21 19:33:48 -07:00
|
|
|
// set_analog_input_pin pps pa4
|
|
|
|
// set_analog_input_pin afr none
|
2015-07-10 06:01:56 -07:00
|
|
|
static void setAnalogInputPin(const char *sensorStr, const char *pinName) {
|
2021-07-17 10:42:10 -07:00
|
|
|
brain_pin_e pin = parseBrainPinWithErrorMessage(pinName);
|
2022-04-28 14:32:39 -07:00
|
|
|
if (pin == Gpio::Invalid) {
|
2015-07-10 06:01:56 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
adc_channel_e channel = getAdcChannel(pin);
|
|
|
|
if (channel == EFI_ADC_ERROR) {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("Error with [%s]", pinName);
|
2015-07-10 06:01:56 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (strEqual("map", sensorStr)) {
|
|
|
|
engineConfiguration->map.sensor.hwChannel = channel;
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("setting MAP to %s/%d", pinName, channel);
|
2019-08-17 14:33:44 -07:00
|
|
|
} else if (strEqual("pps", sensorStr)) {
|
|
|
|
engineConfiguration->throttlePedalPositionAdcChannel = channel;
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("setting PPS to %s/%d", pinName, channel);
|
2020-05-21 19:33:48 -07:00
|
|
|
} else if (strEqual("afr", sensorStr)) {
|
|
|
|
engineConfiguration->afr.hwChannel = channel;
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("setting AFR to %s/%d", pinName, channel);
|
2015-07-10 06:01:56 -07:00
|
|
|
} else if (strEqual("clt", sensorStr)) {
|
|
|
|
engineConfiguration->clt.adcChannel = channel;
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("setting CLT to %s/%d", pinName, channel);
|
2015-07-10 06:01:56 -07:00
|
|
|
} else if (strEqual("iat", sensorStr)) {
|
|
|
|
engineConfiguration->iat.adcChannel = channel;
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("setting IAT to %s/%d", pinName, channel);
|
2015-07-10 06:01:56 -07:00
|
|
|
} else if (strEqual("tps", sensorStr)) {
|
2019-06-30 11:28:47 -07:00
|
|
|
engineConfiguration->tps1_1AdcChannel = channel;
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("setting TPS1 to %s/%d", pinName, channel);
|
2019-11-28 22:35:45 -08:00
|
|
|
} else if (strEqual("tps2", sensorStr)) {
|
|
|
|
engineConfiguration->tps2_1AdcChannel = channel;
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("setting TPS2 to %s/%d", pinName, channel);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
2021-11-16 01:15:29 -08:00
|
|
|
incrementGlobalConfigurationVersion();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
2022-11-23 03:01:34 -08:00
|
|
|
#endif // HAL_USE_ADC
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
static void setLogicInputPin(const char *indexStr, const char *pinName) {
|
|
|
|
int index = atoi(indexStr);
|
|
|
|
if (index < 0 || index > 2) {
|
|
|
|
return;
|
|
|
|
}
|
2021-07-17 10:42:10 -07:00
|
|
|
brain_pin_e pin = parseBrainPinWithErrorMessage(pinName);
|
2022-04-28 14:32:39 -07:00
|
|
|
if (pin == Gpio::Invalid) {
|
2015-07-10 06:01:56 -07:00
|
|
|
return;
|
|
|
|
}
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("setting logic input pin[%d] to %s please save&restart", index, hwPortname(pin));
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->logicAnalyzerPins[index] = pin;
|
2021-11-16 01:15:29 -08:00
|
|
|
incrementGlobalConfigurationVersion();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void showPinFunction(const char *pinName) {
|
2021-07-17 10:42:10 -07:00
|
|
|
brain_pin_e pin = parseBrainPinWithErrorMessage(pinName);
|
2022-04-28 14:32:39 -07:00
|
|
|
if (pin == Gpio::Invalid) {
|
2015-07-10 06:01:56 -07:00
|
|
|
return;
|
|
|
|
}
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("Pin %s: [%s]", pinName, getPinFunction(pin));
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2022-11-23 03:01:34 -08:00
|
|
|
#endif // EFI_PROD_CODE
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
static void setSpiMode(int index, bool mode) {
|
|
|
|
switch (index) {
|
|
|
|
case 1:
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->is_enabled_spi_1 = mode;
|
2015-07-10 06:01:56 -07:00
|
|
|
break;
|
|
|
|
case 2:
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->is_enabled_spi_2 = mode;
|
2015-07-10 06:01:56 -07:00
|
|
|
break;
|
|
|
|
case 3:
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->is_enabled_spi_3 = mode;
|
2015-07-10 06:01:56 -07:00
|
|
|
break;
|
|
|
|
default:
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("invalid spi index %d", index);
|
2015-07-10 06:01:56 -07:00
|
|
|
return;
|
|
|
|
}
|
2023-11-01 10:02:20 -07:00
|
|
|
printSpiState();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2023-08-27 11:55:18 -07:00
|
|
|
bool verboseRxCan = false;
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
static void enableOrDisable(const char *param, bool isEnabled) {
|
2022-12-17 11:58:10 -08:00
|
|
|
if (strEqualCaseInsensitive(param, "useTLE8888_cranking_hack")) {
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->useTLE8888_cranking_hack = isEnabled;
|
2022-12-17 11:58:10 -08:00
|
|
|
#if EFI_SHAFT_POSITION_INPUT
|
|
|
|
} else if (strEqualCaseInsensitive(param, CMD_TRIGGER_HW_INPUT)) {
|
|
|
|
getTriggerCentral()->hwTriggerInputEnabled = isEnabled;
|
|
|
|
#endif // EFI_SHAFT_POSITION_INPUT
|
2020-02-26 23:11:20 -08:00
|
|
|
} else if (strEqualCaseInsensitive(param, "verboseTLE8888")) {
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->verboseTLE8888 = isEnabled;
|
2023-08-27 11:55:18 -07:00
|
|
|
} else if (strEqualCaseInsensitive(param, "verboseRxCan")) {
|
|
|
|
verboseRxCan = isEnabled;
|
2021-12-06 18:31:49 -08:00
|
|
|
} else if (strEqualCaseInsensitive(param, "verboseCan")) {
|
|
|
|
engineConfiguration->verboseCan = isEnabled;
|
2022-08-10 21:17:03 -07:00
|
|
|
} else if (strEqualCaseInsensitive(param, "verboseIsoTp")) {
|
|
|
|
engineConfiguration->verboseIsoTp = isEnabled;
|
2021-09-06 08:10:11 -07:00
|
|
|
} else if (strEqualCaseInsensitive(param, "artificialMisfire")) {
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->artificialTestMisfire = isEnabled;
|
2021-04-07 13:44:21 -07:00
|
|
|
} else if (strEqualCaseInsensitive(param, "logic_level_trigger")) {
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->displayLogicLevelsInEngineSniffer = isEnabled;
|
2020-03-31 13:49:19 -07:00
|
|
|
} else if (strEqualCaseInsensitive(param, "can_broadcast")) {
|
2021-11-17 00:54:21 -08:00
|
|
|
engineConfiguration->enableVerboseCanTx = isEnabled;
|
2017-09-17 19:05:03 -07:00
|
|
|
} else if (strEqualCaseInsensitive(param, "etb_auto")) {
|
|
|
|
engine->etbAutoTune = isEnabled;
|
2023-04-03 13:54:26 -07:00
|
|
|
} else if (strEqualCaseInsensitive(param, "verboseKLine")) {
|
2023-04-03 13:59:09 -07:00
|
|
|
engineConfiguration->verboseKLine = isEnabled;
|
2015-07-10 06:01:56 -07:00
|
|
|
} else if (strEqualCaseInsensitive(param, "stepperidle")) {
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->useStepperIdle = isEnabled;
|
2022-01-16 07:05:24 -08:00
|
|
|
} else if (strEqualCaseInsensitive(param, "boardUseTempPullUp")) {
|
|
|
|
engineConfiguration->boardUseTempPullUp = isEnabled;
|
|
|
|
incrementGlobalConfigurationVersion();
|
|
|
|
} else if (strEqualCaseInsensitive(param, "boardUseTachPullUp")) {
|
|
|
|
engineConfiguration->boardUseTachPullUp = isEnabled;
|
|
|
|
incrementGlobalConfigurationVersion();
|
2016-01-03 07:01:32 -08:00
|
|
|
} else if (strEqualCaseInsensitive(param, "two_wire_wasted_spark")) {
|
|
|
|
engineConfiguration->twoWireBatchIgnition = isEnabled;
|
2021-11-16 01:15:29 -08:00
|
|
|
incrementGlobalConfigurationVersion();
|
2015-07-10 06:01:56 -07:00
|
|
|
} else if (strEqualCaseInsensitive(param, "tpic_advanced_mode")) {
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->useTpicAdvancedMode = isEnabled;
|
2015-07-10 06:01:56 -07:00
|
|
|
} else if (strEqualCaseInsensitive(param, "altcontrol")) {
|
|
|
|
engineConfiguration->isAlternatorControlEnabled = isEnabled;
|
|
|
|
} else if (strEqualCaseInsensitive(param, "sd")) {
|
2019-12-11 14:48:55 -08:00
|
|
|
engineConfiguration->isSdCardEnabled = isEnabled;
|
2019-12-21 17:17:58 -08:00
|
|
|
} else if (strEqualCaseInsensitive(param, CMD_FUNCTIONAL_TEST_MODE)) {
|
2020-08-08 08:25:17 -07:00
|
|
|
engine->isFunctionalTestMode = isEnabled;
|
2015-07-10 06:01:56 -07:00
|
|
|
} else if (strEqualCaseInsensitive(param, "can_read")) {
|
|
|
|
engineConfiguration->canReadEnabled = isEnabled;
|
|
|
|
} else if (strEqualCaseInsensitive(param, "can_write")) {
|
|
|
|
engineConfiguration->canWriteEnabled = isEnabled;
|
2020-08-13 09:26:23 -07:00
|
|
|
} else if (strEqualCaseInsensitive(param, CMD_INJECTION)) {
|
2015-07-10 06:01:56 -07:00
|
|
|
engineConfiguration->isInjectionEnabled = isEnabled;
|
2020-11-26 14:48:09 -08:00
|
|
|
} else if (strEqualCaseInsensitive(param, CMD_PWM)) {
|
|
|
|
engine->isPwmEnabled = isEnabled;
|
2015-07-10 06:01:56 -07:00
|
|
|
} else if (strEqualCaseInsensitive(param, "trigger_details")) {
|
2019-06-24 23:25:26 -07:00
|
|
|
engineConfiguration->verboseTriggerSynchDetails = isEnabled;
|
2020-08-29 14:05:54 -07:00
|
|
|
} else if (strEqualCaseInsensitive(param, "vvt_details")) {
|
|
|
|
engineConfiguration->verboseVVTDecoding = isEnabled;
|
2020-08-29 15:13:00 -07:00
|
|
|
} else if (strEqualCaseInsensitive(param, "invertCamVVTSignal")) {
|
|
|
|
engineConfiguration->invertCamVVTSignal = isEnabled;
|
2020-08-13 09:26:23 -07:00
|
|
|
} else if (strEqualCaseInsensitive(param, CMD_IGNITION)) {
|
2015-07-10 06:01:56 -07:00
|
|
|
engineConfiguration->isIgnitionEnabled = isEnabled;
|
2021-03-11 05:38:52 -08:00
|
|
|
#if EFI_EMULATE_POSITION_SENSORS
|
2020-08-08 08:45:02 -07:00
|
|
|
} else if (strEqualCaseInsensitive(param, CMD_SELF_STIMULATION)) {
|
2021-03-11 05:38:52 -08:00
|
|
|
if (isEnabled) {
|
|
|
|
enableTriggerStimulator();
|
|
|
|
} else {
|
|
|
|
disableTriggerStimulator();
|
|
|
|
}
|
|
|
|
} else if (strEqualCaseInsensitive(param, CMD_EXTERNAL_STIMULATION)) {
|
|
|
|
if (isEnabled) {
|
|
|
|
enableExternalTriggerStimulator();
|
|
|
|
} else {
|
|
|
|
disableTriggerStimulator();
|
|
|
|
}
|
2022-11-23 03:01:34 -08:00
|
|
|
#endif // EFI_EMULATE_POSITION_SENSORS
|
2015-07-10 06:01:56 -07:00
|
|
|
} else {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("unexpected [%s]", param);
|
2015-07-10 06:01:56 -07:00
|
|
|
return; // well, MISRA would not like this 'return' here :(
|
|
|
|
}
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("[%s] %s", param, isEnabled ? "enabled" : "disabled");
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void enable(const char *param) {
|
|
|
|
enableOrDisable(param, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void disable(const char *param) {
|
|
|
|
enableOrDisable(param, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void enableSpi(int index) {
|
|
|
|
setSpiMode(index, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void disableSpi(int index) {
|
|
|
|
setSpiMode(index, false);
|
|
|
|
}
|
|
|
|
|
2019-01-05 20:33:04 -08:00
|
|
|
/**
|
2022-02-01 17:47:17 -08:00
|
|
|
* See 'LimpManager::isEngineStop' for code which actually stops engine
|
2019-01-05 20:33:04 -08:00
|
|
|
*/
|
2023-10-26 12:52:56 -07:00
|
|
|
void scheduleStopEngine() {
|
2021-11-16 01:15:29 -08:00
|
|
|
doScheduleStopEngine();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void getValue(const char *paramStr) {
|
2017-05-12 03:19:47 -07:00
|
|
|
|
2022-05-15 12:40:19 -07:00
|
|
|
{
|
2022-12-03 22:21:38 -08:00
|
|
|
float value = getConfigValueByName(paramStr);
|
|
|
|
if (value != EFI_ERROR_CODE) {
|
|
|
|
efiPrintf("%s value: %.2f", paramStr, value);
|
2017-05-12 03:19:47 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-20 22:21:52 -08:00
|
|
|
if (strEqualCaseInsensitive(paramStr, "tps_min")) {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("tps_min=%d", engineConfiguration->tpsMin);
|
2019-03-02 10:21:12 -08:00
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "tps_max")) {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("tps_max=%d", engineConfiguration->tpsMax);
|
2016-11-14 19:02:35 -08:00
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "global_trigger_offset_angle")) {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("global_trigger_offset=%.2f", engineConfiguration->globalTriggerAngleOffset);
|
2022-12-17 11:58:10 -08:00
|
|
|
#if EFI_SHAFT_POSITION_INPUT
|
2020-08-08 20:56:42 -07:00
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "trigger_hw_input")) {
|
2022-09-13 23:06:52 -07:00
|
|
|
efiPrintf("trigger_hw_input=%s", boolToString(getTriggerCentral()->hwTriggerInputEnabled));
|
2022-12-17 11:58:10 -08:00
|
|
|
#endif // EFI_SHAFT_POSITION_INPUT
|
2020-07-09 17:37:24 -07:00
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "is_enabled_spi_1")) {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("is_enabled_spi_1=%s", boolToString(engineConfiguration->is_enabled_spi_1));
|
2020-07-09 17:37:24 -07:00
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "is_enabled_spi_2")) {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("is_enabled_spi_2=%s", boolToString(engineConfiguration->is_enabled_spi_2));
|
2020-07-09 17:37:24 -07:00
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "is_enabled_spi_3")) {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("is_enabled_spi_3=%s", boolToString(engineConfiguration->is_enabled_spi_3));
|
2020-08-29 15:13:00 -07:00
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "invertCamVVTSignal")) {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("invertCamVVTSignal=%s", boolToString(engineConfiguration->invertCamVVTSignal));
|
2016-07-30 19:02:52 -07:00
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "isHip9011Enabled")) {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("isHip9011Enabled=%d", engineConfiguration->isHip9011Enabled);
|
2022-11-23 12:53:16 -08:00
|
|
|
} else if (strEqualCaseInsensitive(paramStr, CMD_DATE)) {
|
2015-07-10 06:01:56 -07:00
|
|
|
printDateTime();
|
2022-11-23 12:53:16 -08:00
|
|
|
} else {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("Invalid Parameter: %s", paramStr);
|
2018-01-04 15:45:25 -08:00
|
|
|
}
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2021-11-04 20:19:44 -07:00
|
|
|
static void setScriptCurve1Value(float value) {
|
2022-05-01 20:43:43 -07:00
|
|
|
setLinearCurve(config->scriptCurve1, value, value, 1);
|
2017-12-01 20:11:01 -08:00
|
|
|
}
|
|
|
|
|
2021-11-04 20:19:44 -07:00
|
|
|
static void setScriptCurve2Value(float value) {
|
2022-05-01 20:43:43 -07:00
|
|
|
setLinearCurve(config->scriptCurve2, value, value, 1);
|
2017-12-01 20:11:01 -08:00
|
|
|
}
|
|
|
|
|
2021-06-25 17:58:38 -07:00
|
|
|
struct command_i_s {
|
2017-01-06 06:03:33 -08:00
|
|
|
const char *token;
|
|
|
|
VoidInt callback;
|
2021-06-25 17:58:38 -07:00
|
|
|
};
|
2017-01-06 06:03:33 -08:00
|
|
|
|
2021-06-25 17:58:38 -07:00
|
|
|
struct command_f_s {
|
2017-01-06 07:04:41 -08:00
|
|
|
const char *token;
|
|
|
|
VoidFloat callback;
|
2021-06-25 17:58:38 -07:00
|
|
|
};
|
2017-01-06 07:04:41 -08:00
|
|
|
|
2019-01-31 14:55:23 -08:00
|
|
|
const command_f_s commandsF[] = {
|
2020-02-26 15:16:35 -08:00
|
|
|
#if EFI_ENGINE_CONTROL
|
2017-01-06 07:04:41 -08:00
|
|
|
{"global_trigger_offset_angle", setGlobalTriggerAngleOffset},
|
|
|
|
{"cranking_fuel", setCrankingFuel},
|
2017-05-07 15:37:22 -07:00
|
|
|
{"cranking_iac", setCrankingIACExtra},
|
2017-01-06 07:04:41 -08:00
|
|
|
{"cranking_timing_angle", setCrankingTimingAngle},
|
2017-01-06 13:03:41 -08:00
|
|
|
{"tps_accel_threshold", setTpsAccelThr},
|
|
|
|
{"tps_decel_threshold", setTpsDecelThr},
|
|
|
|
{"tps_decel_multiplier", setTpsDecelMult},
|
2018-01-17 16:37:26 -08:00
|
|
|
{"flat_injector_lag", setFlatInjectorLag},
|
2020-02-26 15:16:35 -08:00
|
|
|
#endif // EFI_ENGINE_CONTROL
|
2021-11-04 20:19:44 -07:00
|
|
|
{"script_curve_1_value", setScriptCurve1Value},
|
|
|
|
{"script_curve_2_value", setScriptCurve2Value},
|
2017-01-06 07:04:41 -08:00
|
|
|
};
|
|
|
|
|
2023-11-05 12:55:46 -08:00
|
|
|
const command_i_s commandsI[] = {
|
2020-02-26 15:16:35 -08:00
|
|
|
#if EFI_ENGINE_CONTROL
|
2023-11-05 12:55:46 -08:00
|
|
|
{"ignition_mode", setIgnitionMode},
|
2023-03-16 07:37:01 -07:00
|
|
|
{"driveWheelRevPerKm", [](int value) {
|
|
|
|
engineConfiguration->driveWheelRevPerKm = value;
|
|
|
|
}},
|
2017-01-06 06:03:33 -08:00
|
|
|
{"cranking_rpm", setCrankingRpm},
|
|
|
|
{"cranking_injection_mode", setCrankingInjectionMode},
|
|
|
|
{"injection_mode", setInjectionMode},
|
2017-01-06 07:04:41 -08:00
|
|
|
{"sensor_chart_mode", setSensorChartMode},
|
|
|
|
{"fixed_mode_timing", setFixedModeTiming},
|
|
|
|
{"timing_mode", setTimingMode},
|
2023-08-24 06:48:30 -07:00
|
|
|
{CMD_ENGINE_TYPE, setEngineTypeAndSave},
|
2017-01-06 07:04:41 -08:00
|
|
|
{"rpm_hard_limit", setRpmHardLimit},
|
|
|
|
{"firing_order", setFiringOrder},
|
|
|
|
{"algorithm", setAlgorithmInt},
|
2017-05-13 04:48:42 -07:00
|
|
|
{"debug_mode", setDebugMode},
|
2017-01-06 07:04:41 -08:00
|
|
|
{"trigger_type", setTriggerType},
|
|
|
|
{"idle_solenoid_freq", setIdleSolenoidFrequency},
|
2017-01-06 13:03:41 -08:00
|
|
|
{"tps_accel_len", setTpsAccelLen},
|
2020-02-26 15:16:35 -08:00
|
|
|
#endif // EFI_ENGINE_CONTROL
|
2023-05-24 08:15:07 -07:00
|
|
|
#if EFI_BOR_LEVEL
|
2017-02-14 18:01:56 -08:00
|
|
|
{"bor", setBor},
|
2023-05-24 08:15:07 -07:00
|
|
|
#endif // EFI_BOR_LEVEL
|
|
|
|
#if EFI_PROD_CODE
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_CAN_SUPPORT
|
2017-01-11 18:04:22 -08:00
|
|
|
{"can_mode", setCanType},
|
2020-04-19 15:23:06 -07:00
|
|
|
{"can_vss", setCanVss},
|
2022-11-23 03:01:34 -08:00
|
|
|
#endif // EFI_CAN_SUPPORT
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_IDLE_CONTROL
|
2020-07-26 09:03:36 -07:00
|
|
|
{"idle_position", setManualIdleValvePosition},
|
2017-01-06 14:01:28 -08:00
|
|
|
{"idle_rpm", setTargetIdleRpm},
|
2022-11-23 03:01:34 -08:00
|
|
|
#endif // EFI_IDLE_CONTROL
|
|
|
|
#endif // EFI_PROD_CODE
|
2018-11-26 19:17:16 -08:00
|
|
|
|
2017-01-06 07:04:41 -08:00
|
|
|
// {"", },
|
|
|
|
// {"", },
|
2017-01-06 06:03:33 -08:00
|
|
|
};
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
static void setValue(const char *paramStr, const char *valueStr) {
|
|
|
|
float valueF = atoff(valueStr);
|
|
|
|
int valueI = atoi(valueStr);
|
|
|
|
|
2019-01-05 05:06:18 -08:00
|
|
|
const command_f_s *currentF = &commandsF[0];
|
2017-01-06 07:04:41 -08:00
|
|
|
while (currentF < commandsF + sizeof(commandsF)/sizeof(commandsF[0])) {
|
|
|
|
if (strEqualCaseInsensitive(paramStr, currentF->token)) {
|
|
|
|
currentF->callback(valueF);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
currentF++;
|
|
|
|
}
|
|
|
|
|
2019-01-05 05:06:18 -08:00
|
|
|
const command_i_s *currentI = &commandsI[0];
|
2017-01-06 07:04:41 -08:00
|
|
|
while (currentI < commandsI + sizeof(commandsI)/sizeof(commandsI[0])) {
|
|
|
|
if (strEqualCaseInsensitive(paramStr, currentI->token)) {
|
|
|
|
currentI->callback(valueI);
|
2017-01-06 06:03:33 -08:00
|
|
|
return;
|
|
|
|
}
|
2017-01-06 07:04:41 -08:00
|
|
|
currentI++;
|
2017-01-06 06:03:33 -08:00
|
|
|
}
|
|
|
|
|
2023-11-14 21:56:06 -08:00
|
|
|
|
2021-11-27 05:49:07 -08:00
|
|
|
if (strEqualCaseInsensitive(paramStr, "warning_period")) {
|
2016-07-22 15:04:12 -07:00
|
|
|
engineConfiguration->warningPeriod = valueI;
|
2016-10-15 19:01:57 -07:00
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "dwell")) {
|
2021-11-16 01:15:29 -08:00
|
|
|
setConstantDwell(valueF);
|
2020-10-03 16:45:39 -07:00
|
|
|
} else if (strEqualCaseInsensitive(paramStr, CMD_ENGINESNIFFERRPMTHRESHOLD)) {
|
2016-07-23 12:05:04 -07:00
|
|
|
engineConfiguration->engineSnifferRpmThreshold = valueI;
|
2019-03-02 10:21:12 -08:00
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "tps_max")) {
|
|
|
|
engineConfiguration->tpsMax = valueI;
|
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "tps_min")) {
|
|
|
|
engineConfiguration->tpsMin = valueI;
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_EMULATE_POSITION_SENSORS
|
2020-08-08 08:45:02 -07:00
|
|
|
} else if (strEqualCaseInsensitive(paramStr, CMD_RPM)) {
|
2019-03-11 10:51:03 -07:00
|
|
|
setTriggerEmulatorRPM(valueI);
|
2022-11-23 03:01:34 -08:00
|
|
|
#endif // EFI_EMULATE_POSITION_SENSORS
|
2023-05-15 13:40:03 -07:00
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "mc33_hvolt")) {
|
|
|
|
engineConfiguration->mc33_hvolt = valueI;
|
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "mc33_i_peak")) {
|
|
|
|
engineConfiguration->mc33_i_peak = valueI;
|
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "mc33_i_hold")) {
|
|
|
|
engineConfiguration->mc33_i_hold = valueI;
|
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "mc33_t_max_boost")) {
|
|
|
|
engineConfiguration->mc33_t_max_boost = valueI;
|
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "mc33_t_peak_off")) {
|
|
|
|
engineConfiguration->mc33_t_peak_off = valueI;
|
2016-11-17 20:02:17 -08:00
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "vvt_offset")) {
|
2021-07-03 09:02:00 -07:00
|
|
|
engineConfiguration->vvtOffsets[0] = valueF;
|
2016-11-14 19:02:35 -08:00
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "vvt_mode")) {
|
2021-02-08 18:50:31 -08:00
|
|
|
engineConfiguration->vvtMode[0] = (vvt_mode_e)valueI;
|
2019-01-06 17:45:51 -08:00
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "wwaeTau")) {
|
|
|
|
engineConfiguration->wwaeTau = valueF;
|
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "wwaeBeta")) {
|
|
|
|
engineConfiguration->wwaeBeta = valueF;
|
2022-01-03 11:21:54 -08:00
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "benchTestOffTime")) {
|
|
|
|
engineConfiguration->benchTestOffTime = valueI;
|
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "benchTestCount")) {
|
|
|
|
engineConfiguration->benchTestCount = valueI;
|
2016-10-28 19:03:00 -07:00
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "cranking_dwell")) {
|
|
|
|
engineConfiguration->ignitionDwellForCrankingMs = valueF;
|
2020-08-08 16:39:29 -07:00
|
|
|
#if EFI_PROD_CODE
|
2020-08-08 15:28:43 -07:00
|
|
|
} else if (strEqualCaseInsensitive(paramStr, CMD_VSS_PIN)) {
|
|
|
|
setVssPin(valueStr);
|
2020-08-08 16:39:29 -07:00
|
|
|
#endif // EFI_PROD_CODE
|
2015-07-10 06:01:56 -07:00
|
|
|
} else if (strEqualCaseInsensitive(paramStr, "targetvbatt")) {
|
|
|
|
engineConfiguration->targetVBatt = valueF;
|
2019-09-20 15:12:56 -07:00
|
|
|
} else if (strEqualCaseInsensitive(paramStr, CMD_DATE)) {
|
2017-08-22 21:46:34 -07:00
|
|
|
// rusEfi console invokes this method with timestamp in local timezone
|
2015-07-10 06:01:56 -07:00
|
|
|
setDateTime(valueStr);
|
|
|
|
}
|
2023-06-27 12:05:15 -07:00
|
|
|
|
|
|
|
bool isGoodName = setConfigValueByName(paramStr, valueF);
|
|
|
|
if (isGoodName) {
|
|
|
|
efiPrintf("Settings: applying [%s][%f]", paramStr, valueF);
|
|
|
|
}
|
|
|
|
|
2019-12-21 22:03:58 -08:00
|
|
|
engine->resetEngineSnifferIfInTestMode();
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2023-10-26 12:52:56 -07:00
|
|
|
void initSettings() {
|
2018-01-30 11:56:24 -08:00
|
|
|
#if EFI_SIMULATOR
|
|
|
|
printf("initSettings\n");
|
2022-11-23 03:01:34 -08:00
|
|
|
#endif // EFI_SIMULATOR
|
2018-01-30 11:56:24 -08:00
|
|
|
|
2017-01-06 07:04:41 -08:00
|
|
|
// todo: start saving values into flash right away?
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
addConsoleAction("tpsinfo", printTPSInfo);
|
2019-04-30 16:22:12 -07:00
|
|
|
addConsoleAction("calibrate_tps_1_closed", grabTPSIsClosed);
|
|
|
|
addConsoleAction("calibrate_tps_1_wot", grabTPSIsWideOpen);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2023-11-05 12:55:46 -08:00
|
|
|
|
|
|
|
#if EFI_ENGINE_CONTROL
|
2023-05-24 05:25:21 -07:00
|
|
|
// used by HW CI
|
2023-05-23 22:38:15 -07:00
|
|
|
addConsoleAction(CMD_INDIVIDUAL_INJECTION, setIndividualCoilsIgnition);
|
2023-11-05 12:55:46 -08:00
|
|
|
addConsoleAction("showconfig", doPrintConfiguration);
|
2015-07-10 06:01:56 -07:00
|
|
|
addConsoleActionF("set_whole_phase_map", setWholePhaseMapCmd);
|
|
|
|
addConsoleActionF("set_whole_timing_map", setWholeTimingMapCmd);
|
|
|
|
addConsoleActionF("set_whole_ve_map", setWholeVeCmd);
|
2015-10-18 18:02:32 -07:00
|
|
|
addConsoleActionF("set_whole_ign_corr_map", setWholeIgnitionIatCorr);
|
2023-11-05 12:55:46 -08:00
|
|
|
#endif // EFI_ENGINE_CONTROL
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-01-05 20:33:04 -08:00
|
|
|
addConsoleAction("stopengine", (Void) scheduleStopEngine);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
// todo: refactor this - looks like all boolean flags should be controlled with less code duplication
|
|
|
|
addConsoleActionI("enable_spi", enableSpi);
|
|
|
|
addConsoleActionI("disable_spi", disableSpi);
|
|
|
|
|
2019-07-14 12:47:08 -07:00
|
|
|
addConsoleActionS(CMD_ENABLE, enable);
|
|
|
|
addConsoleActionS(CMD_DISABLE, disable);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2023-06-27 12:05:15 -07:00
|
|
|
addConsoleActionSS(CMD_SET, setValue);
|
|
|
|
addConsoleActionS(CMD_GET, getValue);
|
2015-08-30 10:02:46 -07:00
|
|
|
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_PROD_CODE
|
2015-07-10 06:01:56 -07:00
|
|
|
addConsoleActionS("showpin", showPinFunction);
|
2020-12-08 02:30:12 -08:00
|
|
|
addConsoleActionSS(CMD_INJECTION_PIN, setInjectionPin);
|
|
|
|
addConsoleActionSS(CMD_IGNITION_PIN, setIgnitionPin);
|
2020-08-08 15:28:43 -07:00
|
|
|
addConsoleActionSS(CMD_TRIGGER_PIN, setTriggerInputPin);
|
2020-12-08 02:07:03 -08:00
|
|
|
addConsoleActionSS(CMD_TRIGGER_SIMULATOR_PIN, setTriggerSimulatorPin);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2022-07-30 09:23:53 -07:00
|
|
|
addConsoleActionI(CMD_ECU_UNLOCK, unlockEcu);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
addConsoleActionS("set_fuel_pump_pin", setFuelPumpPin);
|
2019-09-15 08:32:38 -07:00
|
|
|
addConsoleActionS("set_acrelay_pin", setACRelayPin);
|
2020-12-08 01:21:14 -08:00
|
|
|
addConsoleActionS(CMD_ALTERNATOR_PIN, setAlternatorPin);
|
|
|
|
addConsoleActionS(CMD_IDLE_PIN, setIdlePin);
|
2015-07-10 06:01:56 -07:00
|
|
|
addConsoleActionS("set_main_relay_pin", setMainRelayPin);
|
2019-11-25 17:08:01 -08:00
|
|
|
addConsoleActionS("set_starter_relay_pin", setStarterRelayPin);
|
2020-04-10 17:31:58 -07:00
|
|
|
addConsoleActionS("set_trigger_sync_pin", setTriggerSyncPin);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-07-17 10:42:10 -07:00
|
|
|
addConsoleActionS("bench_clearpin", benchClearPin);
|
|
|
|
addConsoleActionS("bench_setpin", benchSetPin);
|
2020-11-25 16:52:22 -08:00
|
|
|
addConsoleActionS("readpin", readPin);
|
2020-05-11 09:17:42 -07:00
|
|
|
|
2019-04-12 19:07:03 -07:00
|
|
|
#if HAL_USE_ADC
|
2023-05-24 06:57:23 -07:00
|
|
|
addConsoleAction("adc_report", printFullAdcReport);
|
2015-07-10 06:01:56 -07:00
|
|
|
addConsoleActionSS("set_analog_input_pin", setAnalogInputPin);
|
2022-11-23 03:01:34 -08:00
|
|
|
#endif // HAL_USE_ADC
|
2020-12-08 01:21:14 -08:00
|
|
|
addConsoleActionSS(CMD_LOGIC_PIN, setLogicInputPin);
|
2022-11-23 03:01:34 -08:00
|
|
|
#endif // EFI_PROD_CODE
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2022-11-23 12:53:16 -08:00
|
|
|
void printDateTime() {
|
|
|
|
#if EFI_RTC
|
|
|
|
printRtcDateTime();
|
|
|
|
#else // EFI_RTC
|
|
|
|
efiPrintf("Cannot print time: RTC not supported");
|
|
|
|
#endif // EFI_RTC
|
|
|
|
}
|
|
|
|
|
|
|
|
void setDateTime(const char * const isoDateTime) {
|
|
|
|
#if EFI_RTC
|
2022-12-05 15:41:30 -08:00
|
|
|
if (strlen(isoDateTime) >= 19 && isoDateTime[10] == 'T') {
|
2022-11-23 12:53:16 -08:00
|
|
|
efidatetime_t dateTime;
|
2022-12-08 10:20:55 -08:00
|
|
|
dateTime.year = atoi(isoDateTime);
|
|
|
|
dateTime.month = atoi(isoDateTime + 5);
|
|
|
|
dateTime.day = atoi(isoDateTime + 8);
|
|
|
|
dateTime.hour = atoi(isoDateTime + 11);
|
|
|
|
dateTime.minute = atoi(isoDateTime + 14);
|
|
|
|
dateTime.second = atoi(isoDateTime + 17);
|
|
|
|
if (dateTime.year != ATOI_ERROR_CODE &&
|
|
|
|
dateTime.month >= 1 && dateTime.month <= 12 &&
|
|
|
|
dateTime.day >= 1 && dateTime.day <= 31 &&
|
|
|
|
dateTime.hour <= 23 &&
|
|
|
|
dateTime.minute <= 59 &&
|
|
|
|
dateTime.second <= 59) {
|
|
|
|
// doesn't concern about leap years or seconds; ChibiOS doesn't support (added) leap seconds anyway
|
2022-11-23 12:53:16 -08:00
|
|
|
setRtcDateTime(&dateTime);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
efiPrintf("date_set Date parameter %s is wrong", isoDateTime);
|
|
|
|
#else // EFI_RTC
|
|
|
|
efiPrintf("Cannot set time: RTC not supported");
|
|
|
|
#endif // EFI_RTC
|
|
|
|
}
|
|
|
|
|
2022-11-23 03:01:34 -08:00
|
|
|
#endif // ! EFI_UNIT_TEST
|
2021-06-25 09:26:29 -07:00
|
|
|
|
2023-08-24 06:48:30 -07:00
|
|
|
void setEngineTypeAndSave(int value) {
|
|
|
|
setEngineType(value, true);
|
|
|
|
}
|
2023-09-25 01:34:43 -07:00
|
|
|
|
2023-08-24 06:48:30 -07:00
|
|
|
void setEngineType(int value, bool isWriteToFlash) {
|
2021-07-14 21:34:22 -07:00
|
|
|
{
|
|
|
|
#if EFI_PROD_CODE
|
|
|
|
chibios_rt::CriticalSectionLocker csl;
|
2022-11-23 03:01:34 -08:00
|
|
|
#endif // EFI_PROD_CODE
|
2021-07-14 21:34:22 -07:00
|
|
|
|
|
|
|
engineConfiguration->engineType = (engine_type_e)value;
|
2021-11-16 01:15:29 -08:00
|
|
|
resetConfigurationExt((engine_type_e)value);
|
2021-07-14 21:34:22 -07:00
|
|
|
engine->resetEngineSnifferIfInTestMode();
|
|
|
|
|
2023-11-03 10:08:35 -07:00
|
|
|
#if (EFI_STORAGE_INT_FLASH == TRUE) || (EFI_STORAGE_MFS == TRUE)
|
2023-08-24 06:48:30 -07:00
|
|
|
if (isWriteToFlash) {
|
|
|
|
writeToFlashNow();
|
|
|
|
}
|
2023-11-03 10:08:35 -07:00
|
|
|
#endif /* (EFI_STORAGE_INT_FLASH == TRUE) || (EFI_STORAGE_MFS == TRUE) */
|
2021-07-14 21:34:22 -07:00
|
|
|
}
|
2023-04-19 19:09:48 -07:00
|
|
|
incrementGlobalConfigurationVersion("engineType");
|
2023-11-05 12:55:46 -08:00
|
|
|
#if EFI_ENGINE_CONTROL && ! EFI_UNIT_TEST
|
2021-07-14 21:34:22 -07:00
|
|
|
doPrintConfiguration();
|
2022-11-23 03:01:34 -08:00
|
|
|
#endif // ! EFI_UNIT_TEST
|
2021-07-14 21:34:22 -07:00
|
|
|
}
|