fuel pump doesn't use fsio (#3576)

* fuel pump

* s

* call correct callback

* more dead

* test adjustment

* don't overflow

* don't need separate function

* java

* give it a name

* generated

* generated

* add to generate script

* import *

* this is so cheap we don't need a flag
This commit is contained in:
Matthew Kennedy 2021-11-19 19:23:12 -08:00 committed by GitHub
parent a79b0c424c
commit e7956a53f6
24 changed files with 245 additions and 73 deletions

View File

@ -81,9 +81,6 @@
#undef EFI_USB_SERIAL
#define EFI_USB_SERIAL TRUE
#undef EFI_FUEL_PUMP
#define EFI_FUEL_PUMP TRUE
#define EFI_SDC_DEVICE SDCD2
#define ADC_CHANNEL_VREF ADC_CHANNEL_IN14

View File

@ -230,8 +230,6 @@
#define EFI_VEHICLE_SPEED TRUE
#endif
#define EFI_FUEL_PUMP TRUE
#ifndef EFI_ENGINE_EMULATOR
#define EFI_ENGINE_EMULATOR TRUE
#endif

View File

@ -246,6 +246,8 @@ static const void * getStructAddr(live_data_e structId) {
return static_cast<trigger_state_s*>(&engine->triggerCentral.triggerState);
case LDS_AC_CONTROL:
return static_cast<ac_control_s*>(&engine->acState);
case LDS_FUEL_PUMP:
return static_cast<fuel_pump_control_s*>(&engine->module<FuelPumpController>().unmock());
#if EFI_ELECTRONIC_THROTTLE_BODY
case LDS_ETB_PID:
return engine->etbControllers[0]->getPidState();

View File

@ -0,0 +1,23 @@
#include "pch.h"
#include "fuel_pump.h"
void FuelPumpController::onSlowCallback() {
auto uptime = getTimeNowSeconds();
// If the ECU just started, turn on the fuel pump to prime
isPrime = uptime >= 0 && uptime < engineConfiguration->startUpFuelPumpDuration;
// If there was a trigger event recently, turn on the pump, the engine is running!
auto timeSinceTrigger = engine->triggerCentral.getTimeSinceTriggerEvent(getTimeNowNt());
engineTurnedRecently = timeSinceTrigger < 1;
isPumpOn = isPrime || engineTurnedRecently;
enginePins.fuelPumpRelay.setValue(isPumpOn);
#if EFI_TUNER_STUDIO
tsOutputChannels.isFuelPumpOn = isPumpOn;
#endif
}

View File

@ -0,0 +1,8 @@
#pragma once
#include "engine_module.h"
#include "fuel_pump_generated.h"
struct FuelPumpController : public EngineModule, public fuel_pump_control_s {
void onSlowCallback() override;
};

View File

@ -0,0 +1,5 @@
struct_no_prefix fuel_pump_control_s
bit isPrime
bit engineTurnedRecently
bit isPumpOn
end_struct

View File

@ -0,0 +1,108 @@
// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/fuel_pump.txt Thu Nov 18 22:11:04 PST 2021
// by class com.rusefi.output.CHeaderConsumer
// begin
#pragma once
#include "rusefi_types.h"
// start of fuel_pump_control_s
struct fuel_pump_control_s {
/**
offset 0 bit 0 */
bool isPrime : 1;
/**
offset 0 bit 1 */
bool engineTurnedRecently : 1;
/**
offset 0 bit 2 */
bool isPumpOn : 1;
/**
offset 0 bit 3 */
bool unusedBit_3_3 : 1;
/**
offset 0 bit 4 */
bool unusedBit_3_4 : 1;
/**
offset 0 bit 5 */
bool unusedBit_3_5 : 1;
/**
offset 0 bit 6 */
bool unusedBit_3_6 : 1;
/**
offset 0 bit 7 */
bool unusedBit_3_7 : 1;
/**
offset 0 bit 8 */
bool unusedBit_3_8 : 1;
/**
offset 0 bit 9 */
bool unusedBit_3_9 : 1;
/**
offset 0 bit 10 */
bool unusedBit_3_10 : 1;
/**
offset 0 bit 11 */
bool unusedBit_3_11 : 1;
/**
offset 0 bit 12 */
bool unusedBit_3_12 : 1;
/**
offset 0 bit 13 */
bool unusedBit_3_13 : 1;
/**
offset 0 bit 14 */
bool unusedBit_3_14 : 1;
/**
offset 0 bit 15 */
bool unusedBit_3_15 : 1;
/**
offset 0 bit 16 */
bool unusedBit_3_16 : 1;
/**
offset 0 bit 17 */
bool unusedBit_3_17 : 1;
/**
offset 0 bit 18 */
bool unusedBit_3_18 : 1;
/**
offset 0 bit 19 */
bool unusedBit_3_19 : 1;
/**
offset 0 bit 20 */
bool unusedBit_3_20 : 1;
/**
offset 0 bit 21 */
bool unusedBit_3_21 : 1;
/**
offset 0 bit 22 */
bool unusedBit_3_22 : 1;
/**
offset 0 bit 23 */
bool unusedBit_3_23 : 1;
/**
offset 0 bit 24 */
bool unusedBit_3_24 : 1;
/**
offset 0 bit 25 */
bool unusedBit_3_25 : 1;
/**
offset 0 bit 26 */
bool unusedBit_3_26 : 1;
/**
offset 0 bit 27 */
bool unusedBit_3_27 : 1;
/**
offset 0 bit 28 */
bool unusedBit_3_28 : 1;
/**
offset 0 bit 29 */
bool unusedBit_3_29 : 1;
/**
offset 0 bit 30 */
bool unusedBit_3_30 : 1;
/**
offset 0 bit 31 */
bool unusedBit_3_31 : 1;
/** total size 4*/
};
// end
// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/fuel_pump.txt Thu Nov 18 22:11:04 PST 2021

View File

@ -27,6 +27,7 @@
#include "injector_model.h"
#include "launch_control.h"
#include "trigger_scheduler.h"
#include "fuel_pump.h"
#include "type_list.h"
#ifndef EFI_UNIT_TEST
@ -112,9 +113,6 @@ public:
// used by HW CI
bool isPwmEnabled = true;
// todo: remove this once all usages are using 'm_lastEventTimer'
int triggerActivityMs = -99 * 1000;
const char *prevOutputName = nullptr;
PinRepository pinRepository;
@ -130,6 +128,7 @@ public:
IdleController,
#endif
TriggerScheduler,
FuelPumpController,
EngineModule // dummy placeholder so the previous entries can all have commas
> engineModules;

View File

@ -81,7 +81,6 @@ public:
float mockRpm = 0;
float mockCrankingRpm = 0;
float mockTimeSinceBoot = 0;
float mockTimeSinceTrigger = 0;
int mockAcToggle = 0;
#endif

View File

@ -19,6 +19,7 @@ LDS_IDLE_PID,
//LDS_CJ125_PID,
LDS_TRIGGER_STATE,
LDS_AC_CONTROL,
LDS_FUEL_PUMP,
LDS_IDLE,
LDS_TPS_ACCEL
} live_data_e;

View File

@ -17,6 +17,7 @@ CONTROLLERS_SRC_CPP = \
$(CONTROLLERS_DIR)/actuators/boost_control.cpp \
$(CONTROLLERS_DIR)/actuators/dc_motors.cpp \
$(CONTROLLERS_DIR)/actuators/fan_control.cpp \
$(CONTROLLERS_DIR)/actuators/fuel_pump.cpp \
$(CONTROLLERS_DIR)/actuators/idle_thread_io.cpp \
$(CONTROLLERS_DIR)/actuators/idle_hardware.cpp \
$(CONTROLLERS_DIR)/actuators/idle_thread.cpp \

View File

@ -48,12 +48,10 @@ typedef enum {
LE_METHOD_EXHAUST_VVT = 118,
LE_METHOD_IS_COOLANT_BROKEN = 119,
LE_METHOD_CRANKING_RPM = 120,
LE_METHOD_STARTUP_FUEL_PUMP_DURATION = 121,
LE_METHOD_IN_SHUTDOWN = 122,
LE_METHOD_FSIO_DIGITAL_INPUT = 123,
LE_METHOD_FSIO_SETTING = 124,
LE_METHOD_PPS = 125,
LE_METHOD_TIME_SINCE_TRIGGER_EVENT = 127,
LE_METHOD_IN_MR_BENCH = 128,
LE_METHOD_FUEL_FLOW_RATE = 131,
LE_METHOD_OIL_PRESSURE = 132,

View File

@ -62,10 +62,8 @@ static LENameOrdinalPair leFsioDigitalInput(LE_METHOD_FSIO_DIGITAL_INPUT, FSIO_M
static LENameOrdinalPair leIntakeVVT(LE_METHOD_INTAKE_VVT, "ivvt");
static LENameOrdinalPair leExhaustVVT(LE_METHOD_EXHAUST_VVT, "evvt");
static LENameOrdinalPair leCrankingRpm(LE_METHOD_CRANKING_RPM, "cranking_rpm");
static LENameOrdinalPair leStartupFuelPumpDuration(LE_METHOD_STARTUP_FUEL_PUMP_DURATION, "startup_fuel_pump_duration");
static LENameOrdinalPair leInShutdown(LE_METHOD_IN_SHUTDOWN, "in_shutdown");
static LENameOrdinalPair leInMrBench(LE_METHOD_IN_MR_BENCH, "in_mr_bench");
static LENameOrdinalPair leTimeSinceTrigger(LE_METHOD_TIME_SINCE_TRIGGER_EVENT, "time_since_trigger");
static LENameOrdinalPair leFuelRate(LE_METHOD_FUEL_FLOW_RATE, "fuel_flow");
#include "fsio_names.def"
@ -76,7 +74,6 @@ static LENameOrdinalPair leFuelRate(LE_METHOD_FUEL_FLOW_RATE, "fuel_flow");
static LEElement sysElements[SYS_ELEMENT_POOL_SIZE] CCM_OPTIONAL;
CCM_OPTIONAL LEElementPool sysPool(sysElements, SYS_ELEMENT_POOL_SIZE);
static LEElement * fuelPumpLogic;
static LEElement * starterRelayDisableLogic;
#if EFI_MAIN_RELAY_CONTROL
@ -112,8 +109,6 @@ FsioResult getEngineValue(le_action_e action) {
case LE_METHOD_EXHAUST_VVT:
return engine->triggerCentral.getVVTPosition(0, 1);
#endif
case LE_METHOD_TIME_SINCE_TRIGGER_EVENT:
return engine->triggerCentral.getTimeSinceTriggerEvent(getTimeNowNt());
case LE_METHOD_TIME_SINCE_BOOT:
#if EFI_MAIN_RELAY_CONTROL
// in main relay control mode, we return the number of seconds since the ignition is turned on
@ -122,9 +117,6 @@ FsioResult getEngineValue(le_action_e action) {
#else
return getTimeNowSeconds();
#endif /* EFI_MAIN_RELAY_CONTROL */
case LE_METHOD_STARTUP_FUEL_PUMP_DURATION:
return engineConfiguration->startUpFuelPumpDuration;
case LE_METHOD_CRANKING_RPM:
return engineConfiguration->cranking.rpm;
case LE_METHOD_IN_SHUTDOWN:
@ -166,8 +158,6 @@ static const char * action2String(le_action_e action) {
return "CLT";
case LE_METHOD_FAN:
return "fan";
case LE_METHOD_STARTUP_FUEL_PUMP_DURATION:
return leStartupFuelPumpDuration.name;
case LE_METHOD_IN_SHUTDOWN:
return leInShutdown.name;
case LE_METHOD_IN_MR_BENCH:
@ -209,12 +199,6 @@ static void setPinState(const char * msg, OutputPin *pin, LEElement *element) {
* this method should be invoked periodically to calculate FSIO and toggle corresponding FSIO outputs
*/
void runFsio() {
#if EFI_FUEL_PUMP
if (isBrainPinValid(engineConfiguration->fuelPumpPin)) {
setPinState("pump", &enginePins.fuelPumpRelay, fuelPumpLogic);
}
#endif /* EFI_FUEL_PUMP */
#if EFI_MAIN_RELAY_CONTROL
if (isBrainPinValid(engineConfiguration->mainRelayPin))
// the MAIN_RELAY_LOGIC calls engine->isInShutdownMode()
@ -254,8 +238,6 @@ static void showFsio(const char *msg, LEElement *element) {
// todo: move somewhere else
static void showFsioInfo() {
#if EFI_PROD_CODE || EFI_SIMULATOR
showFsio("fuel", fuelPumpLogic);
for (int i = 0; i < SCRIPT_SETTING_COUNT; i++) {
float v = engineConfiguration->scriptSetting[i];
if (!cisnan(v)) {
@ -333,10 +315,6 @@ void initFsioImpl() {
sysPool.reset();
#endif
#if EFI_FUEL_PUMP
fuelPumpLogic = sysPool.parseExpression(FUEL_PUMP_LOGIC);
#endif /* EFI_FUEL_PUMP */
#if EFI_MAIN_RELAY_CONTROL
if (isBrainPinValid(engineConfiguration->mainRelayPin))
mainRelayLogic = sysPool.parseExpression(MAIN_RELAY_LOGIC);
@ -373,13 +351,7 @@ void runHardcodedFsio() {
if (isBrainPinValid(engineConfiguration->starterRelayDisablePin)) {
enginePins.starterRelayDisable.setValue(engine->rpmCalculator.getRpm() < engineConfiguration->cranking.rpm);
}
// see FUEL_PUMP_LOGIC
if (isBrainPinValid(engineConfiguration->fuelPumpPin)) {
int triggerActivityOrEcuStartSecond = maxI(0, engine->triggerActivityMs / 1000);
enginePins.fuelPumpRelay.setValue((getTimeNowSeconds() < triggerActivityOrEcuStartSecond + engineConfiguration->startUpFuelPumpDuration) || (engine->rpmCalculator.getRpm() > 0));
}
enginePins.o2heater.setValue(engine->rpmCalculator.isRunning());
}

View File

@ -372,14 +372,7 @@ void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp) {
int rpm = GET_RPM();
if (rpm == 0) {
// this happens while we just start cranking
/**
* While we have start-up priming pulse, we also want to start pumping fuel again as soon as possible.
* Hopefully battery would handle both cranking and fuel pump simultaneously?
*/
enginePins.fuelPumpRelay.setValue(true); // quickly set pin right from the callback here! todo: would it work OK for smart SPI pin?!
#if EFI_PROD_CODE
engine->triggerActivityMs = currentTimeMillis();
#endif
// todo: check for 'trigger->is_synchnonized?'
// TODO: add 'pin shutdown' invocation somewhere - coils might be still open here!
return;

View File

@ -15,9 +15,6 @@
// different way to have the same result would be using "self"
// (self and (coolant > fan_off_setting)) | (coolant > fan_on_setting) | is_clt_broken
// Human-readable: ((time_since_boot >= 0) & (time_since_boot < startup_fuel_pump_duration)) | (time_since_trigger < 1)
#define FUEL_PUMP_LOGIC "time_since_boot 0 >= time_since_boot startup_fuel_pump_duration < & time_since_trigger 1 < |"
// Human-readable: coolant > 120
#define TOO_HOT_LOGIC "coolant 120 >"

View File

@ -9,8 +9,6 @@
# Andrey Belomutskiy, (c) 2012-2017
#
FUEL_PUMP_LOGIC=((time_since_boot >= 0) & (time_since_boot < startup_fuel_pump_duration)) | (time_since_trigger < 1)
TOO_HOT_LOGIC=coolant > 120
# Combined RPM, CLT and VBATT warning light

View File

@ -5,6 +5,9 @@ rm gen_live_documentation.log
bash gen_live_documentation_one_file.sh ac_control AcControl.java controllers/actuators
[ $? -eq 0 ] || { echo "ERROR generating"; exit 1; }
bash gen_live_documentation_one_file.sh fuel_pump FuelPump.java controllers/actuators
[ $? -eq 0 ] || { echo "ERROR generating"; exit 1; }
bash gen_live_documentation_one_file.sh pid_state PidState.java util/math
[ $? -eq 0 ] || { echo "ERROR generating"; exit 1; }

View File

@ -13,6 +13,7 @@ public enum live_data_e {
LDS_IDLE_PID,
LDS_TRIGGER_STATE,
LDS_AC_CONTROL,
LDS_FUEL_PUMP,
LDS_IDLE,
LDS_TPS_ACCEL,
}

View File

@ -25,6 +25,7 @@ public enum StateDictionary {
register(live_data_e.LDS_IDLE, IdleState.VALUES);
register(live_data_e.LDS_TRIGGER_STATE, TriggerState.VALUES); // 11
register(live_data_e.LDS_AC_CONTROL, AcControl.VALUES); // 12
register(live_data_e.LDS_FUEL_PUMP, FuelPump.VALUES);
register(live_data_e.LDS_TPS_ACCEL, TpsAccelState.VALUES);
if (map.size() != live_data_e.values().length) {
Set<live_data_e> missing = new HashSet<live_data_e>(Arrays.asList(live_data_e.values()));

View File

@ -0,0 +1,75 @@
package com.rusefi.config.generated;
// this file was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/fuel_pump.txt Thu Nov 18 22:11:04 PST 2021
// by class com.rusefi.output.FileJavaFieldsConsumer
import com.rusefi.config.*;
public class FuelPump {
public static final Field ISPRIME = Field.create("ISPRIME", 0, FieldType.BIT, 0);
public static final Field ENGINETURNEDRECENTLY = Field.create("ENGINETURNEDRECENTLY", 0, FieldType.BIT, 1);
public static final Field ISPUMPON = Field.create("ISPUMPON", 0, FieldType.BIT, 2);
public static final Field UNUSEDBIT_3_3 = Field.create("UNUSEDBIT_3_3", 0, FieldType.BIT, 3);
public static final Field UNUSEDBIT_3_4 = Field.create("UNUSEDBIT_3_4", 0, FieldType.BIT, 4);
public static final Field UNUSEDBIT_3_5 = Field.create("UNUSEDBIT_3_5", 0, FieldType.BIT, 5);
public static final Field UNUSEDBIT_3_6 = Field.create("UNUSEDBIT_3_6", 0, FieldType.BIT, 6);
public static final Field UNUSEDBIT_3_7 = Field.create("UNUSEDBIT_3_7", 0, FieldType.BIT, 7);
public static final Field UNUSEDBIT_3_8 = Field.create("UNUSEDBIT_3_8", 0, FieldType.BIT, 8);
public static final Field UNUSEDBIT_3_9 = Field.create("UNUSEDBIT_3_9", 0, FieldType.BIT, 9);
public static final Field UNUSEDBIT_3_10 = Field.create("UNUSEDBIT_3_10", 0, FieldType.BIT, 10);
public static final Field UNUSEDBIT_3_11 = Field.create("UNUSEDBIT_3_11", 0, FieldType.BIT, 11);
public static final Field UNUSEDBIT_3_12 = Field.create("UNUSEDBIT_3_12", 0, FieldType.BIT, 12);
public static final Field UNUSEDBIT_3_13 = Field.create("UNUSEDBIT_3_13", 0, FieldType.BIT, 13);
public static final Field UNUSEDBIT_3_14 = Field.create("UNUSEDBIT_3_14", 0, FieldType.BIT, 14);
public static final Field UNUSEDBIT_3_15 = Field.create("UNUSEDBIT_3_15", 0, FieldType.BIT, 15);
public static final Field UNUSEDBIT_3_16 = Field.create("UNUSEDBIT_3_16", 0, FieldType.BIT, 16);
public static final Field UNUSEDBIT_3_17 = Field.create("UNUSEDBIT_3_17", 0, FieldType.BIT, 17);
public static final Field UNUSEDBIT_3_18 = Field.create("UNUSEDBIT_3_18", 0, FieldType.BIT, 18);
public static final Field UNUSEDBIT_3_19 = Field.create("UNUSEDBIT_3_19", 0, FieldType.BIT, 19);
public static final Field UNUSEDBIT_3_20 = Field.create("UNUSEDBIT_3_20", 0, FieldType.BIT, 20);
public static final Field UNUSEDBIT_3_21 = Field.create("UNUSEDBIT_3_21", 0, FieldType.BIT, 21);
public static final Field UNUSEDBIT_3_22 = Field.create("UNUSEDBIT_3_22", 0, FieldType.BIT, 22);
public static final Field UNUSEDBIT_3_23 = Field.create("UNUSEDBIT_3_23", 0, FieldType.BIT, 23);
public static final Field UNUSEDBIT_3_24 = Field.create("UNUSEDBIT_3_24", 0, FieldType.BIT, 24);
public static final Field UNUSEDBIT_3_25 = Field.create("UNUSEDBIT_3_25", 0, FieldType.BIT, 25);
public static final Field UNUSEDBIT_3_26 = Field.create("UNUSEDBIT_3_26", 0, FieldType.BIT, 26);
public static final Field UNUSEDBIT_3_27 = Field.create("UNUSEDBIT_3_27", 0, FieldType.BIT, 27);
public static final Field UNUSEDBIT_3_28 = Field.create("UNUSEDBIT_3_28", 0, FieldType.BIT, 28);
public static final Field UNUSEDBIT_3_29 = Field.create("UNUSEDBIT_3_29", 0, FieldType.BIT, 29);
public static final Field UNUSEDBIT_3_30 = Field.create("UNUSEDBIT_3_30", 0, FieldType.BIT, 30);
public static final Field UNUSEDBIT_3_31 = Field.create("UNUSEDBIT_3_31", 0, FieldType.BIT, 31);
public static final Field[] VALUES = {
ISPRIME,
ENGINETURNEDRECENTLY,
ISPUMPON,
UNUSEDBIT_3_3,
UNUSEDBIT_3_4,
UNUSEDBIT_3_5,
UNUSEDBIT_3_6,
UNUSEDBIT_3_7,
UNUSEDBIT_3_8,
UNUSEDBIT_3_9,
UNUSEDBIT_3_10,
UNUSEDBIT_3_11,
UNUSEDBIT_3_12,
UNUSEDBIT_3_13,
UNUSEDBIT_3_14,
UNUSEDBIT_3_15,
UNUSEDBIT_3_16,
UNUSEDBIT_3_17,
UNUSEDBIT_3_18,
UNUSEDBIT_3_19,
UNUSEDBIT_3_20,
UNUSEDBIT_3_21,
UNUSEDBIT_3_22,
UNUSEDBIT_3_23,
UNUSEDBIT_3_24,
UNUSEDBIT_3_25,
UNUSEDBIT_3_26,
UNUSEDBIT_3_27,
UNUSEDBIT_3_28,
UNUSEDBIT_3_29,
UNUSEDBIT_3_30,
UNUSEDBIT_3_31,
};
}

View File

@ -1,12 +1,12 @@
package com.rusefi.livedata;
import com.rusefi.config.Field;
import com.rusefi.config.generated.AcControl;
import com.rusefi.config.generated.TpsAccelState;
import com.rusefi.config.generated.*;
import com.rusefi.enums.live_data_e;
public enum LiveDataView {
AC_CONTROL(live_data_e.LDS_AC_CONTROL, AcControl.VALUES, "ac_control.cpp"),
FUEL_PUMP(live_data_e.LDS_FUEL_PUMP, FuelPump.VALUES, "fuel_pump.cpp"),
TPS_ACCEL(live_data_e.LDS_TPS_ACCEL, TpsAccelState.VALUES, "accel_enrichment.cpp"),
;

View File

@ -117,7 +117,6 @@
#define EFI_HAS_RESET FALSE
#define EXTREME_TERM_LOGGING FALSE
#define DEBUG_FUEL FALSE
#define EFI_FUEL_PUMP FALSE
#define DEBUG_WAVE FALSE
#define EFI_DEFAILED_LOGGING FALSE

View File

@ -73,6 +73,4 @@
#define EFI_MAP_AVERAGING TRUE
#define EFI_FUEL_PUMP TRUE
#define EFI_LUA TRUE

View File

@ -26,10 +26,6 @@ FsioResult getEngineValue(le_action_e action) {
return engine->fsioState.mockCrankingRpm;
case LE_METHOD_TIME_SINCE_BOOT:
return engine->fsioState.mockTimeSinceBoot;
case LE_METHOD_STARTUP_FUEL_PUMP_DURATION:
return 2.0f;
case LE_METHOD_TIME_SINCE_TRIGGER_EVENT:
return engine->fsioState.mockTimeSinceTrigger;
case LE_METHOD_VBATT:
return 12;
case LE_METHOD_AC_TOGGLE:
@ -258,6 +254,8 @@ TEST(fsio, testLogicExpressions) {
}
}
extern int timeNowUs;
TEST(fsio, fuelPump) {
// this will init fuel pump fsio logic
EngineTestHelper eth(TEST_ENGINE);
@ -268,30 +266,28 @@ TEST(fsio, fuelPump) {
enginePins.fuelPumpRelay.init();
// ECU just started, haven't seen trigger yet
engine->fsioState.mockTimeSinceBoot = 0.5f;
engine->fsioState.mockTimeSinceTrigger = 100;
runFsio();
timeNowUs = 0.5e6;
engine->module<FuelPumpController>().unmock().onSlowCallback();
// Pump should be on!
EXPECT_TRUE(efiReadPin(GPIOA_0));
// Long time since ecu start, haven't seen trigger yet
engine->fsioState.mockTimeSinceBoot = 60;
engine->fsioState.mockTimeSinceTrigger = 100;
runFsio();
timeNowUs = 60e6;
engine->module<FuelPumpController>().unmock().onSlowCallback();
// Pump should be off!
EXPECT_FALSE(efiReadPin(GPIOA_0));
// Long time since ecu start, just saw a trigger!
engine->fsioState.mockTimeSinceBoot = 60;
engine->fsioState.mockTimeSinceTrigger = 0.1f;
runFsio();
timeNowUs = 10e6;
engine->triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING, timeNowUs * US_TO_NT_MULTIPLIER);
engine->module<FuelPumpController>().unmock().onSlowCallback();
// Pump should be on!
EXPECT_TRUE(efiReadPin(GPIOA_0));
// ECU just started, and we just saw a trigger!
engine->fsioState.mockTimeSinceBoot = 0.5f;
engine->fsioState.mockTimeSinceTrigger = 0.1f;
runFsio();
timeNowUs = 10e6;
engine->triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING, timeNowUs * US_TO_NT_MULTIPLIER);
engine->module<FuelPumpController>().unmock().onSlowCallback();
// Pump should be on!
EXPECT_TRUE(efiReadPin(GPIOA_0));
}