Paparazzi UAS  v5.12_stable-4-g9b43e9b
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 #ifndef XBEE_TYPE
34 #define XBEE_TYPE XBEE_24
35 #endif
36 #ifndef XBEE_INIT
37 #define XBEE_INIT ""
38 #endif
39 
40 struct xbee_transport xbee_tp;
41 
42 void xbee_dl_init(void)
43 {
44 #if USE_HARD_FAULT_RECOVERY
45  if (recovering_from_hard_fault)
46  // in case of hardfault recovery, we want to skip xbee init which as an active wait
47  xbee_transport_init(&xbee_tp, &((XBEE_UART).device), AC_ID, XBEE_TYPE, XBEE_BAUD, NULL, XBEE_INIT);
48  else
49 #endif
50  xbee_transport_init(&xbee_tp, &((XBEE_UART).device), AC_ID, XBEE_TYPE, XBEE_BAUD, sys_time_usleep, XBEE_INIT);
51 }
52 
53 void xbee_dl_event(void)
54 {
55  xbee_check_and_parse(&(XBEE_UART).device, &xbee_tp, dl_buffer, &dl_msg_available);
56  DlCheckAndParse(&(XBEE_UART).device, &xbee_tp.trans_tx, dl_buffer, &dl_msg_available);
57 }
58 
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
#define XBEE_TYPE
Definition: xbee_dl.c:34
bool dl_msg_available
Definition: main_demo5.c:61
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:37
struct xbee_transport xbee_tp
XBEE transport structure.
Definition: xbee_dl.c:40
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:42
void xbee_dl_event(void)
Datalink Event.
Definition: xbee_dl.c:53