I messed up the merge, so pushing it over to another repo so I don't lose it. Will tidy up and remove later

Dependencies:   BufferedSerial FatFileSystemCpp mbed

Revision:
0:97661408d0f9
Child:
7:87aea27cc68b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LTCDecode.h	Fri Jan 15 11:49:01 2021 +0000
@@ -0,0 +1,75 @@
+#ifndef __LTCDECODE_H__
+#define __LTCDECODE_H__
+
+#include "mbed.h"
+
+  const uint32_t minBitPeriodUS =
+      (uint32_t)((1000000.0f / 2400) / 1.1f); // allow for 10% time error
+  const uint32_t maxMidSymbolTimeUS = (uint32_t)(
+      ((1000000.0f / (1920 * 2))) * 1.1f); // allow for 10% time error
+
+class LTCDecode {
+
+public:
+  LTCDecode(const PinName pin);
+  void setInputTimer(Timer *inputTimer);
+
+  bool synced() { return LTCsynced; };
+
+  // reads pending data up to a sync marker, returns true is sync is found.
+  bool searchForSync();
+
+  // reads pending data up to the end of the frame, returns true at the end of a
+  // frame. check sync stats and lastFrameData for results.
+  bool readWaitingData();
+
+  typedef struct {
+    int hours;
+    int minutes;
+    int seconds;
+    int frame;
+    bool frameDrop;
+    uint32_t frameStartTime;
+  } LTCData_t;
+
+  const LTCData_t *getLastFrame() { return &lastFrame; };
+
+  // buffer holding received LTC bits and their start times.
+
+private:
+  void LTCOnEdge(void);
+
+  InterruptIn _LTCIn;
+  Timer *_inputTimer;
+
+  LTCData_t lastFrame;
+
+  static const int _newBitBufferSize_ = 80;
+
+  bool newBitBuffer[_newBitBufferSize_];
+  uint32_t bitTimes[_newBitBufferSize_];
+
+  bool LTCsynced;
+
+  volatile int newBitsWrite;
+  int newBitsRead;
+
+  // max bit period = 520.8 ms (1920 Hz)
+  // min bit period = 416.7 ms (2400 Hz)
+  // max period of a '1' symbol = 260.4ms (1920Hz * 2)
+
+  uint32_t lastTransition;
+  uint32_t lastBitStart;
+
+  uint32_t LTCBuffer[3];
+  uint32_t firstMark;
+  int markCount;
+  uint32_t nextSecondStart;
+  uint32_t PPSWidth;
+  int bitCounter ;
+  int dwordCounter ;
+
+  uint32_t timeOfBit, frameStartTime;
+};
+
+#endif