aboutsummaryrefslogtreecommitdiff
path: root/apps/drivers/ms5611/ms5611.cpp
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2012-08-14 00:07:19 -0700
committerpx4dev <px4@purgatory.org>2012-08-14 00:07:19 -0700
commit735f8ffa3d47bcdab1f85f8431928e1bdf3cccec (patch)
tree85f2cb1d2d2ca95210ac0eede105ff21af7fbf77 /apps/drivers/ms5611/ms5611.cpp
parent91d1524837b5c5302593ad8b415e9db9ca8f7680 (diff)
downloadpx4-firmware-735f8ffa3d47bcdab1f85f8431928e1bdf3cccec.tar.gz
px4-firmware-735f8ffa3d47bcdab1f85f8431928e1bdf3cccec.tar.bz2
px4-firmware-735f8ffa3d47bcdab1f85f8431928e1bdf3cccec.zip
Config tweaks to enable the new-style ms5611 driver.
Diffstat (limited to 'apps/drivers/ms5611/ms5611.cpp')
-rw-r--r--apps/drivers/ms5611/ms5611.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/apps/drivers/ms5611/ms5611.cpp b/apps/drivers/ms5611/ms5611.cpp
index 1f75ceb4b..6c6951d9b 100644
--- a/apps/drivers/ms5611/ms5611.cpp
+++ b/apps/drivers/ms5611/ms5611.cpp
@@ -58,6 +58,8 @@
#include <arch/board/up_hrt.h>
+#include <systemlib/perf_counter.h>
+
#include <drivers/drv_baro.h>
/**
@@ -123,13 +125,15 @@ private:
int32_t _dT;
int64_t _temp64;
- int _orbject;
+ int _baro_topic;
unsigned _reads;
unsigned _measure_errors;
unsigned _read_errors;
unsigned _buf_overflows;
+ perf_counter_t _sample_perf;
+
/**
* Test whether the device supported by the driver is present at a
* specific address.
@@ -245,7 +249,8 @@ MS5611::MS5611(int bus) :
_reads(0),
_measure_errors(0),
_read_errors(0),
- _buf_overflows(0)
+ _buf_overflows(0),
+ _sample_perf(perf_alloc(PC_ELAPSED, "ms5611_read"))
{
// enable debug() calls
_debug_enabled = true;
@@ -278,9 +283,9 @@ MS5611::init()
/* if this fails (e.g. no object in the system) that's OK */
memset(&b, 0, sizeof(b));
- _orbject = orb_advertise(ORB_ID(sensor_baro), &b);
+ _baro_topic = orb_advertise(ORB_ID(sensor_baro), &b);
- if (_orbject < 0)
+ if (_baro_topic < 0)
debug("failed to create sensor_baro object");
}
@@ -610,6 +615,8 @@ MS5611::collect()
/* read the most recent measurement */
cmd = 0;
+ perf_begin(_sample_perf);
+
/* this should be fairly close to the end of the conversion, so the best approximation of the time */
_reports[_next_report].timestamp = hrt_absolute_time();
@@ -655,7 +662,7 @@ MS5611::collect()
_reports[_next_report].altitude = (44330.0 * (1.0 - pow((press_int64 / 101325.0), 0.190295)));
/* publish it */
- orb_publish(ORB_ID(sensor_baro), _orbject, &_reports[_next_report]);
+ orb_publish(ORB_ID(sensor_baro), _baro_topic, &_reports[_next_report]);
/* post a report to the ring - note, not locked */
INCREMENT(_next_report, _num_reports);
@@ -670,10 +677,11 @@ MS5611::collect()
poll_notify(POLLIN);
}
-
/* update the measurement state machine */
INCREMENT(_measure_phase, MS5611_MEASUREMENT_RATIO + 1);
+ perf_end(_sample_perf);
+
return OK;
}