Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
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
28
30#include "peripherals/mpl3115.h"
31#include "modules/core/abi.h"
32#include "mcu_periph/sys_time.h"
33
34//Messages
35#include "mcu_periph/uart.h"
36#include "pprzlink/messages.h"
38
39
40#ifndef BARO_MPL3115_I2C_DEV
41#define BARO_MPL3115_I2C_DEV i2c0
42#endif
43
44#ifndef BARO_MPL3115_I2C_SLAVE_ADDR
45#define BARO_MPL3115_I2C_SLAVE_ADDR MPL3115_I2C_ADDR
46#endif
47
48
50
55
56
61
62
64{
66 if (baro_mpl.data_available) {
67 uint32_t now_ts = get_sys_time_usec();
68 float pressure = (float)baro_mpl.pressure / (1 << 2);
69 AbiSendMsgBARO_ABS_RAW(BARO_MPL3115_SENDER_ID, now_ts, pressure);
70 float temp = (float)baro_mpl.temperature / 16.0f;
71 AbiSendMsgTEMPERATURE_RAW(BARO_MPL3115_SENDER_ID, now_ts, temp, TEMPERATURE_TYPE_BARO);
72 baro_mpl.data_available = false;
73 }
74}
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Main include for ABI (AirBorneInterface).
#define TEMPERATURE_TYPE_BARO
barometer die
Definition abi_common.h:91
#define BARO_MPL3115_SENDER_ID
struct Mpl3115 baro_mpl
void baro_mpl3115_read_periodic(void)
#define BARO_MPL3115_I2C_DEV
void baro_mpl3115_init(void)
void baro_mpl3115_read_event(void)
#define BARO_MPL3115_I2C_SLAVE_ADDR
Module for the baro MPL3115A2 from Freescale (i2c).
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
void mpl3115_periodic(struct Mpl3115 *mpl)
Definition mpl3115.c:153
void mpl3115_init(struct Mpl3115 *mpl, struct i2c_periph *i2c_p, uint8_t addr)
Definition mpl3115.c:31
void mpl3115_event(struct Mpl3115 *mpl)
Definition mpl3115.c:107
Driver for the baro MPL3115A2 from Freescale (i2c).
uint32_t pressure
pressure in 1/4 Pascal
Definition mpl3115.h:80
Architecture independent timing functions.
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.