Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
baro_ms5611_i2c.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2011-2013 The Paparazzi Team
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
28
29
31
32#include "math/pprz_isa.h"
33#include "mcu_periph/sys_time.h"
34#include "modules/core/abi.h"
35
36
37#ifndef MS5611_I2C_DEV
38#define MS5611_I2C_DEV i2c0
39#endif
40
41/* address can be 0xEC or 0xEE (CSB\ low = 0xEE) */
42#ifndef MS5611_SLAVE_ADDR
43#define MS5611_SLAVE_ADDR 0xEE
44#endif
45
47#ifndef MS5611_TYPE_MS5607
48#define MS5611_TYPE_MS5607 FALSE
49#endif
51
53
58
61
62
73
79
82{
83 if (sys_time.nb_sec > 1) {
85 }
86}
87
89{
90
92
93 if (baro_ms5611.data_available) {
94 uint32_t now_ts = get_sys_time_usec();
95 float pressure = (float)baro_ms5611.data.pressure;
96 AbiSendMsgBARO_ABS_RAW(BARO_MS5611_SENDER_ID, now_ts, pressure);
97 float temp = baro_ms5611.data.temperature / 100.0f;
98 AbiSendMsgTEMPERATURE_RAW(BARO_MS5611_SENDER_ID, now_ts, temp, TEMPERATURE_TYPE_BARO);
99 baro_ms5611.data_available = false;
100
103
104 }
105}
Main include for ABI (AirBorneInterface).
#define TEMPERATURE_TYPE_BARO
barometer die
Definition abi_common.h:91
#define BARO_MS5611_SENDER_ID
float baro_ms5611_sigma2
bool baro_ms5611_alt_valid
#define MS5611_TYPE_MS5607
set to TRUE if baro is actually a MS5607
float baro_ms5611_alt
struct Ms5611_I2c baro_ms5611
void baro_ms5611_periodic_check(void)
float ftempms
#define MS5611_I2C_DEV
void baro_ms5611_init(void)
float fbaroms
bool baro_ms5611_enabled
void baro_ms5611_read(void)
trigger new measurement or initialize if needed
#define MS5611_SLAVE_ADDR
float baro_ms5611_r
void baro_ms5611_event(void)
#define BARO_MS5611_R
#define BARO_MS5611_SIGMA2
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
static float pprz_isa_altitude_of_pressure(float pressure)
Get absolute altitude from pressure (using simplified equation).
Definition pprz_isa.h:82
void ms5611_i2c_event(struct Ms5611_I2c *ms)
Definition ms5611_i2c.c:119
void ms5611_i2c_init(struct Ms5611_I2c *ms, struct i2c_periph *i2c_p, uint8_t addr, bool is_ms5607)
Definition ms5611_i2c.c:33
void ms5611_i2c_periodic_check(struct Ms5611_I2c *ms)
Periodic function to ensure proper delay after triggering reset or conversion.
Definition ms5611_i2c.c:78
static void ms5611_i2c_read(struct Ms5611_I2c *ms)
convenience function to trigger new measurement.
Definition ms5611_i2c.h:59
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
Paparazzi atmospheric pressure conversion utilities.
Architecture independent timing functions.
volatile uint32_t nb_sec
full seconds since startup
Definition sys_time.h:80
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.