AD4170
AD4170 24-Bit Sigma-Delta ADC with Integrated PGA Linux Driver.
Supported Devices
This driver supports the
Evaluation Boards
Description
This is a Linux industrial I/O (Linux Industrial I/O Subsystem) subsystem driver, targeting single channel serial interface ADCs. The industrial I/O subsystem provides a unified framework for drivers for many different types of converters and sensors using a number of different physical interfaces (i2c, spi, etc). See Linux Industrial I/O Subsystem for more information.
Source Code
Status
Source |
Mainlined? |
|---|---|
Yes |
Files
Function |
File |
|---|---|
driver |
|
devicetree bindings |
Adding Linux driver support
Devicetree configuration
The binding requires compatible, reg, avdd-supply, iovdd-supply,
spi-cpol and spi-cpha. Each channel node uses either diff-channels
for a differential pair, or single-channel with common-mode-channel
for a pseudo-differential input, plus adi,reference-select to pick the
reference source. Input numbers 0-8 are the AIN pins; higher numbers select
internal nodes such as the temperature sensor (17), REFOUT (29) or DGND (24).
#include <dt-bindings/interrupt-controller/irq.h>
spi {
#address-cells = <1>;
#size-cells = <0>;
adc@0 {
compatible = "adi,ad4170-4";
reg = <0>;
spi-max-frequency = <20000000>;
spi-cpol;
spi-cpha;
avdd-supply = <&avdd>;
iovdd-supply = <&iovdd>;
interrupts = <25 IRQ_TYPE_EDGE_FALLING>;
interrupt-names = "dig_aux1";
#address-cells = <1>;
#size-cells = <0>;
/* AIN29 (REFOUT) vs AIN24 (DGND) */
channel@0 {
reg = <0>;
diff-channels = <29 24>;
adi,reference-select = <2>;
};
/* AIN0 vs AIN24 (DGND) */
channel@1 {
reg = <1>;
diff-channels = <0 24>;
bipolar;
adi,reference-select = <2>;
};
/* AIN3 vs AIN4 */
channel@2 {
reg = <2>;
diff-channels = <3 4>;
bipolar;
adi,reference-select = <2>;
};
};
};
Sensor excitation for load cell, RTD and thermocouple setups is described
with adi,sensor-type, adi,excitation-pin-N,
adi,excitation-current-N-microamp and adi,excitation-ac; see the
binding examples for complete weigh-scale, RTD and thermocouple channel
nodes. Changing a channel’s filter_type can change the set of valid
output data rates, so read back sampling_frequency after switching
filters.
Driver testing
Each and every IIO device, typically a hardware chip, has a device folder under
/sys/bus/iio/devices/iio:deviceX. Where X is the IIO index of the device. Under
every of these directory folders reside a set of files, depending on the
characteristics and features of the hardware device in question. These files
are consistently generalized and documented in the IIO ABI documentation. In
order to determine which IIO deviceX corresponds to which hardware device, the
user can read the name file /sys/bus/iio/devices/iio:deviceX/name. In case
the sequence in which the iio device drivers are loaded/registered is constant,
the numbering is constant and may be known in advance.
root@analog:~# cd /sys/bus/iio/devices/
root@analog:/sys/bus/iio/devices# ls
iio:device0 trigger0
root@analog:/sys/bus/iio/devices# cd iio\:device0
root@analog:/sys/bus/iio/devices/iio:device0# ls -l
total 0
drwxr-xr-x 2 root root 0 Sep 13 08:09 buffer
-r--r--r-- 1 root root 4096 Sep 13 08:09 dev
-rw-r--r-- 1 root root 4096 Sep 13 08:09 in_voltage0-voltage24_calibbias
-rw-r--r-- 1 root root 4096 Sep 13 08:09 in_voltage0-voltage24_calibscale
-rw-r--r-- 1 root root 4096 Sep 13 08:09 in_voltage0-voltage24_filter_type
-rw-r--r-- 1 root root 4096 Sep 13 08:09 in_voltage0-voltage24_offset
-rw-r--r-- 1 root root 4096 Sep 13 08:09 in_voltage0-voltage24_raw
-rw-r--r-- 1 root root 4096 Sep 13 08:09 in_voltage0-voltage24_sampling_frequency
-r--r--r-- 1 root root 4096 Sep 13 08:09 in_voltage0-voltage24_sampling_frequency_available
-rw-r--r-- 1 root root 4096 Sep 13 08:09 in_voltage0-voltage24_scale
-r--r--r-- 1 root root 4096 Sep 13 08:09 in_voltage0-voltage24_scale_available
-rw-r--r-- 1 root root 4096 Sep 13 08:09 in_voltage29-voltage24_calibbias
-rw-r--r-- 1 root root 4096 Sep 13 08:09 in_voltage29-voltage24_calibscale
-rw-r--r-- 1 root root 4096 Sep 13 08:09 in_voltage29-voltage24_filter_type
-rw-r--r-- 1 root root 4096 Sep 13 08:09 in_voltage29-voltage24_offset
-rw-r--r-- 1 root root 4096 Sep 13 08:09 in_voltage29-voltage24_raw
-rw-r--r-- 1 root root 4096 Sep 13 08:09 in_voltage29-voltage24_sampling_frequency
-r--r--r-- 1 root root 4096 Sep 13 08:09 in_voltage29-voltage24_sampling_frequency_available
-rw-r--r-- 1 root root 4096 Sep 13 08:09 in_voltage29-voltage24_scale
-r--r--r-- 1 root root 4096 Sep 13 08:09 in_voltage29-voltage24_scale_available
-rw-r--r-- 1 root root 4096 Sep 13 08:09 in_voltage3-voltage4_calibbias
-rw-r--r-- 1 root root 4096 Sep 13 08:09 in_voltage3-voltage4_calibscale
-rw-r--r-- 1 root root 4096 Sep 13 08:09 in_voltage3-voltage4_filter_type
-rw-r--r-- 1 root root 4096 Sep 13 08:09 in_voltage3-voltage4_offset
-rw-r--r-- 1 root root 4096 Sep 13 08:09 in_voltage3-voltage4_raw
-rw-r--r-- 1 root root 4096 Sep 13 08:09 in_voltage3-voltage4_sampling_frequency
-r--r--r-- 1 root root 4096 Sep 13 08:09 in_voltage3-voltage4_sampling_frequency_available
-rw-r--r-- 1 root root 4096 Sep 13 08:09 in_voltage3-voltage4_scale
-r--r--r-- 1 root root 4096 Sep 13 08:09 in_voltage3-voltage4_scale_available
-r--r--r-- 1 root root 4096 Sep 13 08:09 in_voltage-voltage_filter_type_available
-r--r--r-- 1 root root 4096 Sep 13 08:09 name
lrwxrwxrwx 1 root root 0 Sep 13 08:09 of_node -> ../../../../../../../../firmware/devicetree/base/soc/spi@7e204000/ad4170@0
drwxr-xr-x 2 root root 0 Sep 13 08:09 power
drwxr-xr-x 2 root root 0 Sep 13 08:09 scan_elements
lrwxrwxrwx 1 root root 0 Sep 13 08:09 subsystem -> ../../../../../../../../bus/iio
drwxr-xr-x 2 root root 0 Sep 13 08:09 trigger
-rw-r--r-- 1 root root 4096 Sep 13 08:09 uevent
Identify the device
root:/sys/bus/iio/devices/iio:device0> cat name
ad4170
Basic operation
Show channel scale, offset, sampling_frequency, calibbias, calibscale
Set CHAN to the differential channel name reported under the device’s
sysfs directory, e.g. in_voltage29-voltage24.
DEV=/sys/bus/iio/devices/iio:deviceX
CHAN=in_voltage29-voltage24
cat "$DEV/${CHAN}_scale"
cat "$DEV/${CHAN}_offset"
cat "$DEV/${CHAN}_raw"
cat "$DEV/${CHAN}_calibbias"
cat "$DEV/${CHAN}_calibscale"
cat "$DEV/${CHAN}_sampling_frequency"
The voltage is U_mV = (raw + offset) × scale; the offset is in raw-code
units. Bipolar conversion values are sign-extended by the driver.
Show channel scale_available and sampling_frequency_available
Description:
Scales and sampling rates to be applied to the channel.
root:/sys/bus/iio/devices/iio:device0> cat in_voltage29-voltage24_scale_available
0.000149011 0.000074505 0.000037252 0.000018626 0.000009313 0.000004656 0.000002328 0.000001164 0.000298023 0.000149011
root:/sys/bus/iio/devices/iio:device0> cat in_voltage29-voltage24_sampling_frequency_available
[7.629860220 15.259720441 125000.000000000]
Show filter_type_available
root:/sys/bus/iio/devices/iio:device0> cat in_voltage-voltage_filter_type_available
sinc5+avg sinc5 sinc3