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

57 lines
1.4 KiB
C
Raw Normal View History

2014-08-29 07:52:33 -07:00
/*
* @file trigger_central.h
*
* @date Feb 23, 2014
* @author Andrey Belomutskiy, (c) 2012-2014
*/
#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
#include "ec2.h"
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-24 18:03:34 -08:00
void handleShaftSignal(trigger_event_e signal, Engine *engine, engine_configuration_s *engineConfiguration);
2014-08-29 07:52:33 -07:00
int getHwEventCounter(int index);
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
uint64_t getCrankEventCounter(void);
uint64_t getStartOfRevolutionIndex(void);
void hwHandleShaftSignal(trigger_event_e signal);
float getTriggerDutyCycle(int index);
2014-09-08 15:02:52 -07:00
void initTriggerCentral(Engine *engine);
2014-08-29 07:52:33 -07:00
void printAllCallbacksHistogram(void);
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
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);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* TRIGGER_CENTRAL_H_ */