rusefi-1/firmware/controllers/trigger/trigger_central.h

60 lines
1.7 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"
class Engine;
typedef void (*ShaftPositionListener)(trigger_event_e signal, uint32_t index DECLARE_ENGINE_PARAMETER_S);
#ifdef __cplusplus
2015-09-13 14:02:44 -07:00
class Engine;
2015-07-10 06:01:56 -07:00
#define HW_EVENT_TYPES 6
2015-07-15 17:01:33 -07:00
// todo: maybe merge TriggerCentral and TriggerState classes into one class?
2015-07-10 06:01:56 -07:00
class TriggerCentral {
public:
TriggerCentral();
void addEventListener(ShaftPositionListener handler, const char *name, Engine *engine);
void handleShaftSignal(trigger_event_e signal DECLARE_ENGINE_PARAMETER_S);
int getHwEventCounter(int index);
void resetCounters();
TriggerState triggerState;
efitick_t nowNt;
2016-08-20 20:02:09 -07:00
angle_t vvtPosition;
2016-08-22 20:04:55 -07:00
/**
* this is similar to TriggerState#startOfCycleNt but with the crank-only sensor magic
*/
efitick_t timeAtVirtualZeroNt;
2016-08-20 20:02:09 -07:00
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;
2015-07-10 06:01:56 -07:00
int hwEventCounters[HW_EVENT_TYPES];
};
#endif
void triggerInfo(void);
2015-09-13 14:02:44 -07:00
efitime_t getCrankEventCounter(DECLARE_ENGINE_PARAMETER_F);
efitime_t getStartOfRevolutionIndex(DECLARE_ENGINE_PARAMETER_F);
2015-07-10 06:01:56 -07:00
void hwHandleShaftSignal(trigger_event_e signal);
2016-08-20 19:02:12 -07:00
void hwHandleVvtCamSignal(trigger_value_e front);
2015-07-10 06:01:56 -07:00
float getTriggerDutyCycle(int index);
void initTriggerCentral(Logging *sharedLogger, Engine *engine);
void printAllCallbacksHistogram(void);
void printAllTriggers();
void addTriggerEventListener(ShaftPositionListener handler, const char *name, Engine *engine);
int isSignalDecoderError(void);
#endif /* TRIGGER_CENTRAL_H_ */