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.
Xbee.cpp@27:6bd26aff87e6, 2015-11-28 (annotated)
- Committer:
- Xiaofei
- Date:
- Sat Nov 28 06:11:43 2015 +0000
- Revision:
- 27:6bd26aff87e6
- Parent:
- 26:282047f761ea
- Child:
- 28:8fdfd5bffe15
g
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Xiaofei | 0:633baa9653b0 | 1 | #pragma once |
Xiaofei | 0:633baa9653b0 | 2 | #include "Xbee.h" |
Xiaofei | 0:633baa9653b0 | 3 | |
Xiaofei | 27:6bd26aff87e6 | 4 | //Serial pc(USBTX, USBRX); |
Xiaofei | 20:f7abfda12a41 | 5 | |
Xiaofei | 2:33462c1e9f45 | 6 | Xbee::Xbee(PinName tx, PinName rx , PinName rst):_xbee(tx,rx),_rst(rst) |
Xiaofei | 2:33462c1e9f45 | 7 | { |
Xiaofei | 16:cc598ae4ab52 | 8 | _xbee.baud(9600); |
Xiaofei | 16:cc598ae4ab52 | 9 | } |
Xiaofei | 16:cc598ae4ab52 | 10 | |
Xiaofei | 16:cc598ae4ab52 | 11 | void Xbee::Reset() |
Xiaofei | 16:cc598ae4ab52 | 12 | { |
Xiaofei | 2:33462c1e9f45 | 13 | _rst = 0; |
Xiaofei | 2:33462c1e9f45 | 14 | wait(0.01); |
Xiaofei | 2:33462c1e9f45 | 15 | _rst = 1; |
Xiaofei | 2:33462c1e9f45 | 16 | wait(0.01); |
Xiaofei | 5:d14636b861ff | 17 | |
Xiaofei | 2:33462c1e9f45 | 18 | } |
Xiaofei | 2:33462c1e9f45 | 19 | |
Xiaofei | 17:2271d7a273e7 | 20 | void Xbee::Send(const char& buffer) |
Xiaofei | 0:633baa9653b0 | 21 | { |
Xiaofei | 27:6bd26aff87e6 | 22 | if(_xbee.writeable()) |
Xiaofei | 3:fe623a260bf5 | 23 | { |
Xiaofei | 27:6bd26aff87e6 | 24 | _xbee.putc(buffer); |
Xiaofei | 3:fe623a260bf5 | 25 | } |
Xiaofei | 0:633baa9653b0 | 26 | } |
Xiaofei | 0:633baa9653b0 | 27 | |
Xiaofei | 19:4bc3e2e68495 | 28 | void Xbee::Recv(char& buffer) |
Xiaofei | 0:633baa9653b0 | 29 | { |
Xiaofei | 27:6bd26aff87e6 | 30 | while(!_xbee.readable()){} |
Xiaofei | 27:6bd26aff87e6 | 31 | |
Xiaofei | 27:6bd26aff87e6 | 32 | if(_xbee.readable()) |
Xiaofei | 6:9f2db7a38f19 | 33 | { |
Xiaofei | 27:6bd26aff87e6 | 34 | buffer = _xbee.getc(); |
Xiaofei | 6:9f2db7a38f19 | 35 | } |
Xiaofei | 0:633baa9653b0 | 36 | } |