From eef4fbde9b0863346478e6200850a82dd937f5cb Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 8 Aug 2019 22:12:51 -0400 Subject: [PATCH] fixing build & taking a safer route --- firmware/controllers/algo/engine.h | 2 -- firmware/controllers/algo/engine_configuration.cpp | 10 ++++------ firmware/controllers/algo/engine_configuration.h | 11 ++++++++--- unit_tests/engine_test_helper.cpp | 4 ++-- unit_tests/engine_test_helper.h | 3 +-- unit_tests/tests/test_issue_898.cpp | 4 +--- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index d2aed83884..e66693190c 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -319,6 +319,4 @@ void prepareOutputSignals(DECLARE_ENGINE_PARAMETER_SIGNATURE); void validateConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE); void doScheduleStopEngine(DECLARE_ENGINE_PARAMETER_SIGNATURE); -typedef void (*configuration_callback_t)(Engine*); - #endif /* H_ENGINE_H_ */ diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 100cafaeba..0b1182048d 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -1022,7 +1022,7 @@ static void setDefaultFrankensoConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) boardConfiguration->is_enabled_spi_3 = true; } -void resetConfigurationExt(Logging * logger, std::function boardCallback, engine_type_e engineType DECLARE_ENGINE_PARAMETER_SUFFIX) { +void resetConfigurationExt(Logging * logger, configuration_callback_t boardCallback, engine_type_e engineType DECLARE_ENGINE_PARAMETER_SUFFIX) { enginePins.reset(); // that's mostly important for functional tests /** * Let's apply global defaults first @@ -1032,7 +1032,7 @@ void resetConfigurationExt(Logging * logger, std::function board // set initial pin groups setDefaultBasePins(PASS_CONFIG_PARAMETER_SIGNATURE); - boardCallback(engine); + boardCallback(engineConfiguration); #if EFI_PROD_CODE // call overrided board-specific configuration setup, if needed (for custom boards only) @@ -1291,19 +1291,17 @@ void resetConfigurationExt(Logging * logger, std::function board #endif /* EFI_TUNER_STUDIO */ } -void emptyCallbackWithEngine(Engine * engine) { - +void emptyCallbackWithConfiguration(engine_configuration_s * engineConfiguration) { } void resetConfigurationExt(Logging * logger, engine_type_e engineType DECLARE_ENGINE_PARAMETER_SUFFIX) { - resetConfigurationExt(logger, &emptyCallbackWithEngine, engineType PASS_ENGINE_PARAMETER_SUFFIX); + resetConfigurationExt(logger, &emptyCallbackWithConfiguration, engineType PASS_ENGINE_PARAMETER_SUFFIX); } void validateConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) { if (engineConfiguration->adcVcc > 5.0f || engineConfiguration->adcVcc < 1.0f) { engineConfiguration->adcVcc = 3.0f; } - } void applyNonPersistentConfiguration(Logging * logger DECLARE_ENGINE_PARAMETER_SUFFIX) { diff --git a/firmware/controllers/algo/engine_configuration.h b/firmware/controllers/algo/engine_configuration.h index 52a7bc08f8..099be87d5d 100644 --- a/firmware/controllers/algo/engine_configuration.h +++ b/firmware/controllers/algo/engine_configuration.h @@ -13,7 +13,6 @@ #include "crc.h" #include "engine_configuration_generated_structures.h" #include "globalaccess.h" -#include #ifndef DEFAULT_ENGINE_TYPE #define DEFAULT_ENGINE_TYPE DEFAULT_FRANKENSO @@ -81,8 +80,14 @@ void copyTargetAfrTable(fuel_table_t const source, afr_table_t destination); void copyFuelTable(fuel_table_t const source, fuel_table_t destination); void copyTimingTable(ignition_table_t const source, ignition_table_t destination); -void resetConfigurationExt(Logging * logger, std::function, engine_type_e engineType DECLARE_ENGINE_PARAMETER_SUFFIX); +void emptyCallbackWithConfiguration(engine_configuration_s * engine); + +typedef void (*configuration_callback_t)(engine_configuration_s*); + +#ifdef __cplusplus +// because of 'Logging' class parameter these functions are visible only to C++ code but C code +void resetConfigurationExt(Logging * logger, configuration_callback_t boardCallback, engine_type_e engineType DECLARE_ENGINE_PARAMETER_SUFFIX); void resetConfigurationExt(Logging * logger, engine_type_e engineType DECLARE_ENGINE_PARAMETER_SUFFIX); -void emptyCallbackWithEngine(Engine * engine); +#endif /* __cplusplus */ #endif /* ENGINE_CONFIGURATION_H_ */ diff --git a/unit_tests/engine_test_helper.cpp b/unit_tests/engine_test_helper.cpp index 694bbcf2a0..9fe83f1290 100644 --- a/unit_tests/engine_test_helper.cpp +++ b/unit_tests/engine_test_helper.cpp @@ -29,7 +29,7 @@ EngineTestHelperBase::EngineTestHelperBase() { timeNowUs = 0; } -EngineTestHelper::EngineTestHelper(engine_type_e engineType, std::function boardCallback) { +EngineTestHelper::EngineTestHelper(engine_type_e engineType, configuration_callback_t boardCallback) { unitTestWarningCodeState.clear(); testMafValue = 0; @@ -79,7 +79,7 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType, std::function class EngineTestHelperBase { @@ -28,7 +27,7 @@ public: class EngineTestHelper : public EngineTestHelperBase { public: EngineTestHelper(engine_type_e engineType); - EngineTestHelper(engine_type_e engineType, std::function); + EngineTestHelper(engine_type_e engineType, configuration_callback_t boardCallback); void applyTriggerShape(); void setTriggerType(trigger_type_e trigger DECLARE_ENGINE_PARAMETER_SUFFIX); void fireRise(int delayMs); diff --git a/unit_tests/tests/test_issue_898.cpp b/unit_tests/tests/test_issue_898.cpp index 13ad70ad0c..299bb9dc32 100644 --- a/unit_tests/tests/test_issue_898.cpp +++ b/unit_tests/tests/test_issue_898.cpp @@ -7,9 +7,7 @@ #include "engine_test_helper.h" -static void boardConfigurationForIssue898(Engine * engine) { - engine_configuration_s *engineConfiguration = engine->engineConfigurationPtr; - +static void boardConfigurationForIssue898(engine_configuration_s *engineConfiguration) { setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR); engineConfiguration->trigger.type = TT_TOOTHED_WHEEL_60_2; engineConfiguration->useOnlyRisingEdgeForTrigger = true;