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.
Receiver.h@8:7c56fb1ed8c0, 2017-10-25 (annotated)
- Committer:
- ThierryLeonard
- Date:
- Wed Oct 25 04:17:42 2017 +0000
- Revision:
- 8:7c56fb1ed8c0
- Parent:
- 7:332766fb3114
- Child:
- 9:8f479f7c1b54
No guarantees
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| ThierryLeonard | 6:ac7c0ccf9b5d | 1 | #ifndef RECEIVER_H |
| ThierryLeonard | 6:ac7c0ccf9b5d | 2 | #define RECEIVER_H |
| ThierryLeonard | 4:a3c4a43f94f8 | 3 | |
| ThierryLeonard | 4:a3c4a43f94f8 | 4 | #include "mbed.h" |
| ThierryLeonard | 4:a3c4a43f94f8 | 5 | #include "rtos.h" |
| ThierryLeonard | 6:ac7c0ccf9b5d | 6 | |
| ThierryLeonard | 4:a3c4a43f94f8 | 7 | #include <vector> |
| ThierryLeonard | 4:a3c4a43f94f8 | 8 | |
| ThierryLeonard | 4:a3c4a43f94f8 | 9 | |
| ThierryLeonard | 6:ac7c0ccf9b5d | 10 | #include "defines.h" |
| ThierryLeonard | 7:332766fb3114 | 11 | namespace BitData |
| ThierryLeonard | 6:ac7c0ccf9b5d | 12 | { |
| ThierryLeonard | 7:332766fb3114 | 13 | enum |
| ThierryLeonard | 7:332766fb3114 | 14 | { |
| ThierryLeonard | 7:332766fb3114 | 15 | zero, |
| ThierryLeonard | 7:332766fb3114 | 16 | one, |
| ThierryLeonard | 7:332766fb3114 | 17 | timeout |
| ThierryLeonard | 7:332766fb3114 | 18 | }; |
| ThierryLeonard | 6:ac7c0ccf9b5d | 19 | }; |
| ThierryLeonard | 4:a3c4a43f94f8 | 20 | |
| ThierryLeonard | 6:ac7c0ccf9b5d | 21 | class Receiver |
| ThierryLeonard | 6:ac7c0ccf9b5d | 22 | { |
| ThierryLeonard | 6:ac7c0ccf9b5d | 23 | public: |
| ThierryLeonard | 6:ac7c0ccf9b5d | 24 | |
| ThierryLeonard | 6:ac7c0ccf9b5d | 25 | Receiver(); |
| ThierryLeonard | 6:ac7c0ccf9b5d | 26 | void resetTimer(){time.reset();} |
| ThierryLeonard | 7:332766fb3114 | 27 | char getNext(); |
| ThierryLeonard | 6:ac7c0ccf9b5d | 28 | |
| ThierryLeonard | 6:ac7c0ccf9b5d | 29 | |
| ThierryLeonard | 6:ac7c0ccf9b5d | 30 | |
| ThierryLeonard | 6:ac7c0ccf9b5d | 31 | private: |
| ThierryLeonard | 7:332766fb3114 | 32 | void pushData( char bitData ); |
| ThierryLeonard | 7:332766fb3114 | 33 | void edgeFunction(char mode); |
| ThierryLeonard | 6:ac7c0ccf9b5d | 34 | void rise(); |
| ThierryLeonard | 6:ac7c0ccf9b5d | 35 | void fall(); |
| ThierryLeonard | 4:a3c4a43f94f8 | 36 | |
| ThierryLeonard | 6:ac7c0ccf9b5d | 37 | private: |
| ThierryLeonard | 7:332766fb3114 | 38 | static const int size = 8 * 90 *3; |
| ThierryLeonard | 6:ac7c0ccf9b5d | 39 | |
| ThierryLeonard | 6:ac7c0ccf9b5d | 40 | Timer time; |
| ThierryLeonard | 6:ac7c0ccf9b5d | 41 | Semaphore dataReady; |
| ThierryLeonard | 7:332766fb3114 | 42 | char data[size]; |
| ThierryLeonard | 7:332766fb3114 | 43 | |
| ThierryLeonard | 7:332766fb3114 | 44 | |
| ThierryLeonard | 7:332766fb3114 | 45 | int lastTime; |
| ThierryLeonard | 7:332766fb3114 | 46 | bool timedOut; |
| ThierryLeonard | 7:332766fb3114 | 47 | |
| ThierryLeonard | 6:ac7c0ccf9b5d | 48 | int currentData; |
| ThierryLeonard | 6:ac7c0ccf9b5d | 49 | int endData; |
| ThierryLeonard | 6:ac7c0ccf9b5d | 50 | }; |
| ThierryLeonard | 6:ac7c0ccf9b5d | 51 | |
| ThierryLeonard | 6:ac7c0ccf9b5d | 52 | class ManchesterReceiver |
| ThierryLeonard | 4:a3c4a43f94f8 | 53 | { |
| ThierryLeonard | 4:a3c4a43f94f8 | 54 | public: |
| ThierryLeonard | 6:ac7c0ccf9b5d | 55 | void getMessages(); |
| ThierryLeonard | 4:a3c4a43f94f8 | 56 | |
| ThierryLeonard | 8:7c56fb1ed8c0 | 57 | bool getByte(unsigned char &val); |
| ThierryLeonard | 8:7c56fb1ed8c0 | 58 | |
| ThierryLeonard | 7:332766fb3114 | 59 | private: |
| ThierryLeonard | 4:a3c4a43f94f8 | 60 | |
| ThierryLeonard | 7:332766fb3114 | 61 | bool getMessage( vector<unsigned char> &message, int &crc); |
| ThierryLeonard | 4:a3c4a43f94f8 | 62 | |
| ThierryLeonard | 6:ac7c0ccf9b5d | 63 | private: |
| ThierryLeonard | 6:ac7c0ccf9b5d | 64 | Receiver r; |
| ThierryLeonard | 4:a3c4a43f94f8 | 65 | |
| ThierryLeonard | 6:ac7c0ccf9b5d | 66 | bool possiblePreamble; |
| ThierryLeonard | 4:a3c4a43f94f8 | 67 | }; |
| ThierryLeonard | 4:a3c4a43f94f8 | 68 | |
| ThierryLeonard | 4:a3c4a43f94f8 | 69 | |
| ThierryLeonard | 4:a3c4a43f94f8 | 70 | |
| ThierryLeonard | 4:a3c4a43f94f8 | 71 | |
| ThierryLeonard | 6:ac7c0ccf9b5d | 72 | #endif |
