Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
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 
29 #ifndef L3G4200_H
30 #define L3G4200_H
31 
32 #include "std.h"
33 #include "math/pprz_algebra_int.h"
34 #include "mcu_periph/i2c.h"
35 
36 /* Address and register definitions */
38 
39 
40 // Default Output rate 100hz
41 #define L3G4200_DEFAULT_DR L3G4200_DR_100Hz
42 // Default digital lowpass filter 25hz
43 #define L3G4200_DEFAULT_DLPF L3G4200_DLPF_1
44 // Default Scale
45 #define L3G4200_DEFAULT_SCALE L3G4200_SCALE_2000
46 
47 /* Default conf */
48 #define L3G4200_DEFAULT_CTRL_REG1 ((L3G4200_DEFAULT_DR<<6) | (L3G4200_DEFAULT_DLPF<<4) | 0xf);
49 #define L3G4200_DEFAULT_CTRL_REG4 (L3G4200_DEFAULT_SCALE<<4) | 0x00; // 2000deg = 0x30
50 #define L3G4200_DEFAULT_CTRL_REG5 0x00 // first low pass filter enable
51 
52 struct L3g4200Config {
56 };
57 
65 };
66 
67 struct L3g4200 {
68  struct i2c_periph *i2c_p;
70  bool initialized;
72  volatile bool data_available;
73  union {
74  struct Int32Rates rates;
75  int32_t value[3];
76  } data;
78 };
79 
80 // Functions
81 extern void l3g4200_init(struct L3g4200 *l3g, struct i2c_periph *i2c_p, uint8_t i2c_address);
82 extern void l3g4200_set_default_config(struct L3g4200Config *conf);
83 extern void l3g4200_start_configure(struct L3g4200 *l3g);
84 extern void l3g4200_read(struct L3g4200 *l3g);
85 extern void l3g4200_event(struct L3g4200 *l3g);
86 
88 static inline void l3g4200_periodic(struct L3g4200 *l3g)
89 {
90  if (l3g->initialized) {
91  l3g4200_read(l3g);
92  } else {
94  }
95 }
96 
97 #endif // L3G4200_H
l3g4200_regs.h
L3G_CONF_DONE
@ L3G_CONF_DONE
Definition: l3g4200.h:64
Int32Rates
angular rates
Definition: pprz_algebra_int.h:179
L3G_CONF_UNINIT
@ L3G_CONF_UNINIT
Definition: l3g4200.h:60
L3G_CONF_REG5
@ L3G_CONF_REG5
Definition: l3g4200.h:63
L3g4200::config
struct L3g4200Config config
Definition: l3g4200.h:77
l3g4200_periodic
static void l3g4200_periodic(struct L3g4200 *l3g)
convenience function: read or start configuration if not already initialized
Definition: l3g4200.h:88
l3g4200_start_configure
void l3g4200_start_configure(struct L3g4200 *l3g)
Definition: l3g4200.c:93
pprz_algebra_int.h
Paparazzi fixed point algebra.
l3g4200_init
void l3g4200_init(struct L3g4200 *l3g, struct i2c_periph *i2c_p, uint8_t i2c_address)
Initialize L3g4200 struct and set default config options.
Definition: l3g4200.c:47
L3G_CONF_REG1
@ L3G_CONF_REG1
Definition: l3g4200.h:61
std.h
L3g4200::initialized
bool initialized
config done flag
Definition: l3g4200.h:70
L3g4200Config::ctrl_reg4
uint8_t ctrl_reg4
Definition: l3g4200.h:54
L3g4200ConfStatus
L3g4200ConfStatus
config status states
Definition: l3g4200.h:59
L3G_CONF_REG4
@ L3G_CONF_REG4
Definition: l3g4200.h:62
L3g4200Config::ctrl_reg1
uint8_t ctrl_reg1
Definition: l3g4200.h:53
uint8_t
unsigned char uint8_t
Definition: types.h:14
L3g4200
Definition: l3g4200.h:67
l3g4200_read
void l3g4200_read(struct L3g4200 *l3g)
Definition: l3g4200.c:104
L3g4200Config::ctrl_reg5
uint8_t ctrl_reg5
Definition: l3g4200.h:55
l3g4200_set_default_config
void l3g4200_set_default_config(struct L3g4200Config *conf)
Definition: l3g4200.c:33
i2c_transaction
I2C transaction structure.
Definition: i2c.h:93
L3g4200::init_status
enum L3g4200ConfStatus init_status
init status
Definition: l3g4200.h:71
int32_t
signed long int32_t
Definition: types.h:19
L3g4200::data_available
volatile bool data_available
data ready flag
Definition: l3g4200.h:72
L3g4200::i2c_trans
struct i2c_transaction i2c_trans
Definition: l3g4200.h:69
i2c_periph
Definition: i2c.h:144
L3g4200::data
union L3g4200::@320 data
L3g4200Config
Definition: l3g4200.h:52
L3g4200::i2c_p
struct i2c_periph * i2c_p
Definition: l3g4200.h:68
i2c.h
l3g4200_event
void l3g4200_event(struct L3g4200 *l3g)
Definition: l3g4200.c:114