Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 
31 
32 #include "math/pprz_isa.h"
33 #include "mcu_periph/sys_time.h"
34 #include "subsystems/abi.h"
35 #include "mcu_periph/uart.h"
36 #include "messages.h"
38 
39 #ifndef MS5611_SPI_DEV
40 #define MS5611_SPI_DEV spi1
41 #endif
42 
43 #ifndef MS5611_SLAVE_IDX
44 #define MS5611_SLAVE_IDX SPI_SLAVE0
45 #endif
46 
47 
49 
54 
57 
58 
59 void baro_ms5611_init(void) {
61 
64 
67 }
68 
70 
72 
73 #if SENSOR_SYNC_SEND
74  // send coeff every 30s
75  RunOnceEvery((5*BARO_MS5611_PERIODIC_CHECK_FREQ), baro_ms5611_send_coeff());
76 #endif
77 
78 }
79 
81 void baro_ms5611_read(void) {
82  if (sys_time.nb_sec > 1) {
84  }
85 }
86 
87 void baro_ms5611_event( void ) {
88 
90 
92  float pressure = (float)baro_ms5611.data.pressure;
93  AbiSendMsgBARO_ABS(BARO_MS5611_SENDER_ID, &pressure);
95 
98 
99 #ifdef SENSOR_SYNC_SEND
101  fbaroms = baro_ms5611.data.pressure / 100.;
102  DOWNLINK_SEND_BARO_MS5611(DefaultChannel, DefaultDevice,
104  &fbaroms, &ftempms);
105 #endif
106  }
107 }
108 
110  if (baro_ms5611.initialized) {
111  DOWNLINK_SEND_MS5611_COEFF(DefaultChannel, DefaultDevice,
112  &baro_ms5611.data.c[0],
113  &baro_ms5611.data.c[1],
114  &baro_ms5611.data.c[2],
115  &baro_ms5611.data.c[3],
116  &baro_ms5611.data.c[4],
117  &baro_ms5611.data.c[5],
118  &baro_ms5611.data.c[6],
119  &baro_ms5611.data.c[7]);
120  }
121 }
void baro_ms5611_event(void)
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
float fbaroms
uint32_t d1
Definition: ms5611.h:55
struct Ms5611Data data
Definition: ms5611_spi.h:44
struct Ms5611_Spi baro_ms5611
int32_t temperature
temperature with 0.01 degrees Celsius resolution
Definition: ms5611.h:53
Measurement Specialties (Intersema) MS5611-01BA pressure/temperature sensor interface for SPI...
static void ms5611_spi_read(struct Ms5611_Spi *ms)
convenience function to trigger new measurement.
Definition: ms5611_spi.h:59
Main include for ABI (AirBorneInterface).
#define BARO_MS5611_R
float baro_ms5611_alt
#define FALSE
Definition: imu_chimu.h:141
volatile bool_t data_available
data ready flag
Definition: ms5611_spi.h:43
void ms5611_spi_event(struct Ms5611_Spi *ms)
Definition: ms5611_spi.c:131
#define BARO_MS5611_SENDER_ID
Architecture independent timing functions.
Paparazzi atmospheric pressure convertion utilities.
bool_t baro_ms5611_enabled
#define MS5611_SLAVE_IDX
static float pprz_isa_altitude_of_pressure(float pressure)
Get absolute altitude from pressure (using simplified equation).
Definition: pprz_isa.h:58
bool_t baro_ms5611_alt_valid
float ftempms
void baro_ms5611_send_coeff(void)
void baro_ms5611_periodic_check(void)
void ms5611_spi_init(struct Ms5611_Spi *ms, struct spi_periph *spi_p, uint8_t slave_idx)
Definition: ms5611_spi.c:33
#define TRUE
Definition: imu_chimu.h:144
void ms5611_spi_periodic_check(struct Ms5611_Spi *ms)
Periodic function to ensure proper delay after triggering reset or conversion.
Definition: ms5611_spi.c:90
float baro_ms5611_r
bool_t initialized
config done flag
Definition: ms5611_spi.h:42
float baro_ms5611_sigma2
volatile uint32_t nb_sec
full seconds since startup
Definition: sys_time.h:69
void baro_ms5611_init(void)
#define MS5611_SPI_DEV
uint16_t c[PROM_NB]
Definition: ms5611.h:54
void baro_ms5611_read(void)
trigger new measurement or initialize if needed
uint32_t pressure
pressure in Pascal (0.01mbar)
Definition: ms5611.h:52
#define BARO_MS5611_SIGMA2
uint32_t d2
Definition: ms5611.h:56