Paparazzi UAS  v5.15_devel-230-gc96ce27
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
struct Bmi088Config config
Definition: bmi088_i2c.h:51
struct i2c_transaction accel_trans
i2c transaction for accel
Definition: bmi088_i2c.h:40
union Bmi088_I2c::@307 data_accel
void bmi088_i2c_event(struct Bmi088_I2c *bmi)
Definition: bmi088_i2c.c:93
union Bmi088_I2c::@308 data_rates
struct i2c_periph * i2c_p
Definition: bmi088_i2c.h:38
struct i2c_transaction gyro_trans
i2c transaction for gyro
Definition: bmi088_i2c.h:39
signed short int16_t
Definition: types.h:17
I2C transaction structure.
Definition: i2c.h:93
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_start_configure(struct Bmi088_I2c *bmi)
Definition: bmi088_i2c.c:67
unsigned char uint8_t
Definition: types.h:14
volatile bool gyro_available
gyro data ready flag
Definition: bmi088_i2c.h:41
BMI088 driver common interface (I2C and SPI).
bool initialized
config done flag
Definition: bmi088.h:120
volatile bool accel_available
accel data ready flag
Definition: bmi088_i2c.h:42
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
void bmi088_i2c_read(struct Bmi088_I2c *bmi)
Definition: bmi088_i2c.c:77
Paparazzi fixed point algebra.
Architecture independent I2C (Inter-Integrated Circuit Bus) API.