From 731fd89ef7c0febd995e4e0cb9c714ae5cf36baa Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 11 Jun 2023 23:13:36 -0400 Subject: [PATCH] reducing magic constant --- firmware/controllers/engine_cycle/main_trigger_callback.cpp | 2 +- firmware/controllers/engine_cycle/map_averaging.cpp | 4 ++-- firmware/controllers/trigger/trigger_decoder.cpp | 2 +- firmware/hw_layer/hardware.cpp | 4 ++-- firmware/util/datalogging.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/firmware/controllers/engine_cycle/main_trigger_callback.cpp b/firmware/controllers/engine_cycle/main_trigger_callback.cpp index 936bb6fec6..d9b52d436f 100644 --- a/firmware/controllers/engine_cycle/main_trigger_callback.cpp +++ b/firmware/controllers/engine_cycle/main_trigger_callback.cpp @@ -197,7 +197,7 @@ void InjectionEvent::onTriggerTooth(int rpm, efitick_t nowNt, float currentPhase static void handleFuel(int rpm, efitick_t nowNt, float currentPhase, float nextPhase) { ScopePerf perf(PE::HandleFuel); - efiAssertVoid(ObdCode::CUSTOM_STACK_6627, getCurrentRemainingStack() > 128, "lowstck#3"); + efiAssertVoid(ObdCode::CUSTOM_STACK_6627, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lowstck#3"); LimpState limitedFuelState = getLimpManager()->allowInjection(); diff --git a/firmware/controllers/engine_cycle/map_averaging.cpp b/firmware/controllers/engine_cycle/map_averaging.cpp index 3014709975..53da5de51b 100644 --- a/firmware/controllers/engine_cycle/map_averaging.cpp +++ b/firmware/controllers/engine_cycle/map_averaging.cpp @@ -59,7 +59,7 @@ static void endAveraging(MapAverager* arg); static size_t currentMapAverager = 0; static void startAveraging(scheduling_s *endAveragingScheduling) { - efiAssertVoid(ObdCode::CUSTOM_ERR_6649, getCurrentRemainingStack() > 128, "lowstck#9"); + efiAssertVoid(ObdCode::CUSTOM_ERR_6649, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lowstck#9"); // TODO: set currentMapAverager based on cylinder bank auto& averager = getMapAvg(currentMapAverager); @@ -126,7 +126,7 @@ void MapAverager::stop() { * as fast as possible */ void mapAveragingAdcCallback(float instantVoltage) { - efiAssertVoid(ObdCode::CUSTOM_ERR_6650, getCurrentRemainingStack() > 128, "lowstck#9a"); + efiAssertVoid(ObdCode::CUSTOM_ERR_6650, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lowstck#9a"); SensorResult mapResult = getMapAvg(currentMapAverager).submit(instantVoltage); diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 9fd1e7b04f..70a8213121 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -694,7 +694,7 @@ uint32_t TriggerDecoderBase::findTriggerZeroEventIndex( TriggerWaveform& shape, const TriggerConfiguration& triggerConfiguration) { #if EFI_PROD_CODE - efiAssert(ObdCode::CUSTOM_ERR_ASSERT, getCurrentRemainingStack() > 128, "findPos", -1); + efiAssert(ObdCode::CUSTOM_ERR_ASSERT, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "findPos", -1); #endif diff --git a/firmware/hw_layer/hardware.cpp b/firmware/hw_layer/hardware.cpp index 56289df244..f8fe164406 100644 --- a/firmware/hw_layer/hardware.cpp +++ b/firmware/hw_layer/hardware.cpp @@ -80,7 +80,7 @@ extern bool isSpiInitialized[5]; * Only one consumer can use SPI bus at a given time */ void lockSpi(spi_device_e device) { - efiAssertVoid(ObdCode::CUSTOM_STACK_SPI, getCurrentRemainingStack() > 128, "lockSpi"); + efiAssertVoid(ObdCode::CUSTOM_STACK_SPI, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lockSpi"); spiAcquireBus(getSpiDevice(device)); } @@ -177,7 +177,7 @@ void onFastAdcComplete(adcsample_t*) { /** * this callback is executed 10 000 times a second, it needs to be as fast as possible */ - efiAssertVoid(ObdCode::CUSTOM_STACK_ADC, getCurrentRemainingStack() > 128, "lowstck#9b"); + efiAssertVoid(ObdCode::CUSTOM_STACK_ADC, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lowstck#9b"); #if EFI_SENSOR_CHART && EFI_SHAFT_POSITION_INPUT if (getEngineState()->sensorChartMode == SC_AUX_FAST1) { diff --git a/firmware/util/datalogging.cpp b/firmware/util/datalogging.cpp index 7c7a12b743..2aa3d25fc3 100644 --- a/firmware/util/datalogging.cpp +++ b/firmware/util/datalogging.cpp @@ -78,7 +78,7 @@ void Logging::appendFast(const char *text) { } void Logging::appendPrintf(const char *fmt, ...) { - efiAssertVoid(ObdCode::CUSTOM_APPEND_STACK, getCurrentRemainingStack() > 128, "lowstck#4"); + efiAssertVoid(ObdCode::CUSTOM_APPEND_STACK, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lowstck#4"); size_t available = remainingSize();