Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
lsm303dlhc.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 
29 #ifndef LSM303DLHC_H
30 #define LSM303DLHC_H
31 
32 #include "std.h"
33 #include "mcu_periph/i2c.h"
34 #include "math/pprz_algebra_int.h"
35 
36 /* Address and register definitions */
38 
44 };
45 
50 };
51 
59 };
60 
68 };
69 
70 struct Lsm303dlhc {
71  struct i2c_periph *i2c_p;
73  bool_t initialized;
74  union {
77  } init_status;
78  volatile bool_t data_available;
79  union {
80  struct Int16Vect3 vect;
82  } data;
83  union {
86  } config;
87 };
88 
89 
90 
91 // TODO IRQ handling
92 
93 // Functions
94 extern void lsm303dlhc_init(struct Lsm303dlhc *lsm, struct i2c_periph *i2c_p, uint8_t addr);
95 extern void lsm303dlhc_start_configure(struct Lsm303dlhc *lsm);
96 extern void lsm303dlhc_read(struct Lsm303dlhc *lsm);
97 extern void lsm303dlhc_event(struct Lsm303dlhc *lsm);
98 
100 static inline void lsm303dlhc_periodic(struct Lsm303dlhc *lsm) {
101  if (lsm->initialized)
102  lsm303dlhc_read(lsm);
103  else
105 }
106 
107 #endif /* LSM303DLHC_H */
bool_t initialized
config done flag
Definition: lsm303dlhc.h:73
uint8_t rate
Data Output Rate Bits(6 -> 50Hz with HMC5843, 75Hz with HMC5883)
Definition: lsm303dlhc.h:40
uint8_t scale
full scale selection
Definition: lsm303dlhc.h:42
I2C transaction structure.
Definition: i2c.h:93
int16_t value[3]
data values accessible by channel index
Definition: lsm303dlhc.h:81
void lsm303dlhc_event(struct Lsm303dlhc *lsm)
Definition: lsm303dlhc.c:210
struct i2c_transaction i2c_trans
Definition: lsm303dlhc.h:72
uint8_t mode
Measurement mode.
Definition: lsm303dlhc.h:49
Lsm303dlhcAccConfStatus
config status states
Definition: lsm303dlhc.h:53
Register defs for ST LSM303DLHC 3D accelerometer and magnetometer.
uint8_t hres
high resolution output mode
Definition: lsm303dlhc.h:43
Lsm303dlhcMagConfStatus
config status states
Definition: lsm303dlhc.h:62
static void lsm303dlhc_periodic(struct Lsm303dlhc *lsm)
convenience function: read or start configuration if not already initialized
Definition: lsm303dlhc.h:100
uint8_t gain
Gain configuration (1 -> +- 1 Gauss)
Definition: lsm303dlhc.h:48
signed short int16_t
Definition: types.h:17
void lsm303dlhc_init(struct Lsm303dlhc *lsm, struct i2c_periph *i2c_p, uint8_t addr)
Initialize Lsm303dlhc struct and set default config options.
Definition: lsm303dlhc.c:82
uint8_t rate
Data Output Rate Bits(6 -> 50Hz with HMC5843, 75Hz with HMC5883)
Definition: lsm303dlhc.h:47
struct i2c_periph * i2c_p
Definition: lsm303dlhc.h:71
uint8_t lp_mode
Low power mode.
Definition: lsm303dlhc.h:41
unsigned char uint8_t
Definition: types.h:14
volatile bool_t data_available
data ready flag
Definition: lsm303dlhc.h:78
union Lsm303dlhc::@34 init_status
union Lsm303dlhc::@36 config
I2C peripheral structure.
Definition: i2c.h:138
void lsm303dlhc_start_configure(struct Lsm303dlhc *lsm)
Definition: lsm303dlhc.c:165
union Lsm303dlhc::@35 data
enum Lsm303dlhcMagConfStatus mag
init status
Definition: lsm303dlhc.h:76
enum Lsm303dlhcAccConfStatus acc
init status
Definition: lsm303dlhc.h:75
struct Int16Vect3 vect
data vector in acc coordinate system
Definition: lsm303dlhc.h:80
void lsm303dlhc_read(struct Lsm303dlhc *lsm)
Definition: lsm303dlhc.c:185
Paparazzi fixed point algebra.
Architecture independent I2C (Inter-Integrated Circuit Bus) API.