Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
adxl345_i2c.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 
29 #ifndef ADXL345_I2C_H
30 #define ADXL345_I2C_H
31 
32 #include "std.h"
33 #include "math/pprz_algebra_int.h"
34 #include "mcu_periph/i2c.h"
35 
36 /* Include common ADXL345 options and definitions */
37 #include "peripherals/adxl345.h"
38 
39 struct Adxl345_I2c {
40  struct i2c_periph *i2c_p;
43  bool_t initialized;
44  volatile bool_t data_available;
45  union {
46  struct Int16Vect3 vect;
48  } data;
50 };
51 
52 // Functions
53 extern void adxl345_i2c_init(struct Adxl345_I2c *adxl, struct i2c_periph *i2c_p, uint8_t addr);
54 extern void adxl345_i2c_start_configure(struct Adxl345_I2c *adxl);
55 extern void adxl345_i2c_read(struct Adxl345_I2c *adxl);
56 extern void adxl345_i2c_event(struct Adxl345_I2c *adxl);
57 
59 static inline void adxl345_i2c_periodic(struct Adxl345_I2c *adxl) {
60  if (adxl->initialized)
61  adxl345_i2c_read(adxl);
62  else
64 }
65 
66 #endif // ADXL345_I2C_H
void adxl345_i2c_event(struct Adxl345_I2c *adxl)
Definition: adxl345_i2c.c:114
struct i2c_transaction i2c_trans
Definition: adxl345_i2c.h:41
enum Adxl345ConfStatus init_status
init status
Definition: adxl345_i2c.h:42
void adxl345_i2c_init(struct Adxl345_I2c *adxl, struct i2c_periph *i2c_p, uint8_t addr)
Definition: adxl345_i2c.c:36
bool_t initialized
config done flag
Definition: adxl345_i2c.h:43
void adxl345_i2c_read(struct Adxl345_I2c *adxl)
Definition: adxl345_i2c.c:101
struct Int16Vect3 vect
data vector in accel coordinate system
Definition: adxl345_i2c.h:46
static void adxl345_i2c_periodic(struct Adxl345_I2c *adxl)
convenience function: read or start configuration if not already initialized
Definition: adxl345_i2c.h:59
int16_t value[3]
data values accessible by channel index
Definition: adxl345_i2c.h:47
signed short int16_t
Definition: types.h:17
Adxl345ConfStatus
Definition: adxl345.h:36
unsigned char uint8_t
Definition: types.h:14
struct i2c_periph * i2c_p
Definition: adxl345_i2c.h:40
Definition: i2c.h:90
struct Adxl345Config config
Definition: adxl345_i2c.h:49
union Adxl345_I2c::@17 data
Analog Devices ADXL345 accelerometer driver common interface (I2C and SPI).
volatile bool_t data_available
data ready flag
Definition: adxl345_i2c.h:44
void adxl345_i2c_start_configure(struct Adxl345_I2c *adxl)
Start configuration if not already done.
Definition: adxl345_i2c.c:90
Paparazzi fixed point algebra.
Architecture independent I2C (Inter-Integrated Circuit Bus) API.