From 822e07d2102554b59ba84cc44498d3a911257d28 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Sat, 22 Aug 2015 11:02:10 -0400 Subject: [PATCH] auto-sync --- .../controllers/trigger/trigger_decoder.cpp | 3 ++ firmware/hw_layer/trigger_input.cpp | 28 +++++++++++-------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 786d54a9b8..f05597d159 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -103,7 +103,10 @@ static trigger_value_e eventType[6] = { TV_LOW, TV_HIGH, TV_LOW, TV_HIGH, TV_LOW /** * @brief Trigger decoding happens here + * This method is invoked every time we have a fall or rise on one of the trigger sensors. * This method changes the state of trigger_state_s data structure according to the trigger event + * @param signal type of event which just happened + * @param nowNt current time */ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t nowNt DECLARE_ENGINE_PARAMETER_S) { efiAssertVoid(signal <= SHAFT_3RD_UP, "unexpected signal"); diff --git a/firmware/hw_layer/trigger_input.cpp b/firmware/hw_layer/trigger_input.cpp index fceca6fd75..ad15a4eecf 100644 --- a/firmware/hw_layer/trigger_input.cpp +++ b/firmware/hw_layer/trigger_input.cpp @@ -53,7 +53,8 @@ static void shaft_icu_period_callback(ICUDriver *icup) { // todo: add support for 3rd channel // icucnt_t last_period = icuGetPeriod(icup); so far we are fine with system time - trigger_event_e signal = isPrimary ? SHAFT_PRIMARY_DOWN : SHAFT_SECONDARY_DOWN; + trigger_event_e signal = + isPrimary ? SHAFT_PRIMARY_DOWN : SHAFT_SECONDARY_DOWN; if (isLessImportant(signal) && CONFIG(useOnlyFrontForTrigger)) return; hwHandleShaftSignal(signal); @@ -103,7 +104,8 @@ static void turnOffTriggerInputPin(brain_pin_e hwPin) { } static void rememberPrimaryChannel(void) { - primaryCrankDriver = getInputCaptureDriver(boardConfiguration->triggerInputPins[0]); + primaryCrankDriver = getInputCaptureDriver( + boardConfiguration->triggerInputPins[0]); } void turnOnTriggerInputPins(Logging *sharedLogger) { @@ -118,25 +120,27 @@ void turnOnTriggerInputPins(Logging *sharedLogger) { extern engine_configuration_s activeConfiguration; void stopTriggerInputPins(void) { -for (int i = 0; i < TRIGGER_SUPPORTED_CHANNELS; i++) { - if (boardConfiguration->triggerInputPins[i] != activeConfiguration.bc.triggerInputPins[i]) { - turnOffTriggerInputPin(activeConfiguration.bc.triggerInputPins[i]); + for (int i = 0; i < TRIGGER_SUPPORTED_CHANNELS; i++) { + if (boardConfiguration->triggerInputPins[i] + != activeConfiguration.bc.triggerInputPins[i]) { + turnOffTriggerInputPin(activeConfiguration.bc.triggerInputPins[i]); + } } } -} void applyNewTriggerInputPins(void) { // first we will turn off all the changed pins -stopTriggerInputPins(); + stopTriggerInputPins(); // then we will enable all the changed pins -for (int i = 0; i < TRIGGER_SUPPORTED_CHANNELS; i++) { - if (boardConfiguration->triggerInputPins[i] != activeConfiguration.bc.triggerInputPins[i]) { - turnOnTriggerInputPin(boardConfiguration->triggerInputPins[i]); + for (int i = 0; i < TRIGGER_SUPPORTED_CHANNELS; i++) { + if (boardConfiguration->triggerInputPins[i] + != activeConfiguration.bc.triggerInputPins[i]) { + turnOnTriggerInputPin(boardConfiguration->triggerInputPins[i]); + } } -} -rememberPrimaryChannel(); + rememberPrimaryChannel(); } #endif /* EFI_SHAFT_POSITION_INPUT */