Paparazzi UAS  v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
datalink.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005 Pascal Brisset, Antoine Drouin
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  */
27 #ifndef DATALINK_H
28 #define DATALINK_H
29 
30 #ifdef DATALINK_C
31 #define EXTERN
32 #else
33 #define EXTERN extern
34 #endif
35 
36 #ifdef __IEEE_BIG_ENDIAN /* From machine/ieeefp.h */
37 #define Swap32IfBigEndian(_u) { _u = (_u << 32) | (_u >> 32); }
38 #else
39 #define Swap32IfBigEndian(_) {}
40 #endif
41 
42 #include "std.h"
43 #include "dl_protocol.h"
44 
46 #define PPRZ 1
47 #define XBEE 2
48 #define SUPERBITRF 3
49 #define W5100 4
50 #define BLUEGIGA 5
51 
54 
57 
60 
61 #define MSG_SIZE 128
62 EXTERN uint8_t dl_buffer[MSG_SIZE] __attribute__((aligned));
63 
65 EXTERN void dl_parse_msg(void);
66 
67 #if USE_NPS
68 EXTERN bool_t datalink_enabled;
69 #endif
70 
72 static inline void DlCheckAndParse(void)
73 {
74  // make it possible to disable datalink in NPS sim
75 #if USE_NPS
76  if (!datalink_enabled) {
77  return;
78  }
79 #endif
80 
81  if (dl_msg_available) {
82  datalink_time = 0;
84  dl_parse_msg();
86  }
87 }
88 
89 #if defined DATALINK && DATALINK == PPRZ
90 
91 #define DatalinkEvent() { \
92  PprzCheckAndParse(PPRZ_UART, pprz_tp); \
93  DlCheckAndParse(); \
94  }
95 
96 #elif defined DATALINK && DATALINK == XBEE
97 
98 #define DatalinkEvent() { \
99  XBeeCheckAndParse(XBEE_UART, xbee_tp); \
100  DlCheckAndParse(); \
101  }
102 
103 #elif defined DATALINK && DATALINK == W5100
104 
105 #define DatalinkEvent() { \
106  W5100CheckAndParse(W5100, pprz_tp); \
107  DlCheckAndParse(); \
108  }
109 
110 #elif defined DATALINK && DATALINK == SUPERBITRF
111 
112 #define DatalinkEvent() { \
113  SuperbitRFCheckAndParse(); \
114  DlCheckAndParse(); \
115  }
116 
117 #elif defined DATALINK && DATALINK == BLUEGIGA
118 
119 #define DatalinkEvent() { \
120  BlueGigaCheckAndParse(DOWNLINK_DEVICE, pprz_tp); \
121  DlCheckAndParse(); \
122  }
123 
124 #else
125 
126 // Unknown DATALINK
127 #define DatalinkEvent() {}
128 
129 #endif /* DATALINK == */
130 
131 #endif /* DATALINK_H */
unsigned short uint16_t
Definition: types.h:16
#define FALSE
Definition: std.h:5
unsigned char uint8_t
Definition: types.h:14