2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file engine.h
|
|
|
|
*
|
|
|
|
* @date May 21, 2014
|
2020-01-07 21:02:40 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
2019-09-19 21:17:00 -07:00
|
|
|
|
|
|
|
#pragma once
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2022-09-01 08:47:56 -07:00
|
|
|
#include "global_shared.h"
|
2021-11-19 20:06:51 -08:00
|
|
|
#include "engine_module.h"
|
2019-05-27 16:05:59 -07:00
|
|
|
#include "engine_state.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
#include "rpm_calculator.h"
|
|
|
|
#include "event_registry.h"
|
|
|
|
#include "table_helper.h"
|
|
|
|
#include "listener_array.h"
|
|
|
|
#include "accel_enrichment.h"
|
2015-09-13 14:02:44 -07:00
|
|
|
#include "trigger_central.h"
|
2019-04-15 18:02:42 -07:00
|
|
|
#include "local_version_holder.h"
|
2020-09-02 17:17:58 -07:00
|
|
|
#include "buttonshift.h"
|
2020-10-09 20:34:45 -07:00
|
|
|
#include "gear_controller.h"
|
2021-11-19 20:06:51 -08:00
|
|
|
#include "high_pressure_fuel_pump.h"
|
2020-12-26 14:30:46 -08:00
|
|
|
#include "limp_manager.h"
|
2021-07-14 22:56:04 -07:00
|
|
|
#include "pin_repository.h"
|
2021-10-13 21:47:26 -07:00
|
|
|
#include "ac_control.h"
|
2021-11-01 20:33:59 -07:00
|
|
|
#include "knock_logic.h"
|
2021-10-16 20:55:29 -07:00
|
|
|
#include "idle_state_generated.h"
|
2023-02-14 17:39:25 -08:00
|
|
|
#include "sent_state_generated.h"
|
2023-02-13 14:59:45 -08:00
|
|
|
#include "dc_motors_generated.h"
|
2021-11-17 09:13:19 -08:00
|
|
|
#include "idle_thread.h"
|
|
|
|
#include "injector_model.h"
|
2021-11-15 15:57:12 -08:00
|
|
|
#include "launch_control.h"
|
2024-09-27 10:16:13 -07:00
|
|
|
#include "shift_torque_reduction_controller.h"
|
2022-12-16 20:31:51 -08:00
|
|
|
#include "antilag_system.h"
|
2024-05-08 19:14:54 -07:00
|
|
|
#include "start_stop.h"
|
2021-11-18 11:27:21 -08:00
|
|
|
#include "trigger_scheduler.h"
|
2021-11-19 19:23:12 -08:00
|
|
|
#include "fuel_pump.h"
|
2021-11-24 04:47:51 -08:00
|
|
|
#include "main_relay.h"
|
2021-11-25 04:59:31 -08:00
|
|
|
#include "ac_control.h"
|
2021-11-17 09:13:19 -08:00
|
|
|
#include "type_list.h"
|
2021-11-24 09:59:57 -08:00
|
|
|
#include "boost_control.h"
|
2021-12-07 18:28:04 -08:00
|
|
|
#include "ignition_controller.h"
|
2021-12-05 15:33:50 -08:00
|
|
|
#include "alternator_controller.h"
|
2023-02-25 00:13:51 -08:00
|
|
|
#include "harley_acr.h"
|
2022-01-23 16:44:41 -08:00
|
|
|
#include "dfco.h"
|
2022-09-01 19:33:45 -07:00
|
|
|
#include "fuel_computer.h"
|
2022-04-06 13:15:58 -07:00
|
|
|
#include "gear_detector.h"
|
2022-04-13 13:39:59 -07:00
|
|
|
#include "advance_map.h"
|
2022-04-13 14:55:31 -07:00
|
|
|
#include "fan_control.h"
|
2022-07-30 14:08:48 -07:00
|
|
|
#include "sensor_checker.h"
|
2022-09-04 21:48:38 -07:00
|
|
|
#include "fuel_schedule.h"
|
2022-09-07 13:25:50 -07:00
|
|
|
#include "prime_injection.h"
|
2023-03-14 20:12:35 -07:00
|
|
|
#include "throttle_model.h"
|
2023-02-25 13:18:28 -08:00
|
|
|
#include "gc_generic.h"
|
2023-06-28 23:49:50 -07:00
|
|
|
#include "lambda_monitor.h"
|
2023-08-22 11:37:17 -07:00
|
|
|
#include "efi_output.h"
|
2023-07-19 22:16:29 -07:00
|
|
|
#include "vvt.h"
|
2023-09-25 13:16:17 -07:00
|
|
|
#include "trip_odometer.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2024-04-12 11:11:44 -07:00
|
|
|
#include <functional>
|
|
|
|
|
2021-11-17 10:45:10 -08:00
|
|
|
#ifndef EFI_UNIT_TEST
|
|
|
|
#error EFI_UNIT_TEST must be defined!
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef EFI_SIMULATOR
|
|
|
|
#error EFI_SIMULATOR must be defined!
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef EFI_PROD_CODE
|
|
|
|
#error EFI_PROD_CODE must be defined!
|
|
|
|
#endif
|
|
|
|
|
2021-05-14 04:17:22 -07:00
|
|
|
struct AirmassModelBase;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
#define MAF_DECODING_CACHE_SIZE 256
|
|
|
|
|
|
|
|
#define MAF_DECODING_CACHE_MULT (MAF_DECODING_CACHE_SIZE / 5.0)
|
|
|
|
|
2019-01-14 07:58:38 -08:00
|
|
|
/**
|
|
|
|
* I am not sure if this needs to be configurable.
|
|
|
|
*
|
|
|
|
* Also technically the whole feature might be implemented as cranking fuel coefficient curve by TPS.
|
|
|
|
*/
|
|
|
|
// todo: not great location for these
|
|
|
|
#define CLEANUP_MODE_TPS 90
|
|
|
|
#define STEPPER_PARKING_TPS CLEANUP_MODE_TPS
|
2019-01-05 20:48:37 -08:00
|
|
|
|
2019-12-13 10:52:34 -08:00
|
|
|
class IEtbController;
|
2022-09-01 19:33:45 -07:00
|
|
|
|
2021-11-16 13:52:11 -08:00
|
|
|
class Engine final : public TriggerStateListener {
|
2015-07-10 06:01:56 -07:00
|
|
|
public:
|
2016-12-18 07:02:38 -08:00
|
|
|
Engine();
|
2021-11-25 04:59:31 -08:00
|
|
|
|
2024-05-08 19:14:54 -07:00
|
|
|
StartStopState startStopState;
|
|
|
|
|
2024-09-11 07:32:15 -07:00
|
|
|
#if ! EFI_PROD_CODE
|
2021-11-15 17:32:25 -08:00
|
|
|
// todo: technical debt: enableOverdwellProtection #3553
|
2021-10-01 22:10:24 -07:00
|
|
|
bool enableOverdwellProtection = true;
|
2024-09-11 07:32:15 -07:00
|
|
|
#endif
|
2021-11-15 17:32:25 -08:00
|
|
|
|
2021-12-07 17:18:47 -08:00
|
|
|
TunerStudioOutputChannels outputChannels;
|
|
|
|
|
2021-12-07 07:35:52 -08:00
|
|
|
/**
|
|
|
|
* Sometimes for instance during shutdown we need to completely supress CAN TX
|
|
|
|
*/
|
|
|
|
bool allowCanTx = true;
|
|
|
|
|
2021-11-15 17:32:25 -08:00
|
|
|
// used by HW CI
|
2020-11-26 14:48:09 -08:00
|
|
|
bool isPwmEnabled = true;
|
2021-11-15 17:32:25 -08:00
|
|
|
|
2021-06-23 03:10:27 -07:00
|
|
|
const char *prevOutputName = nullptr;
|
2021-12-05 18:20:54 -08:00
|
|
|
/**
|
|
|
|
* ELM327 cannot handle both RX and TX at the same time, we have to stay quite once first ISO/TP packet was detected
|
|
|
|
* this is a pretty temporary hack only while we are trying ELM327, long term ISO/TP and rusEFI broadcast should find a way to coexists
|
|
|
|
*/
|
|
|
|
bool pauseCANdueToSerial = false;
|
2021-06-23 03:10:27 -07:00
|
|
|
|
2024-09-17 20:24:46 -07:00
|
|
|
#if EFI_ELECTRONIC_THROTTLE_BODY
|
2022-04-16 18:23:37 -07:00
|
|
|
IEtbController *etbControllers[ETB_COUNT] = {nullptr};
|
2024-09-17 20:24:46 -07:00
|
|
|
#endif // EFI_ELECTRONIC_THROTTLE_BODY
|
2022-11-26 09:25:04 -08:00
|
|
|
|
2023-05-24 08:46:07 -07:00
|
|
|
#if EFI_ENGINE_CONTROL
|
2022-11-26 09:25:04 -08:00
|
|
|
FuelComputer fuelComputer;
|
2023-05-24 08:46:07 -07:00
|
|
|
#endif // EFI_ENGINE_CONTROL
|
2021-11-17 09:13:19 -08:00
|
|
|
|
|
|
|
type_list<
|
2024-01-07 17:41:52 -08:00
|
|
|
Mockable<InjectorModelPrimary>,
|
|
|
|
Mockable<InjectorModelSecondary>,
|
2021-11-17 09:13:19 -08:00
|
|
|
#if EFI_IDLE_CONTROL
|
2022-01-20 11:08:54 -08:00
|
|
|
Mockable<IdleController>,
|
2021-11-19 20:06:51 -08:00
|
|
|
#endif // EFI_IDLE_CONTROL
|
2021-11-18 11:27:21 -08:00
|
|
|
TriggerScheduler,
|
2021-11-19 20:06:51 -08:00
|
|
|
#if EFI_HPFP && EFI_ENGINE_CONTROL
|
|
|
|
HpfpController,
|
|
|
|
#endif // EFI_HPFP && EFI_ENGINE_CONTROL
|
2023-05-24 07:31:43 -07:00
|
|
|
#if EFI_ENGINE_CONTROL
|
2023-05-11 14:37:48 -07:00
|
|
|
Mockable<ThrottleModel>,
|
2023-05-24 07:31:43 -07:00
|
|
|
#endif // EFI_ENGINE_CONTROL
|
2021-12-05 15:33:50 -08:00
|
|
|
#if EFI_ALTERNATOR_CONTROL
|
|
|
|
AlternatorController,
|
|
|
|
#endif /* EFI_ALTERNATOR_CONTROL */
|
2021-11-19 19:23:12 -08:00
|
|
|
FuelPumpController,
|
2021-11-24 04:47:51 -08:00
|
|
|
MainRelayController,
|
2024-09-17 21:26:58 -07:00
|
|
|
Mockable<IgnitionController>,
|
2023-09-26 04:12:11 -07:00
|
|
|
Mockable<AcController>,
|
|
|
|
FanControl1,
|
|
|
|
FanControl2,
|
2021-12-08 04:26:49 -08:00
|
|
|
PrimeController,
|
2022-01-23 16:44:41 -08:00
|
|
|
DfcoController,
|
2023-10-31 05:56:16 -07:00
|
|
|
#if EFI_HD_ACR
|
2023-02-25 00:13:51 -08:00
|
|
|
HarleyAcr,
|
2023-10-31 05:56:16 -07:00
|
|
|
#endif // EFI_HD_ACR
|
2022-01-27 04:45:50 -08:00
|
|
|
Mockable<WallFuelController>,
|
2022-04-06 13:15:58 -07:00
|
|
|
#if EFI_VEHICLE_SPEED
|
|
|
|
GearDetector,
|
2023-09-25 13:16:17 -07:00
|
|
|
TripOdometer,
|
2022-04-06 13:15:58 -07:00
|
|
|
#endif // EFI_VEHICLE_SPEED
|
2022-04-18 05:03:16 -07:00
|
|
|
KnockController,
|
2022-07-30 14:08:48 -07:00
|
|
|
SensorChecker,
|
2023-11-05 10:54:06 -08:00
|
|
|
#if EFI_ENGINE_CONTROL
|
2022-10-04 17:36:03 -07:00
|
|
|
LimpManager,
|
2023-11-05 10:54:06 -08:00
|
|
|
#endif // EFI_ENGINE_CONTROL
|
2023-07-19 22:16:29 -07:00
|
|
|
#if EFI_VVT_PID
|
|
|
|
VvtController1,
|
|
|
|
VvtController2,
|
|
|
|
VvtController3,
|
|
|
|
VvtController4,
|
|
|
|
#endif // EFI_VVT_PID
|
2023-09-26 10:39:43 -07:00
|
|
|
#if EFI_BOOST_CONTROL
|
|
|
|
BoostController,
|
|
|
|
#endif // EFI_BOOST_CONTROL
|
2024-08-01 21:45:54 -07:00
|
|
|
TpsAccelEnrichment,
|
2021-11-17 09:13:19 -08:00
|
|
|
EngineModule // dummy placeholder so the previous entries can all have commas
|
|
|
|
> engineModules;
|
2019-12-13 10:52:34 -08:00
|
|
|
|
2021-11-17 18:50:00 -08:00
|
|
|
/**
|
|
|
|
* Slightly shorter helper function to keep the code looking clean.
|
|
|
|
*/
|
|
|
|
template<typename get_t>
|
2023-07-01 20:41:44 -07:00
|
|
|
constexpr auto & module() {
|
2021-11-17 18:50:00 -08:00
|
|
|
return engineModules.get<get_t>();
|
|
|
|
}
|
|
|
|
|
2022-04-23 04:34:39 -07:00
|
|
|
#if EFI_TCU
|
2024-08-09 13:13:16 -07:00
|
|
|
GearControllerBase *gearController = nullptr;
|
2022-04-23 04:34:39 -07:00
|
|
|
#endif
|
2023-08-23 21:35:13 -07:00
|
|
|
|
2024-04-07 12:08:58 -07:00
|
|
|
// todo: boolean sensors should leverage sensor framework #6342
|
2023-08-23 21:35:13 -07:00
|
|
|
SwitchedState clutchUpSwitchedState;
|
|
|
|
SwitchedState brakePedalSwitchedState;
|
|
|
|
SwitchedState acButtonSwitchedState;
|
2024-01-06 14:11:25 -08:00
|
|
|
SimpleSwitchedState luaDigitalInputState[LUA_DIGITAL_INPUT_COUNT];
|
2023-08-23 21:35:13 -07:00
|
|
|
|
2021-12-16 13:19:33 -08:00
|
|
|
#if EFI_LAUNCH_CONTROL
|
2021-11-15 15:57:12 -08:00
|
|
|
LaunchControlBase launchController;
|
2024-09-27 10:16:13 -07:00
|
|
|
ShiftTorqueReductionController shiftTorqueReductionController;
|
2021-11-16 10:15:12 -08:00
|
|
|
SoftSparkLimiter softSparkLimiter;
|
2023-05-25 09:41:11 -07:00
|
|
|
// technically not directly related to EFI_LAUNCH_CONTROL since useful for TCU
|
|
|
|
SoftSparkLimiter hardSparkLimiter;
|
2022-02-06 15:46:09 -08:00
|
|
|
#endif // EFI_LAUNCH_CONTROL
|
2020-09-02 12:39:50 -07:00
|
|
|
|
2022-12-16 20:31:51 -08:00
|
|
|
#if EFI_ANTILAG_SYSTEM
|
|
|
|
AntilagSystemBase antilagController;
|
|
|
|
#endif // EFI_ANTILAG_SYSTEM
|
|
|
|
|
2022-12-21 17:12:00 -08:00
|
|
|
#if EFI_ANTILAG_SYSTEM
|
2024-04-23 18:21:29 -07:00
|
|
|
// SoftSparkLimiter ALSsoftSparkLimiter;
|
2022-12-21 17:12:00 -08:00
|
|
|
#endif /* EFI_ANTILAG_SYSTEM */
|
|
|
|
|
2023-12-12 19:05:29 -08:00
|
|
|
#if EFI_SHAFT_POSITION_INPUT
|
2023-06-28 23:49:50 -07:00
|
|
|
LambdaMonitor lambdaMonitor;
|
2023-11-05 10:54:06 -08:00
|
|
|
#endif // EFI_ENGINE_CONTROL
|
2023-06-28 23:49:50 -07:00
|
|
|
|
2022-04-13 13:39:59 -07:00
|
|
|
IgnitionState ignitionState;
|
2022-07-14 09:36:55 -07:00
|
|
|
void resetLua();
|
2022-04-13 13:39:59 -07:00
|
|
|
|
2020-02-26 15:16:35 -08:00
|
|
|
#if EFI_SHAFT_POSITION_INPUT
|
2019-12-05 22:57:11 -08:00
|
|
|
void OnTriggerStateProperState(efitick_t nowNt) override;
|
2023-09-09 16:51:09 -07:00
|
|
|
void OnTriggerSynchronization(bool wasSynchronized, bool isDecodingError) override;
|
2020-01-26 09:02:54 -08:00
|
|
|
void OnTriggerSynchronizationLost() override;
|
2020-02-26 15:16:35 -08:00
|
|
|
#endif
|
2019-12-05 22:57:11 -08:00
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void setConfig();
|
2016-12-18 07:02:38 -08:00
|
|
|
|
2024-09-04 20:40:12 -07:00
|
|
|
#if EFI_AUX_VALVES
|
2019-12-02 21:29:12 -08:00
|
|
|
AuxActor auxValves[AUX_DIGITAL_VALVE_COUNT][2];
|
2024-09-04 20:40:12 -07:00
|
|
|
#endif // EFI_AUX_VALVES
|
2019-11-23 19:55:21 -08:00
|
|
|
|
2019-12-23 18:58:06 -08:00
|
|
|
#if EFI_UNIT_TEST
|
2019-12-23 18:55:08 -08:00
|
|
|
bool needTdcCallback = true;
|
2024-04-24 05:59:41 -07:00
|
|
|
private:
|
|
|
|
int bailedOnDwellCount = 0;
|
|
|
|
public:
|
|
|
|
int getBailedOnDwellCount() const { return bailedOnDwellCount; }
|
|
|
|
void incrementBailedOnDwellCount() { bailedOnDwellCount++; }
|
2019-12-23 18:58:06 -08:00
|
|
|
#endif /* EFI_UNIT_TEST */
|
|
|
|
|
2019-01-15 18:51:09 -08:00
|
|
|
int getGlobalConfigurationVersion(void) const;
|
2021-11-15 17:22:05 -08:00
|
|
|
|
2019-01-15 18:51:09 -08:00
|
|
|
|
2019-01-08 21:53:54 -08:00
|
|
|
// a pointer with interface type would make this code nicer but would carry extra runtime
|
|
|
|
// cost to resolve pointer, we use instances as a micro optimization
|
|
|
|
#if EFI_SIGNAL_EXECUTOR_ONE_TIMER
|
2024-04-24 11:10:52 -07:00
|
|
|
// while theoretically PROD could be using EFI_SIGNAL_EXECUTOR_SLEEP, as of 2024 all PROD uses SingleTimerExecutor
|
2024-07-11 17:03:13 -07:00
|
|
|
SingleTimerExecutor scheduler;
|
2019-01-08 21:53:54 -08:00
|
|
|
#endif
|
|
|
|
#if EFI_SIGNAL_EXECUTOR_SLEEP
|
2024-04-24 11:10:52 -07:00
|
|
|
// at the moment this one is used exclusively by x86 simulator it should theoretically be possible to make it available in embedded if needed
|
2024-07-11 17:03:13 -07:00
|
|
|
SleepExecutor scheduler;
|
2019-01-08 21:53:54 -08:00
|
|
|
#endif
|
|
|
|
#if EFI_UNIT_TEST
|
2024-07-11 17:03:13 -07:00
|
|
|
TestExecutor scheduler;
|
2024-04-12 11:11:44 -07:00
|
|
|
|
|
|
|
std::function<void(IgnitionEvent*, bool)> onIgnitionEvent;
|
2024-05-05 04:46:11 -07:00
|
|
|
std::function<void(const IgnitionEvent&, efitick_t, angle_t, efitick_t)> onScheduleTurnSparkPinHighStartCharging
|
|
|
|
= [](const IgnitionEvent&, efitick_t, angle_t, efitick_t) -> void {};
|
|
|
|
std::function<void(const IgnitionEvent&, efitick_t)> onScheduleOverFireSparkAndPrepareNextSchedule
|
|
|
|
= [](const IgnitionEvent&, efitick_t) -> void {};
|
2022-06-18 11:17:36 -07:00
|
|
|
#endif // EFI_UNIT_TEST
|
2016-01-25 09:01:30 -08:00
|
|
|
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_ENGINE_CONTROL
|
2016-12-18 09:03:48 -08:00
|
|
|
FuelSchedule injectionEvents;
|
2019-10-07 23:35:21 -07:00
|
|
|
IgnitionEventList ignitionEvents;
|
2021-06-24 22:37:43 -07:00
|
|
|
scheduling_s tdcScheduler[2];
|
2016-12-18 09:03:48 -08:00
|
|
|
#endif /* EFI_ENGINE_CONTROL */
|
2016-02-06 07:01:34 -08:00
|
|
|
|
2024-09-17 20:24:46 -07:00
|
|
|
#if EFI_ELECTRONIC_THROTTLE_BODY
|
2022-08-25 16:58:10 -07:00
|
|
|
// todo: move to electronic_throttle something?
|
2019-01-19 19:31:55 -08:00
|
|
|
bool etbAutoTune = false;
|
2024-10-09 15:54:41 -07:00
|
|
|
bool etbIgnoreJamProtection = false;
|
2024-09-17 20:24:46 -07:00
|
|
|
#endif // EFI_ELECTRONIC_THROTTLE_BODY
|
2021-06-24 22:31:53 -07:00
|
|
|
|
2022-06-18 11:17:36 -07:00
|
|
|
#if EFI_UNIT_TEST
|
|
|
|
bool tdcMarkEnabled = true;
|
|
|
|
#endif // EFI_UNIT_TEST
|
2021-06-24 22:31:53 -07:00
|
|
|
|
2016-01-26 20:01:44 -08:00
|
|
|
|
2019-01-14 05:57:08 -08:00
|
|
|
bool slowCallBackWasInvoked = false;
|
2017-05-11 05:32:08 -07:00
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
RpmCalculator rpmCalculator;
|
|
|
|
|
2022-09-09 15:27:16 -07:00
|
|
|
Timer configBurnTimer;
|
|
|
|
|
2019-04-15 18:37:54 -07:00
|
|
|
/**
|
2019-05-02 14:52:48 -07:00
|
|
|
* This counter is incremented every time user adjusts ECU parameters online (either via rusEfi console or other
|
2019-04-15 18:37:54 -07:00
|
|
|
* tuning software)
|
|
|
|
*/
|
2022-08-27 19:28:29 -07:00
|
|
|
int globalConfigurationVersion = 0;
|
2019-04-15 18:37:54 -07:00
|
|
|
|
2022-04-16 14:07:57 -07:00
|
|
|
#if EFI_SHAFT_POSITION_INPUT
|
2015-09-13 14:02:44 -07:00
|
|
|
TriggerCentral triggerCentral;
|
2022-04-16 14:07:57 -07:00
|
|
|
#endif // EFI_SHAFT_POSITION_INPUT
|
2015-09-13 14:02:44 -07:00
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2023-02-28 14:36:01 -08:00
|
|
|
/**
|
|
|
|
* See FAST_CALLBACK_PERIOD_MS
|
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
void periodicFastCallback();
|
2023-02-28 14:36:01 -08:00
|
|
|
/**
|
|
|
|
* See SLOW_CALLBACK_PERIOD_MS
|
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
void periodicSlowCallback();
|
|
|
|
void updateSlowSensors();
|
|
|
|
void updateSwitchInputs();
|
2022-04-02 16:27:18 -07:00
|
|
|
void updateTriggerWaveform();
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-01-19 19:31:55 -08:00
|
|
|
bool isRunningPwmTest = false;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* are we running any kind of functional test? this affect
|
|
|
|
* some areas
|
|
|
|
*/
|
2020-08-08 08:25:17 -07:00
|
|
|
bool isFunctionalTestMode = false;
|
2019-12-21 18:11:09 -08:00
|
|
|
|
2019-12-21 17:43:11 -08:00
|
|
|
void resetEngineSnifferIfInTestMode();
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
EngineState engineState;
|
2023-01-15 05:26:08 -08:00
|
|
|
|
2023-02-13 14:59:45 -08:00
|
|
|
dc_motors_s dc_motors;
|
2023-02-14 17:39:25 -08:00
|
|
|
sent_state_s sent_state;
|
2023-02-13 14:59:45 -08:00
|
|
|
|
2021-10-16 21:27:12 -07:00
|
|
|
/**
|
|
|
|
* idle blip is a development tool: alternator PID research for instance have benefited from a repetitive change of RPM
|
|
|
|
*/
|
|
|
|
percent_t blipIdlePosition;
|
|
|
|
efitimeus_t timeToStopBlip = 0;
|
|
|
|
efitimeus_t timeToStopIdleTest = 0;
|
|
|
|
|
2017-03-06 23:24:57 -08:00
|
|
|
SensorsState sensors;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void preCalculate();
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2022-09-09 15:02:38 -07:00
|
|
|
void efiWatchdog();
|
2023-11-17 12:58:08 -08:00
|
|
|
void onEngineHasStopped();
|
2017-06-24 22:35:46 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Needed by EFI_MAIN_RELAY_CONTROL to shut down the engine correctly.
|
2020-09-07 11:41:04 -07:00
|
|
|
* This method cancels shutdown if the ignition voltage is detected.
|
2017-06-24 22:35:46 -07:00
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
void checkShutdown();
|
2020-09-07 11:41:04 -07:00
|
|
|
|
2017-06-24 22:35:46 -07:00
|
|
|
/**
|
|
|
|
* Allows to finish some long-term shutdown procedures (stepper motor parking etc.)
|
2020-09-07 11:41:04 -07:00
|
|
|
Called when the ignition switch is turned off (vBatt is too low).
|
2017-06-24 22:35:46 -07:00
|
|
|
Returns true if some operations are in progress on background.
|
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
bool isInShutdownMode() const;
|
2020-09-07 11:41:04 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The stepper does not work if the main relay is turned off (it requires +12V).
|
|
|
|
* Needed by the stepper motor code to detect if it works.
|
|
|
|
*/
|
2021-11-16 01:15:29 -08:00
|
|
|
bool isMainRelayEnabled() const;
|
2020-09-07 12:02:11 -07:00
|
|
|
|
2021-09-21 14:39:21 -07:00
|
|
|
void onSparkFireKnockSense(uint8_t cylinderIndex, efitick_t nowNt);
|
|
|
|
|
2022-08-25 19:34:16 -07:00
|
|
|
#if EFI_UNIT_TEST
|
2020-07-26 20:33:18 -07:00
|
|
|
AirmassModelBase* mockAirmassModel = nullptr;
|
2022-08-25 19:34:16 -07:00
|
|
|
#endif
|
2020-07-26 20:33:18 -07:00
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
private:
|
2019-01-19 18:10:58 -08:00
|
|
|
void reset();
|
2020-10-04 16:29:26 -07:00
|
|
|
|
|
|
|
void injectEngineReferences();
|
2015-07-10 06:01:56 -07:00
|
|
|
};
|
|
|
|
|
2021-12-31 12:47:25 -08:00
|
|
|
trigger_type_e getVvtTriggerType(vvt_mode_e vvtMode);
|
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void applyNonPersistentConfiguration();
|
|
|
|
void prepareOutputSignals();
|
2018-02-03 07:48:35 -08:00
|
|
|
|
2022-07-30 09:23:53 -07:00
|
|
|
void scheduleReboot();
|
|
|
|
bool isLockedFromUser();
|
|
|
|
void unlockEcu(int password);
|
2020-10-11 16:05:56 -07:00
|
|
|
|
2021-07-16 15:13:33 -07:00
|
|
|
// These externs aren't needed for unit tests - everything is injected instead
|
|
|
|
#if !EFI_UNIT_TEST
|
|
|
|
extern Engine ___engine;
|
2021-11-17 00:53:17 -08:00
|
|
|
static Engine * const engine = &___engine;
|
|
|
|
#else // EFI_UNIT_TEST
|
2021-11-15 21:23:14 -08:00
|
|
|
extern Engine *engine;
|
2021-11-17 00:53:17 -08:00
|
|
|
#endif // EFI_UNIT_TEST
|