Paparazzi UAS  v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
mpu9250_i2c.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 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 
28 #ifndef MPU9250_I2C_H
29 #define MPU9250_I2C_H
30 
31 #include "std.h"
32 #include "math/pprz_algebra_int.h"
33 #include "mcu_periph/i2c.h"
34 
35 /* Include common MPU9250 options and definitions */
36 #include "peripherals/mpu9250.h"
37 #include "peripherals/ak8963.h"
38 
39 
40 #define MPU9250_BUFFER_EXT_LEN 16
41 
53 };
54 
55 struct Mpu9250_I2c {
56  struct i2c_periph *i2c_p;
58  volatile bool_t data_available;
59  union {
60  struct Int16Vect3 vect;
61  int16_t value[3];
62  } data_accel;
63  union {
64  struct Int16Rates rates;
65  int16_t value[3];
66  } data_rates;
70  struct Ak8963 akm;
71 };
72 
73 // Functions
74 extern void mpu9250_i2c_init(struct Mpu9250_I2c *mpu, struct i2c_periph *i2c_p, uint8_t addr);
75 extern void mpu9250_i2c_start_configure(struct Mpu9250_I2c *mpu);
76 extern void mpu9250_i2c_read(struct Mpu9250_I2c *mpu);
77 extern void mpu9250_i2c_event(struct Mpu9250_I2c *mpu);
78 
80 static inline void mpu9250_i2c_periodic(struct Mpu9250_I2c *mpu)
81 {
82  if (mpu->config.initialized) {
83  mpu9250_i2c_read(mpu);
84  } else {
86  }
87 }
88 
89 #endif // MPU9250_I2C_H
Register and address definitions for AK8963 magnetometer.
union Mpu9250_I2c::@46 data_rates
struct i2c_transaction i2c_trans
Definition: mpu9250_i2c.h:57
MPU-60X0 driver common interface (I2C and SPI).
uint16_t value
Definition: adc_arch.c:586
struct Mpu9250Config config
Definition: mpu9250_i2c.h:68
Mpu9250I2cSlaveInitStatus
Definition: mpu9250_i2c.h:42
uint8_t data_ext[MPU9250_BUFFER_EXT_LEN]
Definition: mpu9250_i2c.h:67
Default Ak8963 structure.
Definition: ak8963.h:53
union Mpu9250_I2c::@45 data_accel
struct Ak8963 akm
"internal" magnetometer
Definition: mpu9250_i2c.h:70
struct i2c_periph * i2c_p
peripheral used for communcation
Definition: ak8963.h:54
signed short int16_t
Definition: types.h:17
void mpu9250_i2c_event(struct Mpu9250_I2c *mpu)
Definition: mpu9250_i2c.c:101
enum Mpu9250I2cSlaveInitStatus slave_init_status
Definition: mpu9250_i2c.h:69
I2C transaction structure.
Definition: i2c.h:93
volatile bool_t data_available
data ready flag
Definition: mpu9250_i2c.h:58
void mpu9250_i2c_init(struct Mpu9250_I2c *mpu, struct i2c_periph *i2c_p, uint8_t addr)
Definition: mpu9250_i2c.c:33
I2C peripheral structure.
Definition: i2c.h:138
bool_t initialized
config done flag
Definition: mpu9250.h:85
unsigned char uint8_t
Definition: types.h:14
static void mpu9250_i2c_periodic(struct Mpu9250_I2c *mpu)
convenience function: read or start configuration if not already initialized
Definition: mpu9250_i2c.h:80
void mpu9250_i2c_read(struct Mpu9250_I2c *mpu)
Definition: mpu9250_i2c.c:84
#define MPU9250_BUFFER_EXT_LEN
Definition: mpu9250_i2c.h:40
void mpu9250_i2c_start_configure(struct Mpu9250_I2c *mpu)
Definition: mpu9250_i2c.c:74
struct i2c_periph * i2c_p
Definition: mpu9250_i2c.h:56
Paparazzi fixed point algebra.
Architecture independent I2C (Inter-Integrated Circuit Bus) API.