Olli Vanhoja
/
xBee
xBee
main.cpp@0:265bb7b57633, 2011-03-01 (annotated)
- Committer:
- HBP
- Date:
- Tue Mar 01 13:41:37 2011 +0000
- Revision:
- 0:265bb7b57633
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
HBP | 0:265bb7b57633 | 1 | #include "mbed.h" |
HBP | 0:265bb7b57633 | 2 | |
HBP | 0:265bb7b57633 | 3 | Serial xbee1(p9, p10); |
HBP | 0:265bb7b57633 | 4 | Serial pc(USBTX, USBRX); |
HBP | 0:265bb7b57633 | 5 | |
HBP | 0:265bb7b57633 | 6 | uint32_t i=0; |
HBP | 0:265bb7b57633 | 7 | |
HBP | 0:265bb7b57633 | 8 | void readxBee() |
HBP | 0:265bb7b57633 | 9 | { |
HBP | 0:265bb7b57633 | 10 | char c; |
HBP | 0:265bb7b57633 | 11 | |
HBP | 0:265bb7b57633 | 12 | i++; |
HBP | 0:265bb7b57633 | 13 | //if(xbee1.readable()) |
HBP | 0:265bb7b57633 | 14 | //{ |
HBP | 0:265bb7b57633 | 15 | xbee1.scanf("%c", &c); |
HBP | 0:265bb7b57633 | 16 | pc.printf("%c", c); |
HBP | 0:265bb7b57633 | 17 | //} |
HBP | 0:265bb7b57633 | 18 | if(c == '?') |
HBP | 0:265bb7b57633 | 19 | { |
HBP | 0:265bb7b57633 | 20 | xbee1.printf("i=%u\n\r", i); |
HBP | 0:265bb7b57633 | 21 | } |
HBP | 0:265bb7b57633 | 22 | } |
HBP | 0:265bb7b57633 | 23 | int main() { |
HBP | 0:265bb7b57633 | 24 | xbee1.attach(&readxBee, Serial::RxIrq); |
HBP | 0:265bb7b57633 | 25 | } |