2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file wave_analyzer.h
|
|
|
|
*
|
2018-04-01 20:28:04 -07:00
|
|
|
* todo: rename all this 'logic analyzer' is probably much more appropriate
|
2015-07-10 06:01:56 -07:00
|
|
|
*
|
|
|
|
* @date Jan 7, 2013
|
2017-01-03 03:05:22 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2017
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef WAVE_ANALYZER_H_
|
|
|
|
#define WAVE_ANALYZER_H_
|
|
|
|
|
2018-09-16 19:26:57 -07:00
|
|
|
#include "global.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
#if EFI_WAVE_ANALYZER || defined(__DOXYGEN__)
|
|
|
|
|
|
|
|
#include "digital_input_hw.h"
|
2015-07-15 18:01:45 -07:00
|
|
|
#include "engine_sniffer.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
#define WA_CHANNEL_1 "input1"
|
|
|
|
#define WA_CHANNEL_2 "input2"
|
|
|
|
#define WA_CHANNEL_3 "input3"
|
|
|
|
#define WA_CHANNEL_4 "input4"
|
|
|
|
|
|
|
|
class WaveReader {
|
|
|
|
public:
|
|
|
|
WaveReader();
|
|
|
|
void onFallEvent();
|
|
|
|
|
|
|
|
digital_input_s *hw;
|
|
|
|
const char *name;
|
2017-01-12 06:02:19 -08:00
|
|
|
volatile int fallEventCounter;
|
|
|
|
volatile int riseEventCounter;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
int currentRevolutionCounter;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Total ON time during last engine cycle
|
|
|
|
*/
|
|
|
|
efitimeus_t prevTotalOnTimeUs;
|
|
|
|
|
|
|
|
efitimeus_t totalOnTimeAccumulatorUs;
|
|
|
|
|
|
|
|
volatile efitimeus_t lastActivityTimeUs; // timestamp in microseconds ticks
|
|
|
|
/**
|
|
|
|
* time of signal fall event, in microseconds
|
|
|
|
*/
|
|
|
|
volatile efitimeus_t periodEventTimeUs;
|
|
|
|
volatile efitimeus_t widthEventTimeUs; // time of signal rise in microseconds
|
|
|
|
|
|
|
|
volatile efitimeus_t signalPeriodUs; // period between two signal rises in microseconds
|
|
|
|
|
|
|
|
/**
|
|
|
|
* offset from engine cycle start in microseconds
|
|
|
|
*/
|
|
|
|
volatile efitimeus_t waveOffsetUs;
|
|
|
|
volatile efitimeus_t last_wave_low_widthUs; // time period in systimer ticks
|
|
|
|
volatile efitimeus_t last_wave_high_widthUs; // time period in systimer ticks
|
|
|
|
};
|
|
|
|
|
|
|
|
void initWaveAnalyzer(Logging *sharedLogger);
|
|
|
|
void printWave(Logging *logging);
|
2017-01-12 06:02:19 -08:00
|
|
|
void showWaveInfo(void);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* WAVE_ANALYZER_H_ */
|
|
|
|
|