From 92c7a19ab42da9271edf911c55cf6771518547c2 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Sun, 24 Jan 2016 18:01:56 -0500 Subject: [PATCH] auto-sync --- firmware/controllers/trigger/trigger_central.cpp | 1 - firmware/controllers/trigger/trigger_decoder.cpp | 1 - firmware/controllers/trigger/trigger_simulator.cpp | 5 ++++- firmware/global.h | 2 +- firmware/hw_layer/trigger_input.cpp | 6 ++++++ unit_tests/global.h | 1 + 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 959133b5c0..ba42233ff3 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -19,7 +19,6 @@ #include "pwm_generator_logic.h" #include "efilib2.h" #include "settings.h" -#include "auto_generated_enums.h" #include "rpm_calculator.h" #if EFI_PROD_CODE || defined(__DOXYGEN__) diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index abc1be1487..5acd99a4f6 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -34,7 +34,6 @@ #include "trigger_nissan.h" #include "trigger_toyota.h" #include "trigger_rover.h" -#include "auto_generated_enums.h" #include "trigger_structure.h" #include "efiGpio.h" #include "engine.h" diff --git a/firmware/controllers/trigger/trigger_simulator.cpp b/firmware/controllers/trigger/trigger_simulator.cpp index fe563f35d5..741752fed5 100644 --- a/firmware/controllers/trigger/trigger_simulator.cpp +++ b/firmware/controllers/trigger/trigger_simulator.cpp @@ -61,7 +61,10 @@ void TriggerStimulatorHelper::assertSyncPositionAndSetDutyCycle(uint32_t index, for (uint32_t i = startIndex; i <= index + 2 * shape->getSize(); i++) { nextStep(state, shape, i, triggerConfig PASS_ENGINE_PARAMETER); } - efiAssertVoid(state->getTotalRevolutionCounter() == 3, "sync failed, wrong gap parameters?"); + if (state->getTotalRevolutionCounter() != 3) { + firmwareError("sync failed/wrong gap parameters trigger=%s", getTrigger_type_e(engineConfiguration->trigger.type)); + return; + } for (int i = 0; i < PWM_PHASE_MAX_WAVE_PER_PWM; i++) { shape->dutyCycle[i] = 1.0 * state->expectedTotalTime[i] / SIMULATION_CYCLE_PERIOD; diff --git a/firmware/global.h b/firmware/global.h index 2cd1f1d299..ffb915f530 100644 --- a/firmware/global.h +++ b/firmware/global.h @@ -29,8 +29,8 @@ typedef unsigned int time_t; #include "rusefi_enums.h" #if EFI_PROD_CODE #include "io_pins.h" -#include "auto_generated_enums.h" #endif +#include "auto_generated_enums.h" #include "obd_error_codes.h" #include "error_handling.h" diff --git a/firmware/hw_layer/trigger_input.cpp b/firmware/hw_layer/trigger_input.cpp index b2ae7f3174..c253d0f6b2 100644 --- a/firmware/hw_layer/trigger_input.cpp +++ b/firmware/hw_layer/trigger_input.cpp @@ -21,6 +21,8 @@ static ICUDriver *primaryCrankDriver; +extern bool hasFirmwareErrorFlag; + EXTERN_ENGINE ; static Logging *logger; @@ -32,6 +34,8 @@ static Logging *logger; static void shaft_icu_width_callback(ICUDriver *icup) { // todo: support for 3rd trigger input channel // todo: start using real event time from HW event, not just software timer? + if (hasFirmwareErrorFlag) + return; int isPrimary = icup == primaryCrankDriver; if (!isPrimary && !engine->triggerShape.needSecondTriggerInput) { return; @@ -44,6 +48,8 @@ static void shaft_icu_width_callback(ICUDriver *icup) { } static void shaft_icu_period_callback(ICUDriver *icup) { + if (hasFirmwareErrorFlag) + return; int isPrimary = icup == primaryCrankDriver; if (!isPrimary && !engine->triggerShape.needSecondTriggerInput) { return; diff --git a/unit_tests/global.h b/unit_tests/global.h index 76cefbef4f..6468e6cd29 100644 --- a/unit_tests/global.h +++ b/unit_tests/global.h @@ -13,6 +13,7 @@ #include #include "efitime.h" +#include "auto_generated_enums.h" #define US_TO_NT_MULTIPLIER 100