Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
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
43 #define ITG3200_DEFAULT_FS_SEL 3
45 #define ITG3200_DEFAULT_DLPF_CFG ITG3200_DLPF_42HZ
47 #define ITG3200_DEFAULT_INT_CFG 1
49 #define ITG3200_DEFAULT_CLK_SEL 1
50 
51 
52 struct Itg3200Config {
55  enum Itg3200DLPF dlpf_cfg;
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;
80  struct Itg3200Config config;
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
I2C transaction structure.
Definition: i2c.h:93
angular rates
Architecture independent I2C (Inter-Integrated Circuit Bus) API.
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
enum Itg3200ConfStatus init_status
init status
Definition: itg3200.h:74
enum Itg3200DLPF dlpf_cfg
Digital Low Pass Filter.
Definition: itg3200.h:55
struct i2c_transaction i2c_trans
Definition: itg3200.h:72
static void itg3200_periodic(struct Itg3200 *itg)
convenience function: read or start configuration if not already initialized
Definition: itg3200.h:93
void itg3200_start_configure(struct Itg3200 *itg)
Definition: itg3200.c:102
uint8_t smplrt_div
Sample rate divider.
Definition: itg3200.h:53
void itg3200_set_default_config(struct Itg3200Config *conf)
Definition: itg3200.c:33
void itg3200_event(struct Itg3200 *itg)
Definition: itg3200.c:126
uint8_t int_cfg
Interrupt config.
Definition: itg3200.h:56
bool initialized
config done flag
Definition: itg3200.h:73
uint8_t fs_sel
Full scale range.
Definition: itg3200.h:54
uint8_t clk_sel
Clock select.
Definition: itg3200.h:57
Itg3200ConfStatus
config status states
Definition: itg3200.h:61
@ ITG_CONF_INT
Definition: itg3200.h:65
@ ITG_CONF_SD
Definition: itg3200.h:63
@ ITG_CONF_PWR
Definition: itg3200.h:66
@ ITG_CONF_UNINIT
Definition: itg3200.h:62
@ ITG_CONF_DONE
Definition: itg3200.h:67
@ ITG_CONF_DF
Definition: itg3200.h:64
struct i2c_periph * i2c_p
Definition: itg3200.h:71
union Itg3200::@327 data
struct Itg3200Config config
Definition: itg3200.h:80
volatile bool data_available
data ready flag
Definition: itg3200.h:75
void itg3200_read(struct Itg3200 *itg)
Definition: itg3200.c:113
Register defs for ITG3200 and IMU3000 gyros.
Itg3200DLPF
Digital Low Pass Filter Options.
Definition: itg3200_regs.h:51
Paparazzi fixed point algebra.
int int32_t
Typedef defining 32 bit int type.
Definition: vl53l1_types.h:83
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98