gyo

SBDBT.cpp

Committer:
gotto0
Date:
2017-05-06
Revision:
0:afe58893bfe7
Child:
1:8810976be033

File content as of revision 0:afe58893bfe7:

#include "SBDBT.h"

namespace raven
{
    
    
    
    SBDBT::SBDBT(PinName p1, PinName p2)
    {
        i = 0;
        flag = 0;
        char data[8]={};
        char olddata[8]={};
        sr = new Serial(p1,p2);
        sr -> baud(2400);
        sr -> attach(this,&SBDBT::getd,Serial::RxIrq);
    }
    
    void SBDBT::getd()
    {
        olddata[i] = data[i];
        data[i] = sr -> getc();
        i++;
        if(i>=8)
        {
            i=0;
            flag = 1;
        }
    }
    
    SBDBT::~SBDBT()
    {
        delete sr;
    }
        
    
}//namespace