rusefi-1/firmware/development/logic_analyzer.h

64 lines
1.5 KiB
C
Raw Normal View History

2015-07-10 06:01:56 -07:00
/**
* @file logic_analyzer.h
2015-07-10 06:01:56 -07:00
*
* @date Jan 7, 2013
2020-01-07 21:02:40 -08:00
* @author Andrey Belomutskiy, (c) 2012-2020
2015-07-10 06:01:56 -07:00
*/
#pragma once
2015-07-10 06:01:56 -07:00
2018-09-16 19:26:57 -07:00
#include "global.h"
2015-07-10 06:01:56 -07:00
#if EFI_LOGIC_ANALYZER
2015-07-10 06:01:56 -07:00
#include "digital_input_icu.h"
2015-07-15 18:01:45 -07:00
#include "engine_sniffer.h"
2015-07-10 06:01:56 -07:00
class WaveReader {
public:
WaveReader();
void onFallEvent();
digital_input_s *hw;
2019-11-03 19:02:52 -08:00
const char *name = nullptr;
volatile int fallEventCounter = 0;
volatile int riseEventCounter = 0;
2015-07-10 06:01:56 -07:00
2019-11-03 19:02:52 -08:00
int currentRevolutionCounter = 0;
2015-07-10 06:01:56 -07:00
/**
* Total ON time during last engine cycle
*/
2019-11-03 19:02:52 -08:00
efitimeus_t prevTotalOnTimeUs = 0;
2015-07-10 06:01:56 -07:00
2019-11-03 19:02:52 -08:00
efitimeus_t totalOnTimeAccumulatorUs = 0;
2015-07-10 06:01:56 -07:00
2019-11-03 19:02:52 -08:00
volatile efitimeus_t lastActivityTimeUs = 0; // timestamp in microseconds ticks
2015-07-10 06:01:56 -07:00
/**
* time of signal fall event, in microseconds
*/
2019-11-03 19:02:52 -08:00
volatile efitimeus_t periodEventTimeUs = 0;
volatile efitimeus_t widthEventTimeUs = 0; // time of signal rise in microseconds
2015-07-10 06:01:56 -07:00
2019-11-03 19:02:52 -08:00
volatile efitimeus_t signalPeriodUs = 0; // period between two signal rises in microseconds
2015-07-10 06:01:56 -07:00
/**
* offset from engine cycle start in microseconds
*/
2019-11-03 19:02:52 -08:00
volatile efitimeus_t waveOffsetUs = 0;
volatile efitimeus_t last_wave_low_widthUs = 0; // time period in systimer ticks
volatile efitimeus_t last_wave_high_widthUs = 0; // time period in systimer ticks
2015-07-10 06:01:56 -07:00
};
void initWaveAnalyzer();
void startLogicAnalyzerPins();
void stopLogicAnalyzerPins();
2015-07-10 06:01:56 -07:00
void printWave(Logging *logging);
2017-01-12 06:02:19 -08:00
void showWaveInfo(void);
void reportLogicAnalyzerToTS(void);
2015-07-10 06:01:56 -07:00
void waTriggerEventListener(trigger_event_e ckpSignalType, uint32_t index, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX);
#endif /* EFI_LOGIC_ANALYZER */
2015-07-10 06:01:56 -07:00