AD5758
AD5758 IIO DAC 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 the single-channel AD5758 voltage and current output DAC. 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
Files
Function |
File |
|---|---|
driver |
Adding Linux driver support
Devicetree configuration
Required properties for the AD5758:
compatible: Must be
adi,ad5758reg: SPI chip select number for the device
spi-max-frequency: Max SPI frequency to use (< 50000000)
spi-cpha: is the only mode that is supported
adi,dc-dc-mode: 1 for DPC current, 2 for DPC voltage, or 3 for PPC current.adi,range-microvolt: Two-cell minimum and maximum voltage range for voltage mode, oradi,range-microampfor current modes.
Optional properties:
reset-gpios: GPIO specifier for the RESET pin.adi,dc-dc-ilim-microamp: DC-to-DC converter current limit in microamps.adi,slew-time-us: Desired full-scale slew time in microseconds.
The following fragment configures a 0–10 V output. The board must define
spi0 and provide the actual power supplies and pin configuration; add
reset-gpios only when its GPIO mapping is known.
&spi0 {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
ad5758@0 {
compatible = "adi,ad5758";
reg = <0>;
spi-max-frequency = <1000000>;
spi-cpha;
adi,dc-dc-mode = <2>;
adi,range-microvolt = <0 10000000>;
adi,dc-dc-ilim-microamp = <200000>;
};
};
Driver testing
root:/> cd /sys/bus/iio/devices/
root:/sys/bus/iio/devices> ls
iio:device0
root:/sys/bus/iio/devices> cd iio\:device0
root:/sys/bus/iio/devices/iio:device0> ls -l
-r--r--r-- 1 root root 4096 May 23 09:14 dev
-rw-r--r-- 1 root root 4096 May 23 09:14 out_voltage_powerdown
-rw-r--r-- 1 root root 4096 May 23 09:14 out_voltage_raw
-rw-r--r-- 1 root root 4096 May 23 09:14 out_voltage_scale
-r--r--r-- 1 root root 4096 May 23 09:14 name
drwxr-xr-x 2 root root 0 May 23 09:14 power
lrwxrwxrwx 1 root root 0 May 23 09:14 subsystem -> ../../../../../../../../bus/iio
-rw-r--r-- 1 root root 4096 May 23 09:14 uevent
Identify the device
root:/sys/bus/iio/devices/iio:device0> cat name
ad5758
Basic operation
Show scale
Description: scale to be applied to out_voltage_raw in order to obtain the measured voltage in millivolts.
root:/sys/bus/iio/devices/iio:device0> cat out_voltage_scale
0.152587890
Set channel 0 output voltage
Description: /sys/bus/iio/devices/iio:deviceX/out_voltage_raw
The channel is unindexed, so voltage-mode attributes have no channel-number
suffix. In current mode, use the corresponding out_current attributes.
Raw (unscaled, no bias etc.) output voltage for channel 0.
root:/sys/bus/iio/devices/iio:device0> echo 32767 > out_voltage_raw
U = out_voltage_raw * out_voltage_scale = 32767 * 0.152587890 = 4999.84 mV
Enable power down mode on output 0
/sys/bus/iio/devices/deviceX/out_voltage_powerdown
Description: Writing 1 causes output 0 to enter the power down mode. Clearing returns to normal operation.
root:/sys/bus/iio/devices/iio:device0> echo 1 > out_voltage_powerdown
root:/sys/bus/iio/devices/iio:device0> cat out_voltage_powerdown
1
root:/sys/bus/iio/devices/iio:device0> echo 0 > out_voltage_powerdown
root:/sys/bus/iio/devices/iio:device0> cat out_voltage_powerdown
0