Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
baro_board.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Felix Ruess <felix.ruess@gmail.com>
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 
26 #include "std.h"
27 
29 #include "peripherals/bmp085.h"
31 #include <libopencm3/stm32/gpio.h>
32 #include "subsystems/abi.h"
33 
34 #include "led.h"
35 
36 
38 
39 static bool baro_eoc(void)
40 {
41  return gpio_get(GPIOB, GPIO0);
42 }
43 
44 void baro_init(void)
45 {
47 
48  /* setup eoc check function */
50 
53 
54 #ifdef BARO_LED
55  LED_OFF(BARO_LED);
56 #endif
57 }
58 
59 
60 void baro_periodic(void)
61 {
64  } else {
66  }
67 }
68 
69 
70 
71 void baro_event(void)
72 {
74 
76  uint32_t now_ts = get_sys_time_usec();
77  float pressure = (float)baro_bmp085.pressure;
78  AbiSendMsgBARO_ABS(BARO_BOARD_SENDER_ID, now_ts, pressure);
79  float temp = baro_bmp085.temperature / 10.0f;
80  AbiSendMsgTEMPERATURE(BARO_BOARD_SENDER_ID, temp);
82 #ifdef BARO_LED
83  RunOnceEvery(10, LED_TOGGLE(BARO_LED));
84 #endif
85  }
86 }
BARO_BOARD_SENDER_ID
#define BARO_BOARD_SENDER_ID
default onboard baro
Definition: abi_sender_ids.h:33
LED_OFF
#define LED_OFF(i)
Definition: led_hw.h:52
abi.h
bmp085_periodic
void bmp085_periodic(struct Bmp085 *bmp)
Start new measurement if idle or read temp/pressure.
Definition: bmp085.c:108
Bmp085::temperature
int32_t temperature
temperature in 0.1 deg Celcius
Definition: bmp085.h:72
uint32_t
unsigned long uint32_t
Definition: types.h:18
GPIOB
#define GPIOB
Definition: gpio_arch.h:37
LED_TOGGLE
#define LED_TOGGLE(i)
Definition: led_hw.h:53
baro_init
void baro_init(void)
Definition: baro_board.c:76
baro_periodic
void baro_periodic(void)
Definition: baro_board.c:90
bmp085_init
void bmp085_init(struct Bmp085 *bmp, struct i2c_periph *i2c_p, uint8_t addr)
Definition: bmp085.c:83
baro_bmp085
struct Bmp085 baro_bmp085
Definition: baro_board.c:35
get_sys_time_usec
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
Definition: sys_time_arch.c:68
gpio_clear
static void gpio_clear(ioportid_t port, uint16_t pin)
Clear a gpio output to low level.
Definition: gpio_arch.h:108
std.h
gpio_setup_input_pulldown
void gpio_setup_input_pulldown(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as inputs with pull down resistors enabled.
Definition: gpio_arch.c:54
Bmp085::eoc
Bmp085EOC eoc
function to check End Of Conversion
Definition: bmp085.h:65
bmp085_regs.h
bmp085.h
Bmp085::initialized
bool initialized
config done flag
Definition: bmp085.h:67
GPIO0
#define GPIO0
Definition: gpio_def.h:31
led.h
arch independent LED (Light Emitting Diodes) API
bmp085_read_eeprom_calib
void bmp085_read_eeprom_calib(struct Bmp085 *bmp)
Definition: bmp085.c:73
baro.h
gpio_get
static uint8_t gpio_get(ioportid_t port, uint16_t pin)
Get level of a gpio.
Definition: gpio_arch.h:88
Bmp085::pressure
int32_t pressure
pressure in Pascal
Definition: bmp085.h:73
baro_event
void baro_event(void)
Definition: baro_board.c:72
Bmp085::data_available
volatile bool data_available
data ready flag
Definition: bmp085.h:68
Bmp085
Definition: bmp085.h:62
BMP085_SLAVE_ADDR
#define BMP085_SLAVE_ADDR
Definition: bmp085_regs.h:57
bmp085_event
void bmp085_event(struct Bmp085 *bmp)
Definition: bmp085.c:142
baro_eoc
static bool baro_eoc(void)
Definition: baro_board.c:39