gyo
SBDBT.cpp@0:afe58893bfe7, 2017-05-06 (annotated)
- Committer:
- gotto0
- Date:
- Sat May 06 02:12:51 2017 +0000
- Revision:
- 0:afe58893bfe7
- Child:
- 1:8810976be033
before rework
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gotto0 | 0:afe58893bfe7 | 1 | #include "SBDBT.h" |
gotto0 | 0:afe58893bfe7 | 2 | |
gotto0 | 0:afe58893bfe7 | 3 | namespace raven |
gotto0 | 0:afe58893bfe7 | 4 | { |
gotto0 | 0:afe58893bfe7 | 5 | |
gotto0 | 0:afe58893bfe7 | 6 | |
gotto0 | 0:afe58893bfe7 | 7 | |
gotto0 | 0:afe58893bfe7 | 8 | SBDBT::SBDBT(PinName p1, PinName p2) |
gotto0 | 0:afe58893bfe7 | 9 | { |
gotto0 | 0:afe58893bfe7 | 10 | i = 0; |
gotto0 | 0:afe58893bfe7 | 11 | flag = 0; |
gotto0 | 0:afe58893bfe7 | 12 | char data[8]={}; |
gotto0 | 0:afe58893bfe7 | 13 | char olddata[8]={}; |
gotto0 | 0:afe58893bfe7 | 14 | sr = new Serial(p1,p2); |
gotto0 | 0:afe58893bfe7 | 15 | sr -> baud(2400); |
gotto0 | 0:afe58893bfe7 | 16 | sr -> attach(this,&SBDBT::getd,Serial::RxIrq); |
gotto0 | 0:afe58893bfe7 | 17 | } |
gotto0 | 0:afe58893bfe7 | 18 | |
gotto0 | 0:afe58893bfe7 | 19 | void SBDBT::getd() |
gotto0 | 0:afe58893bfe7 | 20 | { |
gotto0 | 0:afe58893bfe7 | 21 | olddata[i] = data[i]; |
gotto0 | 0:afe58893bfe7 | 22 | data[i] = sr -> getc(); |
gotto0 | 0:afe58893bfe7 | 23 | i++; |
gotto0 | 0:afe58893bfe7 | 24 | if(i>=8) |
gotto0 | 0:afe58893bfe7 | 25 | { |
gotto0 | 0:afe58893bfe7 | 26 | i=0; |
gotto0 | 0:afe58893bfe7 | 27 | flag = 1; |
gotto0 | 0:afe58893bfe7 | 28 | } |
gotto0 | 0:afe58893bfe7 | 29 | } |
gotto0 | 0:afe58893bfe7 | 30 | |
gotto0 | 0:afe58893bfe7 | 31 | SBDBT::~SBDBT() |
gotto0 | 0:afe58893bfe7 | 32 | { |
gotto0 | 0:afe58893bfe7 | 33 | delete sr; |
gotto0 | 0:afe58893bfe7 | 34 | } |
gotto0 | 0:afe58893bfe7 | 35 | |
gotto0 | 0:afe58893bfe7 | 36 | |
gotto0 | 0:afe58893bfe7 | 37 | }//namespace |