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_mpu6000_hmc5883.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 
28 #ifndef IMU_MPU6000_HMC5883_H
29 #define IMU_MPU6000_HMC5883_H
30 
31 #include "std.h"
32 #include "generated/airframe.h"
33 #include "subsystems/imu.h"
34 
37 #include "peripherals/hmc58xx.h"
38 
39 #if !defined IMU_GYRO_P_SIGN & !defined IMU_GYRO_Q_SIGN & !defined IMU_GYRO_R_SIGN
40 #define IMU_GYRO_P_SIGN 1
41 #define IMU_GYRO_Q_SIGN 1
42 #define IMU_GYRO_R_SIGN 1
43 #endif
44 #if !defined IMU_ACCEL_X_SIGN & !defined IMU_ACCEL_Y_SIGN & !defined IMU_ACCEL_Z_SIGN
45 #define IMU_ACCEL_X_SIGN 1
46 #define IMU_ACCEL_Y_SIGN 1
47 #define IMU_ACCEL_Z_SIGN 1
48 #endif
49 #if !defined IMU_MAG_X_SIGN & !defined IMU_MAG_Y_SIGN & !defined IMU_MAG_Z_SIGN
50 #define IMU_MAG_X_SIGN 1
51 #define IMU_MAG_Y_SIGN 1
52 #define IMU_MAG_Z_SIGN 1
53 #endif
54 
56  volatile bool_t gyro_valid;
57  volatile bool_t accel_valid;
58  volatile bool_t mag_valid;
59  struct Mpu60x0_Spi mpu;
60  struct Hmc58xx hmc;
61 };
62 
63 extern struct ImuMpu6000Hmc5883 imu_mpu_hmc;
64 
65 extern void imu_mpu_hmc_event(void);
66 
67 
68 static inline void ImuEvent(void (* _gyro_handler)(void), void (* _accel_handler)(void), void (* _mag_handler)(void)) {
70  if (imu_mpu_hmc.gyro_valid) {
72  _gyro_handler();
73  }
76  _accel_handler();
77  }
78  if (imu_mpu_hmc.mag_valid) {
80  _mag_handler();
81  }
82 }
83 
84 #endif /* IMU_MPU6000_HMC5883_H */
Default sensitivity definitions for an IMU using the MPU60x0.
static void ImuEvent(void(*_gyro_handler)(void), void(*_accel_handler)(void), void(*_mag_handler)(void))
#define FALSE
Definition: imu_chimu.h:141
struct ImuMpu6000Hmc5883 imu_mpu_hmc
volatile bool_t mag_valid
volatile bool_t accel_valid
void imu_mpu_hmc_event(void)
Inertial Measurement Unit interface.
struct Mpu60x0_Spi mpu
Driver for the MPU-60X0 using SPI.
volatile bool_t gyro_valid