deprecate df_bmp280_wrapper and replace with in tree bmp280

- deprecate DriverFramework bmp280 driver (df_bmp280_wrapper)
 - update beaglebone blue and snapdragon flight eagle boards to use in tree bmp280
 - update posix (really just linux) and qurt I2C wrappers
 - tested on beaglebone blue
This commit is contained in:
Daniel Agar
2020-01-05 13:33:12 -05:00
committed by GitHub
parent 1da7209fe1
commit aaf5670e7d
37 changed files with 227 additions and 777 deletions
@@ -1,45 +0,0 @@
############################################################################
#
# Copyright (c) 2016 PX4 Development Team. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name PX4 nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
include_directories(../../../lib/DriverFramework/drivers)
px4_add_module(
MODULE platforms__posix__drivers__df_bmp280_wrapper
MAIN df_bmp280_wrapper
SRCS
df_bmp280_wrapper.cpp
DEPENDS
git_driverframework
df_driver_framework
df_bmp280
)
@@ -1,300 +0,0 @@
/****************************************************************************
*
* Copyright (c) 2016 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name PX4 nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/**
* @file df_bmp280_wrapper.cpp
* Lightweight driver to access the BMP280 of the DriverFramework.
*
* @author Julian Oes <julian@oes.ch>
*/
#include <px4_platform_common/px4_config.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <unistd.h>
#include <px4_platform_common/getopt.h>
#include <errno.h>
#include <perf/perf_counter.h>
#include <systemlib/err.h>
#include <drivers/drv_hrt.h>
#include <drivers/drv_baro.h>
#include <board_config.h>
//#include <mathlib/math/filter/LowPassFilter2p.hpp>
#include <bmp280/BMP280.hpp>
#include <DevMgr.hpp>
extern "C" { __EXPORT int df_bmp280_wrapper_main(int argc, char *argv[]); }
using namespace DriverFramework;
class DfBmp280Wrapper : public BMP280
{
public:
DfBmp280Wrapper();
~DfBmp280Wrapper();
/**
* Start automatic measurement.
*
* @return 0 on success
*/
int start();
/**
* Stop automatic measurement.
*
* @return 0 on success
*/
int stop();
private:
int _publish(struct baro_sensor_data &data);
orb_advert_t _baro_topic;
int _baro_orb_class_instance;
perf_counter_t _baro_sample_perf;
};
DfBmp280Wrapper::DfBmp280Wrapper() :
BMP280(BARO_DEVICE_PATH),
_baro_topic(nullptr),
_baro_orb_class_instance(-1),
_baro_sample_perf(perf_alloc(PC_ELAPSED, "df_baro_read"))
{
}
DfBmp280Wrapper::~DfBmp280Wrapper()
{
perf_free(_baro_sample_perf);
}
int DfBmp280Wrapper::start()
{
/* Init device and start sensor. */
int ret = init();
if (ret != 0) {
PX4_ERR("BMP280 init fail: %d", ret);
return ret;
}
ret = BMP280::start();
if (ret != 0) {
PX4_ERR("BMP280 start fail: %d", ret);
return ret;
}
#if defined(__DF_BBBLUE)
PX4_INFO("BMP280 started");
#endif
return 0;
}
int DfBmp280Wrapper::stop()
{
/* Stop sensor. */
int ret = BMP280::stop();
if (ret != 0) {
PX4_ERR("BMP280 stop fail: %d", ret);
return ret;
}
return 0;
}
int DfBmp280Wrapper::_publish(struct baro_sensor_data &data)
{
perf_begin(_baro_sample_perf);
sensor_baro_s baro_report = {};
baro_report.timestamp = hrt_absolute_time();
baro_report.error_count = data.error_counter;
baro_report.pressure = data.pressure_pa / 100.0f; // to mbar
baro_report.temperature = data.temperature_c;
// TODO: when is this ever blocked?
if (!(m_pub_blocked)) {
if (_baro_topic == nullptr) {
_baro_topic = orb_advertise_multi(ORB_ID(sensor_baro), &baro_report,
&_baro_orb_class_instance, ORB_PRIO_DEFAULT);
} else {
orb_publish(ORB_ID(sensor_baro), _baro_topic, &baro_report);
}
}
perf_end(_baro_sample_perf);
return 0;
};
namespace df_bmp280_wrapper
{
DfBmp280Wrapper *g_dev = nullptr;
int start(/* enum Rotation rotation */);
int stop();
int info();
void usage();
int start(/*enum Rotation rotation*/)
{
g_dev = new DfBmp280Wrapper(/*rotation*/);
if (g_dev == nullptr) {
PX4_ERR("failed instantiating DfBmp280Wrapper object");
return -1;
}
int ret = g_dev->start();
if (ret != 0) {
PX4_ERR("DfBmp280Wrapper start failed");
return ret;
}
// Open the IMU sensor
DevHandle h;
DevMgr::getHandle(BARO_DEVICE_PATH, h);
if (!h.isValid()) {
DF_LOG_INFO("Error: unable to obtain a valid handle for the receiver at: %s (%d)",
BARO_DEVICE_PATH, h.getError());
return -1;
}
DevMgr::releaseHandle(h);
return 0;
}
int stop()
{
if (g_dev == nullptr) {
PX4_ERR("driver not running");
return 1;
}
int ret = g_dev->stop();
if (ret != 0) {
PX4_ERR("driver could not be stopped");
return ret;
}
delete g_dev;
g_dev = nullptr;
return 0;
}
/**
* Print a little info about the driver.
*/
int
info()
{
if (g_dev == nullptr) {
PX4_ERR("driver not running");
return 1;
}
PX4_DEBUG("state @ %p", g_dev);
return 0;
}
void
usage()
{
PX4_WARN("Usage: df_bmp280_wrapper 'start', 'info', 'stop'");
}
} // namespace df_bmp280_wrapper
int
df_bmp280_wrapper_main(int argc, char *argv[])
{
int ret = 0;
int myoptind = 1;
if (argc <= 1) {
df_bmp280_wrapper::usage();
return 1;
}
const char *verb = argv[myoptind];
if (!strcmp(verb, "start")) {
ret = df_bmp280_wrapper::start();
}
else if (!strcmp(verb, "stop")) {
ret = df_bmp280_wrapper::stop();
}
else if (!strcmp(verb, "info")) {
ret = df_bmp280_wrapper::info();
}
else {
df_bmp280_wrapper::usage();
return 1;
}
return ret;
}
+7 -2
View File
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2012-2017 PX4 Development Team. All rights reserved.
* Copyright (c) 2012-2020 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -62,17 +62,20 @@
#define DRV_MAG_DEVTYPE_QMC5883 0x08
#define DRV_MAG_DEVTYPE_AK09916 0x09
#define DRV_DEVTYPE_ICM20948 0x0A
#define DRV_ACC_DEVTYPE_LSM303D 0x11
#define DRV_ACC_DEVTYPE_BMA180 0x12
#define DRV_ACC_DEVTYPE_MPU6000 0x13
#define DRV_ACC_DEVTYPE_ACCELSIM 0x14
#define DRV_ACC_DEVTYPE_MPU9250 0x16
#define DRV_ACC_DEVTYPE_BMI160 0x17
#define DRV_GYR_DEVTYPE_MPU6000 0x21
#define DRV_GYR_DEVTYPE_L3GD20 0x22
#define DRV_GYR_DEVTYPE_GYROSIM 0x23
#define DRV_GYR_DEVTYPE_MPU9250 0x24
#define DRV_GYR_DEVTYPE_BMI160 0x25
#define DRV_RNG_DEVTYPE_MB12XX 0x31
#define DRV_RNG_DEVTYPE_LL40LS 0x32
#define DRV_ACC_DEVTYPE_MPU6050 0x33
@@ -92,12 +95,13 @@
#define DRV_ACC_DEVTYPE_BMI055 0x41
#define DRV_GYR_DEVTYPE_BMI055 0x42
#define DRV_MAG_DEVTYPE_BMM150 0x43
#define DRV_BARO_DEVTYPE_BMP285 0x44
#define DRV_DIFF_PRESS_DEVTYPE_ETS3 0x45
#define DRV_DIFF_PRESS_DEVTYPE_MS4525 0x46
#define DRV_DIFF_PRESS_DEVTYPE_MS5525 0x47
#define DRV_DIFF_PRESS_DEVTYPE_SDP31 0x48
#define DRV_DIFF_PRESS_DEVTYPE_SDP32 0x49
#define DRV_DIFF_PRESS_DEVTYPE_SDP33 0x50
#define DRV_BARO_DEVTYPE_MPL3115A2 0x51
#define DRV_ACC_DEVTYPE_FXOS8701C 0x52
@@ -108,6 +112,7 @@
#define DRV_GYR_DEVTYPE_ADIS16448 0x57
#define DRV_BARO_DEVTYPE_LPS22HB 0x58
#define DRV_ACC_DEVTYPE_ADIS16477 0x59
#define DRV_GYR_DEVTYPE_ADIS16477 0x60
#define DRV_ACC_DEVTYPE_LSM303AGR 0x61
#define DRV_MAG_DEVTYPE_LSM303AGR 0x62
@@ -487,9 +487,6 @@ start(int argc, char *argv[])
while (1) {
const int busses_to_try[] = {
PX4_I2C_BUS_EXPANSION,
#ifdef PX4_I2C_BUS_ESC
PX4_I2C_BUS_ESC,
#endif
#ifdef PX4_I2C_BUS_ONBOARD
PX4_I2C_BUS_ONBOARD,
#endif