Paparazzi UAS  v5.18.0_stable
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;
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
mpl3115_configure
void mpl3115_configure(struct Mpl3115 *mpl)
Definition: mpl3115.c:81
MPL_CONF_DONE
@ MPL_CONF_DONE
Definition: mpl3115.h:67
MPL_CONF_CTRL1
@ MPL_CONF_CTRL1
Definition: mpl3115.h:66
uint32_t
unsigned long uint32_t
Definition: types.h:18
mpl3115_read
void mpl3115_read(struct Mpl3115 *mpl)
Definition: mpl3115.c:92
Mpl3115::pressure
uint32_t pressure
pressure in 1/4 Pascal
Definition: mpl3115.h:80
pprz_algebra_int.h
Paparazzi fixed point algebra.
Mpl3115
Definition: mpl3115.h:70
mpl3115_init
void mpl3115_init(struct Mpl3115 *mpl, struct i2c_periph *i2c_p, uint8_t addr)
Definition: mpl3115.c:31
std.h
MPL_CONF_PT_DATA
@ MPL_CONF_PT_DATA
Definition: mpl3115.h:65
Mpl3115::req_trans
struct i2c_transaction req_trans
I2C transaction for conversion request.
Definition: mpl3115.h:73
Mpl3115::initialized
bool initialized
config done flag
Definition: mpl3115.h:75
int16_t
signed short int16_t
Definition: types.h:17
uint8_t
unsigned char uint8_t
Definition: types.h:14
i2c_transaction
I2C transaction structure.
Definition: i2c.h:93
Mpl3115::init_status
enum Mpl3115Status init_status
Definition: mpl3115.h:74
Mpl3115::raw_mode
bool raw_mode
set to TRUE to enable raw output
Definition: mpl3115.h:77
Mpl3115::trans
struct i2c_transaction trans
I2C transaction for reading and configuring.
Definition: mpl3115.h:72
Mpl3115::alt_mode
bool alt_mode
set to TRUE to enable altitude output (otherwise pressure)
Definition: mpl3115.h:78
mpl3115_periodic
void mpl3115_periodic(struct Mpl3115 *mpl)
Definition: mpl3115.c:153
Mpl3115Status
Mpl3115Status
Definition: mpl3115.h:63
MPL_CONF_UNINIT
@ MPL_CONF_UNINIT
Definition: mpl3115.h:64
Mpl3115::temperature
int16_t temperature
temperature in 1/16 degrees Celcius
Definition: mpl3115.h:79
mpl3115_event
void mpl3115_event(struct Mpl3115 *mpl)
Definition: mpl3115.c:107
Mpl3115::altitude
float altitude
altitude in meters
Definition: mpl3115.h:81
Mpl3115::i2c_p
struct i2c_periph * i2c_p
Definition: mpl3115.h:71
Mpl3115::data_available
volatile bool data_available
data ready flag
Definition: mpl3115.h:76
i2c_periph
Definition: i2c.h:144
i2c.h