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
- Committer:
- ThierryLeonard
- Date:
- 2017-10-23
- Revision:
- 4:a3c4a43f94f8
- Child:
- 6:ac7c0ccf9b5d
File content as of revision 4:a3c4a43f94f8:
#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]);
}
}
}
*/
