aboutsummaryrefslogtreecommitdiff
path: root/apps/drivers/l3gd20/l3gd20.cpp
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2012-08-30 22:32:42 -0700
committerpx4dev <px4@purgatory.org>2012-08-30 22:32:42 -0700
commit1e80bd544ba535dbaabc86cf26bcf3dcf4576921 (patch)
tree7b121738bae4464a8ee44d2040a7eb7fa294fb11 /apps/drivers/l3gd20/l3gd20.cpp
parent2e4424f405b16203caf60387295d5822aacae52e (diff)
downloadpx4-firmware-1e80bd544ba535dbaabc86cf26bcf3dcf4576921.tar.gz
px4-firmware-1e80bd544ba535dbaabc86cf26bcf3dcf4576921.tar.bz2
px4-firmware-1e80bd544ba535dbaabc86cf26bcf3dcf4576921.zip
Make the buffer ring work.
Avoid reading from the misaligned structure more than once. Discard some redundant whitespace / prototype.
Diffstat (limited to 'apps/drivers/l3gd20/l3gd20.cpp')
-rw-r--r--apps/drivers/l3gd20/l3gd20.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/apps/drivers/l3gd20/l3gd20.cpp b/apps/drivers/l3gd20/l3gd20.cpp
index 812cf418f..bfdabe273 100644
--- a/apps/drivers/l3gd20/l3gd20.cpp
+++ b/apps/drivers/l3gd20/l3gd20.cpp
@@ -146,9 +146,6 @@ static const int ERROR = -1;
#define FIFO_CTRL_STREAM_TO_FIFO_MODE (3<<5)
#define FIFO_CTRL_BYPASS_TO_STREAM_MODE (1<<7)
-
-
-
extern "C" { __EXPORT int l3gd20_main(int argc, char *argv[]); }
class L3GD20 : public device::SPI
@@ -268,12 +265,6 @@ private:
#define INCREMENT(_x, _lim) do { _x++; if (_x >= _lim) _x = 0; } while(0)
-/*
- * Driver 'main' command.
- */
-extern "C" { int l3gd20_main(int argc, char *argv[]); }
-
-
L3GD20::L3GD20(int bus, spi_dev_e device) :
SPI("L3GD20", GYRO_DEVICE_PATH, bus, device, SPIDEV_MODE3, 8000000),
_call_interval(0),
@@ -689,12 +680,19 @@ L3GD20::measure()
report->y_raw = raw_report.y;
report->z_raw = raw_report.z;
- report->x = ((raw_report.x * _gyro_range_scale) - _gyro_scale.x_offset) * _gyro_scale.x_scale;
- report->y = ((raw_report.y * _gyro_range_scale) - _gyro_scale.y_offset) * _gyro_scale.y_scale;
- report->z = ((raw_report.z * _gyro_range_scale) - _gyro_scale.z_offset) * _gyro_scale.z_scale;
+ report->x = ((report->x_raw * _gyro_range_scale) - _gyro_scale.x_offset) * _gyro_scale.x_scale;
+ report->y = ((report->y_raw * _gyro_range_scale) - _gyro_scale.y_offset) * _gyro_scale.y_scale;
+ report->z = ((report->z_raw * _gyro_range_scale) - _gyro_scale.z_offset) * _gyro_scale.z_scale;
report->scaling = _gyro_range_scale;
report->range_rad_s = _gyro_range_rad_s;
+ /* post a report to the ring - note, not locked */
+ INCREMENT(_next_report, _num_reports);
+
+ /* if we are running up against the oldest report, fix it */
+ if (_next_report == _oldest_report)
+ INCREMENT(_oldest_report, _num_reports);
+
/* notify anyone waiting for data */
poll_notify(POLLIN);