rusefi-1/firmware/controllers/engine_cycle/high_pressure_fuel_pump.cpp

86 lines
1.8 KiB
C++
Raw Normal View History

2020-11-05 13:34:25 -08:00
/*
* @file high_pressure_fuel_pump.cpp
*
*
* todo: there is some similarity with aux_valves.cpp and even map_averaging.cpp maybe reduce code duplication?
*
* @date Nov 5, 2020
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#include "pin_repository.h"
2020-11-05 13:34:25 -08:00
#include "high_pressure_fuel_pump.h"
2020-11-09 19:21:38 -08:00
#include "spark_logic.h"
2020-11-22 22:10:12 -08:00
#include "map.h"
2020-11-09 19:21:38 -08:00
2020-11-09 19:53:23 -08:00
#if EFI_HPFP
2020-11-09 19:21:38 -08:00
EXTERN_ENGINE
;
#define LOBE_COUNT 3
class HpfpActor {
public:
angle_t extra;
int phaseIndex;
AngleBasedEvent open;
AngleBasedEvent close;
DECLARE_ENGINE_PTR;
};
static HpfpActor actors[LOBE_COUNT];
static void plainPinTurnOff(RegisteredNamedOutputPin *output) {
output->setLow();
}
void hpfpPlainPinTurnOn(HpfpActor *current);
2020-12-08 18:33:59 -08:00
static void scheduleNextCycle(HpfpActor *actor) {
2020-11-09 19:33:48 -08:00
#if EFI_UNIT_TEST
Engine *engine = actor->engine;
EXPAND_Engine;
#endif /* EFI_UNIT_TEST */
2020-11-09 19:21:38 -08:00
scheduleOrQueue(&actor->open,
TRIGGER_EVENT_UNDEFINED, getTimeNowNt(), actor->extra + CONFIG(tempHpfpStart),
{hpfpPlainPinTurnOn, actor }
PASS_ENGINE_PARAMETER_SUFFIX
);
scheduleOrQueue(&actor->close,
TRIGGER_EVENT_UNDEFINED, getTimeNowNt(),
actor->extra + CONFIG(tempHpfpStart) + CONFIG(tempHpfpDuration),
{ plainPinTurnOff, &enginePins.hpfpValve }
PASS_ENGINE_PARAMETER_SUFFIX
);
}
void hpfpPlainPinTurnOn(HpfpActor *current) {
RegisteredNamedOutputPin *output = &enginePins.hpfpValve;
2020-11-22 22:10:12 -08:00
int highPressureKpa = Sensor::get(SensorType::FuelPressureHigh).Value;
// very basic control strategy
if (highPressureKpa < BAR2KPA(50)) {
output->setHigh();
}
2020-12-08 18:33:59 -08:00
scheduleNextCycle(current);
2020-11-09 19:21:38 -08:00
}
2020-11-05 13:34:25 -08:00
2020-11-05 13:42:56 -08:00
void initHPFP(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (!isBrainPinValid(engineConfiguration->hpfpValvePin)) {
2020-11-09 19:21:38 -08:00
return;
}
for (int i = 0; i < LOBE_COUNT; i++) {
HpfpActor *actor = &actors[i];
INJECT_ENGINE_REFERENCE(actor);
2020-11-05 13:42:56 -08:00
2020-11-09 19:21:38 -08:00
actor->extra = 720 / LOBE_COUNT * i;
2020-12-08 18:33:59 -08:00
scheduleNextCycle(actor);
2020-11-09 19:21:38 -08:00
}
2020-11-05 13:42:56 -08:00
}
2020-11-09 19:53:23 -08:00
#endif // EFI_HPFP