From bc2a2b9ab9b9e0b0b2d33c9d0cfa303c1d989cb2 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sun, 25 Jun 2023 02:08:53 -0400 Subject: [PATCH] only:better method name --- firmware/console/binary/tooth_logger.cpp | 2 +- firmware/controllers/algo/engine_configuration.cpp | 2 +- firmware/controllers/algo/obd_error_codes.h | 2 +- firmware/controllers/core/common_headers.h | 3 ++- firmware/controllers/engine_cycle/main_trigger_callback.cpp | 2 +- firmware/controllers/engine_cycle/map_averaging.cpp | 4 ++-- firmware/controllers/system/timer/single_timer_executor.cpp | 2 +- firmware/controllers/trigger/decoders/trigger_structure.cpp | 2 +- firmware/controllers/trigger/trigger_central.cpp | 2 +- firmware/controllers/trigger/trigger_decoder.cpp | 2 +- firmware/global.h | 1 + firmware/hw_layer/hardware.cpp | 6 +++--- firmware/util/datalogging.cpp | 2 +- misc/stm32f1_test_project/timer/single_timer_executor.cpp | 2 +- 14 files changed, 18 insertions(+), 16 deletions(-) diff --git a/firmware/console/binary/tooth_logger.cpp b/firmware/console/binary/tooth_logger.cpp index 6c3be87a8c..da61343747 100644 --- a/firmware/console/binary/tooth_logger.cpp +++ b/firmware/console/binary/tooth_logger.cpp @@ -240,7 +240,7 @@ static void SetNextCompositeEntry(efitick_t timestamp) { #endif // EFI_UNIT_TEST void LogTriggerTooth(trigger_event_e tooth, efitick_t timestamp) { - efiAssertVoid(ObdCode::CUSTOM_ERR_6650, assertRemainingStack(), "l-t-t"); + efiAssertVoid(ObdCode::CUSTOM_ERR_6650, hasLotsOfRemainingStack(), "l-t-t"); // bail if we aren't enabled if (!ToothLoggerEnabled) { return; diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index ca44a393a6..27a669ec31 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -1003,7 +1003,7 @@ void validateConfiguration() { void applyNonPersistentConfiguration() { #if EFI_PROD_CODE - efiAssertVoid(ObdCode::CUSTOM_APPLY_STACK, assertRemainingStack(), "apply c"); + efiAssertVoid(ObdCode::CUSTOM_APPLY_STACK, hasLotsOfRemainingStack(), "apply c"); efiPrintf("applyNonPersistentConfiguration()"); #endif diff --git a/firmware/controllers/algo/obd_error_codes.h b/firmware/controllers/algo/obd_error_codes.h index cc74e06a75..a33032c934 100644 --- a/firmware/controllers/algo/obd_error_codes.h +++ b/firmware/controllers/algo/obd_error_codes.h @@ -2125,7 +2125,7 @@ enum class ObdCode : uint16_t { STACK_USAGE_MIL = 6901, STACK_USAGE_BENCH = 6902, STACK_USAGE_STATUS = 6903, - STACK_USAGE_4 = 6904, + STACK_USAGE_MISC = 6904, // 8000-8050 logging errors CUSTOM_OBD_MMC_ERROR = 8000, diff --git a/firmware/controllers/core/common_headers.h b/firmware/controllers/core/common_headers.h index 6066db146f..21214b22d4 100644 --- a/firmware/controllers/core/common_headers.h +++ b/firmware/controllers/core/common_headers.h @@ -42,4 +42,5 @@ #define EXPECTED_REMAINING_STACK 128 -#define assertRemainingStack() (getCurrentRemainingStack() > EXPECTED_REMAINING_STACK) +// see also validateStack +#define hasLotsOfRemainingStack() (getCurrentRemainingStack() > EXPECTED_REMAINING_STACK) diff --git a/firmware/controllers/engine_cycle/main_trigger_callback.cpp b/firmware/controllers/engine_cycle/main_trigger_callback.cpp index d1280a3a6c..688fe84d2f 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, assertRemainingStack(), "lowstck#3"); + efiAssertVoid(ObdCode::CUSTOM_STACK_6627, hasLotsOfRemainingStack(), "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 844214f6ee..e42cf4285f 100644 --- a/firmware/controllers/engine_cycle/map_averaging.cpp +++ b/firmware/controllers/engine_cycle/map_averaging.cpp @@ -62,7 +62,7 @@ static void endAveraging(MapAverager* arg); static size_t currentMapAverager = 0; static void startAveraging(scheduling_s *endAveragingScheduling) { - efiAssertVoid(ObdCode::CUSTOM_ERR_6649, assertRemainingStack(), "lowstck#9"); + efiAssertVoid(ObdCode::CUSTOM_ERR_6649, hasLotsOfRemainingStack(), "lowstck#9"); // TODO: set currentMapAverager based on cylinder bank auto& averager = getMapAvg(currentMapAverager); @@ -129,7 +129,7 @@ void MapAverager::stop() { * as fast as possible */ void mapAveragingAdcCallback(float instantVoltage) { - efiAssertVoid(ObdCode::CUSTOM_ERR_6650, assertRemainingStack(), "lowstck#9a"); + efiAssertVoid(ObdCode::CUSTOM_ERR_6650, hasLotsOfRemainingStack(), "lowstck#9a"); SensorResult mapResult = getMapAvg(currentMapAverager).submit(instantVoltage); diff --git a/firmware/controllers/system/timer/single_timer_executor.cpp b/firmware/controllers/system/timer/single_timer_executor.cpp index d6d9bc8cba..34a7d74355 100644 --- a/firmware/controllers/system/timer/single_timer_executor.cpp +++ b/firmware/controllers/system/timer/single_timer_executor.cpp @@ -34,7 +34,7 @@ uint32_t hwSetTimerDuration; void globalTimerCallback() { - efiAssertVoid(ObdCode::CUSTOM_ERR_6624, assertRemainingStack(), "lowstck#2y"); + efiAssertVoid(ObdCode::CUSTOM_ERR_6624, hasLotsOfRemainingStack(), "lowstck#2y"); ___engine.executor.onTimerCallback(); } diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp index 72b034543e..691723505b 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.cpp +++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp @@ -413,7 +413,7 @@ void TriggerWaveform::setThirdTriggerSynchronizationGap(float syncRatio) { void TriggerWaveform::initializeTriggerWaveform(operation_mode_e triggerOperationMode, const trigger_config_s &triggerType) { #if EFI_PROD_CODE - efiAssertVoid(ObdCode::CUSTOM_ERR_6641, assertRemainingStack(), "init t"); + efiAssertVoid(ObdCode::CUSTOM_ERR_6641, hasLotsOfRemainingStack(), "init t"); efiPrintf("initializeTriggerWaveform(%s/%d)", getTrigger_type_e(triggerType.type), (int)triggerType.type); #endif diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 5d72789151..3ef733fe90 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -1039,7 +1039,7 @@ static void calculateTriggerSynchPoint( TriggerDecoderBase& initState) { #if EFI_PROD_CODE - efiAssertVoid(ObdCode::CUSTOM_TRIGGER_STACK, assertRemainingStack(), "calc s"); + efiAssertVoid(ObdCode::CUSTOM_TRIGGER_STACK, hasLotsOfRemainingStack(), "calc s"); #endif shape.initializeSyncPoint(initState, primaryTriggerConfiguration); diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 534894d7af..a3672ae60c 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, assertRemainingStack(), "findPos", -1); + efiAssert(ObdCode::CUSTOM_ERR_ASSERT, hasLotsOfRemainingStack(), "findPos", -1); #endif diff --git a/firmware/global.h b/firmware/global.h index 51a839b195..5a032895e0 100644 --- a/firmware/global.h +++ b/firmware/global.h @@ -55,6 +55,7 @@ typedef unsigned int time_t; #define UTILITY_THREAD_STACK_SIZE 400 #endif /* UTILITY_THREAD_STACK_SIZE */ +// see also validateStack #define getCurrentRemainingStack() getRemainingStack(chThdGetSelfX()) #define EFI_ERROR_CODE 0xffffffff diff --git a/firmware/hw_layer/hardware.cpp b/firmware/hw_layer/hardware.cpp index c42ef80ca1..a70e327027 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, assertRemainingStack(), "lockSpi"); + efiAssertVoid(ObdCode::CUSTOM_STACK_SPI, hasLotsOfRemainingStack(), "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, assertRemainingStack(), "lowstck#9b"); + efiAssertVoid(ObdCode::CUSTOM_STACK_ADC, hasLotsOfRemainingStack(), "lowstck#9b"); #if EFI_SENSOR_CHART && EFI_SHAFT_POSITION_INPUT if (getEngineState()->sensorChartMode == SC_AUX_FAST1) { @@ -370,7 +370,7 @@ void setBor(int borValue) { // This function initializes hardware that can do so before configuration is loaded void initHardwareNoConfig() { - efiAssertVoid(ObdCode::CUSTOM_IH_STACK, assertRemainingStack(), "init h"); + efiAssertVoid(ObdCode::CUSTOM_IH_STACK, hasLotsOfRemainingStack(), "init h"); efiPrintf("initHardware()"); diff --git a/firmware/util/datalogging.cpp b/firmware/util/datalogging.cpp index a76f1d6759..bd048cd9cf 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, assertRemainingStack(), "lowstck#4"); + efiAssertVoid(ObdCode::CUSTOM_APPEND_STACK, hasLotsOfRemainingStack(), "lowstck#4"); size_t available = remainingSize(); diff --git a/misc/stm32f1_test_project/timer/single_timer_executor.cpp b/misc/stm32f1_test_project/timer/single_timer_executor.cpp index 2d4baea8be..0956ba76c5 100644 --- a/misc/stm32f1_test_project/timer/single_timer_executor.cpp +++ b/misc/stm32f1_test_project/timer/single_timer_executor.cpp @@ -34,7 +34,7 @@ uint32_t hwSetTimerDuration; void globalTimerCallback() { - efiAssertVoid(ObdCode::CUSTOM_ERR_6624, assertRemainingStack(), "lowstck#2y"); + efiAssertVoid(ObdCode::CUSTOM_ERR_6624, hasLotsOfRemainingStack(), "lowstck#2y"); ___engine.executor.onTimerCallback(); }