makes GPIO_PIN_RST optional for the sx1276
[ExpressLRS.git] / src / lib / PFD / PFD.h
blob5c4800627c8ab968688e3df30d7c84ef2305b5e7
1 #pragma once
2 #include <Arduino.h>
3 #include <stdio.h>
4 #include "../../src/include/targets.h"
6 class PFD
8 private:
9 uint32_t intEventTime = 0;
10 uint32_t extEventTime = 0;
11 int32_t result;
12 bool gotExtEvent;
13 bool gotIntEvent;
15 public:
16 inline void extEvent(uint32_t time) // reference (external osc)
18 extEventTime = time;
19 gotExtEvent = true;
22 inline void intEvent(uint32_t time) // internal osc event
24 intEventTime = time;
25 gotIntEvent = true;
28 inline void reset()
30 gotExtEvent = false;
31 gotIntEvent = false;
34 inline void calcResult()
36 result = (gotExtEvent && gotIntEvent) ? (int32_t)(extEventTime - intEventTime) : 0;
39 inline int32_t getResult()
41 return result;
44 volatile uint32_t getIntEventTime() const { return intEventTime; }
45 volatile uint32_t getExtEventTime() const { return extEventTime; }