Xbee API library with support SPI connection. (use only SPI supported model. see also http://www.digi.com/support/kbase/kbaseresultdetl?id=3362 )
Dependents: XBeeWiFi_SPI_example
Fork of XBee by
Diff: XBee.cpp
- Revision:
- 10:eb70be6ceb6d
- Parent:
- 9:e32c2e5390d3
diff -r e32c2e5390d3 -r eb70be6ceb6d XBee.cpp --- 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);