Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
xbee.h File Reference
#include "subsystems/datalink/datalink.h"
#include "generated/airframe.h"
#include "subsystems/datalink/xbee24.h"
#include "subsystems/datalink/transport.h"
+ Include dependency graph for xbee.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  xbee_transport
 

Macros

#define XBEE_START   0x7e
 Constants for the API protocol. More...
 
#define TX_OPTIONS   0x00
 
#define NO_FRAME_ID   0
 
#define GROUND_STATION_ADDR   0x100
 Ground station address. More...
 
#define XBEE_MY_ADDR   AC_ID
 Initialisation in API mode and setting of the local address FIXME: busy wait. More...
 
#define XBeeAPISizeOf(_dev, _x)   (_x+5)
 
#define XBeeTransportCheckFreeSpace(_dev, x)   TransportLink(_dev, CheckFreeSpace(x))
 
#define XBeeTransportPut1Byte(_dev, x)   TransportLink(_dev, Transmit(x))
 
#define XBeeTransportSendMessage(_dev)   TransportLink(_dev, SendMessage())
 
#define XBeeTransportPutUint8(_dev, _x)
 
#define XBeeTransportPut1ByteByAddr(_dev, _byte)
 
#define XBeeTransportPut2Bytes(_dev, _x)
 
#define XBeeTransportPut2ByteByAddr(_dev, _byte)
 
#define XBeeTransportPut4ByteByAddr(_dev, _byte)
 
#define XBeeTransportPutDoubleByAddr(_dev, _byte)
 
#define XBeeTransportPutInt8ByAddr(_dev, _x)   XBeeTransportPut1ByteByAddr(_dev, _x)
 
#define XBeeTransportPutUint8ByAddr(_dev, _x)   XBeeTransportPut1ByteByAddr(_dev, (const uint8_t*)_x)
 
#define XBeeTransportPutInt16ByAddr(_dev, _x)   XBeeTransportPut2ByteByAddr(_dev, (const uint8_t*)_x)
 
#define XBeeTransportPutUint16ByAddr(_dev, _x)   XBeeTransportPut2ByteByAddr(_dev, (const uint8_t*)_x)
 
#define XBeeTransportPutInt32ByAddr(_dev, _x)   XBeeTransportPut4ByteByAddr(_dev, (const uint8_t*)_x)
 
#define XBeeTransportPutUint32ByAddr(_dev, _x)   XBeeTransportPut4ByteByAddr(_dev, (const uint8_t*)_x)
 
#define XBeeTransportPutFloatByAddr(_dev, _x)   XBeeTransportPut4ByteByAddr(_dev, (const uint8_t*)_x)
 
#define XBeeTransportPutNamedUint8(_dev, _name, _byte)   XBeeTransportPutUint8(_dev, _byte)
 
#define XBeeTransportPutArray(_dev, _put, _n, _x)
 
#define XBeeTransportPutInt16Array(_dev, _n, _x)   XBeeTransportPutArray(_dev, XBeeTransportPutInt16ByAddr, _n, _x)
 
#define XBeeTransportPutUint16Array(_dev, _n, _x)   XBeeTransportPutArray(_dev, XBeeTransportPutUint16ByAddr, _n, _x)
 
#define XBeeTransportPutUint8Array(_dev, _n, _x)   XBeeTransportPutArray(_dev, XBeeTransportPutUint8ByAddr, _n, _x)
 
#define XBeeTransportPutFloatArray(_dev, _n, _x)   XBeeTransportPutArray(_dev, XBeeTransportPutFloatByAddr, _n, _x)
 
#define XBeeTransportPutDoubleArray(_dev, _n, _x)   XBeeTransportPutArray(_dev, XBeeTransportPutDoubleByAddr, _n, _x)
 
#define XBeeTransportHeader(_dev, _len)
 
#define XBeeTransportTrailer(_dev)
 
#define XBEE_UNINIT   0
 Status of the API packet receiver automata. More...
 
#define XBEE_GOT_START   1
 
#define XBEE_GOT_LENGTH_MSB   2
 
#define XBEE_GOT_LENGTH_LSB   3
 
#define XBEE_GOT_PAYLOAD   4
 
#define XBeeBuffer(_dev)   TransportLink(_dev,ChAvailable())
 
#define ReadXBeeBuffer(_dev, _trans)   { while (TransportLink(_dev,ChAvailable())&&!(_trans.trans.msg_received)) parse_xbee(&(_trans),TransportLink(_dev,Getch())); }
 
#define XBeeCheckAndParse(_dev, _trans)
 
#define XBeePrintString(_dev, s)   TransportLink(_dev,PrintString(s))
 
#define XBeePrintHex16(_dev, x)   TransportLink(_dev,PrintHex16(x))
 

Functions

void xbee_init (void)
 
static void parse_xbee (struct xbee_transport *t, uint8_t c)
 Parsing a XBee API frame. More...
 
static void xbee_parse_payload (struct xbee_transport *t)
 Parsing a frame data and copy the payload to the datalink buffer. More...
 

Variables

uint8_t xbee_cs
 
uint8_t xbee_rssi
 
struct xbee_transport xbee_tp
 

Macro Definition Documentation

#define GROUND_STATION_ADDR   0x100

Ground station address.

Definition at line 46 of file xbee.h.

#define NO_FRAME_ID   0

Definition at line 43 of file xbee.h.

#define ReadXBeeBuffer (   _dev,
  _trans 
)    { while (TransportLink(_dev,ChAvailable())&&!(_trans.trans.msg_received)) parse_xbee(&(_trans),TransportLink(_dev,Getch())); }

Definition at line 224 of file xbee.h.

#define TX_OPTIONS   0x00

Definition at line 42 of file xbee.h.

#define XBEE_GOT_LENGTH_LSB   3

Definition at line 148 of file xbee.h.

Referenced by parse_xbee().

#define XBEE_GOT_LENGTH_MSB   2

Definition at line 147 of file xbee.h.

Referenced by parse_xbee().

#define XBEE_GOT_PAYLOAD   4

Definition at line 149 of file xbee.h.

Referenced by parse_xbee().

#define XBEE_GOT_START   1

Definition at line 146 of file xbee.h.

Referenced by parse_xbee().

#define XBEE_MY_ADDR   AC_ID

Initialisation in API mode and setting of the local address FIXME: busy wait.

Definition at line 53 of file xbee.h.

Referenced by xbee_init().

#define XBEE_START   0x7e

Constants for the API protocol.

Definition at line 41 of file xbee.h.

Referenced by parse_xbee().

#define XBEE_UNINIT   0

Status of the API packet receiver automata.

Definition at line 145 of file xbee.h.

Referenced by parse_xbee(), and xbee_init().

#define XBeeAPISizeOf (   _dev,
  _x 
)    (_x+5)

Definition at line 57 of file xbee.h.

#define XBeeBuffer (   _dev)    TransportLink(_dev,ChAvailable())

Definition at line 223 of file xbee.h.

#define XBeeCheckAndParse (   _dev,
  _trans 
)
Value:
{ \
if (XBeeBuffer(_dev)) { \
ReadXBeeBuffer(_dev,_trans); \
if (_trans.trans.msg_received) { \
xbee_parse_payload(&(_trans)); \
_trans.trans.msg_received = FALSE; \
} \
} \
}
#define XBeeBuffer(_dev)
Definition: xbee.h:223
#define ReadXBeeBuffer(_dev, _trans)
Definition: xbee.h:224
#define FALSE
Definition: imu_chimu.h:141
static void xbee_parse_payload(struct xbee_transport *t)
Parsing a frame data and copy the payload to the datalink buffer.
Definition: xbee.h:208

Definition at line 225 of file xbee.h.

#define XBeePrintHex16 (   _dev,
 
)    TransportLink(_dev,PrintHex16(x))

Definition at line 236 of file xbee.h.

Referenced by xbee_init().

#define XBeePrintString (   _dev,
 
)    TransportLink(_dev,PrintString(s))

Definition at line 235 of file xbee.h.

Referenced by xbee_init().

#define XBeeTransportCheckFreeSpace (   _dev,
 
)    TransportLink(_dev, CheckFreeSpace(x))

Definition at line 59 of file xbee.h.

#define XBeeTransportHeader (   _dev,
  _len 
)
Value:
{ \
uint8_t payload_len = XBeeAPISizeOf(_dev, _len); \
XBeeTransportPut2Bytes(_dev, payload_len); \
xbee_cs = 0; \
}
#define XBeeTransportPut2Bytes(_dev, _x)
Definition: xbee.h:73
uint8_t xbee_cs
Definition: xbee.c:33
#define XBeeTransportPutTXHeader(_dev)
Definition: xbee24.h:34
#define XBeeTransportPut1Byte(_dev, x)
Definition: xbee.h:60
#define XBEE_START
Constants for the API protocol.
Definition: xbee.h:41
unsigned char uint8_t
Definition: types.h:14
#define XBeeAPISizeOf(_dev, _x)
Definition: xbee.h:57

Definition at line 128 of file xbee.h.

#define XBeeTransportPut1Byte (   _dev,
 
)    TransportLink(_dev, Transmit(x))

Definition at line 60 of file xbee.h.

#define XBeeTransportPut1ByteByAddr (   _dev,
  _byte 
)
Value:
{ \
uint8_t _x = *(_byte); \
}
unsigned char uint8_t
Definition: types.h:14
#define XBeeTransportPutUint8(_dev, _x)
Definition: xbee.h:63

Definition at line 68 of file xbee.h.

#define XBeeTransportPut2ByteByAddr (   _dev,
  _byte 
)
Value:
{ \
XBeeTransportPut1ByteByAddr(_dev, (const uint8_t*)_byte+1); \
}
#define XBeeTransportPut1ByteByAddr(_dev, _byte)
Definition: xbee.h:68
unsigned char uint8_t
Definition: types.h:14

Definition at line 79 of file xbee.h.

#define XBeeTransportPut2Bytes (   _dev,
  _x 
)
Value:
{ \
uint16_t x16 = _x; \
XBeeTransportPut1Byte(_dev, x16>>8); \
XBeeTransportPut1Byte(_dev, x16 & 0xff); \
}
unsigned short uint16_t
Definition: types.h:16
#define XBeeTransportPut1Byte(_dev, x)
Definition: xbee.h:60

Definition at line 73 of file xbee.h.

#define XBeeTransportPut4ByteByAddr (   _dev,
  _byte 
)
Value:
{ \
XBeeTransportPut2ByteByAddr(_dev, (const uint8_t*)_byte+2); \
}
unsigned char uint8_t
Definition: types.h:14
#define XBeeTransportPut2ByteByAddr(_dev, _byte)
Definition: xbee.h:79

Definition at line 84 of file xbee.h.

#define XBeeTransportPutArray (   _dev,
  _put,
  _n,
  _x 
)
Value:
{ \
for(_i = 0; _i < _n; _i++) { \
_put(_dev, &_x[_i]); \
} \
}
unsigned char uint8_t
Definition: types.h:14
#define XBeeTransportPutUint8(_dev, _x)
Definition: xbee.h:63

Definition at line 111 of file xbee.h.

#define XBeeTransportPutDoubleArray (   _dev,
  _n,
  _x 
)    XBeeTransportPutArray(_dev, XBeeTransportPutDoubleByAddr, _n, _x)

Definition at line 124 of file xbee.h.

#define XBeeTransportPutDoubleByAddr (   _dev,
  _byte 
)
Value:
{ \
XBeeTransportPut4ByteByAddr(_dev, (const uint8_t*)_byte); \
XBeeTransportPut4ByteByAddr(_dev, (const uint8_t*)_byte+4); \
}
#define XBeeTransportPut4ByteByAddr(_dev, _byte)
Definition: xbee.h:84
unsigned char uint8_t
Definition: types.h:14

Definition at line 95 of file xbee.h.

#define XBeeTransportPutFloatArray (   _dev,
  _n,
  _x 
)    XBeeTransportPutArray(_dev, XBeeTransportPutFloatByAddr, _n, _x)

Definition at line 123 of file xbee.h.

#define XBeeTransportPutFloatByAddr (   _dev,
  _x 
)    XBeeTransportPut4ByteByAddr(_dev, (const uint8_t*)_x)

Definition at line 108 of file xbee.h.

#define XBeeTransportPutInt16Array (   _dev,
  _n,
  _x 
)    XBeeTransportPutArray(_dev, XBeeTransportPutInt16ByAddr, _n, _x)

Definition at line 119 of file xbee.h.

#define XBeeTransportPutInt16ByAddr (   _dev,
  _x 
)    XBeeTransportPut2ByteByAddr(_dev, (const uint8_t*)_x)

Definition at line 104 of file xbee.h.

#define XBeeTransportPutInt32ByAddr (   _dev,
  _x 
)    XBeeTransportPut4ByteByAddr(_dev, (const uint8_t*)_x)

Definition at line 106 of file xbee.h.

#define XBeeTransportPutInt8ByAddr (   _dev,
  _x 
)    XBeeTransportPut1ByteByAddr(_dev, _x)

Definition at line 102 of file xbee.h.

#define XBeeTransportPutNamedUint8 (   _dev,
  _name,
  _byte 
)    XBeeTransportPutUint8(_dev, _byte)

Definition at line 109 of file xbee.h.

#define XBeeTransportPutUint16Array (   _dev,
  _n,
  _x 
)    XBeeTransportPutArray(_dev, XBeeTransportPutUint16ByAddr, _n, _x)

Definition at line 121 of file xbee.h.

#define XBeeTransportPutUint16ByAddr (   _dev,
  _x 
)    XBeeTransportPut2ByteByAddr(_dev, (const uint8_t*)_x)

Definition at line 105 of file xbee.h.

#define XBeeTransportPutUint32ByAddr (   _dev,
  _x 
)    XBeeTransportPut4ByteByAddr(_dev, (const uint8_t*)_x)

Definition at line 107 of file xbee.h.

#define XBeeTransportPutUint8 (   _dev,
  _x 
)
Value:
{ \
xbee_cs += _x; \
}
uint8_t xbee_cs
Definition: xbee.c:33
#define XBeeTransportPut1Byte(_dev, x)
Definition: xbee.h:60

Definition at line 63 of file xbee.h.

#define XBeeTransportPutUint8Array (   _dev,
  _n,
  _x 
)    XBeeTransportPutArray(_dev, XBeeTransportPutUint8ByAddr, _n, _x)

Definition at line 122 of file xbee.h.

#define XBeeTransportPutUint8ByAddr (   _dev,
  _x 
)    XBeeTransportPut1ByteByAddr(_dev, (const uint8_t*)_x)

Definition at line 103 of file xbee.h.

#define XBeeTransportSendMessage (   _dev)    TransportLink(_dev, SendMessage())

Definition at line 61 of file xbee.h.

#define XBeeTransportTrailer (   _dev)
Value:
{ \
xbee_cs = 0xff - xbee_cs; \
}
uint8_t xbee_cs
Definition: xbee.c:33
#define XBeeTransportPut1Byte(_dev, x)
Definition: xbee.h:60
#define XBeeTransportSendMessage(_dev)
Definition: xbee.h:61

Definition at line 136 of file xbee.h.

Function Documentation

void xbee_init ( void  )
  • busy wait 1.25s

Switching to AT mode (FIXME: busy waiting)

  • busy wait 1.25s

Setting my address

Switching back to normal mode

Definition at line 47 of file xbee.c.

References AT_AP_MODE, AT_COMMAND_SEQUENCE, AT_EXIT, AT_SET_MY, FALSE, transport::msg_received, xbee_transport::status, sys_time_usleep(), xbee_transport::trans, XBEE_MY_ADDR, xbee_tp, XBEE_UNINIT, XBeePrintHex16, and XBeePrintString.

Referenced by init_ap(), and main_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void xbee_parse_payload ( struct xbee_transport t)
inlinestatic

Parsing a frame data and copy the payload to the datalink buffer.

Definition at line 208 of file xbee.h.

References dl_msg_available, transport::payload, transport::payload_len, xbee_transport::trans, TRUE, XBEE_RFDATA_OFFSET, XBEE_RX_ID, XBEE_TX_ID, and XbeeGetRSSI.

Variable Documentation

uint8_t xbee_cs

Definition at line 33 of file xbee.c.

uint8_t xbee_rssi

Definition at line 34 of file xbee.c.

struct xbee_transport xbee_tp

Definition at line 36 of file xbee.c.

Referenced by xbee_init().