Paparazzi UAS  v5.14.0_stable-0-g3f680d1
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
lsm303dlhc_i2c.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011 Gautier Hattenberger <gautier.hattenberger@enac.fr>
3  * 2013 Felix Ruess <felix.ruess@gmail.com>
4  *
5  * This file is part of paparazzi.
6  *
7  * paparazzi is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * paparazzi is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with paparazzi; see the file COPYING. If not, write to
19  * the Free Software Foundation, 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22 
30 #ifndef LSM303DLHC_H
31 #define LSM303DLHC_H
32 
33 #include "std.h"
34 #include "mcu_periph/i2c.h"
35 #include "math/pprz_algebra_int.h"
36 
37 #include "peripherals/lsm303dlhc.h"
38 
39 #warning "The Lsm303dlhc I2C driver has not been tested. Use with caution."
40 
42  struct i2c_periph *i2c_p;
44  bool initialized;
45  union {
46  enum Lsm303dlhcAccConfStatus acc;
47  enum Lsm303dlhcMagConfStatus mag;
48  } init_status;
49  volatile bool data_available;
50  union {
51  struct Int16Vect3 vect;
52  int16_t value[3];
53  } data_accel;
54  union {
55  struct Lsm303dlhcAccConfig acc;
56  struct Lsm303dlhcMagConfig mag;
57  } config;
58 };
59 
60 // TODO IRQ handling
61 
62 // Functions
63 extern void lsm303dlhc_i2c_init(struct Lsm303dlhc_i2c *lsm, struct i2c_periph *i2c_p, uint8_t addr);
64 extern void lsm303dlhc_i2c_start_configure(struct Lsm303dlhc_i2c *lsm);
65 extern void lsm303dlhc_i2c_read(struct Lsm303dlhc_i2c *lsm);
66 extern void lsm303dlhc_i2c_event(struct Lsm303dlhc_i2c *lsm);
67 
69 static inline void lsm303dlhc_i2c_periodic(struct Lsm303dlhc_i2c *lsm)
70 {
71  if (lsm->initialized) {
73  } else {
75  }
76 }
77 
78 #endif /* LSM303DLHC_H */
struct i2c_transaction i2c_trans
struct i2c_periph * i2c_p
void lsm303dlhc_i2c_event(struct Lsm303dlhc_i2c *lsm)
bool initialized
config done flag
signed short int16_t
Definition: types.h:17
I2C transaction structure.
Definition: i2c.h:93
union Lsm303dlhc_i2c::@311 data_accel
I2C peripheral structure.
Definition: i2c.h:138
union Lsm303dlhc_i2c::@312 config
unsigned char uint8_t
Definition: types.h:14
volatile bool data_available
data ready flag
static void lsm303dlhc_i2c_periodic(struct Lsm303dlhc_i2c *lsm)
convenience function: read or start configuration if not already initialized
void lsm303dlhc_i2c_start_configure(struct Lsm303dlhc_i2c *lsm)
void lsm303dlhc_i2c_read(struct Lsm303dlhc_i2c *lsm)
void lsm303dlhc_i2c_init(struct Lsm303dlhc_i2c *lsm, struct i2c_periph *i2c_p, uint8_t addr)
Initialize Lsm303dlhc struct and set default config options.
Driver for ST LSM303DLHC 3D accelerometer and magnetometer.
Paparazzi fixed point algebra.
union Lsm303dlhc_i2c::@310 init_status
Architecture independent I2C (Inter-Integrated Circuit Bus) API.