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.c
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Copyright (C) 2006 Pascal Brisset, Antoine Drouin
5  *
6  * This file is part of paparazzi.
7  *
8  * paparazzi is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * paparazzi is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with paparazzi; see the file COPYING. If not, write to
20  * the Free Software Foundation, 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  *
23  */
24 
25 #include "mcu_periph/sys_time.h"
26 #include "print.h"
28 
29 #ifdef SIM_UART
30 #include "sim_uart.h"
31 #endif
32 
35 
37 
38 #define AT_COMMAND_SEQUENCE "+++"
39 #define AT_INIT_PERIOD_US 2000000
40 #define AT_SET_MY "ATMY"
41 #define AT_AP_MODE "ATAP1\r"
42 #define AT_EXIT "ATCN\r"
43 
45 
46 
47 void xbee_init( void ) {
50 
51 #ifndef NO_XBEE_API_INIT
52 
53  sys_time_usleep(1250000);
54 
57 
59  sys_time_usleep(1250000);
60 
62  XBeePrintString(XBEE_UART,AT_SET_MY);
63  uint16_t addr = XBEE_MY_ADDR;
64  XBeePrintHex16(XBEE_UART,addr);
65  XBeePrintString(XBEE_UART,"\r");
66 
67  XBeePrintString(XBEE_UART,AT_AP_MODE);
68 
69 #ifdef XBEE_INIT
70  XBeePrintString(XBEE_UART,XBEE_INIT);
71 #endif
72 
74  XBeePrintString(XBEE_UART,AT_EXIT);
75 #endif
76 }
unsigned short uint16_t
Definition: types.h:16
#define XBEE_MY_ADDR
Initialisation in API mode and setting of the local address FIXME: busy wait.
Definition: xbee.h:53
uint8_t xbee_cs
Definition: xbee.c:33
static void sys_time_usleep(uint32_t us)
Busy wait, in microseconds.
Definition: sys_time_arch.h:79
uint8_t xbee_rssi
Definition: xbee.c:34
#define AT_COMMAND_SEQUENCE
Definition: xbee.c:38
#define XBeePrintString(_dev, s)
Definition: xbee.h:235
struct xbee_transport xbee_tp
Definition: xbee.c:36
uint8_t status
Definition: xbee.h:155
#define XBeePrintHex16(_dev, x)
Definition: xbee.h:236
Simulation of uart transmission on an Unix pipe.
uint32_t xbee_delay_time
Definition: xbee.c:44
#define FALSE
Definition: imu_chimu.h:141
#define AT_AP_MODE
Definition: xbee.c:41
Architecture independent timing functions.
unsigned long uint32_t
Definition: types.h:18
#define XBEE_UNINIT
Status of the API packet receiver automata.
Definition: xbee.h:145
#define AT_EXIT
Definition: xbee.c:42
unsigned char uint8_t
Definition: types.h:14
volatile bool_t msg_received
Definition: transport.h:45
#define AT_SET_MY
Definition: xbee.c:40
void xbee_init(void)
Definition: xbee.c:47
struct transport trans
Definition: xbee.h:153