linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Jonathan Cameron <jic23@cam.ac.uk>
Cc: linux-iio@vger.kernel.org, drivers@analog.com,
	Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 08/11] staging:iio: Fix adis16260 channel offsets and scales
Date: Mon, 15 Oct 2012 11:35:31 +0200	[thread overview]
Message-ID: <1350293734-21951-8-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <1350293734-21951-1-git-send-email-lars@metafoo.de>

Most of the channel offsets and scales in the adis16260 are incorrect:
	* Temperature scale is off by a factor of 1000
	* Voltage scale is off by a factor of 1000
	* Temperature offset is completely wrong

This patch fixes these issues. Also use the IIO_DEGREE_TO_RAD for the angle
velocity since this makes it much easier to compare it to the value given in the
datasheet.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/staging/iio/gyro/adis16260_core.c |   29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c
index 9571c03..aa964a2 100644
--- a/drivers/staging/iio/gyro/adis16260_core.c
+++ b/drivers/staging/iio/gyro/adis16260_core.c
@@ -498,28 +498,33 @@ static int adis16260_read_raw(struct iio_dev *indio_dev,
 		switch (chan->type) {
 		case IIO_ANGL_VEL:
 			*val = 0;
-			if (spi_get_device_id(st->us)->driver_data)
-				*val2 = 320;
-			else
-				*val2 = 1278;
+			if (spi_get_device_id(st->us)->driver_data) {
+				/* 0.01832 degree / sec */
+				*val2 = IIO_DEGREE_TO_RAD(18320);
+			} else {
+				/* 0.07326 degree / sec */
+				*val2 = IIO_DEGREE_TO_RAD(73260);
+			}
 			return IIO_VAL_INT_PLUS_MICRO;
 		case IIO_VOLTAGE:
-			*val = 0;
-			if (chan->channel == 0)
-				*val2 = 18315;
-			else
-				*val2 = 610500;
+			if (chan->channel == 0) {
+				*val = 1;
+				*val2 = 831500; /* 1.8315 mV */
+			} else {
+				*val = 0;
+				*val2 = 610500; /* 610.5 uV */
+			}
 			return IIO_VAL_INT_PLUS_MICRO;
 		case IIO_TEMP:
-			*val = 0;
-			*val2 = 145300;
+			*val = 145;
+			*val2 = 300000; /* 0.1453 C */
 			return IIO_VAL_INT_PLUS_MICRO;
 		default:
 			return -EINVAL;
 		}
 		break;
 	case IIO_CHAN_INFO_OFFSET:
-		*val = 25;
+		*val = 250000 / 1453; /* 25 C = 0x00 */
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_CALIBBIAS:
 		switch (chan->type) {
-- 
1.7.10.4


  parent reply	other threads:[~2012-10-15  9:34 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-15  9:35 [PATCH 01/11] iio: Add some helper macros for unit conversion Lars-Peter Clausen
2012-10-15  9:35 ` [PATCH 02/11] staging:iio: Fix adis16201 channel offsets and scales Lars-Peter Clausen
2012-10-18  9:06   ` Jonathan Cameron
2012-10-15  9:35 ` [PATCH 03/11] staging:iio: Fix adis16203 " Lars-Peter Clausen
2012-10-18  9:07   ` Jonathan Cameron
2012-10-15  9:35 ` [PATCH 04/11] " Lars-Peter Clausen
2012-10-15  9:42   ` Lars-Peter Clausen
2012-10-18  9:07     ` Jonathan Cameron
2012-10-15  9:35 ` [PATCH 05/11] staging:iio: Fix adis16209 " Lars-Peter Clausen
2012-10-18  9:09   ` Jonathan Cameron
2012-10-15  9:35 ` [PATCH 06/11] staging:iio: Fix adis16220 " Lars-Peter Clausen
2012-10-15  9:35 ` [PATCH 07/11] staging:iio: Fix adis16240 " Lars-Peter Clausen
2012-10-15  9:35 ` Lars-Peter Clausen [this message]
2012-10-15  9:35 ` [PATCH 09/11] staging:iio: Fix adis16400 " Lars-Peter Clausen
2012-10-15  9:35 ` [PATCH 10/11] staging:iio:adis16400: Report correct temperature scale and offset Lars-Peter Clausen
2012-10-15  9:35 ` [PATCH 11/11] staging:iio:adis16400: Fixup adis16336 temp channel attributes Lars-Peter Clausen
2012-10-18  8:57 ` [PATCH 01/11] iio: Add some helper macros for unit conversion Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1350293734-21951-8-git-send-email-lars@metafoo.de \
    --to=lars@metafoo.de \
    --cc=drivers@analog.com \
    --cc=jic23@cam.ac.uk \
    --cc=linux-iio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).