staticint adis16201_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask)
{ struct adis *st = iio_priv(indio_dev); int ret; int bits;
u8 addr;
s16 val16;
switch (mask) { case IIO_CHAN_INFO_RAW: return adis_single_conversion(indio_dev, chan,
ADIS16201_ERROR_ACTIVE, val); case IIO_CHAN_INFO_SCALE: switch (chan->type) { case IIO_VOLTAGE: if (chan->channel == 0) { /* Voltage base units are mV hence 1.22 mV */
*val = 1;
*val2 = 220000;
} else { /* Voltage base units are mV hence 0.61 mV */
*val = 0;
*val2 = 610000;
} return IIO_VAL_INT_PLUS_MICRO; case IIO_TEMP:
*val = -470;
*val2 = 0; return IIO_VAL_INT_PLUS_MICRO; case IIO_ACCEL: /* * IIO base unit for sensitivity of accelerometer * is milli g. * 1 LSB represents 0.244 mg.
*/
*val = 0;
*val2 = IIO_G_TO_M_S_2(462400); return IIO_VAL_INT_PLUS_NANO; case IIO_INCLI:
*val = 0;
*val2 = 100000; return IIO_VAL_INT_PLUS_MICRO; default: return -EINVAL;
} break; case IIO_CHAN_INFO_OFFSET: /* * The raw ADC value is 1278 when the temperature * is 25 degrees and the scale factor per milli * degree celcius is -470.
*/
*val = 25000 / -470 - 1278; return IIO_VAL_INT; case IIO_CHAN_INFO_CALIBBIAS: switch (chan->type) { case IIO_ACCEL:
bits = 12; break; case IIO_INCLI:
bits = 9; break; default: return -EINVAL;
}
addr = adis16201_addresses[chan->scan_index];
ret = adis_read_reg_16(st, addr, &val16); if (ret) return ret;
staticint adis16201_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, int val2, long mask)
{ struct adis *st = iio_priv(indio_dev); int m;
if (mask != IIO_CHAN_INFO_CALIBBIAS) return -EINVAL;
switch (chan->type) { case IIO_ACCEL:
m = GENMASK(11, 0); break; case IIO_INCLI:
m = GENMASK(8, 0); break; default: return -EINVAL;
}
return adis_write_reg_16(st, adis16201_addresses[chan->scan_index],
val & m);
}
MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
MODULE_DESCRIPTION("Analog Devices ADIS16201 Dual-Axis Digital Inclinometer and Accelerometer");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("spi:adis16201");
MODULE_IMPORT_NS("IIO_ADISLIB");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.