Paparazzi UAS  v5.18.0_stable
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
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
Itg3200Config::smplrt_div
uint8_t smplrt_div
Sample rate divider.
Definition: itg3200.h:53
Itg3200::config
struct Itg3200Config config
Definition: itg3200.h:80
Itg3200Config::fs_sel
uint8_t fs_sel
Full scale range.
Definition: itg3200.h:54
itg3200_init
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
itg3200_set_default_config
void itg3200_set_default_config(struct Itg3200Config *conf)
Definition: itg3200.c:33
Int32Rates
angular rates
Definition: pprz_algebra_int.h:179
Itg3200::initialized
bool initialized
config done flag
Definition: itg3200.h:73
ITG_CONF_INT
@ ITG_CONF_INT
Definition: itg3200.h:65
itg3200_read
void itg3200_read(struct Itg3200 *itg)
Definition: itg3200.c:113
itg3200_event
void itg3200_event(struct Itg3200 *itg)
Definition: itg3200.c:126
Itg3200Config::int_cfg
uint8_t int_cfg
Interrupt config.
Definition: itg3200.h:56
itg3200_start_configure
void itg3200_start_configure(struct Itg3200 *itg)
Definition: itg3200.c:102
ITG_CONF_SD
@ ITG_CONF_SD
Definition: itg3200.h:63
pprz_algebra_int.h
Paparazzi fixed point algebra.
Itg3200Config
Definition: itg3200.h:52
Itg3200DLPF
Itg3200DLPF
Digital Low Pass Filter Options.
Definition: itg3200_regs.h:51
Itg3200::init_status
enum Itg3200ConfStatus init_status
init status
Definition: itg3200.h:74
std.h
Itg3200::i2c_p
struct i2c_periph * i2c_p
Definition: itg3200.h:71
Itg3200::i2c_trans
struct i2c_transaction i2c_trans
Definition: itg3200.h:72
Itg3200Config::dlpf_cfg
enum Itg3200DLPF dlpf_cfg
Digital Low Pass Filter.
Definition: itg3200.h:55
uint8_t
unsigned char uint8_t
Definition: types.h:14
ITG_CONF_UNINIT
@ ITG_CONF_UNINIT
Definition: itg3200.h:62
ITG_CONF_PWR
@ ITG_CONF_PWR
Definition: itg3200.h:66
Itg3200::data
union Itg3200::@319 data
i2c_transaction
I2C transaction structure.
Definition: i2c.h:93
itg3200_regs.h
Itg3200Config::clk_sel
uint8_t clk_sel
Clock select.
Definition: itg3200.h:57
ITG_CONF_DONE
@ ITG_CONF_DONE
Definition: itg3200.h:67
Itg3200ConfStatus
Itg3200ConfStatus
config status states
Definition: itg3200.h:61
int32_t
signed long int32_t
Definition: types.h:19
Itg3200
Definition: itg3200.h:70
i2c_periph
Definition: i2c.h:144
i2c.h
Itg3200::data_available
volatile bool data_available
data ready flag
Definition: itg3200.h:75
ITG_CONF_DF
@ ITG_CONF_DF
Definition: itg3200.h:64
itg3200_periodic
static void itg3200_periodic(struct Itg3200 *itg)
convenience function: read or start configuration if not already initialized
Definition: itg3200.h:93