Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
imu_navstik.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Freek van Tienen <freek.v.tienen@gmail.com>
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 
28 #ifndef IMU_NAVSTIK_H
29 #define IMU_NAVSTIK_H
30 
31 #include "generated/airframe.h"
32 #include "subsystems/imu.h"
33 
34 #include "peripherals/hmc58xx.h"
36 
37 /* Defaults */
38 #if !defined IMU_MAG_X_SIGN & !defined IMU_MAG_Y_SIGN & !defined IMU_MAG_Z_SIGN
39 #define IMU_MAG_X_SIGN 1
40 #define IMU_MAG_Y_SIGN 1
41 #define IMU_MAG_Z_SIGN 1
42 #endif
43 #if !defined IMU_GYRO_P_SIGN & !defined IMU_GYRO_Q_SIGN & !defined IMU_GYRO_R_SIGN
44 #define IMU_GYRO_P_SIGN 1
45 #define IMU_GYRO_Q_SIGN 1
46 #define IMU_GYRO_R_SIGN 1
47 #endif
48 #if !defined IMU_ACCEL_X_SIGN & !defined IMU_ACCEL_Y_SIGN & !defined IMU_ACCEL_Z_SIGN
49 #define IMU_ACCEL_X_SIGN 1
50 #define IMU_ACCEL_Y_SIGN 1
51 #define IMU_ACCEL_Z_SIGN 1
52 #endif
53 
59 #if !defined IMU_GYRO_P_SENS & !defined IMU_GYRO_Q_SENS & !defined IMU_GYRO_R_SENS
60 // FIXME
61 #define IMU_GYRO_P_SENS 2.17953
62 #define IMU_GYRO_P_SENS_NUM 18271
63 #define IMU_GYRO_P_SENS_DEN 8383
64 #define IMU_GYRO_Q_SENS 2.17953
65 #define IMU_GYRO_Q_SENS_NUM 18271
66 #define IMU_GYRO_Q_SENS_DEN 8383
67 #define IMU_GYRO_R_SENS 2.17953
68 #define IMU_GYRO_R_SENS_NUM 18271
69 #define IMU_GYRO_R_SENS_DEN 8383
70 #endif
71 #if !defined IMU_GYRO_P_NEUTRAL & !defined IMU_GYRO_Q_NEUTRAL & !defined IMU_GYRO_R_NEUTRAL
72 #define IMU_GYRO_P_NEUTRAL 0
73 #define IMU_GYRO_Q_NEUTRAL 0
74 #define IMU_GYRO_R_NEUTRAL 0
75 #endif
76 
81 #if !defined IMU_ACCEL_X_SENS & !defined IMU_ACCEL_Y_SENS & !defined IMU_ACCEL_Z_SENS
82 // FIXME
83 #define IMU_ACCEL_X_SENS 2.4525
84 #define IMU_ACCEL_X_SENS_NUM 981
85 #define IMU_ACCEL_X_SENS_DEN 400
86 #define IMU_ACCEL_Y_SENS 2.4525
87 #define IMU_ACCEL_Y_SENS_NUM 981
88 #define IMU_ACCEL_Y_SENS_DEN 400
89 #define IMU_ACCEL_Z_SENS 2.4525
90 #define IMU_ACCEL_Z_SENS_NUM 981
91 #define IMU_ACCEL_Z_SENS_DEN 400
92 #endif
93 #if !defined IMU_ACCEL_X_NEUTRAL & !defined IMU_ACCEL_Y_NEUTRAL & !defined IMU_ACCEL_Z_NEUTRAL
94 #define IMU_ACCEL_X_NEUTRAL 0
95 #define IMU_ACCEL_Y_NEUTRAL 0
96 #define IMU_ACCEL_Z_NEUTRAL 0
97 #endif
98 
99 
100 struct ImuNavstik {
102  volatile uint8_t gyro_valid;
103  volatile uint8_t mag_valid;
104  struct Mpu60x0_I2c mpu;
105  struct Hmc58xx hmc;
106 };
107 
108 extern struct ImuNavstik imu_navstik;
109 extern void imu_navstik_event(void);
110 
111 
112 static inline void ImuEvent(void (* _gyro_handler)(void), void (* _accel_handler)(void), void (* _mag_handler)(void)) {
114  if (imu_navstik.gyro_valid) {
116  _gyro_handler();
117  }
118  if (imu_navstik.accel_valid) {
120  _accel_handler();
121  }
122  if (imu_navstik.mag_valid) {
124  _mag_handler();
125  }
126 }
127 
128 #endif /* IMU_NAVSTIK_H */
struct Mpu60x0_I2c mpu
Definition: imu_navstik.h:104
struct Hmc58xx hmc
Definition: imu_navstik.h:105
#define FALSE
Definition: imu_chimu.h:141
volatile uint8_t mag_valid
Definition: imu_navstik.h:103
volatile uint8_t gyro_valid
Definition: imu_navstik.h:102
volatile uint8_t accel_valid
Definition: imu_navstik.h:101
Inertial Measurement Unit interface.
Driver for the MPU-60X0 using I2C.
unsigned char uint8_t
Definition: types.h:14
void imu_navstik_event(void)
Handle all the events of the Navstik IMU components.
Definition: imu_navstik.c:112
static void ImuEvent(void(*_gyro_handler)(void), void(*_accel_handler)(void), void(*_mag_handler)(void))
Definition: imu_navstik.h:112
struct ImuNavstik imu_navstik
Basic Navstik IMU data.
Definition: imu_navstik.c:73