Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
imu_drotek_10dof_v2.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Felix Ruess <felix.ruess@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 
29 #ifndef IMU_DROTEK_10DOF_V2_H
30 #define IMU_DROTEK_10DOF_V2_H
31 
32 #include "std.h"
33 #include "generated/airframe.h"
34 #include "subsystems/imu.h"
35 
37 #include "peripherals/hmc58xx.h"
38 
39 
40 #if !defined IMU_MAG_X_SIGN & !defined IMU_MAG_Y_SIGN & !defined IMU_MAG_Z_SIGN
41 #define IMU_MAG_X_SIGN 1
42 #define IMU_MAG_Y_SIGN 1
43 #define IMU_MAG_Z_SIGN 1
44 #endif
45 #if !defined IMU_GYRO_P_SIGN & !defined IMU_GYRO_Q_SIGN & !defined IMU_GYRO_R_SIGN
46 #define IMU_GYRO_P_SIGN 1
47 #define IMU_GYRO_Q_SIGN 1
48 #define IMU_GYRO_R_SIGN 1
49 #endif
50 #if !defined IMU_ACCEL_X_SIGN & !defined IMU_ACCEL_Y_SIGN & !defined IMU_ACCEL_Z_SIGN
51 #define IMU_ACCEL_X_SIGN 1
52 #define IMU_ACCEL_Y_SIGN 1
53 #define IMU_ACCEL_Z_SIGN 1
54 #endif
55 
56 
62 #if !defined IMU_GYRO_P_SENS & !defined IMU_GYRO_Q_SENS & !defined IMU_GYRO_R_SENS
63 // FIXME
64 #define IMU_GYRO_P_SENS 2.17953
65 #define IMU_GYRO_P_SENS_NUM 18271
66 #define IMU_GYRO_P_SENS_DEN 8383
67 #define IMU_GYRO_Q_SENS 2.17953
68 #define IMU_GYRO_Q_SENS_NUM 18271
69 #define IMU_GYRO_Q_SENS_DEN 8383
70 #define IMU_GYRO_R_SENS 2.17953
71 #define IMU_GYRO_R_SENS_NUM 18271
72 #define IMU_GYRO_R_SENS_DEN 8383
73 #endif
74 #if !defined IMU_GYRO_P_NEUTRAL & !defined IMU_GYRO_Q_NEUTRAL & !defined IMU_GYRO_R_NEUTRAL
75 #define IMU_GYRO_P_NEUTRAL 0
76 #define IMU_GYRO_Q_NEUTRAL 0
77 #define IMU_GYRO_R_NEUTRAL 0
78 #endif
79 
84 #if !defined IMU_ACCEL_X_SENS & !defined IMU_ACCEL_Y_SENS & !defined IMU_ACCEL_Z_SENS
85 // FIXME
86 #define IMU_ACCEL_X_SENS 2.4525
87 #define IMU_ACCEL_X_SENS_NUM 981
88 #define IMU_ACCEL_X_SENS_DEN 400
89 #define IMU_ACCEL_Y_SENS 2.4525
90 #define IMU_ACCEL_Y_SENS_NUM 981
91 #define IMU_ACCEL_Y_SENS_DEN 400
92 #define IMU_ACCEL_Z_SENS 2.4525
93 #define IMU_ACCEL_Z_SENS_NUM 981
94 #define IMU_ACCEL_Z_SENS_DEN 400
95 #endif
96 #if !defined IMU_ACCEL_X_NEUTRAL & !defined IMU_ACCEL_Y_NEUTRAL & !defined IMU_ACCEL_Z_NEUTRAL
97 #define IMU_ACCEL_X_NEUTRAL 0
98 #define IMU_ACCEL_Y_NEUTRAL 0
99 #define IMU_ACCEL_Z_NEUTRAL 0
100 #endif
101 
102 
103 struct ImuDrotek2 {
104  volatile bool_t gyro_valid;
105  volatile bool_t accel_valid;
106  volatile bool_t mag_valid;
107  struct Mpu60x0_I2c mpu;
108  struct Hmc58xx hmc;
109 };
110 
111 extern struct ImuDrotek2 imu_drotek2;
112 
113 extern void imu_drotek2_event(void);
114 extern bool_t imu_drotek2_configure_mag_slave(Mpu60x0ConfigSet mpu_set, void* mpu);
115 
116 
117 static inline void ImuEvent(void (* _gyro_handler)(void), void (* _accel_handler)(void), void (* _mag_handler)(void)) {
119  if (imu_drotek2.gyro_valid) {
121  _gyro_handler();
122  }
123  if (imu_drotek2.accel_valid) {
125  _accel_handler();
126  }
127  if (imu_drotek2.mag_valid) {
129  _mag_handler();
130  }
131 }
132 
133 #endif /* IMU_DROTEK_10DOF_V2_H */
struct Hmc58xx hmc
bool_t imu_drotek2_configure_mag_slave(Mpu60x0ConfigSet mpu_set, void *mpu)
callback function to configure hmc5883 mag
static void ImuEvent(void(*_gyro_handler)(void), void(*_accel_handler)(void), void(*_mag_handler)(void))
void imu_drotek2_event(void)
volatile bool_t gyro_valid
struct ImuDrotek2 imu_drotek2
#define FALSE
Definition: imu_chimu.h:141
volatile bool_t mag_valid
struct Mpu60x0_I2c mpu
Inertial Measurement Unit interface.
Driver for the MPU-60X0 using I2C.
void(* Mpu60x0ConfigSet)(void *mpu, uint8_t _reg, uint8_t _val)
Configuration function prototype.
Definition: mpu60x0.h:64
volatile bool_t accel_valid