mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-15 18:33:33 +08:00
lps22hb cleanup unnecessary Device CDev usage
This commit is contained in:
@@ -45,16 +45,13 @@
|
||||
#define LPS22HB_CONVERSION_INTERVAL (1000000 / 25) /* microseconds */
|
||||
|
||||
LPS22HB::LPS22HB(device::Device *interface, const char *path) :
|
||||
CDev("LPS22HB", path),
|
||||
CDev(path),
|
||||
_interface(interface),
|
||||
_sample_perf(perf_alloc(PC_ELAPSED, "lps22hb_read")),
|
||||
_comms_errors(perf_alloc(PC_COUNT, "lps22hb_comms_errors"))
|
||||
{
|
||||
// set the device type from the interface
|
||||
_device_id.devid_s.bus_type = _interface->get_device_bus_type();
|
||||
_device_id.devid_s.bus = _interface->get_device_bus();
|
||||
_device_id.devid_s.address = _interface->get_device_address();
|
||||
_device_id.devid_s.devtype = DRV_BARO_DEVTYPE_LPS22HB;
|
||||
// set the interface device type
|
||||
_interface->set_device_type(DRV_BARO_DEVTYPE_LPS22HB);
|
||||
}
|
||||
|
||||
LPS22HB::~LPS22HB()
|
||||
@@ -79,7 +76,7 @@ LPS22HB::init()
|
||||
int ret = CDev::init();
|
||||
|
||||
if (ret != OK) {
|
||||
DEVICE_DEBUG("CDev init failed");
|
||||
PX4_DEBUG("CDev init failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -227,7 +224,7 @@ LPS22HB::cycle()
|
||||
|
||||
/* perform collection */
|
||||
if (OK != collect()) {
|
||||
DEVICE_DEBUG("collection error");
|
||||
PX4_DEBUG("collection error");
|
||||
/* restart the measurement state machine */
|
||||
start();
|
||||
return;
|
||||
@@ -254,7 +251,7 @@ LPS22HB::cycle()
|
||||
|
||||
/* measurement phase */
|
||||
if (OK != measure()) {
|
||||
DEVICE_DEBUG("measure error");
|
||||
PX4_DEBUG("measure error");
|
||||
}
|
||||
|
||||
/* next phase is collection */
|
||||
@@ -319,23 +316,20 @@ LPS22HB::collect()
|
||||
new_report.temperature = 42.5f + (TEMP_OUT / 480.0f);
|
||||
|
||||
/* get device ID */
|
||||
new_report.device_id = _device_id.devid;
|
||||
new_report.device_id = _interface->get_device_id();
|
||||
new_report.error_count = perf_event_count(_comms_errors);
|
||||
|
||||
if (!(_pub_blocked)) {
|
||||
if (_baro_topic != nullptr) {
|
||||
/* publish it */
|
||||
orb_publish(ORB_ID(sensor_baro), _baro_topic, &new_report);
|
||||
|
||||
if (_baro_topic != nullptr) {
|
||||
/* publish it */
|
||||
orb_publish(ORB_ID(sensor_baro), _baro_topic, &new_report);
|
||||
} else {
|
||||
bool sensor_is_onboard = !_interface->external();
|
||||
_baro_topic = orb_advertise_multi(ORB_ID(sensor_baro), &new_report, &_orb_class_instance,
|
||||
(sensor_is_onboard) ? ORB_PRIO_HIGH : ORB_PRIO_MAX);
|
||||
|
||||
} else {
|
||||
bool sensor_is_onboard = !_interface->external();
|
||||
_baro_topic = orb_advertise_multi(ORB_ID(sensor_baro), &new_report, &_orb_class_instance,
|
||||
(sensor_is_onboard) ? ORB_PRIO_HIGH : ORB_PRIO_MAX);
|
||||
|
||||
if (_baro_topic == nullptr) {
|
||||
DEVICE_DEBUG("ADVERT FAIL");
|
||||
}
|
||||
if (_baro_topic == nullptr) {
|
||||
PX4_ERR("advertise failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <drivers/device/CDev.hpp>
|
||||
#include <lib/cdev/CDev.hpp>
|
||||
#include <drivers/device/Device.hpp>
|
||||
#include <px4_config.h>
|
||||
#include <px4_workqueue.h>
|
||||
@@ -83,7 +83,7 @@ extern device::Device *LPS22HB_SPI_interface(int bus);
|
||||
extern device::Device *LPS22HB_I2C_interface(int bus);
|
||||
typedef device::Device *(*LPS22HB_constructor)(int);
|
||||
|
||||
class LPS22HB : public device::CDev
|
||||
class LPS22HB : public cdev::CDev
|
||||
{
|
||||
public:
|
||||
LPS22HB(device::Device *interface, const char *path);
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
void print_info();
|
||||
|
||||
protected:
|
||||
Device *_interface;
|
||||
device::Device *_interface;
|
||||
|
||||
private:
|
||||
work_s _work{};
|
||||
|
||||
Reference in New Issue
Block a user