aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/hmc5883/hmc5883.cpp
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2013-09-08 21:42:00 +1000
committerLorenz Meier <lm@inf.ethz.ch>2013-09-12 00:51:13 +0200
commit04f8e338b682d0f72f00ad12f22b5071a8f6bd18 (patch)
treeae5d60facf20383b3c8f87391007e7aac69b0de0 /src/drivers/hmc5883/hmc5883.cpp
parent1f19a27e3cd5d0686dd65ecad6a171d025058b7c (diff)
downloadpx4-firmware-04f8e338b682d0f72f00ad12f22b5071a8f6bd18.tar.gz
px4-firmware-04f8e338b682d0f72f00ad12f22b5071a8f6bd18.tar.bz2
px4-firmware-04f8e338b682d0f72f00ad12f22b5071a8f6bd18.zip
hmc5883: add perf count, and removed unnecessary checks for -32768
we've already checked that the absolute value is <= 2048
Diffstat (limited to 'src/drivers/hmc5883/hmc5883.cpp')
-rw-r--r--src/drivers/hmc5883/hmc5883.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/drivers/hmc5883/hmc5883.cpp b/src/drivers/hmc5883/hmc5883.cpp
index 0de82c304..378f433cd 100644
--- a/src/drivers/hmc5883/hmc5883.cpp
+++ b/src/drivers/hmc5883/hmc5883.cpp
@@ -842,8 +842,10 @@ HMC5883::collect()
*/
if ((abs(report.x) > 2048) ||
(abs(report.y) > 2048) ||
- (abs(report.z) > 2048))
+ (abs(report.z) > 2048)) {
+ perf_count(_comms_errors);
goto out;
+ }
/*
* RAW outputs
@@ -852,7 +854,7 @@ HMC5883::collect()
* and y needs to be negated
*/
_reports[_next_report].x_raw = report.y;
- _reports[_next_report].y_raw = ((report.x == -32768) ? 32767 : -report.x);
+ _reports[_next_report].y_raw = -report.x;
/* z remains z */
_reports[_next_report].z_raw = report.z;
@@ -878,14 +880,14 @@ HMC5883::collect()
/* to align the sensor axes with the board, x and y need to be flipped */
_reports[_next_report].x = ((report.y * _range_scale) - _scale.x_offset) * _scale.x_scale;
/* flip axes and negate value for y */
- _reports[_next_report].y = ((((report.x == -32768) ? 32767 : -report.x) * _range_scale) - _scale.y_offset) * _scale.y_scale;
+ _reports[_next_report].y = ((-report.x * _range_scale) - _scale.y_offset) * _scale.y_scale;
/* z remains z */
_reports[_next_report].z = ((report.z * _range_scale) - _scale.z_offset) * _scale.z_scale;
} else {
#endif
/* the standard external mag by 3DR has x pointing to the right, y pointing backwards, and z down,
* therefore switch x and y and invert y */
- _reports[_next_report].x = ((((report.y == -32768) ? 32767 : -report.y) * _range_scale) - _scale.x_offset) * _scale.x_scale;
+ _reports[_next_report].x = ((-report.y * _range_scale) - _scale.x_offset) * _scale.x_scale;
/* flip axes and negate value for y */
_reports[_next_report].y = ((report.x * _range_scale) - _scale.y_offset) * _scale.y_scale;
/* z remains z */