2#if !defined(__SYNC_INTERRUPT_H)
3#define __SYNC_INTERRUPT_H
9constexpr int32_t Hz_4000 = 4000;
10constexpr int32_t Hz_1000 = 1000;
11constexpr int32_t sync_1 = 1;
12constexpr int32_t sync_150 = 150;
13constexpr int32_t sync_250 = 250;
14constexpr int32_t threshold_250 = 250;
15constexpr int32_t threshold_65 = 65;
19constexpr double MILLISECONDS_PER_SECOND = 1.0e3;
20constexpr double MICROSECONDS_PER_SECOND = 1.0e6;
21constexpr double MICROSECONDS_PER_MILLISECOND = 1.0e3;
25template<
typename DataType>
26class StatisticsBufferTemplate
30 StatisticsBufferTemplate() :
31 min(std::numeric_limits<DataType>::max()),
32 max(std::numeric_limits<DataType>::lowest())
34 virtual void Init() = 0;
35 virtual void Reset() = 0;
36 virtual void AddData(
const DataType& datum)
48using StatisticsBuffer = StatisticsBufferTemplate<double>;
53extern uint32_t cpuFrequency;
54extern int32_t currentPerformanceCounter;
55extern int32_t previousPerformanceCounter;
56extern int32_t deltaPerformanceCounter;
57extern int32_t syncInterruptIterations;
58extern double deltaMicroseconds;
59extern int32_t syncInterruptSampleCounter;
60extern int32_t lastSyncInterruptSampleCounter;
62extern int32_t returnCode;
63extern std::atomic_bool readyToCleanup;
66extern int32_t sampleRate;
67extern int32_t syncPeriod;
68extern int32_t printFrequency;
70extern int32_t timeout_mS;
71extern int32_t syncPeriodThreshold_uS;
74extern StatisticsBuffer& buffered_stats;
75void printTimingHeaderString();
76void PrintTimingInfo();
77void StatisticsThread();