Éric Bisson / Mbed 2 deprecated S5info_APP4

Dependencies:   mbed-rtos mbed CRC16

Fork of S5info_APP2 by Éric Bisson

Committer:
ericbisson
Date:
Tue Mar 07 04:39:57 2017 +0000
Revision:
14:bd909277eb13
temp commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ericbisson 14:bd909277eb13 1 #include "mbed.h"
ericbisson 14:bd909277eb13 2 #include "rtos.h"
ericbisson 14:bd909277eb13 3 DigitalIn in(p30);
ericbisson 14:bd909277eb13 4 Thread ThreadLecture;
ericbisson 14:bd909277eb13 5 const int PREAMBULE = 0b01010101;
ericbisson 14:bd909277eb13 6 const int START = 0b01111110;
ericbisson 14:bd909277eb13 7 const int END = 0b01111110;
ericbisson 14:bd909277eb13 8
ericbisson 14:bd909277eb13 9 void read()
ericbisson 14:bd909277eb13 10 {
ericbisson 14:bd909277eb13 11 char byte;
ericbisson 14:bd909277eb13 12 vector<char> bytes;
ericbisson 14:bd909277eb13 13 while (true)
ericbisson 14:bd909277eb13 14 {
ericbisson 14:bd909277eb13 15 ThreadLecture.signal_wait(1);
ericbisson 14:bd909277eb13 16
ericbisson 14:bd909277eb13 17 byte = (byte << 1) + in;
ericbisson 14:bd909277eb13 18
ericbisson 14:bd909277eb13 19 shift++;
ericbisson 14:bd909277eb13 20 if (shift == 8)
ericbisson 14:bd909277eb13 21 {
ericbisson 14:bd909277eb13 22 bytes.push_back(byte);
ericbisson 14:bd909277eb13 23 shift = 0;
ericbisson 14:bd909277eb13 24 }
ericbisson 14:bd909277eb13 25 }
ericbisson 14:bd909277eb13 26 }