-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
ins_module.h
104 lines (83 loc) · 2.56 KB
/
ins_module.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* Copyright (C) 2003 Pascal Brisset, Antoine Drouin
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/** \file ins_module.h
* \brief Device independent INS code
*
*/
#ifndef INS_MODULE_H
#define INS_MODULE_H
#include "std.h"
#include "subsystems/ins.h"
#ifndef INS_FORMAT
#define INS_FORMAT float
#endif
extern INS_FORMAT ins_x;
extern INS_FORMAT ins_y;
extern INS_FORMAT ins_z;
extern INS_FORMAT ins_vx;
extern INS_FORMAT ins_vy;
extern INS_FORMAT ins_vz;
extern INS_FORMAT ins_phi;
extern INS_FORMAT ins_theta;
extern INS_FORMAT ins_psi;
extern INS_FORMAT ins_p;
extern INS_FORMAT ins_q;
extern INS_FORMAT ins_r;
extern INS_FORMAT ins_ax;
extern INS_FORMAT ins_ay;
extern INS_FORMAT ins_az;
extern INS_FORMAT ins_mx;
extern INS_FORMAT ins_my;
extern INS_FORMAT ins_mz;
#if USE_INS_MODULE
extern INS_FORMAT ins_roll_neutral;
extern INS_FORMAT ins_pitch_neutral;
#endif
extern volatile uint8_t ins_msg_received;
extern volatile uint8_t new_ins_attitude;
void handle_ins_msg(void);
void parse_ins_msg(void);
void parse_ins_buffer(uint8_t);
#include "mcu_periph/link_device.h"
#define InsLinkDevice (&((INS_LINK).device))
#ifndef SITL
#include "mcu_periph/uart.h"
#include "mcu_periph/spi.h"
#define InsSend1(c) InsLinkDevice->put_byte(InsLinkDevice->periph, c)
#define InsUartSend1(c) InsSend1(c)
#define InsSend(_dat,_len) { for (uint8_t i = 0; i< (_len); i++) InsSend1(_dat[i]); };
#define InsUartSetBaudrate(_b) uart_periph_set_baudrate(INS_LINK, _b)
#endif /** !SITL */
static inline void ins_event_check_and_handle(void (* handler)(void))
{
struct link_device *dev = InsLinkDevice;
if (dev->char_available(dev->periph)) {
while (dev->char_available(dev->periph) && !ins_msg_received) {
parse_ins_buffer(dev->get_byte(dev->periph));
}
}
if (ins_msg_received) {
parse_ins_msg();
handler();
ins_msg_received = FALSE;
}
}
#endif /* INS_MODULE_H */