Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
mpl3115.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011 Gautier Hattenberger
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
22 
27 #ifndef MPL3115_H
28 #define MPL3115_H
29 
30 #include "std.h"
31 #include "math/pprz_algebra_int.h"
32 #include "mcu_periph/i2c.h"
33 
34 /* Device address (8 bits) */
35 #define MPL3115_I2C_ADDR 0xC0
36 
37 /* Registers */
38 #define MPL3115_REG_STATUS 0x00
39 #define MPL3115_REG_OUT_P_MSB 0x01
40 #define MPL3115_REG_OUT_P_CSB 0x02
41 #define MPL3115_REG_OUT_P_LSB 0x03
42 #define MPL3115_REG_OUT_T_MSB 0x04
43 #define MPL3115_REG_OUT_T_LSB 0x05
44 #define MPL3115_REG_WHO_AM_I 0x0C
45 #define MPL3115_REG_PT_DATA_CFG 0x13
46 #define MPL3115_REG_CTRL_REG1 0x26
47 #define MPL3115_REG_CTRL_REG2 0x27
48 #define MPL3115_REG_CTRL_REG3 0x28
49 #define MPL3115_REG_CTRL_REG4 0x29
50 #define MPL3115_REG_CTRL_REG5 0x2A
51 
52 #define MPL3115_OST_BIT (1<<1) // One Shot control bit
53 
54 /* Default conf */
55 #ifndef MPL3115_PT_DATA_CFG
56 #define MPL3115_PT_DATA_CFG 0x2 // Enable data event flag for pressure
57 #endif
58 #ifndef MPL3115_OVERSAMPLING
59 #define MPL3115_OVERSAMPLING 0x5 // Oversample ratio (0x5: 130ms between data sample)
60 #endif
61 
62 
68 };
69 
70 struct Mpl3115 {
71  struct i2c_periph *i2c_p;
75  bool initialized;
76  volatile bool data_available;
77  bool raw_mode;
78  bool alt_mode;
81  float altitude;
82 };
83 
84 // Functions
85 extern void mpl3115_init(struct Mpl3115 *mpl, struct i2c_periph *i2c_p, uint8_t addr);
86 extern void mpl3115_configure(struct Mpl3115 *mpl);
87 extern void mpl3115_read(struct Mpl3115 *mpl);
88 extern void mpl3115_event(struct Mpl3115 *mpl);
89 extern void mpl3115_periodic(struct Mpl3115 *mpl);
90 
91 #endif // MPL3115_H
volatile bool data_available
data ready flag
Definition: mpl3115.h:76
void mpl3115_read(struct Mpl3115 *mpl)
Definition: mpl3115.c:92
uint32_t pressure
pressure in 1/4 Pascal
Definition: mpl3115.h:80
bool raw_mode
set to TRUE to enable raw output
Definition: mpl3115.h:77
unsigned long uint32_t
Definition: types.h:18
struct i2c_transaction req_trans
I2C transaction for conversion request.
Definition: mpl3115.h:73
signed short int16_t
Definition: types.h:17
void mpl3115_init(struct Mpl3115 *mpl, struct i2c_periph *i2c_p, uint8_t addr)
Definition: mpl3115.c:31
void mpl3115_periodic(struct Mpl3115 *mpl)
Definition: mpl3115.c:153
Mpl3115Status
Definition: mpl3115.h:63
I2C transaction structure.
Definition: i2c.h:93
bool alt_mode
set to TRUE to enable altitude output (otherwise pressure)
Definition: mpl3115.h:78
int16_t temperature
temperature in 1/16 degrees Celcius
Definition: mpl3115.h:79
bool initialized
config done flag
Definition: mpl3115.h:75
struct i2c_transaction trans
I2C transaction for reading and configuring.
Definition: mpl3115.h:72
I2C peripheral structure.
Definition: i2c.h:138
enum Mpl3115Status init_status
Definition: mpl3115.h:74
float altitude
altitude in meters
Definition: mpl3115.h:81
unsigned char uint8_t
Definition: types.h:14
void mpl3115_configure(struct Mpl3115 *mpl)
Definition: mpl3115.c:81
Paparazzi fixed point algebra.
Architecture independent I2C (Inter-Integrated Circuit Bus) API.
void mpl3115_event(struct Mpl3115 *mpl)
Definition: mpl3115.c:107
struct i2c_periph * i2c_p
Definition: mpl3115.h:71