Paparazzi UAS  v5.15_devel-230-gc96ce27
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
xsens_parser.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 
27 #ifndef XSENS_PARSER_H
28 #define XSENS_PARSER_H
29 
30 #include "std.h"
31 
33 #include "xsens_protocol.h"
34 
35 #define XSENS_MAX_PAYLOAD 254
36 
37 // Status
38 #define UNINIT 0
39 #define GOT_START 1
40 #define GOT_BID 2
41 #define GOT_MID 3
42 #define GOT_LEN 4
43 #define GOT_DATA 5
44 #define GOT_CHECKSUM 6
45 
46 struct XsensParser {
54 };
55 
56 
57 // Only 1 send allowed at the same time:
58 extern uint8_t send_ck;
59 
60 #define XsensLinkDevice (&((XSENS_LINK).device))
61 
62 #define XsensInitCheksum() { send_ck = 0; }
63 #define XsensUpdateChecksum(c) { send_ck += c; }
64 
65 #define XsensUartSend1(c) XsensLinkDevice->put_byte(XsensLinkDevice->periph, 0, c)
66 #define XsensSend1(c) { uint8_t i8=c; XsensUartSend1(i8); XsensUpdateChecksum(i8); }
67 #define XsensSend1ByAddr(x) { XsensSend1(*x); }
68 #define XsensSend2ByAddr(x) { XsensSend1(*(x+1)); XsensSend1(*x); }
69 #define XsensSend4ByAddr(x) { XsensSend1(*(x+3)); XsensSend1(*(x+2)); XsensSend1(*(x+1)); XsensSend1(*x); }
70 
71 #define XsensHeader(msg_id, len) { \
72  XsensUartSend1(XSENS_START); \
73  XsensInitCheksum(); \
74  XsensSend1(XSENS_BID); \
75  XsensSend1(msg_id); \
76  XsensSend1(len); \
77  }
78 #define XsensTrailer() { uint8_t i8=0x100-send_ck; XsensUartSend1(i8); }
79 
80 
81 extern void xsens_parser_event(struct XsensParser *xsensparser);
82 
83 #endif /* XSENS_PARSER_H */
uint8_t len
Definition: xsens_parser.h:50
void xsens_parser_event(struct XsensParser *xsensparser)
Definition: xsens_parser.c:35
uint8_t send_ck
Definition: xsens_parser.c:31
volatile uint8_t msg_received
Definition: xsens_parser.h:47
uint8_t status
Definition: xsens_parser.h:49
uint8_t id
Definition: xsens_parser.h:48
uint8_t ck
Definition: xsens_parser.h:52
uint8_t msg_buf[XSENS_MAX_PAYLOAD]
Definition: xsens_parser.h:53
unsigned char uint8_t
Definition: types.h:14
uint8_t msg_idx
Definition: xsens_parser.h:51
#define XSENS_MAX_PAYLOAD
Includes macros generated from xsens_MTi-G.xml.
Definition: xsens_parser.h:35