Fork to see if I can get working

Dependencies:   BufferedSerial OneWire WinbondSPIFlash libxDot-dev-mbed5-deprecated

Fork of xDotBridge_update_test20180823 by Matt Briggs

Files at this revision

API Documentation at this revision

Comitter:
Matt Briggs
Date:
Mon Apr 10 16:06:31 2017 -0600
Parent:
72:bcc66cdfd101
Child:
74:dc969906f1f7
Commit message:
Forgot to add some files.

Changed in this revision

xDotBridge/inc/EepromLog.h Show annotated file Show diff for this revision Revisions of this file
xDotBridge/inc/SimpleRxSeqLog.h Show annotated file Show diff for this revision Revisions of this file
xDotBridge/inc/util.h Show annotated file Show diff for this revision Revisions of this file
xDotBridge/src/EepromLog.cpp Show annotated file Show diff for this revision Revisions of this file
xDotBridge_20170330_backTo7Sec.bin Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xDotBridge/inc/EepromLog.h	Mon Apr 10 16:06:31 2017 -0600
@@ -0,0 +1,20 @@
+#ifndef EEPROMLOG_H_
+#define EEPROMLOG_H_
+
+#include <stdint.h>
+
+class EepromLog {
+public:
+    EepromLog (uint16_t baseAddr, uint8_t size);
+    ~EepromLog ();
+    void clear();
+    bool read();
+    bool save();
+
+protected:
+    uint16_t mBaseAddr;
+    uint8_t *mData;
+    uint8_t mLogSize;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xDotBridge/inc/SimpleRxSeqLog.h	Mon Apr 10 16:06:31 2017 -0600
@@ -0,0 +1,45 @@
+/*
+ * simpleRxSeqLog.h
+ *
+ *  Created on: Mar 23, 2017
+ *      Author: mbriggs
+ */
+
+#ifndef SIMPLERXSEQLOG_H_
+#define SIMPLERXSEQLOG_H_
+
+#include "EepromLog.h"
+
+const uint8_t SIMPLE_RX_SEQ_LOG_SIZE = 3*sizeof(uint32_t);
+
+class SimpleRxSeqLog : public EepromLog {
+public:
+    SimpleRxSeqLog (uint16_t baseAddr) : EepromLog(baseAddr, SIMPLE_RX_SEQ_LOG_SIZE) {}
+
+    uint32_t loopCount()
+    {
+        return *((uint32_t *)(mData+0*sizeof(uint32_t)));
+    }
+    void setLoopCount(uint32_t val)
+    {
+        *((uint32_t*) (mData+0*sizeof(uint32_t))) = val;
+    }
+    uint32_t rxMsgCount()
+    {
+        return *((uint32_t *)(mData+1*sizeof(uint32_t)));
+    }
+    void setRxMsgCount(uint32_t val)
+    {
+        *((uint32_t*) (mData+1*sizeof(uint32_t))) = val;
+    }
+    uint32_t maxSeenMsgSeqNum()
+    {
+        return *((uint32_t*)(mData+2*sizeof(uint32_t)));
+    }
+    void setMaxSeenMsgSeqNum(uint32_t val)
+    {
+        *((uint32_t*) (mData+2*sizeof(uint32_t))) = val;
+    }
+};
+
+#endif /* XDOTBRIDGE_INC_SIMPLERXSEQLOG_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xDotBridge/inc/util.h	Mon Apr 10 16:06:31 2017 -0600
@@ -0,0 +1,28 @@
+/*
+ * util.h
+ *
+ *  Created on: Mar 14, 2017
+ *      Author: mbriggs
+ */
+
+#ifndef XDOTBRIDGE_INC_UTIL_H_
+#define XDOTBRIDGE_INC_UTIL_H_
+
+#include <vector>
+
+void appendUint16ToVector (std::vector<uint8_t> &dest, uint16_t in)
+{
+    dest.push_back((in & 0xFF00) >> 8); // High data byte
+    dest.push_back((in & 0x00FF)); // Low data byte
+}
+void appendUint32ToVector (std::vector<uint8_t> &dest, uint32_t in)
+{
+    dest.push_back((in & 0xFF000000) >> 24);
+    dest.push_back((in & 0x00FF0000) >> 16);
+    dest.push_back((in & 0x0000FF00) >> 8);
+    dest.push_back((in & 0x000000FF));
+}
+
+
+
+#endif /* XDOTBRIDGE_INC_UTIL_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xDotBridge/src/EepromLog.cpp	Mon Apr 10 16:06:31 2017 -0600
@@ -0,0 +1,40 @@
+/*
+ * EepromLog.cpp
+ *
+ *  Created on: Mar 23, 2017
+ *      Author: mbriggs
+ */
+
+#include "EepromLog.h"
+#include "dot_util.h"
+#include <cstring>
+
+EepromLog::EepromLog(uint16_t baseAddr, uint8_t size)
+{
+    mBaseAddr = baseAddr;
+    mLogSize = size;
+    mData = new uint8_t[size];
+}
+EepromLog::~EepromLog()
+{
+    mLogSize=0;
+    delete mData;
+}
+void EepromLog::clear()
+{
+    if (mLogSize == 0 || mData == NULL)
+        return;
+    std::memset(mData, 0x00, mLogSize);
+}
+bool EepromLog::read()
+{
+    if (mLogSize == 0 || mData == NULL)
+        return false;
+    return dot->nvmRead(mBaseAddr, mData, mLogSize);
+}
+bool EepromLog::save()
+{
+    if (mLogSize == 0 || mData == NULL)
+        return false;
+    return dot->nvmWrite(mBaseAddr, mData, mLogSize);
+}
Binary file xDotBridge_20170330_backTo7Sec.bin has changed