Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
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;
49  volatile bool data_available;
50  union {
51  struct Int16Vect3 vect;
52  int16_t value[3];
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);
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 */
I2C transaction structure.
Definition: i2c.h:93
Architecture independent I2C (Inter-Integrated Circuit Bus) API.
Driver for ST LSM303DLHC 3D accelerometer and magnetometer.
volatile bool data_available
data ready flag
void lsm303dlhc_i2c_read(struct Lsm303dlhc_i2c *lsm)
static void lsm303dlhc_i2c_periodic(struct Lsm303dlhc_i2c *lsm)
convenience function: read or start configuration if not already initialized
void lsm303dlhc_i2c_init(struct Lsm303dlhc_i2c *lsm, struct i2c_periph *i2c_p, uint8_t addr)
Initialize Lsm303dlhc struct and set default config options.
union Lsm303dlhc_i2c::@338 config
struct i2c_transaction i2c_trans
union Lsm303dlhc_i2c::@336 init_status
struct i2c_periph * i2c_p
bool initialized
config done flag
union Lsm303dlhc_i2c::@337 data_accel
void lsm303dlhc_i2c_event(struct Lsm303dlhc_i2c *lsm)
void lsm303dlhc_i2c_start_configure(struct Lsm303dlhc_i2c *lsm)
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