868MHz module support

This commit is contained in:
Pascal Brisset
2009-05-07 08:05:29 +00:00
parent 9871fab6cf
commit 5c4f56b172
3 changed files with 118 additions and 22 deletions
+15 -22
View File
@@ -30,6 +30,17 @@
#include "datalink.h"
#include "airframe.h"
#ifdef XBEE868
#include "xbee868.h"
#else /* Not 868 */
#include "xbee24.h"
#endif
/** Constants for the API protocol */
#define XBEE_START 0x7e
#define TX_OPTIONS 0x00
#define NO_FRAME_ID 0
#define GROUND_STATION_ADDR 0x100
extern uint8_t xbee_cs;
@@ -59,8 +70,6 @@ void xbee_init( void );
#define XBeeTransportCheckFreeSpace(x) XBeeLink(CheckFreeSpace(x))
/* 5 = Start + len_msb + len_lsb + API_id + checksum */
#define XBeeAPISizeOf(_x) (_x+5)
/* 4 = frame_id + addr_msb + addr_lsb + options */
#define XBeeTransportSizeOf(_x) XBeeAPISizeOf(_x+4)
#define XBeeTransportSendMessage() XBeeLink(SendMessage())
#define XBeeTransportPutUint8(_x) { \
@@ -113,29 +122,13 @@ void xbee_init( void );
#define XBeeTransportPutUint8Array(_n, _x) XBeeTransportPutArray(XBeeTransportPutUint8ByAddr, _n, _x)
/** Constants for the API protocol */
#define XBEE_START 0x7e
#define XBEE_TX16_ID 0x01
#define TX16_OPTIONS 0x00
#define NO_FRAME_ID 0
#define XBEE_RFDATA_OFFSET 5
#define XBEE_RX16_ID 0x81
#define XBeeTransportPutTX16Header() { \
XBeeTransportPutUint8(XBEE_TX16_ID); \
XBeeTransportPutUint8(NO_FRAME_ID); \
XBeeTransportPutUint8(GROUND_STATION_ADDR >> 8); \
XBeeTransportPutUint8(GROUND_STATION_ADDR & 0xff); \
XBeeTransportPutUint8(TX16_OPTIONS); \
}
#define XBeeTransportHeader(_len) { \
XBeeTransportPut1Byte(XBEE_START); \
uint8_t payload_len = XBeeAPISizeOf(_len); \
XBeeTransportPut2Bytes(payload_len); \
xbee_cs = 0; \
XBeeTransportPutTX16Header(); \
XBeeTransportPutTXHeader(); \
}
#define XBeeTransportTrailer() { \
@@ -202,9 +195,9 @@ static inline void parse_xbee( uint8_t c ) {
/** Parsing a frame data and copy the payload to the datalink buffer */
static inline void xbee_parse_payload(void) {
switch (xbee_payload[0]) {
case XBEE_RX16_ID:
case XBEE_TX16_ID: /* Useful if A/C is connected to the PC with a cable */
xbee_rssi = xbee_payload[3];
case XBEE_RX_ID:
case XBEE_TX_ID: /* Useful if A/C is connected to the PC with a cable */
XbeeGetRSSI();
uint8_t i;
for(i = XBEE_RFDATA_OFFSET; i < xbee_payload_len; i++)
dl_buffer[i-XBEE_RFDATA_OFFSET] = xbee_payload[i];
+47
View File
@@ -0,0 +1,47 @@
/*
* $Id$
*
* Copyright (C) 2009 ENAC, Pascal Brisset
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
/* Configuration for 2.4GHz "series 1" and 900MHz modules */
#ifndef XBEE24_H
#define XBEE24_H
#define XBEE_TX_ID 0x01 /* 16 bits address */
#define XBEE_RX_ID 0x81 /* 16 bits address */
#define XBEE_RFDATA_OFFSET 5
#define XBeeTransportPutTXHeader() { \
XBeeTransportPutUint8(XBEE_TX_ID); \
XBeeTransportPutUint8(NO_FRAME_ID); \
XBeeTransportPutUint8(GROUND_STATION_ADDR >> 8); \
XBeeTransportPutUint8(GROUND_STATION_ADDR & 0xff); \
XBeeTransportPutUint8(TX_OPTIONS); \
}
/* 4 = frame_id + addr_msb + addr_lsb + options */
#define XBeeTransportSizeOf(_x) XBeeAPISizeOf(_x+4)
#define XbeeGetRSSI() { xbee_rssi = xbee_payload[3]; }
#endif // XBEE24_H
+56
View File
@@ -0,0 +1,56 @@
/*
* $Id$
*
* Copyright (C) 2009 ENAC, Pascal Brisset
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
/* Configuration for 868MHz modules */
#ifndef XBEE868_H
#define XBEE868_H
#define XBEE_TX_ID 0x10
#define XBEE_RX_ID 0x90
#define XBEE_RFDATA_OFFSET 12
#define XBeeTransportPutTXHeader() { \
XBeeTransportPutUint8(XBEE_TX_ID); \
XBeeTransportPutUint8(NO_FRAME_ID); \
XBeeTransportPutUint8(0x00); \
XBeeTransportPutUint8(0x00); \
XBeeTransportPutUint8(0x00); \
XBeeTransportPutUint8(0x00); \
XBeeTransportPutUint8(0x00); \
XBeeTransportPutUint8(0x00); \
XBeeTransportPutUint8(GROUND_STATION_ADDR >> 8); \
XBeeTransportPutUint8(GROUND_STATION_ADDR & 0xff); \
XBeeTransportPutUint8(0xff); \
XBeeTransportPutUint8(0xfe); \
XBeeTransportPutUint8(0x00); \
XBeeTransportPutUint8(TX_OPTIONS); \
}
/* 13 = frame_id + addr==8 + 3 + options */
#define XBeeTransportSizeOf(_x) XBeeAPISizeOf(_x+13)
#define XbeeGetRSSI() {}
#endif // XBEE868_H