Paparazzi UAS  v6.2_unstable
Paparazzi is a free software Unmanned Aircraft System.
baro_mpl3115.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Gautier Hattenberger (ENAC)
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 
30 #include "peripherals/mpl3115.h"
31 #include "modules/core/abi.h"
32 
33 //Messages
34 #include "mcu_periph/uart.h"
35 #include "pprzlink/messages.h"
37 
38 
39 #ifndef BARO_MPL3115_I2C_DEV
40 #define BARO_MPL3115_I2C_DEV i2c0
41 #endif
42 
43 #ifndef BARO_MPL3115_I2C_SLAVE_ADDR
44 #define BARO_MPL3115_I2C_SLAVE_ADDR MPL3115_I2C_ADDR
45 #endif
46 
47 
49 
51 {
53 }
54 
55 
57 {
59 }
60 
61 
63 {
66  uint32_t now_ts = get_sys_time_usec();
67  float pressure = (float)baro_mpl.pressure / (1 << 2);
68  AbiSendMsgBARO_ABS(BARO_MPL3115_SENDER_ID, pressure);
69  float temp = (float)baro_mpl.pressure / 16.0f;
70  AbiSendMsgTEMPERATURE(BARO_MPL3115_SENDER_ID, now_ts, temp);
71 #ifdef SENSOR_SYNC_SEND
72  DOWNLINK_SEND_MPL3115_BARO(DefaultChannel, DefaultDevice, &baro_mpl.pressure, &baro_mpl.temperature, &baro_mpl.alt);
73 #endif
74  baro_mpl.data_available = false;
75  }
76 }
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
88 
89 
90 
91 
uint32_t
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
Definition: vl53l1_types.h:78
mpl3115_event
void mpl3115_event(struct Mpl3115 *mpl)
Definition: mpl3115.c:107
abi.h
mpl3115.h
BARO_MPL3115_I2C_SLAVE_ADDR
#define BARO_MPL3115_I2C_SLAVE_ADDR
Definition: baro_mpl3115.c:44
BARO_MPL3115_I2C_DEV
#define BARO_MPL3115_I2C_DEV
Definition: baro_mpl3115.c:40
Mpl3115::pressure
uint32_t pressure
pressure in 1/4 Pascal
Definition: mpl3115.h:80
Mpl3115
Definition: mpl3115.h:70
get_sys_time_usec
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
Definition: sys_time_arch.c:75
baro_mpl3115_read_event
void baro_mpl3115_read_event(void)
Definition: baro_mpl3115.c:62
uart.h
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
baro_mpl3115_read_periodic
void baro_mpl3115_read_periodic(void)
Definition: baro_mpl3115.c:56
mpl3115_periodic
void mpl3115_periodic(struct Mpl3115 *mpl)
Definition: mpl3115.c:153
baro_mpl3115_init
void baro_mpl3115_init(void)
Definition: baro_mpl3115.c:50
BARO_MPL3115_SENDER_ID
#define BARO_MPL3115_SENDER_ID
Definition: abi_sender_ids.h:64
Mpl3115::temperature
int16_t temperature
temperature in 1/16 degrees Celcius
Definition: mpl3115.h:79
Mpl3115::data_available
volatile bool data_available
data ready flag
Definition: mpl3115.h:76
baro_mpl3115.h
baro_mpl
struct Mpl3115 baro_mpl
Definition: baro_mpl3115.c:48
mpl3115_init
void mpl3115_init(struct Mpl3115 *mpl, struct i2c_periph *i2c_p, uint8_t addr)
Definition: mpl3115.c:31