Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
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 
Int32Rates
angular rates
Definition: pprz_algebra_int.h:179
Ak8963::data
union Ak8963::@306 data
Mpu9250_I2c
Definition: mpu9250_i2c.h:59
imu_mpu9250_report
void imu_mpu9250_report(void)
Definition: imu_mpu9250.c:55
Int32Rates::q
int32_t q
in rad/s with INT32_RATE_FRAC
Definition: pprz_algebra_int.h:181
Mpu9250_I2c::data_rates
union Mpu9250_I2c::@336 data_rates
Int32Vect3::z
int32_t z
Definition: pprz_algebra_int.h:91
imu_mpu9250_periodic
void imu_mpu9250_periodic(void)
Definition: imu_mpu9250.c:42
IMU_MPU9250_ADDR
#define IMU_MPU9250_ADDR
Definition: imu_mpu9250.c:32
pprz_algebra_int.h
Paparazzi fixed point algebra.
mpu9250
struct Mpu9250_I2c mpu9250
Definition: imu_mpu9250.c:35
Int32Rates::p
int32_t p
in rad/s with INT32_RATE_FRAC
Definition: pprz_algebra_int.h:180
mpu9250_i2c_periodic
static void mpu9250_i2c_periodic(struct Mpu9250_I2c *mpu)
convenience function: read or start configuration if not already initialized
Definition: mpu9250_i2c.h:86
Int32Vect3
Definition: pprz_algebra_int.h:88
Int32Vect3::y
int32_t y
Definition: pprz_algebra_int.h:90
mpu9250_i2c_event
void mpu9250_i2c_event(struct Mpu9250_I2c *mpu)
Definition: mpu9250_i2c.c:106
Mpu9250_I2c::data_accel
union Mpu9250_I2c::@335 data_accel
imu_mpu9250_init
void imu_mpu9250_init(void)
Definition: imu_mpu9250.c:37
imu_mpu9250.h
int32_t
signed long int32_t
Definition: types.h:19
imu_mpu9250_event
void imu_mpu9250_event(void)
Definition: imu_mpu9250.c:47
Int32Vect3::x
int32_t x
Definition: pprz_algebra_int.h:89
mpu9250_i2c_init
void mpu9250_i2c_init(struct Mpu9250_I2c *mpu, struct i2c_periph *i2c_p, uint8_t addr)
Definition: mpu9250_i2c.c:33
Int32Rates::r
int32_t r
in rad/s with INT32_RATE_FRAC
Definition: pprz_algebra_int.h:182
Mpu9250_I2c::akm
struct Ak8963 akm
"internal" magnetometer
Definition: mpu9250_i2c.h:75