Paparazzi UAS  v5.15_devel-50-g4d7045d
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
mavlink.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Freek van Tienen <freek.v.tienen@gmail.com>
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, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
22 
27 #ifndef DATALINK_MAVLINK_H
28 #define DATALINK_MAVLINK_H
29 
30 #define MAVLINK_USE_CONVENIENCE_FUNCTIONS
31 #define MAVLINK_ALIGNED_FIELDS 0
32 
33 #include <mavlink/mavlink_types.h>
34 
35 #if USE_UDP
36 #include "mcu_periph/udp.h"
37 #endif
38 #if USE_USB_SERIAL
39 #include "mcu_periph/usb_serial.h"
40 #endif
41 #include "mcu_periph/uart.h"
42 
43 #ifndef MAVLINK_DEBUG
44 #define MAVLINK_DEBUG(...) {}
45 #endif
46 
47 #if MAVLINK_DEBUG == printf
48 #include <stdio.h>
49 #endif
50 
51 /*
52  * MAVLink description before main MAVLink include
53  */
54 extern mavlink_system_t mavlink_system;
55 
56 #ifndef MAVLINK_DEV
57 #define MAVLINK_DEV uart1
58 #endif
59 
60 /*
61  * The MAVLink link description
62  */
63 #define MAVLinkDev (&(MAVLINK_DEV).device)
64 #define MAVLinkTransmit(c) MAVLinkDev->put_byte(MAVLinkDev->periph, 0, c)
65 #define MAVLinkChAvailable() MAVLinkDev->char_available(MAVLinkDev->periph)
66 #define MAVLinkGetch() MAVLinkDev->get_byte(MAVLinkDev->periph)
67 #define MAVLinkSendMessage() MAVLinkDev->send_message(MAVLinkDev->periph, 0)
68 
72 void mavlink_init(void);
73 void mavlink_periodic(void);
75 void mavlink_event(void);
76 
83 static inline void comm_send_ch(mavlink_channel_t chan __attribute__((unused)), uint8_t ch)
84 {
85  // Send bytes
86  MAVLinkTransmit(ch);
87 }
88 
89 #endif // DATALINK_MAVLINK_H
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
unsigned char uint8_t
Definition: types.h:14
arch independent UDP API
arch independent USB API