Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces 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
29#ifndef L3G4200_H
30#define L3G4200_H
31
32#include "std.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
57
66
67struct L3g4200 {
72 volatile bool data_available;
73 union {
74 struct Int32Rates rates;
75 int32_t value[3];
78};
79
80// Functions
81extern void l3g4200_init(struct L3g4200 *l3g, struct i2c_periph *i2c_p, uint8_t i2c_address);
82extern void l3g4200_set_default_config(struct L3g4200Config *conf);
83extern void l3g4200_start_configure(struct L3g4200 *l3g);
84extern void l3g4200_read(struct L3g4200 *l3g);
85extern void l3g4200_event(struct L3g4200 *l3g);
86
88static 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
I2C transaction structure.
Definition i2c.h:93
angular rates
Architecture independent I2C (Inter-Integrated Circuit Bus) API.
void l3g4200_start_configure(struct L3g4200 *l3g)
Definition l3g4200.c:93
static void l3g4200_periodic(struct L3g4200 *l3g)
convenience function: read or start configuration if not already initialized
Definition l3g4200.h:88
uint8_t ctrl_reg5
Definition l3g4200.h:55
bool initialized
config done flag
Definition l3g4200.h:70
volatile bool data_available
data ready flag
Definition l3g4200.h:72
uint8_t ctrl_reg4
Definition l3g4200.h:54
struct i2c_periph * i2c_p
Definition l3g4200.h:68
struct i2c_transaction i2c_trans
Definition l3g4200.h:69
uint8_t ctrl_reg1
Definition l3g4200.h:53
struct L3g4200Config config
Definition l3g4200.h:77
enum L3g4200ConfStatus init_status
init status
Definition l3g4200.h:71
void l3g4200_read(struct L3g4200 *l3g)
Definition l3g4200.c:104
L3g4200ConfStatus
config status states
Definition l3g4200.h:59
@ L3G_CONF_REG1
Definition l3g4200.h:61
@ L3G_CONF_REG4
Definition l3g4200.h:62
@ L3G_CONF_UNINIT
Definition l3g4200.h:60
@ L3G_CONF_DONE
Definition l3g4200.h:64
@ L3G_CONF_REG5
Definition l3g4200.h:63
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
void l3g4200_set_default_config(struct L3g4200Config *conf)
Definition l3g4200.c:33
union L3g4200::@330 data
void l3g4200_event(struct L3g4200 *l3g)
Definition l3g4200.c:114
Register defs for L3G4200 gyros.
uint16_t foo
Definition main_demo5.c:58
Paparazzi fixed point algebra.
int int32_t
Typedef defining 32 bit int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.