diff --git a/firmware/controllers/system/efi_gpio.cpp b/firmware/controllers/system/efi_gpio.cpp index 82855c913b..b247572da0 100644 --- a/firmware/controllers/system/efi_gpio.cpp +++ b/firmware/controllers/system/efi_gpio.cpp @@ -424,6 +424,8 @@ void OutputPin::setValue(int logicValue) { #endif // ENABLE_PERF_TRACE #if EFI_UNIT_TEST + unitTestTurnedOnCounter++; + if (verboseMode) { efiPrintf("pin goes %d", logicValue); } @@ -495,6 +497,10 @@ void OutputPin::initPin(const char *msg, brain_pin_e brainPin) { } void OutputPin::initPin(const char *msg, brain_pin_e brainPin, const pin_output_mode_e *outputMode, bool forceInitWithFatalError) { +#if EFI_UNIT_TEST + unitTestTurnedOnCounter = 0; +#endif + if (!isBrainPinValid(brainPin)) { return; } diff --git a/firmware/controllers/system/efi_gpio.h b/firmware/controllers/system/efi_gpio.h index ea3775bbad..e5f448befb 100644 --- a/firmware/controllers/system/efi_gpio.h +++ b/firmware/controllers/system/efi_gpio.h @@ -65,6 +65,10 @@ public: uint8_t pin = 0; #endif /* EFI_GPIO_HARDWARE */ +#if EFI_UNIT_TEST + int unitTestTurnedOnCounter = 0; +#endif + brain_pin_e brainPin = GPIO_UNASSIGNED; #if (EFI_GPIO_HARDWARE && (BOARD_EXT_GPIOCHIPS > 0)) diff --git a/unit_tests/tests/test_hpfp_integrated.cpp b/unit_tests/tests/test_hpfp_integrated.cpp new file mode 100644 index 0000000000..e40168e350 --- /dev/null +++ b/unit_tests/tests/test_hpfp_integrated.cpp @@ -0,0 +1,40 @@ +/* + * @file test_hpfp_integrated.cpp + * + * Created on: Jan 18, 2022 + * More integrated version of HPFP test + */ + +#include "pch.h" + +TEST(HPFP, IntegratedSchedule) { + EngineTestHelper eth(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) { + engineConfiguration->hpfpValvePin = GPIOA_2; // arbitrary + }); + + engineConfiguration->specs.cylindersCount = 4; + engineConfiguration->hpfpCamLobes = 3; + engineConfiguration->hpfpPumpVolume = 0.2; // cc/lobe + + + engineConfiguration->trigger.customTotalToothCount = 16; + engineConfiguration->trigger.customSkippedToothCount = 0; + eth.setTriggerType(TT_TOOTHED_WHEEL); + engineConfiguration->ambiguousOperationMode = FOUR_STROKE_CAM_SENSOR; + engineConfiguration->isFasterEngineSpinUpEnabled = true; + + + eth.smartFireTriggerEvents2(/*count*/40, /*delay*/ 4); + ASSERT_EQ(937, GET_RPM()); + + for (int i = 0;i<100;i++) { + eth.smartFireTriggerEvents2(/*count*/1, /*delay*/ 4); + engine->periodicFastCallback(); + } + /** + * overall this is a pretty lame test but helps to know that the whole on/off/on dance does in fact happen for HPFP + */ + ASSERT_EQ(31, enginePins.hpfpValve.unitTestTurnedOnCounter); +} + + diff --git a/unit_tests/tests/tests.mk b/unit_tests/tests/tests.mk index 58f8bb49c9..11d91f8e8b 100644 --- a/unit_tests/tests/tests.mk +++ b/unit_tests/tests/tests.mk @@ -88,6 +88,7 @@ TESTS_SRC_CPP = \ tests/test_boost.cpp \ tests/test_gppwm.cpp \ tests/test_hpfp.cpp \ + tests/test_hpfp_integrated.cpp \ tests/test_fuel_math.cpp \ tests/test_binary_log.cpp \ tests/test_dynoview.cpp \