Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
baro_bmp3.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Gautier Hattenberger <gautier.hattenberger@enac.fr>
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, see
18  * <http://www.gnu.org/licenses/>.
19  *
20  */
21 
30 #include "baro_bmp3.h"
31 
32 #include "modules/core/abi.h"
33 #include "mcu_periph/uart.h"
34 #include "pprzlink/messages.h"
36 
38 #ifndef BMP3_SLAVE_ADDR
39 #define BMP3_SLAVE_ADDR BMP3_I2C_ADDR
40 #endif
41 
42 struct Bmp3_I2c baro_bmp3;
43 
44 void baro_bmp3_init(void)
45 {
46  bmp3_i2c_init(&baro_bmp3, &BMP3_I2C_DEV, BMP3_SLAVE_ADDR);
47 }
48 
50 {
52 }
53 
54 void baro_bmp3_event(void)
55 {
57 
59  uint32_t now_ts = get_sys_time_usec();
60  // send ABI message
61  AbiSendMsgBARO_ABS(BARO_BMP3_SENDER_ID, now_ts, baro_bmp3.pressure);
62  AbiSendMsgTEMPERATURE(BARO_BMP3_SENDER_ID, baro_bmp3.temperature);
63  baro_bmp3.data_available = false;
64 
65 #ifdef BMP3_SYNC_SEND
69  int32_t t = (int32_t) (10.f * baro_bmp3.temperature);
70  DOWNLINK_SEND_BMP_STATUS(DefaultChannel, DefaultDevice, &up, &ut, &p, &t);
71 #endif
72  }
73 }
74 
Main include for ABI (AirBorneInterface).
#define BARO_BMP3_SENDER_ID
void baro_bmp3_periodic(void)
Definition: baro_bmp3.c:49
void baro_bmp3_init(void)
Definition: baro_bmp3.c:44
#define BMP3_SLAVE_ADDR
default slave address
Definition: baro_bmp3.c:39
void baro_bmp3_event(void)
Definition: baro_bmp3.c:54
struct Bmp3_I2c baro_bmp3
Definition: baro_bmp3.c:42
Bosch BMP3 I2C sensor interface.
void bmp3_i2c_event(struct Bmp3_I2c *bmp)
Definition: bmp3_i2c.c:125
void bmp3_i2c_periodic(struct Bmp3_I2c *bmp)
Start new measurement if sensor ready.
Definition: bmp3_i2c.c:78
void bmp3_i2c_init(struct Bmp3_I2c *bmp, struct i2c_periph *i2c_p, uint8_t addr)
init function
Definition: bmp3_i2c.c:60
float temperature
temperature in deg Celcius
Definition: bmp3_i2c.h:51
volatile bool data_available
data ready flag
Definition: bmp3_i2c.h:43
float pressure
pressure in Pascal
Definition: bmp3_i2c.h:50
uint32_t raw_temperature
uncompensated temperature
Definition: bmp3_i2c.h:49
uint32_t raw_pressure
uncompensated pressure
Definition: bmp3_i2c.h:48
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
Definition: sys_time_arch.c:71
static float p[2][2]
uint16_t up[LIGHT_NB]
Definition: light_solar.c:48
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
int int32_t
Typedef defining 32 bit int type.
Definition: vl53l1_types.h:83
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
Definition: vl53l1_types.h:78