Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Receiver.h
- Revision:
- 7:332766fb3114
- Parent:
- 6:ac7c0ccf9b5d
- Child:
- 8:7c56fb1ed8c0
--- a/Receiver.h Tue Oct 24 02:33:50 2017 +0000
+++ b/Receiver.h Tue Oct 24 07:04:28 2017 +0000
@@ -8,63 +8,56 @@
#include "defines.h"
-
-enum Edge
+namespace BitData
{
- rising,
- falling
+ enum
+ {
+ zero,
+ one,
+ timeout
+ };
};
class Receiver
{
-
public:
- struct EdgeData {
- EdgeData(){}
- EdgeData(int us,Edge value):us_timeStamp(us),value(value) {}
-
- int us_timeStamp;
- Edge value;
- };
-
Receiver();
void resetTimer(){time.reset();}
- EdgeData getNext();
+ char getNext();
private:
- void pushState(Edge edge);
+ void pushData( char bitData );
+ void edgeFunction(char mode);
void rise();
void fall();
private:
-static const int size = 150;
+static const int size = 8 * 90 *3;
Timer time;
Semaphore dataReady;
- EdgeData data[size];
-public:
+ char data[size];
+
+
+ int lastTime;
+ bool timedOut;
+
int currentData;
int endData;
};
-typedef Receiver::EdgeData EdgeData;
-
class ManchesterReceiver
{
public:
void getMessages();
-private:
- void getState(Edge &edge, int &timeStamp);
-
- unsigned char getFirstByte(int &lastTime);
+private:
+ bool getByte(unsigned char &val);
- bool getByte(int& lastTime, unsigned char &val);
-
- bool getMessage(int lastTime, vector<unsigned char> &message);
+ bool getMessage( vector<unsigned char> &message, int &crc);
private:
Receiver r;
