Paparazzi UAS  v7.0_unstable
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 
35 struct Mpu9250_I2c mpu9250;
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 #include "modules/core/abi.h"
55 
57 {
59  float temp = NAN;
60 
61  struct Int32Vect3 accel = {
62  (int32_t)(mpu9250.data_accel.vect.x),
63  (int32_t)(mpu9250.data_accel.vect.y),
64  (int32_t)(mpu9250.data_accel.vect.z)
65  };
66  DOWNLINK_SEND_IMU_ACCEL_RAW(DefaultChannel, DefaultDevice, &id, &temp, &accel.x, &accel.y, &accel.z);
67 
68  struct Int32Rates rates = {
69  (int32_t)(mpu9250.data_rates.rates.p),
70  (int32_t)(mpu9250.data_rates.rates.q),
71  (int32_t)(mpu9250.data_rates.rates.r)
72  };
73  DOWNLINK_SEND_IMU_GYRO_RAW(DefaultChannel, DefaultDevice, &id, &temp, &rates.p, &rates.q, &rates.r);
74 
75  struct Int32Vect3 mag = {
76  (int32_t)(mpu9250.akm.data.vect.x),
77  (int32_t)(mpu9250.akm.data.vect.y),
78  (int32_t)(mpu9250.akm.data.vect.z)
79  };
80  DOWNLINK_SEND_IMU_MAG_RAW(DefaultChannel, DefaultDevice, &id, &mag.x, &mag.y, &mag.z);
81 }
82 
Main include for ABI (AirBorneInterface).
#define IMU_MPU9250_ID
union Ak8963::@310 data
int32_t p
in rad/s with INT32_RATE_FRAC
int32_t r
in rad/s with INT32_RATE_FRAC
int32_t q
in rad/s with INT32_RATE_FRAC
angular rates
void imu_mpu9250_periodic(void)
Definition: imu_mpu9250.c:42
void imu_mpu9250_report(void)
Definition: imu_mpu9250.c:56
void imu_mpu9250_init(void)
Definition: imu_mpu9250.c:37
#define IMU_MPU9250_ADDR
Definition: imu_mpu9250.c:32
struct Mpu9250_I2c mpu9250
Definition: imu_mpu9250.c:35
void imu_mpu9250_event(void)
Definition: imu_mpu9250.c:47
void mpu9250_i2c_event(struct Mpu9250_I2c *mpu)
Definition: mpu9250_i2c.c:106
void mpu9250_i2c_init(struct Mpu9250_I2c *mpu, struct i2c_periph *i2c_p, uint8_t addr)
Definition: mpu9250_i2c.c:33
union Mpu9250_I2c::@344 data_rates
struct Ak8963 akm
"internal" magnetometer
Definition: mpu9250_i2c.h:75
union Mpu9250_I2c::@343 data_accel
static void mpu9250_i2c_periodic(struct Mpu9250_I2c *mpu)
convenience function: read or start configuration if not already initialized
Definition: mpu9250_i2c.h:86
Paparazzi fixed point algebra.
int int32_t
Typedef defining 32 bit int type.
Definition: vl53l1_types.h:83
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98