Paparazzi UAS  v5.18.0_stable
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;
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 */
Lsm303dlhcMagConfig
Definition: lsm303dlhc.h:61
lsm303dlhc_i2c_read
void lsm303dlhc_i2c_read(struct Lsm303dlhc_i2c *lsm)
Int16Vect3
Definition: pprz_algebra_int.h:62
lsm303dlhc_i2c_event
void lsm303dlhc_i2c_event(struct Lsm303dlhc_i2c *lsm)
Lsm303dlhc_i2c::i2c_trans
struct i2c_transaction i2c_trans
Definition: lsm303dlhc_i2c.h:43
lsm303dlhc.h
pprz_algebra_int.h
Paparazzi fixed point algebra.
lsm303dlhc_i2c_periodic
static void lsm303dlhc_i2c_periodic(struct Lsm303dlhc_i2c *lsm)
convenience function: read or start configuration if not already initialized
Definition: lsm303dlhc_i2c.h:69
std.h
lsm303dlhc_i2c_init
void lsm303dlhc_i2c_init(struct Lsm303dlhc_i2c *lsm, struct i2c_periph *i2c_p, uint8_t addr)
Initialize Lsm303dlhc struct and set default config options.
Definition: lsm303dlhc_i2c.c:39
Lsm303dlhc_i2c::data_available
volatile bool data_available
data ready flag
Definition: lsm303dlhc_i2c.h:49
int16_t
signed short int16_t
Definition: types.h:17
Lsm303dlhcAccConfig
Definition: lsm303dlhc.h:56
uint8_t
unsigned char uint8_t
Definition: types.h:14
i2c_transaction
I2C transaction structure.
Definition: i2c.h:93
Lsm303dlhc_i2c::init_status
union Lsm303dlhc_i2c::@326 init_status
Lsm303dlhc_i2c::data_accel
union Lsm303dlhc_i2c::@327 data_accel
Lsm303dlhc_i2c
Definition: lsm303dlhc_i2c.h:41
Lsm303dlhc_i2c::initialized
bool initialized
config done flag
Definition: lsm303dlhc_i2c.h:44
lsm303dlhc_i2c_start_configure
void lsm303dlhc_i2c_start_configure(struct Lsm303dlhc_i2c *lsm)
i2c_periph
Definition: i2c.h:144
i2c.h
Lsm303dlhc_i2c::i2c_p
struct i2c_periph * i2c_p
Definition: lsm303dlhc_i2c.h:42
Lsm303dlhc_i2c::config
union Lsm303dlhc_i2c::@328 config