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

50 lines
1.3 KiB
C
Raw Normal View History

2014-08-29 07:52:33 -07:00
/*
* @file trigger_central.h
*
* @date Feb 23, 2014
2015-01-12 15:04:10 -08:00
* @author Andrey Belomutskiy, (c) 2012-2015
2014-08-29 07:52:33 -07:00
*/
#ifndef TRIGGER_CENTRAL_H_
#define TRIGGER_CENTRAL_H_
#include "rusefi_enums.h"
#include "listener_array.h"
#include "trigger_decoder.h"
2014-11-11 12:03:07 -08:00
class Engine;
2014-11-24 18:03:34 -08:00
typedef void (*ShaftPositionListener)(trigger_event_e signal, uint32_t index DECLARE_ENGINE_PARAMETER_S);
2014-08-29 07:52:33 -07:00
#ifdef __cplusplus
2014-09-08 15:02:52 -07:00
#include "engine.h"
2014-08-29 07:52:33 -07:00
#define HW_EVENT_TYPES 6
class TriggerCentral {
public:
TriggerCentral();
2014-11-11 12:03:07 -08:00
void addEventListener(ShaftPositionListener handler, const char *name, Engine *engine);
2014-11-26 13:03:29 -08:00
void handleShaftSignal(trigger_event_e signal DECLARE_ENGINE_PARAMETER_S);
2014-08-29 07:52:33 -07:00
int getHwEventCounter(int index);
2015-02-02 05:06:40 -08:00
void resetCounters();
2014-08-29 07:52:33 -07:00
TriggerState triggerState;
2014-11-16 20:03:34 -08:00
uint64_t nowNt;
2014-08-29 07:52:33 -07:00
private:
IntListenerArray triggerListeneres;
int hwEventCounters[HW_EVENT_TYPES];
};
#endif
2014-12-14 20:03:37 -08:00
void triggerInfo(Engine *engine);
2014-08-29 07:52:33 -07:00
uint64_t getCrankEventCounter(void);
uint64_t getStartOfRevolutionIndex(void);
void hwHandleShaftSignal(trigger_event_e signal);
float getTriggerDutyCycle(int index);
2015-01-15 13:03:51 -08:00
void initTriggerCentral(Logging *sharedLogger, Engine *engine);
2014-08-29 07:52:33 -07:00
void printAllCallbacksHistogram(void);
2014-11-11 12:03:07 -08:00
void addTriggerEventListener(ShaftPositionListener handler, const char *name, Engine *engine);
2014-08-29 07:52:33 -07:00
int isSignalDecoderError(void);
#endif /* TRIGGER_CENTRAL_H_ */