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.
Dependents: XBeeWiFi_SPI_example
Fork of XBee by
Revision 10:eb70be6ceb6d, committed 2014-01-04
- Comitter:
- ban4jp
- Date:
- Sat Jan 04 15:34:59 2014 +0000
- Parent:
- 9:e32c2e5390d3
- Commit message:
- Fixed #define USE_XBEE_SPI
Changed in this revision
--- a/XBee.cpp Fri Jan 03 03:33:03 2014 +0000
+++ b/XBee.cpp Sat Jan 04 15:34:59 2014 +0000
@@ -672,7 +672,7 @@
_response.reset();
}
-#ifdef XBEE_USE_UART
+#ifndef USE_XBEE_SPI
XBee::XBee(PinName p_tx, PinName p_rx): _xbee(p_tx, p_rx) {
_pos = 0;
_epos = 0;
@@ -727,7 +727,7 @@
}
#endif
-#ifdef XBEE_USE_SPI
+#ifdef USE_XBEE_SPI
XBee::XBee(PinName p_mosi, PinName p_miso, PinName p_sclk, PinName p_ssel, PinName p_attn, PinName p_reset):
_xbee(p_mosi, p_miso, p_sclk), _ssel(p_ssel), _attn(p_attn), _reset(p_reset) {
_ssel = 1;
@@ -763,7 +763,7 @@
return _nextFrameId;
}
-#ifdef XBEE_USE_UART
+#ifndef USE_XBEE_SPI
void XBee::begin(long baud) {
_xbee.baud(baud);
}
@@ -832,7 +832,7 @@
return false;
}
-#ifdef XBEE_USE_UART
+#ifndef USE_XBEE_SPI
void XBee::isr_recv () {
_rxbuf[_rxaddr_w] = _xbee.getc();
_rxaddr_w = (_rxaddr_w + 1) % MAX_RXBUF_SIZE;
@@ -859,14 +859,14 @@
resetResponse();
}
-#ifdef XBEE_USE_UART
+#ifndef USE_XBEE_SPI
// while (_xbee.readable()) {
while ((! _rts && _xbee.readable()) || (_rts && bufreadable())) {
#else
while (! _attn || bufreadable()) {
#endif
-#ifdef XBEE_USE_UART
+#ifndef USE_XBEE_SPI
// b = _xbee.getc();
if (_rts) {
b = getbuf();
@@ -886,13 +886,13 @@
// new packet start before previous packeted completed -- discard previous packet and start over
DBG("error: %02x %d %d\r\n", b, _pos, _epos);
_response.setErrorCode(UNEXPECTED_START_BYTE);
-#ifdef XBEE_USE_SPI
+#ifdef USE_XBEE_SPI
_ssel = 1;
#endif
return;
}
-#ifdef XBEE_USE_UART
+#ifndef USE_XBEE_SPI
if (_pos > 0 && b == ESCAPE) {
if (_xbee.readable()) {
// b = _xbee.getc();
@@ -912,7 +912,7 @@
#endif
DBG("%02x_", b);
-#ifdef XBEE_USE_UART
+#ifndef USE_XBEE_SPI
if (_escape == true) {
b = 0x20 ^ b;
_escape = false;
@@ -955,7 +955,7 @@
if (_pos > MAX_FRAME_DATA_SIZE) {
// exceed max size. should never occur
_response.setErrorCode(PACKET_EXCEEDS_BYTE_ARRAY_LENGTH);
-#ifdef XBEE_USE_SPI
+#ifdef USE_XBEE_SPI
_ssel = 1;
#endif
return;
@@ -989,7 +989,7 @@
_checksumTotal = 0;
-#ifdef XBEE_USE_SPI
+#ifdef USE_XBEE_SPI
_ssel = 1;
#endif
return;
@@ -1000,7 +1000,7 @@
}
}
}
-#ifdef XBEE_USE_SPI
+#ifdef USE_XBEE_SPI
_ssel = 1;
#endif
}
@@ -1461,7 +1461,7 @@
//}
void XBee::send(XBeeRequest &request) {
-#ifdef XBEE_USE_SPI
+#ifdef USE_XBEE_SPI
_ssel = 0;
#endif
// the new new deal
@@ -1504,7 +1504,7 @@
// send packet
Serial.flush();
*/
-#ifdef XBEE_USE_SPI
+#ifdef USE_XBEE_SPI
_ssel = 1;
#endif
DBG("\r\n");
@@ -1512,7 +1512,7 @@
void XBee::sendByte(uint8_t b, bool escape) {
-#ifdef XBEE_USE_UART
+#ifndef USE_XBEE_SPI
if (escape && (b == START_BYTE || b == ESCAPE || b == XON || b == XOFF)) {
// std::cout << "escaping byte [" << toHexString(b) << "] " << std::endl;
_xbee.putc(ESCAPE);
--- a/XBee.h Fri Jan 03 03:33:03 2014 +0000
+++ b/XBee.h Sat Jan 04 15:34:59 2014 +0000
@@ -681,7 +681,7 @@
*/
class XBee {
public:
-#ifdef XBEE_USE_UART
+#ifndef USE_XBEE_SPI
XBee(PinName p_tx, PinName p_rx);
XBee(PinName p_tx, PinName p_rx, PinName p_cts, PinName p_rts);
#else
@@ -713,7 +713,7 @@
* call forever!! often it's better to use a timeout: readPacket(int)
*/
void readPacketUntilAvailable();
-#ifdef XBEE_USE_UART
+#ifndef USE_XBEE_SPI
/**
* Starts the serial connection at the supplied baud rate
*/
@@ -751,7 +751,7 @@
uint8_t _nextFrameId;
// buffer for incoming RX packets. holds only the api specific frame data, starting after the api id byte and prior to checksum
uint8_t _responseFrameData[MAX_FRAME_DATA_SIZE];
-#ifdef XBEE_USE_UART
+#ifndef USE_XBEE_SPI
Serial _xbee;
#else
SPI _xbee;
--- a/XBeeWiFi.cpp Fri Jan 03 03:33:03 2014 +0000
+++ b/XBeeWiFi.cpp Sat Jan 04 15:34:59 2014 +0000
@@ -21,12 +21,12 @@
#define REVERSE_ENDIAN(x) (uint16_t)(((uint16_t)x >> 8) | ((uint16_t)x << 8))
-#ifdef XBEE_USE_UART
+#ifndef USE_XBEE_SPI
XBeeWiFi::XBeeWiFi (PinName p_tx, PinName p_rx, PinName p_cts, PinName p_rts) : XBee(p_tx, p_rx, p_cts, p_rts) {
}
#endif
-#ifdef XBEE_USE_SPI
+#ifdef USE_XBEE_SPI
XBeeWiFi::XBeeWiFi (PinName p_mosi, PinName p_miso, PinName p_sclk, PinName p_ssel, PinName p_attn, PinName p_reset) :
XBee(p_mosi, p_miso, p_sclk, p_ssel, p_attn, p_reset) {
}
@@ -120,7 +120,7 @@
send(atRequest);
r = getWiResponse(AT_COMMAND_RESPONSE, atRequest.getFrameId());
-#ifdef XBEE_USE_UART
+#ifndef USE_XBEE_SPI
if (r == 0) {
begin(b);
}
--- a/XBeeWiFi.h Fri Jan 03 03:33:03 2014 +0000
+++ b/XBeeWiFi.h Sat Jan 04 15:34:59 2014 +0000
@@ -105,7 +105,7 @@
*/
class XBeeWiFi : public XBee {
public:
-#ifdef XBEE_USE_UART
+#ifndef USE_XBEE_SPI
XBeeWiFi (PinName p_tx, PinName p_rx, PinName p_cts, PinName p_rts);
#else
XBeeWiFi (PinName p_mosi, PinName p_miso, PinName p_sclk, PinName p_ssel, PinName p_attn, PinName p_reset);
--- a/XBee_conf.h_example.txt Fri Jan 03 03:33:03 2014 +0000 +++ b/XBee_conf.h_example.txt Sat Jan 04 15:34:59 2014 +0000 @@ -1,11 +1,9 @@ #ifndef XBee_conf_h #define XBee_conf_h -//#define XBEE_USE_UART -#define XBEE_USE_SPI +#define ENABLE_XBEE_WIFI -//#define ENABLE_XBEE_WIFI - +#define USE_XBEE_SPI //#define USE_WIFIDNS #endif
