From 5c4f56b172430751ac831502fe1aa498d25d6f2f Mon Sep 17 00:00:00 2001 From: Pascal Brisset Date: Thu, 7 May 2009 08:05:29 +0000 Subject: [PATCH] 868MHz module support --- sw/airborne/xbee.h | 37 ++++++++++++---------------- sw/airborne/xbee24.h | 47 ++++++++++++++++++++++++++++++++++++ sw/airborne/xbee868.h | 56 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+), 22 deletions(-) create mode 100644 sw/airborne/xbee24.h create mode 100644 sw/airborne/xbee868.h diff --git a/sw/airborne/xbee.h b/sw/airborne/xbee.h index 2069c762d7..003d78693b 100644 --- a/sw/airborne/xbee.h +++ b/sw/airborne/xbee.h @@ -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]; diff --git a/sw/airborne/xbee24.h b/sw/airborne/xbee24.h new file mode 100644 index 0000000000..4bd3299af1 --- /dev/null +++ b/sw/airborne/xbee24.h @@ -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 diff --git a/sw/airborne/xbee868.h b/sw/airborne/xbee868.h new file mode 100644 index 0000000000..08e37063f8 --- /dev/null +++ b/sw/airborne/xbee868.h @@ -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