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:
- 4:a3c4a43f94f8
- Child:
- 6:ac7c0ccf9b5d
diff -r 36faaaa70f8b -r a3c4a43f94f8 Receiver.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Receiver.h Mon Oct 23 21:18:07 2017 +0000
@@ -0,0 +1,93 @@
+
+#include "mbed.h"
+#include "rtos.h"
+#include <vector>
+
+
+const unsigned char preamble = 85;
+
+
+
+class ReceiverData
+{
+public:
+ ReceiverData():lastTime(0),receiving(false),data(80),temp(0),currentBit(0),ready(false){}
+
+ const vector<unsigned char> & receivedData(){ return data; }
+
+ bool waiting(){return receiving == false;}
+
+ void fall();
+
+ void rise();
+
+ void setTime();
+
+ void addBit(unsigned char bit);
+
+ void start();
+ void waitData();
+ void clear();
+
+ void timeout();
+
+private:
+ Timer time;
+ Ticker watchDog;
+
+ Semaphore dataSemaphore;
+
+ int lastTime;
+ bool receiving;
+ bool ready;
+
+ vector<unsigned char> data;
+ unsigned char temp;
+ int currentBit;
+};
+
+
+
+
+
+/*
+ void* arg = NULL;
+ Thread receiver(arg,&receive);
+
+ bool bit = false;
+ MO = false;
+ for(int i = 0; i < 16 ; i++)
+ {
+ printf("MO\n");
+ Thread::wait(us_period/2000);
+ MO = bit;
+ bit = !bit;
+ }
+ while(1)
+ {
+ Thread::wait(2);
+ }
+
+void receive(void* args)
+{
+ pc.printf("Receive Start\n");
+ ReceiverData data;
+ while(true)
+ {
+ data.start();
+ data.waitData();
+ vector<unsigned char> vec = data.receivedData();
+ pc.printf("print");
+ for(int i = 0 ; i < vec.size();i++)
+ {
+ pc.printf("%c",vec[i]);
+ }
+ }
+
+
+}
+
+
+
+
+ */
\ No newline at end of file
