Paparazzi UAS  v5.12_stable-4-g9b43e9b
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
imu_apogee.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011 Gautier Hattenberger
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 
30 #ifndef IMU_APOGEE_H
31 #define IMU_APOGEE_H
32 
33 #include "std.h"
34 #include "generated/airframe.h"
35 #include "subsystems/imu.h"
36 #if APOGEE_USE_MPU9150
37 #include "peripherals/ak8975.h"
38 #endif
39 
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 
54 #ifndef APOGEE_GYRO_RANGE
55 #define APOGEE_GYRO_RANGE MPU60X0_GYRO_RANGE_1000
56 #endif
57 #ifndef APOGEE_ACCEL_RANGE
58 #define APOGEE_ACCEL_RANGE MPU60X0_ACCEL_RANGE_8G
59 #endif
60 
61 // Set default sensitivity based on range if needed
62 #if !defined IMU_GYRO_P_SENS & !defined IMU_GYRO_Q_SENS & !defined IMU_GYRO_R_SENS
63 #define IMU_GYRO_P_SENS MPU60X0_GYRO_SENS[APOGEE_GYRO_RANGE]
64 #define IMU_GYRO_P_SENS_NUM MPU60X0_GYRO_SENS_FRAC[APOGEE_GYRO_RANGE][0]
65 #define IMU_GYRO_P_SENS_DEN MPU60X0_GYRO_SENS_FRAC[APOGEE_GYRO_RANGE][1]
66 #define IMU_GYRO_Q_SENS MPU60X0_GYRO_SENS[APOGEE_GYRO_RANGE]
67 #define IMU_GYRO_Q_SENS_NUM MPU60X0_GYRO_SENS_FRAC[APOGEE_GYRO_RANGE][0]
68 #define IMU_GYRO_Q_SENS_DEN MPU60X0_GYRO_SENS_FRAC[APOGEE_GYRO_RANGE][1]
69 #define IMU_GYRO_R_SENS MPU60X0_GYRO_SENS[APOGEE_GYRO_RANGE]
70 #define IMU_GYRO_R_SENS_NUM MPU60X0_GYRO_SENS_FRAC[APOGEE_GYRO_RANGE][0]
71 #define IMU_GYRO_R_SENS_DEN MPU60X0_GYRO_SENS_FRAC[APOGEE_GYRO_RANGE][1]
72 #endif
73 #if !defined IMU_GYRO_P_NEUTRAL & !defined IMU_GYRO_Q_NEUTRAL & !defined IMU_GYRO_R_NEUTRAL
74 #define IMU_GYRO_P_NEUTRAL 0
75 #define IMU_GYRO_Q_NEUTRAL 0
76 #define IMU_GYRO_R_NEUTRAL 0
77 #endif
78 
79 
80 // Set default sensitivity based on range if needed
81 #if !defined IMU_ACCEL_X_SENS & !defined IMU_ACCEL_Y_SENS & !defined IMU_ACCEL_Z_SENS
82 #define IMU_ACCEL_X_SENS MPU60X0_ACCEL_SENS[APOGEE_ACCEL_RANGE]
83 #define IMU_ACCEL_X_SENS_NUM MPU60X0_ACCEL_SENS_FRAC[APOGEE_ACCEL_RANGE][0]
84 #define IMU_ACCEL_X_SENS_DEN MPU60X0_ACCEL_SENS_FRAC[APOGEE_ACCEL_RANGE][1]
85 #define IMU_ACCEL_Y_SENS MPU60X0_ACCEL_SENS[APOGEE_ACCEL_RANGE]
86 #define IMU_ACCEL_Y_SENS_NUM MPU60X0_ACCEL_SENS_FRAC[APOGEE_ACCEL_RANGE][0]
87 #define IMU_ACCEL_Y_SENS_DEN MPU60X0_ACCEL_SENS_FRAC[APOGEE_ACCEL_RANGE][1]
88 #define IMU_ACCEL_Z_SENS MPU60X0_ACCEL_SENS[APOGEE_ACCEL_RANGE]
89 #define IMU_ACCEL_Z_SENS_NUM MPU60X0_ACCEL_SENS_FRAC[APOGEE_ACCEL_RANGE][0]
90 #define IMU_ACCEL_Z_SENS_DEN MPU60X0_ACCEL_SENS_FRAC[APOGEE_ACCEL_RANGE][1]
91 #endif
92 #if !defined IMU_ACCEL_X_NEUTRAL & !defined IMU_ACCEL_Y_NEUTRAL & !defined IMU_ACCEL_Z_NEUTRAL
93 #define IMU_ACCEL_X_NEUTRAL 0
94 #define IMU_ACCEL_Y_NEUTRAL 0
95 #define IMU_ACCEL_Z_NEUTRAL 0
96 #endif
97 
98 struct ImuApogee {
99  struct Mpu60x0_I2c mpu;
100 #if APOGEE_USE_MPU9150
101  struct Ak8975 ak;
102 #endif
103 };
104 
105 extern struct ImuApogee imu_apogee;
106 
107 extern void imu_apogee_init(void);
108 extern void imu_apogee_periodic(void);
109 extern void imu_apogee_event(void);
110 extern void imu_apogee_downlink_raw(void);
111 
112 #endif // IMU_APOGEE_H
struct Mpu60x0_I2c mpu
Definition: imu_apogee.h:99
void imu_apogee_downlink_raw(void)
Definition: imu_apogee.c:129
Definition: ak8975.h:59
void imu_apogee_periodic(void)
Definition: imu_apogee.c:116
void imu_apogee_event(void)
Definition: imu_apogee.c:138
Inertial Measurement Unit interface.
Driver for the MPU-60X0 using I2C.
Driver for the AKM AK8975 magnetometer.
void imu_apogee_init(void)
Definition: imu_apogee.c:94
struct ImuApogee imu_apogee
Definition: imu_apogee.c:85