Paparazzi UAS  v7.0_unstable
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];
47  union {
48  struct Int16Rates rates;
49  int16_t value[3];
51  struct Bmi088Config config;
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
BMI088 driver common interface (I2C and SPI).
bool initialized
config done flag
Definition: bmi088.h:121
static void bmi088_i2c_periodic(struct Bmi088_I2c *bmi)
convenience function: read or start configuration if not already initialized
Definition: bmi088_i2c.h:61
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
struct i2c_transaction gyro_trans
i2c transaction for gyro
Definition: bmi088_i2c.h:39
volatile bool accel_available
accel data ready flag
Definition: bmi088_i2c.h:42
struct i2c_transaction accel_trans
i2c transaction for accel
Definition: bmi088_i2c.h:40
struct Bmi088Config config
Definition: bmi088_i2c.h:51
void bmi088_i2c_read(struct Bmi088_I2c *bmi)
Definition: bmi088_i2c.c:77
union Bmi088_I2c::@303 data_rates
volatile bool gyro_available
gyro data ready flag
Definition: bmi088_i2c.h:41
void bmi088_i2c_event(struct Bmi088_I2c *bmi)
Definition: bmi088_i2c.c:93
union Bmi088_I2c::@302 data_accel
void bmi088_i2c_start_configure(struct Bmi088_I2c *bmi)
Definition: bmi088_i2c.c:67
struct i2c_periph * i2c_p
Definition: bmi088_i2c.h:38
I2C transaction structure.
Definition: i2c.h:93
Architecture independent I2C (Inter-Integrated Circuit Bus) API.
Paparazzi fixed point algebra.
short int16_t
Typedef defining 16 bit short type.
Definition: vl53l1_types.h:93
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98