Skip to content

Commit

Permalink
Merge branch 'master' into nms/tunerstudio-command-x14-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mck1117 committed Aug 14, 2024
2 parents 2e64b5b + d507712 commit 4df1e43
Show file tree
Hide file tree
Showing 95 changed files with 11,524 additions and 11,218 deletions.
3 changes: 3 additions & 0 deletions firmware/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@ or
- Add options to enable/disable optional CAN frames (cams, EGT so far)
- Add 1-5-4-8-3-7-2-6 and 1-6-5-10-2-7-3-8-4-9 firing orders
- Console command `set_sensor_mock` now accepts a sensor by name, instead of index. Example: `set_sensor_mock CLT 85.5`
- TunerStudio UI improvements (#436, etc)

### Fixed
- Improve performance with Lua CAN reception of a high volume of frames
- Displayed units in TunerStudio change when switching between volume vs. mass injector flow modes #42
- Make Toyota "3 Tooth Cam" decoder more robust #382
- Flex sensor-derived fuel temperature indication works properly
- Fix a scenario where noisy trigger can cause overdwell [rusefi/rusefi#6349](https://github.com/rusefi/rusefi/issues/6349)
- Fix decel fuel cutoff (DFCO) on engines without a MAP sensor #457
- Automatic calculation of knock sense frequency based on cylinder bore #379

## December 2023 Release

Expand Down
1 change: 0 additions & 1 deletion firmware/config/boards/hellen/hellen81/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ DDEFS += -DEFI_MAIN_RELAY_CONTROL=TRUE
# Add them all together
DDEFS += -DFIRMWARE_ID=\"hellen81\"
#DDEFS += -DEFI_SOFTWARE_KNOCK=TRUE -DSTM32_ADC_USE_ADC3=TRUE
DDEFS += -DHAL_TRIGGER_USE_ADC=TRUE

# we need fast ADC for software trigger detector
#DDEFS += -DADC_FAST_DEVICE=ADCD1 -DADC_SLOW_DEVICE=ADCD3 -DSTM32_ADC_USE_ADC3=TRUE
Expand Down
6 changes: 0 additions & 6 deletions firmware/config/stm32f4ems/efifeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@

#define EFI_TEXT_LOGGING TRUE

#define EFI_ACTIVE_CONFIGURATION_IN_FLASH FALSE

#ifndef EFI_MC33816
#define EFI_MC33816 TRUE
#endif
Expand Down Expand Up @@ -79,10 +77,6 @@
#define HAL_TRIGGER_USE_PAL TRUE
#endif /* HAL_TRIGGER_USE_PAL */

#ifndef HAL_TRIGGER_USE_ADC
#define HAL_TRIGGER_USE_ADC FALSE
#endif /* HAL_TRIGGER_USE_ADC */

/**
* TunerStudio support.
*/
Expand Down
8 changes: 7 additions & 1 deletion firmware/console/binary/output_channels.txt
Original file line number Diff line number Diff line change
Expand Up @@ -366,5 +366,11 @@ float mapFast
uint16_t autoscale actualLastInjectionStage2;@@GAUGE_NAME_FUEL_LAST_INJECTION_STAGE_2@@;"ms",{1/@@PACK_MULT_MS@@}, 0, 0, 0, 3
uint8_t autoscale injectorDutyCycleStage2;@@GAUGE_NAME_FUEL_INJ_DUTY_STAGE_2@@;"%",{1/2}, 0, 0, 0, 0

uint8_t[117 iterate] unusedAtTheEnd;;"",1, 0, 0, 0, 0
uint8_t pad

uint16_t mapAveragingSamples

uint8_t[12 iterate] mapPerCylinder;;"kPa", 1, 0, 0, 0, 0

uint8_t[102 iterate] unusedAtTheEnd;;"",1, 0, 0, 0, 0
end_struct
14 changes: 12 additions & 2 deletions firmware/console/binary/output_channels_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,14 @@ struct output_channels_s {
// offset 682
scaled_channel<uint8_t, 2, 1> injectorDutyCycleStage2 = (uint8_t)0;
// offset 683
uint8_t unusedAtTheEnd[117];
uint8_t pad = (uint8_t)0;
// offset 684
uint16_t mapAveragingSamples = (uint16_t)0;
// kPa
// offset 686
uint8_t mapPerCylinder[12];
// offset 698
uint8_t unusedAtTheEnd[102];
};
static_assert(sizeof(output_channels_s) == 800);
static_assert(offsetof(output_channels_s, RPMValue) == 4);
Expand Down Expand Up @@ -955,5 +962,8 @@ static_assert(offsetof(output_channels_s, afrGasolineScale) == 676);
static_assert(offsetof(output_channels_s, afr2GasolineScale) == 678);
static_assert(offsetof(output_channels_s, actualLastInjectionStage2) == 680);
static_assert(offsetof(output_channels_s, injectorDutyCycleStage2) == 682);
static_assert(offsetof(output_channels_s, unusedAtTheEnd) == 683);
static_assert(offsetof(output_channels_s, pad) == 683);
static_assert(offsetof(output_channels_s, mapAveragingSamples) == 684);
static_assert(offsetof(output_channels_s, mapPerCylinder) == 686);
static_assert(offsetof(output_channels_s, unusedAtTheEnd) == 698);

3 changes: 0 additions & 3 deletions firmware/console/eficonsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ void initializeConsole() {
sayHello();
addConsoleAction("test", [](){ /* do nothing */});
addConsoleAction("hello", sayHello);
#if EFI_HAS_RESET
addConsoleAction("reset", scheduleReset);
#endif

addConsoleAction("critical", testCritical);
addConsoleAction("error", myerror);
Expand Down
1 change: 0 additions & 1 deletion firmware/console/status_loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ extern bool main_loop_started;
#include "pin_repository.h"
#include "max31855.h"
#include "single_timer_executor.h"
#include "periodic_task.h"
#endif /* EFI_PROD_CODE */

#if EFI_INTERNAL_FLASH
Expand Down
1 change: 0 additions & 1 deletion firmware/controllers/actuators/ac_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ static Deadband<5> maxCltDeadband;
static Deadband<5> maxTpsDeadband;

bool AcController::getAcState() {
latest_usage_ac_control = getTimeNowS();
auto rpm = Sensor::getOrZero(SensorType::Rpm);

engineTooSlow = rpm < 500;
Expand Down
1 change: 0 additions & 1 deletion firmware/controllers/actuators/ac_control.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ bit tpsTooHigh;AC tps too high
bit isDisabledByLua;AC disabled by Lua
bit acCompressorState;AC compressor on

int latest_usage_ac_control;AC latest activity
! todo: extract some helper which would contain boolean state and most recent toggle time?
int acSwitchLastChangeTimeMs;

Expand Down
8 changes: 2 additions & 6 deletions firmware/controllers/actuators/ac_control_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,9 @@ struct ac_control_s {
bool unusedBit_0_30 : 1 {};
// offset 0 bit 31
bool unusedBit_0_31 : 1 {};
// AC latest activity
// offset 4
int latest_usage_ac_control = (int)0;
// offset 8
int acSwitchLastChangeTimeMs = (int)0;
};
static_assert(sizeof(ac_control_s) == 12);
static_assert(offsetof(ac_control_s, latest_usage_ac_control) == 4);
static_assert(offsetof(ac_control_s, acSwitchLastChangeTimeMs) == 8);
static_assert(sizeof(ac_control_s) == 8);
static_assert(offsetof(ac_control_s, acSwitchLastChangeTimeMs) == 4);

1 change: 0 additions & 1 deletion firmware/controllers/actuators/alternator_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "alternator_controller.h"
#include "efi_pid.h"
#include "local_version_holder.h"
#include "periodic_task.h"

#if defined(HAS_OS_ACCESS)
#error "Unexpected OS ACCESS HERE"
Expand Down
1 change: 0 additions & 1 deletion firmware/controllers/actuators/boost_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/
#pragma once

#include "periodic_task.h"
#include "closed_loop_controller.h"
#include "efi_pid.h"
#include "boost_control_generated.h"
Expand Down
2 changes: 0 additions & 2 deletions firmware/controllers/actuators/dc_motors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

#include "pch.h"

#include "periodic_task.h"

#include "dc_motors.h"

void DcHardware::start(bool useTwoWires,
Expand Down
1 change: 0 additions & 1 deletion firmware/controllers/actuators/idle_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "idle_thread.h"
#include "idle_hardware.h"

#include "periodic_task.h"
#include "dc_motors.h"

#if EFI_TUNER_STUDIO
Expand Down
1 change: 0 additions & 1 deletion firmware/controllers/actuators/idle_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include "engine_module.h"
#include "rusefi_types.h"
#include "periodic_task.h"
#include "efi_pid.h"
#include "sensor.h"
#include "idle_state_generated.h"
Expand Down
4 changes: 2 additions & 2 deletions firmware/controllers/actuators/vvt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void VvtController::setOutput(expected<percent_t> outputValue) {

// Compensate for battery voltage so that the % output is actually % solenoid current normalized
// to a 14v supply (boost duty when battery is low, etc)
float voltageRatio = 14 / Sensor::get(SensorType::BatteryVoltage).value_or(14);
float voltageRatio = 14 / clampF(10, Sensor::get(SensorType::BatteryVoltage).value_or(14), 24);
vvtPct *= voltageRatio;

vvtOutput = vvtPct;
Expand Down Expand Up @@ -157,7 +157,7 @@ static const char *vvtOutputNames[CAM_INPUTS_COUNT] = {
};

static OutputPin vvtPins[CAM_INPUTS_COUNT];
static SimplePwm vvtPwms[CAM_INPUTS_COUNT];
static SimplePwm vvtPwms[CAM_INPUTS_COUNT] = { "VVT1", "VVT2", "VVT3", "VVT4" };

static void turnVvtPidOn(int index) {
if (!isBrainPinValid(engineConfiguration->vvtPins[index])) {
Expand Down
1 change: 0 additions & 1 deletion firmware/controllers/algo/antilag_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#if EFI_ANTILAG_SYSTEM
#include "antilag_system.h"
#include "periodic_task.h"
#include "advance_map.h"
#include "engine_state.h"
#include "advance_map.h"
Expand Down
3 changes: 3 additions & 0 deletions firmware/controllers/algo/defaults/default_base_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ void setDefaultBaseEngine() {

setDefaultVrThresholds();

// Oil pressure protection
engineConfiguration->minimumOilPressureTimeout = 0.5f;
setLinearCurve(config->minimumOilPressureBins, 0, 7000);
}

void setPPSInputs(adc_channel_e pps1, adc_channel_e pps2) {
Expand Down
2 changes: 1 addition & 1 deletion firmware/controllers/algo/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ void Engine::periodicFastCallback() {
tachUpdate();
speedoUpdate();

engine->engineModules.apply_all([](auto & m) { m.onFastCallback(); });
engineModules.apply_all([](auto & m) { m.onFastCallback(); });
}

EngineRotationState * getEngineRotationState() {
Expand Down
16 changes: 1 addition & 15 deletions firmware/controllers/algo/engine_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,10 @@
*
* todo: place this field next to 'engineConfiguration'?
*/
#if EFI_ACTIVE_CONFIGURATION_IN_FLASH
#include "flash_int.h"
engine_configuration_s & activeConfiguration = reinterpret_cast<persistent_config_container_s*>(getFlashAddrFirstCopy())->persistentConfiguration.engineConfiguration;
// we cannot use this activeConfiguration until we call rememberCurrentConfiguration()
bool isActiveConfigurationVoid = true;
#else
static engine_configuration_s activeConfigurationLocalStorage;
engine_configuration_s & activeConfiguration = activeConfigurationLocalStorage;
#endif /* EFI_ACTIVE_CONFIGURATION_IN_FLASH */
engine_configuration_s activeConfiguration;

void rememberCurrentConfiguration() {
#if ! EFI_ACTIVE_CONFIGURATION_IN_FLASH
memcpy(&activeConfiguration, engineConfiguration, sizeof(engine_configuration_s));
#else
isActiveConfigurationVoid = false;
#endif /* EFI_ACTIVE_CONFIGURATION_IN_FLASH */
}

static void wipeString(char *string, int size) {
Expand Down Expand Up @@ -599,10 +587,8 @@ static void setDefaultEngineConfiguration() {
#endif

void loadConfiguration() {
#if ! EFI_ACTIVE_CONFIGURATION_IN_FLASH
// Clear the active configuration so that registered output pins (etc) detect the change on startup and init properly
prepareVoidConfiguration(&activeConfiguration);
#endif /* EFI_ACTIVE_CONFIGURATION_IN_FLASH */

#if EFI_INTERNAL_FLASH
if (IGNORE_FLASH_CONFIGURATION) {
Expand Down
17 changes: 1 addition & 16 deletions firmware/controllers/algo/engine_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,10 @@ extern engine_configuration_s *engineConfiguration;
extern persistent_config_s *config;
#endif // EFI_UNIT_TEST

/**
* & is reference in C++ (not C)
* Ref is a pointer that:
* you access with dot instead of arrow
* Cannot be null
* This is about EFI_ACTIVE_CONFIGURATION_IN_FLASH
*/
extern engine_configuration_s & activeConfiguration;
extern engine_configuration_s activeConfiguration;

#if ! EFI_ACTIVE_CONFIGURATION_IN_FLASH
// We store a special changeable copy of configuration is RAM, so we can just compare them
#define isConfigurationChanged(x) (engineConfiguration->x != activeConfiguration.x)
#else
// We cannot call prepareVoidConfiguration() for activeConfiguration if it's stored in flash,
// so we need to tell the firmware that it's "void" (i.e. zeroed, invalid) by setting a special flag variable,
// and then we consider 'x' as changed if it's just non-zero.
extern bool isActiveConfigurationVoid;
#define isConfigurationChanged(x) ((engineConfiguration->x != activeConfiguration.x) || (isActiveConfigurationVoid && (int)(engineConfiguration->x) != 0))
#endif /* EFI_ACTIVE_CONFIGURATION_IN_FLASH */

#define isPinOrModeChanged(pin, mode) (isConfigurationChanged(pin) || isConfigurationChanged(mode))

Expand Down
5 changes: 1 addition & 4 deletions firmware/controllers/algo/engine_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@ class EngineState : public engine_state_s {
* MAP averaging angle start, in relation to 'mapAveragingSchedulingAtIndex' trigger index index
*/
angle_t mapAveragingStart[MAX_CYLINDER_COUNT];
angle_t mapAveragingDuration = 0;

/**
* timing advance is angle distance before Top Dead Center (TDP), i.e. "10 degree timing advance" means "happens 10 degrees before TDC"
*/
// degrees timing advance - 10 means fire spark 10 degrees BTDC
angle_t timingAdvance[MAX_CYLINDER_COUNT] = {0};

// Angle between firing the main (primary) spark and the secondary (trailing) spark
Expand Down
2 changes: 2 additions & 0 deletions firmware/controllers/algo/engine_state.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,7 @@ struct_no_prefix engine_state_s

uint16_t autoscale veTableYAxis;;"%",{1/100}, 0, 0, 0, 0

uint16_t autoscale mapAveragingDuration;;"deg", 0.01, 0, 0, 0, 0

! engine_state_s
end_struct
4 changes: 3 additions & 1 deletion firmware/controllers/algo/engine_state_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,9 @@ struct engine_state_s {
// %
// offset 80
scaled_channel<uint16_t, 100, 1> veTableYAxis = (uint16_t)0;
// deg
// offset 82
uint8_t alignmentFill_at_82[2];
scaled_channel<uint16_t, 100, 1> mapAveragingDuration = (uint16_t)0;
};
static_assert(sizeof(engine_state_s) == 84);
static_assert(offsetof(engine_state_s, baroCorrection) == 36);
Expand All @@ -240,4 +241,5 @@ static_assert(offsetof(engine_state_s, sparkCounter) == 68);
static_assert(offsetof(engine_state_s, fuelingLoad) == 72);
static_assert(offsetof(engine_state_s, ignitionLoad) == 76);
static_assert(offsetof(engine_state_s, veTableYAxis) == 80);
static_assert(offsetof(engine_state_s, mapAveragingDuration) == 82);

9 changes: 7 additions & 2 deletions firmware/controllers/algo/fuel/dfco.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@ bool DfcoController::getState() const {
const auto map = Sensor::get(SensorType::Map);

// If some sensor is broken, inhibit DFCO
if (!tps || !clt || !map) {
if (!tps || !clt) {
return false;
}

// MAP sensor is optional, only inhibit if the sensor is present but broken
if (Sensor::hasSensor(SensorType::Map) && !map) {
return false;
}

float rpm = Sensor::getOrZero(SensorType::Rpm);
float vss = Sensor::getOrZero(SensorType::VehicleSpeed);

bool mapActivate = map.Value < engineConfiguration->coastingFuelCutMap;
bool mapActivate = map.value_or(0) < engineConfiguration->coastingFuelCutMap;
bool tpsActivate = tps.Value < engineConfiguration->coastingFuelCutTps;
bool cltActivate = clt.Value > engineConfiguration->coastingFuelCutClt;
// True if throttle, MAP, and CLT are all acceptable for DFCO to occur
Expand Down
1 change: 0 additions & 1 deletion firmware/controllers/algo/launch_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#if EFI_LAUNCH_CONTROL
#include "boost_control.h"
#include "launch_control.h"
#include "periodic_task.h"
#include "advance_map.h"
#include "engine_state.h"
#include "advance_map.h"
Expand Down
2 changes: 1 addition & 1 deletion firmware/controllers/date_stamp.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#pragma once
#define VCS_DATE 20240803
#define VCS_DATE 20240814
4 changes: 4 additions & 0 deletions firmware/controllers/engine_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,10 @@ bool validateConfig() {
}
#endif

if (engineConfiguration->enableOilPressureProtect) {
ensureArrayIsAscending("Oil pressure protection", config->minimumOilPressureBins);
}

return true;
}

Expand Down
Loading

0 comments on commit 4df1e43

Please sign in to comment.