GCC Code Coverage Report


Directory: ./
File: firmware/controllers/engine_cycle/high_pressure_fuel_pump.h
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 100.0% 4 0 4
Functions: 100.0% 1 0 1
Branches: -% 0 0 0
Decisions: -% 0 - 0

Line Branch Decision Exec Source
1 /*
2 * @file high_pressure_fuel_pump.h
3 * @brief High Pressure Fuel Pump controller for GDI applications
4 *
5 * @date Nov 6, 2021
6 * @author Scott Smith, (c) 2021
7 */
8
9 /*
10 * This file is part of rusEfi - see http://rusefi.com
11 *
12 * rusEfi is free software; you can redistribute it and/or modify it under the terms of
13 * the GNU General Public License as published by the Free Software Foundation; either
14 * version 3 of the License, or (at your option) any later version.
15 *
16 * rusEfi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
17 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along with this program.
21 * If not, see <http://www.gnu.org/licenses/>.
22 */
23
24 #pragma once
25 #include "high_pressure_fuel_pump_generated.h"
26
27 class HpfpLobe {
28 public:
29 uint8_t m_lobe_index = 0; ///< 0-based index of the last lobe returned
30
31 angle_t findNextLobe(); ///< Calculate the angle (after crank TDC) for the top of the next lobe
32 };
33
34 bool isGdiEngine();
35
36 class HpfpController;
37
38 class HpfpQuantity {
39 public:
40 /**
41 * Calculate where the pump should become active, in degrees before pump lobe TDC
42 */
43 angle_t pumpAngleFuel(float rpm, HpfpController *model);
44
45 /**
46 * Calculate the percent of the pump stroke needed to replace the fuel injected. Also
47 * includes pump compensation calculations.
48 *
49 * This is used by internal tests and shouldn't be called directly. Instead use
50 * pumpAngleFuel.
51 *
52 * Return value is nominally 0-100, but may be outside that range (including negative) if
53 * model parameters are not accurate.
54 */
55 float calcFuelPercent(float rpm);
56
57 /**
58 * Calculates the PI controller contribution as a percent. This amount should be added to
59 * calcFuelPercent() above.
60 *
61 * This is used by internal tests and shouldn't be called directly. Instead use
62 * pumpAngleFuel.
63 *
64 * Return value is nominally 0-100, but may be outside that range (including negative) if
65 * model parameters are not accurate. The sum of this and calc_fuel_percent will be 0-100.
66 */
67 float calcPI(float rpm, float calc_fuel_percent, HpfpController *model);
68
69 };
70
71 class HpfpController : public EngineModule, public high_pressure_fuel_pump_s {
72 public:
73 // Mockable<> interface
74 using interface_t = HpfpController;
75
76 /**
77 * Reset internal state due to a stopped engine.
78 */
79 1118 void resetQuantity() {
80 1118 hpfp_i_control_percent = 0;
81 1118 m_pressureTarget_kPa = 0;
82 1118 }
83
84 void onFastCallback() final;
85 angle_t m_deadangle = 0; ///< Computed solenoid deadtime in degrees
86
87 #if !EFI_UNIT_TEST
88 private:
89 #endif // EFI_UNIT_TEST
90 AngleBasedEvent m_event;
91
92 HpfpQuantity m_quantity;
93 HpfpLobe m_lobe;
94
95 volatile bool m_running = false; ///< Whether events are being scheduled or not
96
97 void scheduleNextCycle();
98
99 static void pinTurnOn(HpfpController *self);
100 static void pinTurnOff(HpfpController *self);
101 };
102