2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file test_logic_expression.cpp
|
|
|
|
*
|
|
|
|
* https://sourceforge.net/p/rusefi/tickets/102/
|
|
|
|
*
|
|
|
|
* @date Oct 3, 2014
|
2020-01-13 18:57:43 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
|
|
|
|
2021-08-03 19:05:01 -07:00
|
|
|
#include "pch.h"
|
|
|
|
|
2021-11-19 19:23:12 -08:00
|
|
|
extern int timeNowUs;
|
|
|
|
|
2022-02-02 13:36:35 -08:00
|
|
|
TEST(Actuators, FuelPump) {
|
2023-05-31 22:31:28 -07:00
|
|
|
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
2020-12-09 22:23:24 -08:00
|
|
|
|
2021-12-07 18:28:04 -08:00
|
|
|
FuelPumpController dut;
|
|
|
|
|
2020-12-09 22:23:24 -08:00
|
|
|
// Mock a fuel pump pin
|
2022-04-28 14:32:39 -07:00
|
|
|
engineConfiguration->fuelPumpPin = Gpio::A0;
|
2020-12-09 22:23:24 -08:00
|
|
|
// Re-init so it picks up the new config
|
2021-11-16 01:15:29 -08:00
|
|
|
enginePins.fuelPumpRelay.init();
|
2020-12-09 22:23:24 -08:00
|
|
|
|
|
|
|
// ECU just started, haven't seen trigger yet
|
2021-11-19 19:23:12 -08:00
|
|
|
timeNowUs = 0.5e6;
|
2021-12-07 18:28:04 -08:00
|
|
|
dut.onIgnitionStateChanged(true);
|
|
|
|
dut.onSlowCallback();
|
2020-12-09 22:23:24 -08:00
|
|
|
// Pump should be on!
|
2022-04-28 14:32:39 -07:00
|
|
|
EXPECT_TRUE(efiReadPin(Gpio::A0));
|
2020-12-09 22:23:24 -08:00
|
|
|
|
|
|
|
// Long time since ecu start, haven't seen trigger yet
|
2021-12-07 18:28:04 -08:00
|
|
|
dut.onIgnitionStateChanged(true);
|
|
|
|
timeNowUs += 10e6;
|
|
|
|
dut.onSlowCallback();
|
2020-12-09 22:23:24 -08:00
|
|
|
// Pump should be off!
|
2022-04-28 14:32:39 -07:00
|
|
|
EXPECT_FALSE(efiReadPin(Gpio::A0));
|
2020-12-09 22:23:24 -08:00
|
|
|
|
|
|
|
// Long time since ecu start, just saw a trigger!
|
2021-12-07 18:28:04 -08:00
|
|
|
dut.onIgnitionStateChanged(true);
|
|
|
|
timeNowUs += 10e6;
|
2021-11-19 19:23:12 -08:00
|
|
|
engine->triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING, timeNowUs * US_TO_NT_MULTIPLIER);
|
2021-12-07 18:28:04 -08:00
|
|
|
dut.onSlowCallback();
|
2020-12-09 22:23:24 -08:00
|
|
|
// Pump should be on!
|
2022-04-28 14:32:39 -07:00
|
|
|
EXPECT_TRUE(efiReadPin(Gpio::A0));
|
2020-12-09 22:23:24 -08:00
|
|
|
|
|
|
|
// ECU just started, and we just saw a trigger!
|
2021-12-07 18:28:04 -08:00
|
|
|
dut.onIgnitionStateChanged(true);
|
2021-11-19 19:23:12 -08:00
|
|
|
engine->triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING, timeNowUs * US_TO_NT_MULTIPLIER);
|
2021-12-07 18:28:04 -08:00
|
|
|
dut.onSlowCallback();
|
2020-12-09 22:23:24 -08:00
|
|
|
// Pump should be on!
|
2022-04-28 14:32:39 -07:00
|
|
|
EXPECT_TRUE(efiReadPin(Gpio::A0));
|
2020-12-09 22:23:24 -08:00
|
|
|
}
|