diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 229bdf2caf..a0949e1f78 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -839,11 +839,11 @@ uint32_t TriggerDecoderBase::findTriggerZeroEventIndex( TriggerStimulatorHelper helper; - uint32_t syncIndex = helper.findTriggerSyncPoint(shape, + expected syncIndex = helper.findTriggerSyncPoint(shape, triggerConfiguration, *this); - if (syncIndex == EFI_ERROR_CODE) { - return syncIndex; + if (!syncIndex) { + return EFI_ERROR_CODE; } // Assert that we found the sync point on the very first revolution @@ -856,9 +856,9 @@ uint32_t TriggerDecoderBase::findTriggerZeroEventIndex( #endif /* EFI_UNIT_TEST */ helper.assertSyncPosition(triggerConfiguration, - syncIndex, *this, shape); + syncIndex.Value, *this, shape); - return syncIndex % shape.getSize(); + return syncIndex.Value % shape.getSize(); } #endif /* EFI_SHAFT_POSITION_INPUT */ diff --git a/firmware/controllers/trigger/trigger_simulator.cpp b/firmware/controllers/trigger/trigger_simulator.cpp index 9ef27192ae..7edcdb4b5d 100644 --- a/firmware/controllers/trigger/trigger_simulator.cpp +++ b/firmware/controllers/trigger/trigger_simulator.cpp @@ -127,7 +127,7 @@ void TriggerStimulatorHelper::assertSyncPosition( /** * @return trigger synchronization point index, or error code if not found */ -uint32_t TriggerStimulatorHelper::findTriggerSyncPoint( +expected TriggerStimulatorHelper::findTriggerSyncPoint( TriggerWaveform& shape, const TriggerConfiguration& triggerConfiguration, TriggerDecoderBase& state) { @@ -140,5 +140,5 @@ uint32_t TriggerStimulatorHelper::findTriggerSyncPoint( } shape.setShapeDefinitionError(true); warning(CUSTOM_ERR_TRIGGER_SYNC, "findTriggerZeroEventIndex() failed"); - return EFI_ERROR_CODE; + return unexpected; } diff --git a/firmware/controllers/trigger/trigger_simulator.h b/firmware/controllers/trigger/trigger_simulator.h index 893158ebf1..aac6d13c0d 100644 --- a/firmware/controllers/trigger/trigger_simulator.h +++ b/firmware/controllers/trigger/trigger_simulator.h @@ -17,7 +17,7 @@ int getSimulatedEventTime(const TriggerWaveform& shape, int i); class TriggerStimulatorHelper { public: - uint32_t findTriggerSyncPoint( + expected findTriggerSyncPoint( TriggerWaveform& shape, const TriggerConfiguration& triggerConfiguration, TriggerDecoderBase& state);