Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
xsens_common.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2003 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 
26 #ifndef XSENS_COMMON_H
27 #define XSENS_COMMON_H
28 
29 #include "std.h"
30 
32 #include "xsens_protocol.h"
33 
34 extern uint8_t xsens_id;
35 extern uint8_t xsens_status;
36 extern uint8_t xsens_len;
37 extern uint8_t xsens_msg_idx;
38 extern uint8_t ck;
39 extern uint8_t send_ck;
40 
41 #define XsensLinkDevice (&((XSENS_LINK).device))
42 
43 #define XsensInitCheksum() { send_ck = 0; }
44 #define XsensUpdateChecksum(c) { send_ck += c; }
45 
46 #define XsensUartSend1(c) XsensLinkDevice->put_byte(XsensLinkDevice->periph, 0, c)
47 #define XsensSend1(c) { uint8_t i8=c; XsensUartSend1(i8); XsensUpdateChecksum(i8); }
48 #define XsensSend1ByAddr(x) { XsensSend1(*x); }
49 #define XsensSend2ByAddr(x) { XsensSend1(*(x+1)); XsensSend1(*x); }
50 #define XsensSend4ByAddr(x) { XsensSend1(*(x+3)); XsensSend1(*(x+2)); XsensSend1(*(x+1)); XsensSend1(*x); }
51 
52 #define XsensHeader(msg_id, len) { \
53  XsensUartSend1(XSENS_START); \
54  XsensInitCheksum(); \
55  XsensSend1(XSENS_BID); \
56  XsensSend1(msg_id); \
57  XsensSend1(len); \
58  }
59 #define XsensTrailer() { uint8_t i8=0x100-send_ck; XsensUartSend1(i8); }
60 
61 
62 #define XSENS_MAX_PAYLOAD 254
64 
65 #define UNINIT 0
66 #define GOT_START 1
67 #define GOT_BID 2
68 #define GOT_MID 3
69 #define GOT_LEN 4
70 #define GOT_DATA 5
71 #define GOT_CHECKSUM 6
72 
73 extern void xsens_event(void);
74 
75 #endif /* XSENS_COMMON_H */
uint8_t send_ck
Definition: xsens_common.c:38
#define XSENS_MAX_PAYLOAD
Definition: xsens_common.h:62
uint8_t xsens_id
Includes macros generated from xsens_MTi-G.xml.
Definition: xsens_common.c:33
uint8_t xsens_status
Definition: xsens_common.c:34
uint8_t xsens_len
Definition: xsens_common.c:35
uint8_t ck
Definition: xsens_common.c:37
uint8_t xsens_msg_idx
Definition: xsens_common.c:36
unsigned char uint8_t
Definition: types.h:14
uint8_t xsens_msg_buf[XSENS_MAX_PAYLOAD]
Definition: xsens_common.c:40
void xsens_event(void)
Definition: xsens_common.c:44