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
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 #include "std.h"
37 #include "pprzlink/dl_protocol.h"
38 
40 #define PPRZ 1
41 #define XBEE 2
42 #define SUPERBITRF 3
43 #define W5100 4
44 #define BLUEGIGA 5
45 
48 
51 
54 
55 #define MSG_SIZE 256
56 EXTERN uint8_t dl_buffer[MSG_SIZE] __attribute__((aligned));
57 
59 EXTERN void dl_parse_msg(struct link_device *dev, struct transport_tx *trans, uint8_t *buf);
60 
62 EXTERN void firmware_parse_msg(struct link_device *dev, struct transport_tx *trans, uint8_t *buf);
63 
64 #if USE_NPS
65 EXTERN bool datalink_enabled;
66 #endif
67 
69 #define DatalinkFillDlBuffer(_buf, _len) { \
70  uint8_t _i = 0; \
71  for (_i = 0; _i < _len; _i++) { \
72  dl_buffer[_i] = _buf[_i]; \
73  } \
74  dl_msg_available = true; \
75 }
76 
78 static inline void DlCheckAndParse(struct link_device *dev, struct transport_tx *trans, uint8_t *buf, bool *msg_available)
79 {
80  // make it possible to disable datalink in NPS sim
81 #if USE_NPS
82  if (!datalink_enabled) {
83  return;
84  }
85 #endif
86 
87  if (*msg_available) {
88  datalink_time = 0;
90  dl_parse_msg(dev, trans, buf);
91  *msg_available = false;
92  }
93 }
94 
95 #endif /* DATALINK_H */
unsigned short uint16_t
Definition: types.h:16
static const struct usb_device_descriptor dev
Definition: usb_ser_hw.c:73
unsigned char uint8_t
Definition: types.h:14