From e08cdf0fb61a621e7f1a96f102bdc9ad6fa1f49d Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 3 Mar 2023 00:21:40 -0500 Subject: [PATCH] trigger refactoring only:mre_f4 --- firmware/controllers/trigger/decoders/trigger_structure.cpp | 3 +-- firmware/controllers/trigger/decoders/trigger_structure.h | 2 +- firmware/controllers/trigger/trigger_central.cpp | 4 ++-- unit_tests/tests/trigger/test_trigger_decoder_2.cpp | 3 ++- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp index 7c24a26ff6..1d591a525e 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.cpp +++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp @@ -405,8 +405,7 @@ void TriggerWaveform::setThirdTriggerSynchronizationGap(float syncRatio) { /** * External logger is needed because at this point our logger is not yet initialized */ -void TriggerWaveform::initializeTriggerWaveform(operation_mode_e triggerOperationMode, const TriggerConfiguration& triggerConfig) { - const trigger_config_s &triggerType = triggerConfig.TriggerType; +void TriggerWaveform::initializeTriggerWaveform(operation_mode_e triggerOperationMode, const trigger_config_s &triggerType) { #if EFI_PROD_CODE efiAssertVoid(CUSTOM_ERR_6641, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "init t"); diff --git a/firmware/controllers/trigger/decoders/trigger_structure.h b/firmware/controllers/trigger/decoders/trigger_structure.h index 8ad35c3f01..3b321c0ade 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.h +++ b/firmware/controllers/trigger/decoders/trigger_structure.h @@ -60,7 +60,7 @@ class TriggerConfiguration; class TriggerWaveform { public: TriggerWaveform(); - void initializeTriggerWaveform(operation_mode_e triggerOperationMode, const TriggerConfiguration& triggerConfig); + void initializeTriggerWaveform(operation_mode_e triggerOperationMode, const trigger_config_s &triggerType); void setShapeDefinitionError(bool value); /** diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 12a3c17e35..046b3732c6 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -1009,7 +1009,7 @@ void onConfigurationChangeTriggerCallback() { } static void initVvtShape(TriggerWaveform& shape, const TriggerConfiguration& config, TriggerDecoderBase &initState) { - shape.initializeTriggerWaveform(FOUR_STROKE_CAM_SENSOR, config); + shape.initializeTriggerWaveform(FOUR_STROKE_CAM_SENSOR, config.TriggerType); shape.initializeSyncPoint(initState, config); } @@ -1058,7 +1058,7 @@ void TriggerCentral::updateWaveform() { vvtTriggerConfiguration[camIndex].update(); } - triggerShape.initializeTriggerWaveform(lookupOperationMode(), primaryTriggerConfiguration); + triggerShape.initializeTriggerWaveform(lookupOperationMode(), primaryTriggerConfiguration.TriggerType); /** * this is only useful while troubleshooting a new trigger shape in the field diff --git a/unit_tests/tests/trigger/test_trigger_decoder_2.cpp b/unit_tests/tests/trigger/test_trigger_decoder_2.cpp index 05cdbc4d18..c4f13e5c97 100644 --- a/unit_tests/tests/trigger/test_trigger_decoder_2.cpp +++ b/unit_tests/tests/trigger/test_trigger_decoder_2.cpp @@ -32,8 +32,9 @@ struct MockTriggerDecoder : public TriggerDecoderBase { }; static auto makeTriggerShape(operation_mode_e mode, const TriggerConfiguration& config) { + // huh? do we return local method instance? how come it's not a SegmFault? is it not allocated on stack?! TriggerWaveform shape; - shape.initializeTriggerWaveform(mode, config); + shape.initializeTriggerWaveform(mode, config.TriggerType); return shape; }