diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2012-10-15 05:35:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2012-10-19 11:23:32 -0400 |
commit | acba41f81f4380ad24905df4c3c0ad7f272b338f (patch) | |
tree | 49ada0eecf9d38e7945e81bcac8d60d10075ccf0 /drivers | |
parent | 45240340568a799fa140645af2a45600dfe68694 (diff) |
staging:iio: Fix adis16240 channel offsets and scales
Most of the channel offsets and scales in the adis16240 are incorrect:
* Temperature scale is of by a factor of 1000
* Voltage scale is of by a factor of 1000
* Temperature offset is completely wrong
* Peak scale is completely wrong
This patch fixes these issues. Also use the IIO_G_TO_M_S_2 macro for the
acceleration scale 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>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/iio/accel/adis16240_core.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c index 0fc26a49d681..35e093973d5c 100644 --- a/drivers/staging/iio/accel/adis16240_core.c +++ b/drivers/staging/iio/accel/adis16240_core.c | |||
@@ -373,30 +373,31 @@ static int adis16240_read_raw(struct iio_dev *indio_dev, | |||
373 | case IIO_CHAN_INFO_SCALE: | 373 | case IIO_CHAN_INFO_SCALE: |
374 | switch (chan->type) { | 374 | switch (chan->type) { |
375 | case IIO_VOLTAGE: | 375 | case IIO_VOLTAGE: |
376 | *val = 0; | 376 | if (chan->channel == 0) { |
377 | if (chan->channel == 0) | 377 | *val = 4; |
378 | *val2 = 4880; | 378 | *val2 = 880000; /* 4.88 mV */ |
379 | else | 379 | return IIO_VAL_INT_PLUS_MICRO; |
380 | } else { | ||
380 | return -EINVAL; | 381 | return -EINVAL; |
381 | return IIO_VAL_INT_PLUS_MICRO; | 382 | } |
382 | case IIO_TEMP: | 383 | case IIO_TEMP: |
383 | *val = 0; | 384 | *val = 244; /* 0.244 C */ |
384 | *val2 = 244000; | 385 | *val2 = 0; |
385 | return IIO_VAL_INT_PLUS_MICRO; | 386 | return IIO_VAL_INT_PLUS_MICRO; |
386 | case IIO_ACCEL: | 387 | case IIO_ACCEL: |
387 | *val = 0; | 388 | *val = 0; |
388 | *val2 = 504062; | 389 | *val2 = IIO_G_TO_M_S_2(51400); /* 51.4 mg */ |
389 | return IIO_VAL_INT_PLUS_MICRO; | 390 | return IIO_VAL_INT_PLUS_MICRO; |
390 | default: | 391 | default: |
391 | return -EINVAL; | 392 | return -EINVAL; |
392 | } | 393 | } |
393 | break; | 394 | break; |
394 | case IIO_CHAN_INFO_PEAK_SCALE: | 395 | case IIO_CHAN_INFO_PEAK_SCALE: |
395 | *val = 6; | 396 | *val = 0; |
396 | *val2 = 629295; | 397 | *val2 = IIO_G_TO_M_S_2(51400); /* 51.4 mg */ |
397 | return IIO_VAL_INT_PLUS_MICRO; | 398 | return IIO_VAL_INT_PLUS_MICRO; |
398 | case IIO_CHAN_INFO_OFFSET: | 399 | case IIO_CHAN_INFO_OFFSET: |
399 | *val = 25; | 400 | *val = 25000 / 244 - 0x133; /* 25 C = 0x133 */ |
400 | return IIO_VAL_INT; | 401 | return IIO_VAL_INT; |
401 | case IIO_CHAN_INFO_CALIBBIAS: | 402 | case IIO_CHAN_INFO_CALIBBIAS: |
402 | bits = 10; | 403 | bits = 10; |