15#include <rusefi/timer.h>
18#include "cyclic_buffer.h"
20#define MAP_CAM_BUFFER 64
22#ifndef RPM_LOW_THRESHOLD
24#define RPM_LOW_THRESHOLD 25
30#define HAVE_CAM_INPUT() (isBrainPinValid(engineConfiguration->camInputs[0]))
69#if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
144 constexpr float oneRevolutionLimitInSeconds = 60.0 / RPM_LOW_THRESHOLD;
148 auto maxAllowedGap = maxAverageToothTime * 10;
151 maxAllowedGap = clampF(0.1f, maxAllowedGap, oneRevolutionLimitInSeconds);
175#if EFI_SHAFT_POSITION_INPUT
184#if CAMS_PER_BANK >= 2
191#if CAMS_PER_BANK >= 2
240#define SYMMETRICAL_CRANK_SENSOR_DIVIDER (2 * 2)
241#define SYMMETRICAL_THREE_TIMES_CRANK_SENSOR_DIVIDER (3 * 2)
242#define SYMMETRICAL_SIX_TIMES_CRANK_SENSOR_DIVIDER (6 * 2)
243#define SYMMETRICAL_TWELVE_TIMES_CRANK_SENSOR_DIVIDER (12 * 2)
VvtTriggerDecoder vvtState[BANKS_COUNT][CAMS_PER_BANK]
bool engineMovedRecently() const
float getSecondsSinceTriggerEvent(efitick_t nowNt) const
InstantRpmCalculator instantRpm
PrimaryTriggerDecoder triggerState
float m_lastToothPhaseFromSyncPoint
bool engineMovedRecently(efitick_t nowNt) const
angle_t findNextTriggerToothAngle(int nextToothIndex)
angle_t getVVTPosition(uint8_t bankIndex, uint8_t camIndex)
TriggerWaveform vvtShape[CAMS_PER_BANK]
LocalVersionHolder triggerVersion
int getHwEventCounter(int index) const
int vvtEventFallCounter[CAM_INPUTS_COUNT]
bool isTriggerDecoderError()
bool isSpinningJustForWatchdog
bool isEngineSnifferEnabled
expected< float > expectedNextPhase
TriggerWaveform triggerShape
bool isToothExpectedNow(efitick_t timestamp)
angle_t vvtPosition[BANKS_COUNT][CAMS_PER_BANK]
TriggerFormDetails triggerFormDetails
void applyShapesConfiguration()
void handleShaftSignal(trigger_event_e signal, efitick_t timestamp)
float mapCamPrevCycleValue
TriggerNoiseFilter noiseFilter
bool checkIfTriggerConfigChanged()
cyclic_buffer< int > triggerErrorDetection
VvtTriggerConfiguration vvtTriggerConfiguration[CAMS_PER_BANK]
void decodeMapCam(efitick_t nowNt, float currentPhase)
int vvtEventRiseCounter[CAM_INPUTS_COUNT]
expected< float > getCurrentEnginePhase(efitick_t nowNt) const
bool isTriggerConfigChanged()
void validateCamVvtCounters()
bool directSelfStimulation
bool hwTriggerInputEnabled
bool triggerConfigChangedOnLastConfigurationChange
void prepareTriggerShape()
PrimaryTriggerConfiguration primaryTriggerConfiguration
angle_t currentVVTEventPosition[BANKS_COUNT][CAMS_PER_BANK]
uint32_t engineCycleEventCount
angle_t syncEnginePhaseAndReport(int divider, int remainder)
efitick_t accumSignalPrevPeriods[HW_EVENT_TYPES]
bool noiseFilter(efitick_t nowNt, TriggerDecoderBase *triggerState, trigger_event_e signal)
efitick_t accumSignalPeriods[HW_EVENT_TYPES]
efitick_t lastSignalTimes[HW_EVENT_TYPES]
void resetAccumSignalData()
static constexpr engine_configuration_s * engineConfiguration
Fundamental rusEFI enumerable types live here.
@ SHAFT_SECONDARY_FALLING
float triggerEventsTimeoutMs
constexpr bool isTriggerUpEvent(trigger_event_e event)
void handleVvtCamSignal(TriggerValue front, efitick_t timestamp, int index)
int getCrankDivider(operation_mode_e operationMode)
void validateTriggerInputs()
void hwHandleShaftSignal(int signalIndex, bool isRising, efitick_t timestamp)
void(* ShaftPositionListener)(trigger_event_e signal, uint32_t index, efitick_t edgeTimestamp)
void initTriggerCentral()
TriggerCentral * getTriggerCentral()
int isSignalDecoderError(void)
void onConfigurationChangeTriggerCallback()
void handleShaftSignal(int signalIndex, bool isRising, efitick_t timestamp)
void hwHandleVvtCamSignal(TriggerValue front, efitick_t timestamp, int index)