Paparazzi UAS  v5.15_devel-112-g521f3cf
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
itg3200.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  */
23 
30 #ifndef ITG3200_H
31 #define ITG3200_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 
41 #define ITG3200_DEFAULT_SMPLRT_DIV 0
42 #define ITG3200_DEFAULT_FS_SEL 3
44 #define ITG3200_DEFAULT_DLPF_CFG ITG3200_DLPF_42HZ
46 #define ITG3200_DEFAULT_INT_CFG 1
48 #define ITG3200_DEFAULT_CLK_SEL 1
50 
51 
52 struct Itg3200Config {
58 };
59 
68 };
69 
70 struct Itg3200 {
71  struct i2c_periph *i2c_p;
73  bool initialized;
75  volatile bool data_available;
76  union {
77  struct Int32Rates rates;
78  int32_t value[3];
79  } data;
81 };
82 
83 // TODO IRQ handling
84 
85 // Functions
86 extern void itg3200_init(struct Itg3200 *itg, struct i2c_periph *i2c_p, uint8_t i2c_address);
87 extern void itg3200_set_default_config(struct Itg3200Config *conf);
88 extern void itg3200_start_configure(struct Itg3200 *itg);
89 extern void itg3200_read(struct Itg3200 *itg);
90 extern void itg3200_event(struct Itg3200 *itg);
91 
93 static inline void itg3200_periodic(struct Itg3200 *itg)
94 {
95  if (itg->initialized) {
96  itg3200_read(itg);
97  } else {
99  }
100 }
101 
102 #endif // ITG3200_H
void itg3200_event(struct Itg3200 *itg)
Definition: itg3200.c:126
angular rates
void itg3200_read(struct Itg3200 *itg)
Definition: itg3200.c:113
void itg3200_set_default_config(struct Itg3200Config *conf)
Definition: itg3200.c:33
uint8_t smplrt_div
Sample rate divider.
Definition: itg3200.h:53
union Itg3200::@310 data
void itg3200_start_configure(struct Itg3200 *itg)
Definition: itg3200.c:102
uint8_t int_cfg
Interrupt config.
Definition: itg3200.h:56
uint8_t fs_sel
Full scale range.
Definition: itg3200.h:54
void itg3200_init(struct Itg3200 *itg, struct i2c_periph *i2c_p, uint8_t i2c_address)
Initialize Itg3200 struct and set default config options.
Definition: itg3200.c:49
struct i2c_periph * i2c_p
Definition: itg3200.h:71
Itg3200DLPF
Digital Low Pass Filter Options.
Definition: itg3200_regs.h:51
struct i2c_transaction i2c_trans
Definition: itg3200.h:72
enum Itg3200ConfStatus init_status
init status
Definition: itg3200.h:74
Register defs for ITG3200 and IMU3000 gyros.
uint8_t clk_sel
Clock select.
Definition: itg3200.h:57
Itg3200ConfStatus
config status states
Definition: itg3200.h:61
I2C transaction structure.
Definition: i2c.h:93
signed long int32_t
Definition: types.h:19
I2C peripheral structure.
Definition: i2c.h:138
enum Itg3200DLPF dlpf_cfg
Digital Low Pass Filter.
Definition: itg3200.h:55
unsigned char uint8_t
Definition: types.h:14
static void itg3200_periodic(struct Itg3200 *itg)
convenience function: read or start configuration if not already initialized
Definition: itg3200.h:93
volatile bool data_available
data ready flag
Definition: itg3200.h:75
struct Itg3200Config config
Definition: itg3200.h:80
bool initialized
config done flag
Definition: itg3200.h:73
Paparazzi fixed point algebra.
Architecture independent I2C (Inter-Integrated Circuit Bus) API.