fome-fw/firmware/controllers/trigger/trigger_central.h

76 lines
2.5 KiB
C
Raw Normal View History

2015-07-10 06:01:56 -07:00
/*
* @file trigger_central.h
*
* @date Feb 23, 2014
2017-01-03 03:05:22 -08:00
* @author Andrey Belomutskiy, (c) 2012-2017
2015-07-10 06:01:56 -07:00
*/
#ifndef TRIGGER_CENTRAL_H_
#define TRIGGER_CENTRAL_H_
#include "rusefi_enums.h"
#include "listener_array.h"
#include "trigger_decoder.h"
#include "trigger_structs.h"
2015-07-10 06:01:56 -07:00
class Engine;
2017-05-15 20:33:22 -07:00
typedef void (*ShaftPositionListener)(trigger_event_e signal, uint32_t index DECLARE_ENGINE_PARAMETER_SUFFIX);
2015-07-10 06:01:56 -07:00
#define HAVE_CAM_INPUT() engineConfiguration->camInputs[0] != GPIO_UNASSIGNED
2017-05-18 13:16:55 -07:00
/**
* Maybe merge TriggerCentral and TriggerState classes into one class?
* Probably not: we have an instance of TriggerState which is used for trigger initialization,
* also composition probably better than inheritance here
*/
class TriggerCentral : public trigger_central_s {
2015-07-10 06:01:56 -07:00
public:
TriggerCentral();
void addEventListener(ShaftPositionListener handler, const char *name, Engine *engine);
2017-05-15 20:33:22 -07:00
void handleShaftSignal(trigger_event_e signal DECLARE_ENGINE_PARAMETER_SUFFIX);
int getHwEventCounter(int index) const;
2015-07-10 06:01:56 -07:00
void resetCounters();
void resetAccumSignalData();
bool noiseFilter(efitick_t nowNt, trigger_event_e signal DECLARE_ENGINE_PARAMETER_SUFFIX);
2017-05-18 13:16:55 -07:00
TriggerStateWithRunningStatistics triggerState;
2019-01-22 16:07:36 -08:00
efitick_t nowNt = 0;
angle_t vvtPosition = 0;
2016-08-22 20:04:55 -07:00
/**
* this is similar to TriggerState#startOfCycleNt but with the crank-only sensor magic
*/
2019-01-22 16:07:36 -08:00
efitick_t timeAtVirtualZeroNt = 0;
2016-08-20 20:02:09 -07:00
2017-03-01 19:18:25 -08:00
TriggerShape triggerShape;
efitick_t previousVvtCamTime = 0;
efitick_t previousVvtCamDuration = 0;
2016-01-26 19:03:19 -08:00
volatile efitime_t previousShaftEventTimeNt;
2015-07-10 06:01:56 -07:00
private:
2016-07-05 17:02:56 -07:00
IntListenerArray<15> triggerListeneres;
// Used by 'useNoiselessTriggerDecoder', see handleShaftSignal()
efitick_t lastSignalTimes[HW_EVENT_TYPES];
efitick_t accumSignalPeriods[HW_EVENT_TYPES];
efitick_t accumSignalPrevPeriods[HW_EVENT_TYPES];
2015-07-10 06:01:56 -07:00
};
void triggerInfo(void);
2017-05-15 20:33:22 -07:00
efitime_t getCrankEventCounter(DECLARE_ENGINE_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
void hwHandleShaftSignal(trigger_event_e signal);
void hwHandleVvtCamSignal(trigger_value_e front DECLARE_ENGINE_PARAMETER_SUFFIX);
2017-12-12 14:36:49 -08:00
2017-05-15 17:31:16 -07:00
void initTriggerCentral(Logging *sharedLogger);
2015-07-10 06:01:56 -07:00
void printAllCallbacksHistogram(void);
void printAllTriggers();
void addTriggerEventListener(ShaftPositionListener handler, const char *name, Engine *engine);
int isSignalDecoderError(void);
2017-05-19 18:52:10 -07:00
void resetMaxValues();
2015-07-10 06:01:56 -07:00
void onConfigurationChangeTriggerCallback(engine_configuration_s *previousConfiguration DECLARE_ENGINE_PARAMETER_SUFFIX);
bool checkIfTriggerConfigChanged(DECLARE_ENGINE_PARAMETER_SIGNATURE);
2019-05-10 18:29:17 -07:00
bool isTriggerConfigChanged(DECLARE_ENGINE_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
#endif /* TRIGGER_CENTRAL_H_ */