Paparazzi UAS  v5.14.0_stable-0-g3f680d1
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
xbee_dl.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Gautier Hattenberger <gautier.hattenberger@enac.fr>
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, see
18  * <http://www.gnu.org/licenses/>.
19  *
20  */
21 
28 #include "mcu.h"
29 #include "mcu_periph/sys_time.h"
30 #include "mcu_periph/uart.h"
31 #include "generated/airframe.h"
32 
33 #define STR_(s) #s
34 #define STR(s) STR_(s)
35 
36 #ifndef XBEE_TYPE
37 #define XBEE_TYPE XBEE_24
38 #endif
39 #ifndef XBEE_INIT
40 #define XBEE_INIT ""
41 #endif
42 
43 #ifdef XBEE_CHANNEL
44 #define XBEE_CHANNEL_CONF "ATCH" STR(XBEE_CHANNEL) "\r"
45 INFO("XBEE channel configured : " XBEE_CHANNEL_CONF)
46 #else
47 #define XBEE_CHANNEL_CONF ""
48 #endif
49 
50 #define CONCAT(a, b) a b
51 
52 struct xbee_transport xbee_tp;
53 
54 void xbee_dl_init(void)
55 {
56 #if USE_HARD_FAULT_RECOVERY
57  if (recovering_from_hard_fault)
58  // in case of hardfault recovery, we want to skip xbee init which as an active wait
59  xbee_transport_init(&xbee_tp, &((XBEE_UART).device), AC_ID, XBEE_TYPE, XBEE_BAUD, NULL, CONCAT(XBEE_INIT, XBEE_CHANNEL_CONF));
60  else
61 #endif
62  xbee_transport_init(&xbee_tp, &((XBEE_UART).device), AC_ID, XBEE_TYPE, XBEE_BAUD, sys_time_usleep, CONCAT(XBEE_INIT, XBEE_CHANNEL_CONF));
63 }
64 
65 void xbee_dl_event(void)
66 {
67  xbee_check_and_parse(&(XBEE_UART).device, &xbee_tp, dl_buffer, &dl_msg_available);
68  DlCheckAndParse(&(XBEE_UART).device, &xbee_tp.trans_tx, dl_buffer, &dl_msg_available);
69 }
70 
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
#define XBEE_TYPE
Definition: xbee_dl.c:37
bool dl_msg_available
Definition: main_demo5.c:61
#define CONCAT(a, b)
Definition: xbee_dl.c:50
#define XBEE_CHANNEL_CONF
Definition: xbee_dl.c:47
void sys_time_usleep(uint32_t us)
sys_time_usleep(uint32_t us)
Definition: sys_time_arch.c:95
Architecture independent timing functions.
#define XBEE_INIT
Definition: xbee_dl.c:40
struct xbee_transport xbee_tp
XBEE transport structure.
Definition: xbee_dl.c:52
Arch independent mcu ( Micro Controller Unit ) utilities.
Datalink using XBEE protocol.
uint8_t dl_buffer[MSG_SIZE]
Definition: main_demo5.c:64
void xbee_dl_init(void)
Init function.
Definition: xbee_dl.c:54
void xbee_dl_event(void)
Datalink Event.
Definition: xbee_dl.c:65