Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
l3g4200.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  * 2013 Eduardo Lavratti <agressiva@hotmail.com>
5  *
6  * This file is part of paparazzi.
7  *
8  * paparazzi is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * paparazzi is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with paparazzi; see the file COPYING. If not, write to
20  * the Free Software Foundation, 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  *
23  */
24 
30 #ifndef L3G4200_H
31 #define L3G4200_H
32 
33 #include "std.h"
34 #include "math/pprz_algebra_int.h"
35 #include "mcu_periph/i2c.h"
36 
37 /* Address and register definitions */
39 
40 
42 #define L3G4200_DEFAULT_DR L3G4200_DR_800Hz
43 #define L3G4200_DEFAULT_DLPF L3G4200_DLPF_2
45 
46 
47 /* Default conf */
48 #define L3G4200_DEFAULT_CTRL_REG1 0x8f // 400hz ODR, 20hz filter, run!
49 #define L3G4200_DEFAULT_CTRL_REG5 0x02 // low pass filter enable
50 
51 struct L3g4200Config {
54 };
55 
62 };
63 
64 struct L3g4200 {
65  struct i2c_periph *i2c_p;
67  bool_t initialized;
69  volatile bool_t data_available;
70  union {
71  struct Int32Rates rates;
73  } data;
75 };
76 
77 // Functions
78 extern void l3g4200_init(struct L3g4200 *itg, struct i2c_periph *i2c_p, uint8_t i2c_address);
79 extern void l3g4200_set_default_config(struct L3g4200Config *conf);
80 extern void l3g4200_start_configure(struct L3g4200 *l3g);
81 extern void l3g4200_read(struct L3g4200 *l3g);
82 extern void l3g4200_event(struct L3g4200 *l3g);
83 
85 static inline void l3g4200_periodic(struct L3g4200 *l3g) {
86  if (l3g->initialized)
87  l3g4200_read(l3g);
88  else
90 }
91 
92 #endif // L3G4200_H
void l3g4200_event(struct L3g4200 *l3g)
Definition: l3g4200.c:109
int32_t value[3]
data values accessible by channel index
Definition: l3g4200.h:72
void l3g4200_start_configure(struct L3g4200 *l3g)
Definition: l3g4200.c:88
struct Int32Rates rates
data as angular rates in gyro coordinate system
Definition: l3g4200.h:71
static void l3g4200_periodic(struct L3g4200 *l3g)
convenience function: read or start configuration if not already initialized
Definition: l3g4200.h:85
bool_t initialized
config done flag
Definition: l3g4200.h:67
struct i2c_periph * i2c_p
Definition: l3g4200.h:65
uint8_t ctrl_reg1
Definition: l3g4200.h:52
union L3g4200::@22 data
void l3g4200_read(struct L3g4200 *l3g)
Definition: l3g4200.c:99
volatile bool_t data_available
data ready flag
Definition: l3g4200.h:69
Register defs for L3G4200 gyros.
void l3g4200_set_default_config(struct L3g4200Config *conf)
Definition: l3g4200.c:34
angular rates
uint8_t ctrl_reg5
Definition: l3g4200.h:53
signed long int32_t
Definition: types.h:19
L3g4200ConfStatus
config status states
Definition: l3g4200.h:57
struct L3g4200Config config
Definition: l3g4200.h:74
unsigned char uint8_t
Definition: types.h:14
enum L3g4200ConfStatus init_status
init status
Definition: l3g4200.h:68
void l3g4200_init(struct L3g4200 *itg, struct i2c_periph *i2c_p, uint8_t i2c_address)
Initialize L3g4200 struct and set default config options.
Definition: l3g4200.c:46
Definition: i2c.h:90
struct i2c_transaction i2c_trans
Definition: l3g4200.h:66
Paparazzi fixed point algebra.
Architecture independent I2C (Inter-Integrated Circuit Bus) API.