Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
imu_mpu9250.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Gautier Hattenberger <gautier.hattenberger@enac.fr>
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, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
29 
30 // Default I2C address
31 #ifndef IMU_MPU9250_ADDR
32 #define IMU_MPU9250_ADDR MPU9250_ADDR
33 #endif
34 
36 
37 void imu_mpu9250_init(void)
38 {
39  mpu9250_i2c_init(&mpu9250, &(IMU_MPU9250_I2C_DEV), IMU_MPU9250_ADDR);
40 }
41 
43 {
45 }
46 
48 {
50 }
51 
52 #include "math/pprz_algebra_int.h"
54 
56 {
57  struct Int32Vect3 accel = {
58  (int32_t)(mpu9250.data_accel.vect.x),
59  (int32_t)(mpu9250.data_accel.vect.y),
60  (int32_t)(mpu9250.data_accel.vect.z)
61  };
62  DOWNLINK_SEND_IMU_ACCEL_RAW(DefaultChannel, DefaultDevice, &accel.x, &accel.y, &accel.z);
63 
64  struct Int32Rates rates = {
65  (int32_t)(mpu9250.data_rates.rates.p),
66  (int32_t)(mpu9250.data_rates.rates.q),
67  (int32_t)(mpu9250.data_rates.rates.r)
68  };
69  DOWNLINK_SEND_IMU_GYRO_RAW(DefaultChannel, DefaultDevice, &rates.p, &rates.q, &rates.r);
70 
71  struct Int32Vect3 mag = {
72  (int32_t)(mpu9250.akm.data.vect.x),
73  (int32_t)(mpu9250.akm.data.vect.y),
74  (int32_t)(mpu9250.akm.data.vect.z)
75  };
76  DOWNLINK_SEND_IMU_MAG_RAW(DefaultChannel, DefaultDevice, &mag.x, &mag.y, &mag.z);
77 }
78 
angular rates
union Mpu9250_I2c::@316 data_accel
struct Mpu9250_I2c mpu9250
Definition: imu_mpu9250.c:35
void mpu9250_i2c_init(struct Mpu9250_I2c *mpu, struct i2c_periph *i2c_p, uint8_t addr)
Definition: mpu9250_i2c.c:33
#define IMU_MPU9250_ADDR
Definition: imu_mpu9250.c:32
union Ak8963::@293 data
void mpu9250_i2c_event(struct Mpu9250_I2c *mpu)
Definition: mpu9250_i2c.c:101
int32_t r
in rad/s with INT32_RATE_FRAC
struct Ak8963 akm
"internal" magnetometer
Definition: mpu9250_i2c.h:70
void imu_mpu9250_init(void)
Definition: imu_mpu9250.c:37
void imu_mpu9250_report(void)
Definition: imu_mpu9250.c:55
signed long int32_t
Definition: types.h:19
void imu_mpu9250_periodic(void)
Definition: imu_mpu9250.c:42
static void mpu9250_i2c_periodic(struct Mpu9250_I2c *mpu)
convenience function: read or start configuration if not already initialized
Definition: mpu9250_i2c.h:80
int32_t p
in rad/s with INT32_RATE_FRAC
union Mpu9250_I2c::@317 data_rates
void imu_mpu9250_event(void)
Definition: imu_mpu9250.c:47
int32_t q
in rad/s with INT32_RATE_FRAC
Paparazzi fixed point algebra.