Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
mpu60x0_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 MPU60X0_I2C_H
29 #define MPU60X0_I2C_H
30 
31 #include "std.h"
32 #include "math/pprz_algebra_int.h"
33 #include "mcu_periph/i2c.h"
34 
35 /* Include common MPU60X0 options and definitions */
36 #include "peripherals/mpu60x0.h"
37 
38 
39 #define MPU60X0_BUFFER_EXT_LEN 16
40 
52 };
53 
54 struct Mpu60x0_I2c {
55  struct i2c_periph *i2c_p;
57  volatile bool data_available;
58  union {
59  struct Int16Vect3 vect;
60  int16_t value[3];
61  } data_accel;
62  union {
63  struct Int16Rates rates;
64  int16_t value[3];
65  } data_rates;
66  float temp;
70 };
71 
72 // Functions
73 extern void mpu60x0_i2c_init(struct Mpu60x0_I2c *mpu, struct i2c_periph *i2c_p, uint8_t addr);
74 extern void mpu60x0_i2c_start_configure(struct Mpu60x0_I2c *mpu);
75 extern void mpu60x0_i2c_read(struct Mpu60x0_I2c *mpu);
76 extern void mpu60x0_i2c_event(struct Mpu60x0_I2c *mpu);
77 
79 static inline void mpu60x0_i2c_periodic(struct Mpu60x0_I2c *mpu)
80 {
81  if (mpu->config.initialized) {
82  mpu60x0_i2c_read(mpu);
83  } else {
85  }
86 }
87 
88 #endif // MPU60X0_I2C_H
Mpu60x0_I2c::temp
float temp
temperature in degrees Celcius
Definition: mpu60x0_i2c.h:66
Int16Vect3
Definition: pprz_algebra_int.h:62
mpu60x0_i2c_init
void mpu60x0_i2c_init(struct Mpu60x0_I2c *mpu, struct i2c_periph *i2c_p, uint8_t addr)
Definition: mpu60x0_i2c.c:31
mpu60x0_i2c_periodic
static void mpu60x0_i2c_periodic(struct Mpu60x0_I2c *mpu)
convenience function: read or start configuration if not already initialized
Definition: mpu60x0_i2c.h:79
MPU60X0_I2C_CONF_I2C_MST_DELAY
@ MPU60X0_I2C_CONF_I2C_MST_DELAY
Definition: mpu60x0_i2c.h:48
MPU60X0_I2C_CONF_SLAVES_CONFIGURE
@ MPU60X0_I2C_CONF_SLAVES_CONFIGURE
Definition: mpu60x0_i2c.h:45
mpu60x0_i2c_start_configure
void mpu60x0_i2c_start_configure(struct Mpu60x0_I2c *mpu)
Definition: mpu60x0_i2c.c:61
MPU60X0_I2C_CONF_I2C_MST_CLK
@ MPU60X0_I2C_CONF_I2C_MST_CLK
Definition: mpu60x0_i2c.h:47
MPU60X0_I2C_CONF_DONE
@ MPU60X0_I2C_CONF_DONE
Definition: mpu60x0_i2c.h:51
MPU60X0_I2C_CONF_I2C_SMPLRT
@ MPU60X0_I2C_CONF_I2C_SMPLRT
Definition: mpu60x0_i2c.h:49
MPU60X0_BUFFER_EXT_LEN
#define MPU60X0_BUFFER_EXT_LEN
Definition: mpu60x0_i2c.h:39
MPU60X0_I2C_CONF_I2C_BYPASS_DIS
@ MPU60X0_I2C_CONF_I2C_BYPASS_DIS
Definition: mpu60x0_i2c.h:46
Mpu60x0_I2c::i2c_p
struct i2c_periph * i2c_p
Definition: mpu60x0_i2c.h:55
pprz_algebra_int.h
Paparazzi fixed point algebra.
MPU60X0_I2C_CONF_I2C_MST_DIS
@ MPU60X0_I2C_CONF_I2C_MST_DIS
Definition: mpu60x0_i2c.h:43
mpu60x0_i2c_read
void mpu60x0_i2c_read(struct Mpu60x0_I2c *mpu)
Definition: mpu60x0_i2c.c:71
MPU60X0_I2C_CONF_I2C_MST_EN
@ MPU60X0_I2C_CONF_I2C_MST_EN
Definition: mpu60x0_i2c.h:50
std.h
Mpu60x0_I2c::slave_init_status
enum Mpu60x0I2cSlaveInitStatus slave_init_status
Definition: mpu60x0_i2c.h:69
int16_t
signed short int16_t
Definition: types.h:17
uint8_t
unsigned char uint8_t
Definition: types.h:14
Mpu60x0_I2c::i2c_trans
struct i2c_transaction i2c_trans
Definition: mpu60x0_i2c.h:56
mpu60x0.h
mpu60x0_i2c_event
void mpu60x0_i2c_event(struct Mpu60x0_I2c *mpu)
Definition: mpu60x0_i2c.c:82
Mpu60x0_I2c::config
struct Mpu60x0Config config
Definition: mpu60x0_i2c.h:68
Int16Rates
Definition: pprz_algebra_int.h:169
i2c_transaction
I2C transaction structure.
Definition: i2c.h:93
Mpu60x0I2cSlaveInitStatus
Mpu60x0I2cSlaveInitStatus
Definition: mpu60x0_i2c.h:41
Mpu60x0_I2c::data_ext
uint8_t data_ext[MPU60X0_BUFFER_EXT_LEN]
Definition: mpu60x0_i2c.h:67
Mpu60x0_I2c::data_accel
union Mpu60x0_I2c::@331 data_accel
MPU60X0_I2C_CONF_I2C_BYPASS_EN
@ MPU60X0_I2C_CONF_I2C_BYPASS_EN
Definition: mpu60x0_i2c.h:44
Mpu60x0_I2c::data_rates
union Mpu60x0_I2c::@332 data_rates
MPU60X0_I2C_CONF_UNINIT
@ MPU60X0_I2C_CONF_UNINIT
Definition: mpu60x0_i2c.h:42
Mpu60x0_I2c::data_available
volatile bool data_available
data ready flag
Definition: mpu60x0_i2c.h:57
Mpu60x0Config
Definition: mpu60x0.h:138
i2c_periph
Definition: i2c.h:144
i2c.h
Mpu60x0Config::initialized
bool initialized
config done flag
Definition: mpu60x0.h:149
Mpu60x0_I2c
Definition: mpu60x0_i2c.h:54