Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
bmi088_i2c.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 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 
27 #ifndef BMI088_I2C_H
28 #define BMI088_I2C_H
29 
30 #include "std.h"
31 #include "math/pprz_algebra_int.h"
32 #include "mcu_periph/i2c.h"
33 
34 /* Include common BMI088 options and definitions */
35 #include "peripherals/bmi088.h"
36 
37 struct Bmi088_I2c {
38  struct i2c_periph *i2c_p;
41  volatile bool gyro_available;
42  volatile bool accel_available;
43  union {
44  struct Int16Vect3 vect;
45  int16_t value[3];
46  } data_accel;
47  union {
48  struct Int16Rates rates;
49  int16_t value[3];
50  } data_rates;
52 };
53 
54 // Functions
55 extern void bmi088_i2c_init(struct Bmi088_I2c *bmi, struct i2c_periph *i2c_p, uint8_t gyro_addr, uint8_t accel_addr);
56 extern void bmi088_i2c_start_configure(struct Bmi088_I2c *bmi);
57 extern void bmi088_i2c_read(struct Bmi088_I2c *bmi);
58 extern void bmi088_i2c_event(struct Bmi088_I2c *bmi);
59 
61 static inline void bmi088_i2c_periodic(struct Bmi088_I2c *bmi)
62 {
63  if (bmi->config.initialized) {
64  bmi088_i2c_read(bmi);
65  } else {
67  }
68 }
69 
70 #endif // BMI088_I2C_H
Int16Vect3
Definition: pprz_algebra_int.h:62
Bmi088_I2c::config
struct Bmi088Config config
Definition: bmi088_i2c.h:51
Bmi088_I2c::accel_available
volatile bool accel_available
accel data ready flag
Definition: bmi088_i2c.h:42
bmi088_i2c_periodic
static void bmi088_i2c_periodic(struct Bmi088_I2c *bmi)
convenience function: read or start configuration if not already initialized
Definition: bmi088_i2c.h:61
Bmi088_I2c::i2c_p
struct i2c_periph * i2c_p
Definition: bmi088_i2c.h:38
Bmi088_I2c::data_accel
union Bmi088_I2c::@308 data_accel
Bmi088_I2c::accel_trans
struct i2c_transaction accel_trans
i2c transaction for accel
Definition: bmi088_i2c.h:40
Bmi088_I2c::data_rates
union Bmi088_I2c::@309 data_rates
pprz_algebra_int.h
Paparazzi fixed point algebra.
std.h
Bmi088_I2c::gyro_trans
struct i2c_transaction gyro_trans
i2c transaction for gyro
Definition: bmi088_i2c.h:39
int16_t
signed short int16_t
Definition: types.h:17
uint8_t
unsigned char uint8_t
Definition: types.h:14
Bmi088Config::initialized
bool initialized
config done flag
Definition: bmi088.h:120
Bmi088Config
Definition: bmi088.h:113
Bmi088_I2c
Definition: bmi088_i2c.h:37
Bmi088_I2c::gyro_available
volatile bool gyro_available
gyro data ready flag
Definition: bmi088_i2c.h:41
Int16Rates
Definition: pprz_algebra_int.h:169
i2c_transaction
I2C transaction structure.
Definition: i2c.h:93
bmi088_i2c_start_configure
void bmi088_i2c_start_configure(struct Bmi088_I2c *bmi)
Definition: bmi088_i2c.c:67
bmi088.h
bmi088_i2c_init
void bmi088_i2c_init(struct Bmi088_I2c *bmi, struct i2c_periph *i2c_p, uint8_t gyro_addr, uint8_t accel_addr)
Definition: bmi088_i2c.c:30
bmi088_i2c_read
void bmi088_i2c_read(struct Bmi088_I2c *bmi)
Definition: bmi088_i2c.c:77
bmi088_i2c_event
void bmi088_i2c_event(struct Bmi088_I2c *bmi)
Definition: bmi088_i2c.c:93
i2c_periph
Definition: i2c.h:144
i2c.h