Éric Bisson / Mbed 2 deprecated S5info_APP4

Dependencies:   mbed-rtos mbed CRC16

Fork of S5info_APP2 by Éric Bisson

read.h

Committer:
ericbisson
Date:
2017-03-07
Revision:
14:bd909277eb13

File content as of revision 14:bd909277eb13:

#include "mbed.h"
#include "rtos.h"
DigitalIn in(p30);
Thread ThreadLecture;
const int PREAMBULE = 0b01010101;
const int START = 0b01111110;
const int END = 0b01111110;

void read()
{
    char byte;
    vector<char> bytes;
    while (true)
    {
        ThreadLecture.signal_wait(1);
        
        byte = (byte << 1) + in;
        
        shift++;
        if (shift == 8)
        {
            bytes.push_back(byte);
            shift = 0;
        }
    }
}