aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/airspeed/airspeed.h
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2013-09-09 16:35:20 +1000
committerLorenz Meier <lm@inf.ethz.ch>2013-09-12 00:52:21 +0200
commit36b7b7bc5f078f373f67cdce3f5c7855c0dcd58b (patch)
tree52c3de86dba3ce03079c0cccb4e4f3fcbac7c12e /src/drivers/airspeed/airspeed.h
parent815ccee0e7f642b2471084296c893a4dd49e5dfb (diff)
downloadpx4-firmware-36b7b7bc5f078f373f67cdce3f5c7855c0dcd58b.tar.gz
px4-firmware-36b7b7bc5f078f373f67cdce3f5c7855c0dcd58b.tar.bz2
px4-firmware-36b7b7bc5f078f373f67cdce3f5c7855c0dcd58b.zip
airspeed: convert to using RingBuffer class
Diffstat (limited to 'src/drivers/airspeed/airspeed.h')
-rw-r--r--src/drivers/airspeed/airspeed.h19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/drivers/airspeed/airspeed.h b/src/drivers/airspeed/airspeed.h
index b87494b40..7850ccc7e 100644
--- a/src/drivers/airspeed/airspeed.h
+++ b/src/drivers/airspeed/airspeed.h
@@ -68,6 +68,7 @@
#include <drivers/drv_airspeed.h>
#include <drivers/drv_hrt.h>
+#include <drivers/device/ringbuffer.h>
#include <uORB/uORB.h>
#include <uORB/topics/differential_pressure.h>
@@ -102,6 +103,10 @@ public:
*/
virtual void print_info();
+private:
+ RingBuffer<differential_pressure_s> *_reports;
+ perf_counter_t _buffer_overflows;
+
protected:
virtual int probe();
@@ -114,10 +119,7 @@ protected:
virtual int collect() = 0;
work_s _work;
- unsigned _num_reports;
- volatile unsigned _next_report;
- volatile unsigned _oldest_report;
- differential_pressure_s *_reports;
+ uint16_t _max_differential_pressure_pa;
bool _sensor_ok;
int _measure_ticks;
bool _collect_phase;
@@ -129,7 +131,6 @@ protected:
perf_counter_t _sample_perf;
perf_counter_t _comms_errors;
- perf_counter_t _buffer_overflows;
/**
@@ -162,8 +163,12 @@ protected:
*/
static void cycle_trampoline(void *arg);
+ /**
+ * add a new report to the reports queue
+ *
+ * @param report differential_pressure_s report
+ */
+ void new_report(const differential_pressure_s &report);
};
-/* helper macro for handling report buffer indices */
-#define INCREMENT(_x, _lim) do { __typeof__(_x) _tmp = _x+1; if (_tmp >= _lim) _tmp = 0; _x = _tmp; } while(0)