mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-09 22:49:53 +08:00
[Lia] Fixed compilation warnings for Lia board
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Felix Ruess <felix.ruess@gmail.com>
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/** @file boards/lisa_m/baro_board.c
|
||||
* Baro board interface for Bosch BMP085 on LisaM I2C2 with EOC check.
|
||||
*/
|
||||
|
||||
#include "std.h"
|
||||
|
||||
#include "subsystems/sensors/baro.h"
|
||||
#include "peripherals/bmp085.h"
|
||||
#include "peripherals/bmp085_regs.h"
|
||||
#include <libopencm3/stm32/gpio.h>
|
||||
#include "subsystems/abi.h"
|
||||
|
||||
#include "led.h"
|
||||
|
||||
|
||||
struct Bmp085 baro_bmp085;
|
||||
|
||||
static bool baro_eoc(void)
|
||||
{
|
||||
return gpio_get(GPIOB, GPIO0);
|
||||
}
|
||||
|
||||
void baro_init(void)
|
||||
{
|
||||
bmp085_init(&baro_bmp085, &i2c2, BMP085_SLAVE_ADDR);
|
||||
|
||||
/* setup eoc check function */
|
||||
baro_bmp085.eoc = &baro_eoc;
|
||||
|
||||
gpio_clear(GPIOB, GPIO0);
|
||||
gpio_set_mode(GPIOB, GPIO_MODE_INPUT,
|
||||
GPIO_CNF_INPUT_PULL_UPDOWN, GPIO0);
|
||||
|
||||
#ifdef BARO_LED
|
||||
LED_OFF(BARO_LED);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void baro_periodic(void)
|
||||
{
|
||||
if (baro_bmp085.initialized) {
|
||||
bmp085_periodic(&baro_bmp085);
|
||||
} else {
|
||||
bmp085_read_eeprom_calib(&baro_bmp085);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void baro_event(void)
|
||||
{
|
||||
bmp085_event(&baro_bmp085);
|
||||
|
||||
if (baro_bmp085.data_available) {
|
||||
float pressure = (float)baro_bmp085.pressure;
|
||||
AbiSendMsgBARO_ABS(BARO_BOARD_SENDER_ID, pressure);
|
||||
float temp = baro_bmp085.temperature / 10.0f;
|
||||
AbiSendMsgTEMPERATURE(BARO_BOARD_SENDER_ID, temp);
|
||||
baro_bmp085.data_available = false;
|
||||
#ifdef BARO_LED
|
||||
RunOnceEvery(10, LED_TOGGLE(BARO_LED));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
/*
|
||||
* board specific functions for the lia board
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BOARDS_LIA_BARO_H
|
||||
#define BOARDS_LIA_BARO_H
|
||||
|
||||
// only for printing the baro type during compilation
|
||||
#ifndef BARO_BOARD
|
||||
#define BARO_BOARD BARO_BOARD_BMP085
|
||||
#endif
|
||||
|
||||
extern void baro_event(void);
|
||||
#define BaroEvent baro_event
|
||||
|
||||
#endif /* BOARDS_LIA_BARO_H */
|
||||
@@ -127,9 +127,10 @@
|
||||
|
||||
#define DefaultVoltageOfAdc(adc) (0.0045*adc)
|
||||
|
||||
|
||||
// FIXME, using baro_board right now to include the appropriate header
|
||||
#define USE_BARO_BOARD 0
|
||||
/* by default activate onboard baro */
|
||||
#ifndef USE_BARO_BOARD
|
||||
#define USE_BARO_BOARD 1
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CONFIG_LIA_1_1_H */
|
||||
|
||||
Reference in New Issue
Block a user