Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
baro_ms5611_spi.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#if USE_BARO_MEDIAN_FILTER
38struct MedianFilterFloat baro_median_temp;
39struct MedianFilterFloat baro_median_pressure;
40#endif
41
42#ifndef MS5611_SPI_DEV
43#define MS5611_SPI_DEV spi1
44#endif
45
46#ifndef MS5611_SLAVE_IDX
47#define MS5611_SLAVE_IDX SPI_SLAVE0
48#endif
49
51
56
59
60
62{
63#if USE_BARO_MEDIAN_FILTER
64 init_median_filter_f(&baro_median_temp, MEDIAN_DEFAULT_SIZE);
65 init_median_filter_f(&baro_median_pressure, MEDIAN_DEFAULT_SIZE);
66#endif
67
69
72
75}
76
81
84{
85 if (sys_time.nb_sec > 1) {
87 }
88}
89
91{
92
94
95 if (baro_ms5611.data_available) {
96 uint32_t now_ts = get_sys_time_usec();
97 #if USE_BARO_MEDIAN_FILTER
98 baro_ms5611.data.temperature = update_median_filter_f(&baro_median_temp, baro_ms5611.data.temperature);
99 #endif
100 float temp = baro_ms5611.data.temperature / 100.0f;
101 // First Temp as ABI since pressure could depend on temp
102 AbiSendMsgTEMPERATURE_RAW(BARO_MS5611_SENDER_ID, now_ts, temp, TEMPERATURE_TYPE_BARO);
103
104 #if USE_BARO_MEDIAN_FILTER
105 baro_ms5611.data.pressure = update_median_filter_f(&baro_median_pressure, baro_ms5611.data.pressure);
106 #endif
107 float pressure = (float)baro_ms5611.data.pressure;
108 AbiSendMsgBARO_ABS_RAW(BARO_MS5611_SENDER_ID, now_ts, pressure);
109
110 baro_ms5611.data_available = false;
111
114
115 }
116}
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
float baro_ms5611_alt
struct Ms5611_I2c baro_ms5611
float ftempms
float fbaroms
bool baro_ms5611_enabled
float baro_ms5611_r
#define BARO_MS5611_R
#define BARO_MS5611_SIGMA2
void baro_ms5611_periodic_check(void)
void baro_ms5611_init(void)
void baro_ms5611_read(void)
trigger new measurement or initialize if needed
void baro_ms5611_event(void)
#define MS5611_SPI_DEV
#define MS5611_SLAVE_IDX
Measurement Specialties (Intersema) MS5611-01BA pressure/temperature sensor interface for SPI.
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
static float update_median_filter_f(struct MedianFilterFloat *filter, float new_data)
static void init_median_filter_f(struct MedianFilterFloat *filter, uint8_t size)
#define MEDIAN_DEFAULT_SIZE
void ms5611_spi_event(struct Ms5611_Spi *ms)
Definition ms5611_spi.c:133
void ms5611_spi_periodic_check(struct Ms5611_Spi *ms)
Periodic function to ensure proper delay after triggering reset or conversion.
Definition ms5611_spi.c:92
void ms5611_spi_init(struct Ms5611_Spi *ms, struct spi_periph *spi_p, uint8_t slave_idx, bool is_ms5607)
Definition ms5611_spi.c:33
static void ms5611_spi_read(struct Ms5611_Spi *ms)
convenience function to trigger new measurement.
Definition ms5611_spi.h:61
Paparazzi atmospheric pressure conversion utilities.
#define FALSE
Definition std.h:5
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.