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_umarim.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011 Gautier Hattenberger
3  * Derived from Aspirin and ppzuavimu drivers
4  *
5  * This file is part of paparazzi.
6  *
7  * paparazzi is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * paparazzi is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with paparazzi; see the file COPYING. If not, write to
19  * the Free Software Foundation, 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22 
32 #ifndef IMU_UMARIM_H
33 #define IMU_UMARIM_H
34 
35 #include "std.h"
36 #include "generated/airframe.h"
37 #include "subsystems/imu.h"
38 
39 #include "peripherals/itg3200.h"
41 
42 // Default configuration
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 #define IMU_GYRO_P_SENS 4.973
61 #define IMU_GYRO_P_SENS_NUM 4973
62 #define IMU_GYRO_P_SENS_DEN 1000
63 #define IMU_GYRO_Q_SENS 4.973
64 #define IMU_GYRO_Q_SENS_NUM 4973
65 #define IMU_GYRO_Q_SENS_DEN 1000
66 #define IMU_GYRO_R_SENS 4.973
67 #define IMU_GYRO_R_SENS_NUM 4973
68 #define IMU_GYRO_R_SENS_DEN 1000
69 #endif
70 #if !defined IMU_GYRO_P_NEUTRAL & !defined IMU_GYRO_Q_NEUTRAL & !defined IMU_GYRO_R_NEUTRAL
71 #define IMU_GYRO_P_NEUTRAL 0
72 #define IMU_GYRO_Q_NEUTRAL 0
73 #define IMU_GYRO_R_NEUTRAL 0
74 #endif
75 
76 
88 #if !defined IMU_ACCEL_X_SENS & !defined IMU_ACCEL_Y_SENS & !defined IMU_ACCEL_Z_SENS
89 #define IMU_ACCEL_X_SENS 37.91
90 #define IMU_ACCEL_X_SENS_NUM 3791
91 #define IMU_ACCEL_X_SENS_DEN 100
92 #define IMU_ACCEL_Y_SENS 37.91
93 #define IMU_ACCEL_Y_SENS_NUM 3791
94 #define IMU_ACCEL_Y_SENS_DEN 100
95 #define IMU_ACCEL_Z_SENS 39.24
96 #define IMU_ACCEL_Z_SENS_NUM 39.24
97 #define IMU_ACCEL_Z_SENS_DEN 100
98 #endif
99 #if !defined IMU_ACCEL_X_NEUTRAL & !defined IMU_ACCEL_Y_NEUTRAL & !defined IMU_ACCEL_Z_NEUTRAL
100 #define IMU_ACCEL_X_NEUTRAL 0
101 #define IMU_ACCEL_Y_NEUTRAL 0
102 #define IMU_ACCEL_Z_NEUTRAL 0
103 #endif
104 
105 extern volatile bool_t gyr_valid;
106 extern volatile bool_t acc_valid;
107 
108 struct ImuUmarim {
109  volatile bool_t gyr_valid;
110  volatile bool_t acc_valid;
111  struct Itg3200 itg;
113 };
114 
115 extern struct ImuUmarim imu_umarim;
116 
117 
118 /* must be defined in order to be IMU code: declared in imu.h
119 extern void imu_impl_init(void);
120 extern void imu_periodic(void);
121 */
122 
123 /* Own Extra Functions */
124 extern void imu_umarim_event( void );
125 extern void imu_umarim_downlink_raw( void );
126 
127 
128 static inline void ImuEvent(void (* _gyro_handler)(void), void (* _accel_handler)(void), void (* _mag_handler)(void) __attribute__((unused))) {
130  if (imu_umarim.gyr_valid) {
132  _gyro_handler();
133  }
134  if (imu_umarim.acc_valid) {
136  _accel_handler();
137  }
138 }
139 
140 #endif // PPZUAVIMU_H
void imu_umarim_downlink_raw(void)
Definition: imu_umarim.c:93
volatile bool_t acc_valid
Definition: imu_aspirin2.c:43
struct ImuUmarim imu_umarim
Definition: imu_umarim.c:61
void imu_umarim_event(void)
Definition: imu_umarim.c:100
#define FALSE
Definition: imu_chimu.h:141
volatile bool_t gyr_valid
Definition: imu_aspirin2.c:42
volatile bool_t acc_valid
Definition: imu_umarim.h:110
struct Adxl345_I2c adxl
Definition: imu_umarim.h:112
Driver for the gyro ITG3200 from InvenSense.
Inertial Measurement Unit interface.
struct Itg3200 itg
Definition: imu_umarim.h:111
static void ImuEvent(void(*_gyro_handler)(void), void(*_accel_handler)(void), void(*_mag_handler)(void))
Definition: imu_umarim.h:128
Driver for the accelerometer ADXL345 from Analog Devices using I2C.
volatile bool_t gyr_valid
Definition: imu_umarim.h:109