Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
lsm6ds33_i2c.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Alexis Cornard <alexiscornard@gmail.com>
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 LSM6_I2C_H
29 #define LSM6_I2C_H
30 
31 #include "std.h"
32 #include "math/pprz_algebra_int.h"
33 #include "mcu_periph/i2c.h"
34 
35 /* Include common LSM6DS33 options and definitions */
36 #include "peripherals/lsm6ds33.h"
37 
38 struct Lsm6_I2c {
39  struct i2c_periph *i2c_p;
42  bool initialized;
43  volatile bool data_available;
44  union {
45  struct Int16Vect3 vect;
46  int16_t value[3];
47  } data_xl;
48  union {
49  struct Int16Rates rates;
50  int16_t value[3];
51  } data_g;
53 };
54 
55 // Functions
56 extern void lsm6_i2c_init(struct Lsm6_I2c *lsm, struct i2c_periph *i2c_p, uint8_t addr);
57 extern void lsm6_i2c_start_configure(struct Lsm6_I2c *lsm);
58 extern void lsm6_i2c_read(struct Lsm6_I2c *lsm);
59 extern void lsm6_i2c_event(struct Lsm6_I2c *lsm);
60 
62 static inline void lsm6_i2c_periodic(struct Lsm6_I2c *lsm)
63 {
64  if (lsm->initialized) {
65  lsm6_i2c_read(lsm);
66  } else {
68  }
69 }
70 
71 #endif // LSM6_I2C_H
Int16Vect3
Definition: pprz_algebra_int.h:62
Lsm6Config
Definition: lsm6ds33.h:111
Lsm6_I2c
Definition: lsm6ds33_i2c.h:38
lsm6ds33.h
Lsm6_I2c::config
struct Lsm6Config config
Definition: lsm6ds33_i2c.h:52
Lsm6_I2c::data_xl
union Lsm6_I2c::@329 data_xl
Lsm6ConfStatus
Lsm6ConfStatus
Definition: lsm6ds33.h:102
pprz_algebra_int.h
Paparazzi fixed point algebra.
lsm6_i2c_read
void lsm6_i2c_read(struct Lsm6_I2c *lsm)
Definition: lsm6ds33_i2c.c:99
std.h
lsm6_i2c_init
void lsm6_i2c_init(struct Lsm6_I2c *lsm, struct i2c_periph *i2c_p, uint8_t addr)
Definition: lsm6ds33_i2c.c:33
int16_t
signed short int16_t
Definition: types.h:17
uint8_t
unsigned char uint8_t
Definition: types.h:14
Lsm6_I2c::initialized
bool initialized
config done flag
Definition: lsm6ds33_i2c.h:42
Int16Rates
Definition: pprz_algebra_int.h:169
i2c_transaction
I2C transaction structure.
Definition: i2c.h:93
lsm6_i2c_event
void lsm6_i2c_event(struct Lsm6_I2c *lsm)
Definition: lsm6ds33_i2c.c:114
Lsm6_I2c::data_g
union Lsm6_I2c::@330 data_g
Lsm6_I2c::data_available
volatile bool data_available
data ready flag
Definition: lsm6ds33_i2c.h:43
Lsm6_I2c::i2c_trans
struct i2c_transaction i2c_trans
Definition: lsm6ds33_i2c.h:40
i2c_periph
Definition: i2c.h:144
i2c.h
lsm6_i2c_periodic
static void lsm6_i2c_periodic(struct Lsm6_I2c *lsm)
convenience function: read or start configuration if not already initialized
Definition: lsm6ds33_i2c.h:62
Lsm6_I2c::i2c_p
struct i2c_periph * i2c_p
Definition: lsm6ds33_i2c.h:39
lsm6_i2c_start_configure
void lsm6_i2c_start_configure(struct Lsm6_I2c *lsm)
Definition: lsm6ds33_i2c.c:88
Lsm6_I2c::init_status
enum Lsm6ConfStatus init_status
init status
Definition: lsm6ds33_i2c.h:41