Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
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;
72  struct i2c_transaction trans;
73  struct i2c_transaction req_trans;
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
I2C transaction structure.
Definition: i2c.h:93
Architecture independent I2C (Inter-Integrated Circuit Bus) API.
uint32_t pressure
pressure in 1/4 Pascal
Definition: mpl3115.h:80
bool alt_mode
set to TRUE to enable altitude output (otherwise pressure)
Definition: mpl3115.h:78
float altitude
altitude in meters
Definition: mpl3115.h:81
void mpl3115_read(struct Mpl3115 *mpl)
Definition: mpl3115.c:92
bool initialized
config done flag
Definition: mpl3115.h:75
Mpl3115Status
Definition: mpl3115.h:63
@ MPL_CONF_UNINIT
Definition: mpl3115.h:64
@ MPL_CONF_PT_DATA
Definition: mpl3115.h:65
@ MPL_CONF_DONE
Definition: mpl3115.h:67
@ MPL_CONF_CTRL1
Definition: mpl3115.h:66
struct i2c_transaction req_trans
I2C transaction for conversion request.
Definition: mpl3115.h:73
bool raw_mode
set to TRUE to enable raw output
Definition: mpl3115.h:77
void mpl3115_periodic(struct Mpl3115 *mpl)
Definition: mpl3115.c:153
int16_t temperature
temperature in 1/16 degrees Celcius
Definition: mpl3115.h:79
struct i2c_periph * i2c_p
Definition: mpl3115.h:71
void mpl3115_init(struct Mpl3115 *mpl, struct i2c_periph *i2c_p, uint8_t addr)
Definition: mpl3115.c:31
void mpl3115_configure(struct Mpl3115 *mpl)
Definition: mpl3115.c:81
enum Mpl3115Status init_status
Definition: mpl3115.h:74
struct i2c_transaction trans
I2C transaction for reading and configuring.
Definition: mpl3115.h:72
volatile bool data_available
data ready flag
Definition: mpl3115.h:76
void mpl3115_event(struct Mpl3115 *mpl)
Definition: mpl3115.c:107
Paparazzi fixed point algebra.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
Definition: vl53l1_types.h:78
short int16_t
Typedef defining 16 bit short type.
Definition: vl53l1_types.h:93
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98