Wiki

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
resources:tools-software:linux-drivers:iio-dac:ad5593r [20 Nov 2015 15:11] – [Reference Circuits] Lars-Peter Clausenresources:tools-software:linux-drivers:iio-dac:ad5593r [22 Feb 2016 17:52] – [Device tree example] Michael Hennerich
Line 66: Line 66:
     * "adi,ad5593r"     * "adi,ad5593r"
   * **reg**: I2C address of the chip (generally 0x10).   * **reg**: I2C address of the chip (generally 0x10).
-  * **channel-modes**: An array of eight 8-bit values (one per channel) describing the mode of each channel according to the following: +  * **channel-modes**: An array of eight 8-bit values (one per channel) describing the mode of each channel. Macros specifying the valid values can be found in <dt-bindings/iio/adi,ad5592r.h>. The following values are currently supported
-    0 = unused (pulled down), + CH_MODE_ADC (the pin is ADC input
-    1 = DAC, + CH_MODE_DAC (the pin is DAC output) 
-    2 = ADC, + CH_MODE_DAC_AND_ADC (the pin is DAC output but can be monitored by an ADC) 
-    tri-state + CH_MODE_UNUSED_PULL_DOWN  (the pin is pulled down) 
 + * CH_MODE_UNUSED_OUT_LOW (the pin is output low) 
 + * CH_MODE_UNUSED_OUT_HIGH (the pin is output high) 
 + * CH_MODE_UNUSED_OUT_TRISTATE (the pin is tristated output) 
 + * CH_MODE_GPIO (the pin is registered with GPIOLIB) 
 + * CH_MODE_GPIO_OPEN_DRAIN (the pin is configured open drain and registered with GPIOLIB) 
 +==== Optional properties ==== 
 +  * **vref-supply**: Phandle to the external reference voltage supply. This should only be set if there is an external reference voltage connected to the VREF pin. If the property is not set the internal 2.5V reference is used. 
 +  * **reset-gpios**: GPIO spec for the RESET pin. If specified, it will be asserted during driver probe.
 ==== Device tree example ==== ==== Device tree example ====
-The following example instanciates the ad5593r driver for a AD5593R device connected on a I2C bus. It sets the I/O0 port as a DAC, the I/O1 and I/O2 ports as ADCs. The other I/O ports are connected to the ground with a pull-down resistor.+The following example instanciates the ad5593r driver for a AD5593R device connected on a I2C bus. It sets the I/O0 port as a DAC, the I/O1 port as ADC. I/O2 and I/O3 are configured for primary function DAC the additional ADC can measure the voltage being provided by the DAC. This feature can monitor the output voltage to detect short circuits or overload conditions. I/O4 is connected to the ground with a pull-down resistor. The other I/Os are registered with the Linux GPIO subsystem. 
 + 
  
 <code> <code>
-ad5593r@+ #include <dt-bindings/iio/adi,ad5592r.h> 
- compatible = "adi,ad5593r"; + 
- reg = <0x10>; + vref: regulator-vref { 
- channel-modes = /bits/ 8 <1 2 2 0 0 0 0 0>;+ compatible = "regulator-fixed"; 
 + regulator-name = "vref-ad559x"; 
 + regulator-min-microvolt = <3300000>; 
 + regulator-max-microvolt = <3300000>; 
 + regulator-always-on; 
 + }; 
 + 
 +&i2c0 { 
 + status = "okay"; 
 + clock-frequency = <400000>; 
 + 
 + ad5593r@10 
 + compatible = "adi,ad5593r"; 
 + reg = <0x10>; 
 + 
 + channel-modes = /bits/ 8 < 
 + CH_MODE_DAC 
 + CH_MODE_ADC 
 + CH_MODE_DAC_AND_ADC 
 + CH_MODE_DAC_AND_ADC 
 + CH_MODE_UNUSED_PULL_DOWN 
 + CH_MODE_GPIO 
 + CH_MODE_GPIO 
 + CH_MODE_GPIO 
 + >; 
 + 
 + vref-supply = <&vref>; /* optional */ 
 + reset-gpios = <&gpio0 86 0>;  /* optional */ 
 + };
 }; };
 </code> </code>
Line 89: Line 125:
 root@linaro-ubuntu-desktop:~# iio_info  root@linaro-ubuntu-desktop:~# iio_info 
 IIO context created: local IIO context created: local
-IIO context has devices: +IIO context has devices: 
-        iio:device1: ad5593r +        iio:device2: ad5593r 
-                channels found:+                channels found:
                         voltage0:  (output)                         voltage0:  (output)
-                        channel-specific attributes found:+                        channel-specific attributes found:
                                 attr 0: raw value: 0                                 attr 0: raw value: 0
 +                                attr 1: scale_available value: 0.732421875 1.464843750
 +                                attr 2: scale value: 0.732421875
 +                        voltage2:  (output)
 +                        3 channel-specific attributes found:
 +                                attr 0: raw value: 0
 +                                attr 1: scale_available value: 0.732421875 1.464843750
 +                                attr 2: scale value: 0.732421875
 +                        voltage3:  (output)
 +                        3 channel-specific attributes found:
 +                                attr 0: raw value: 0
 +                                attr 1: scale_available value: 0.732421875 1.464843750
 +                                attr 2: scale value: 0.732421875
                         voltage1:  (input)                         voltage1:  (input)
-                        channel-specific attributes found:+                        channel-specific attributes found:
                                 attr 0: raw value: 0                                 attr 0: raw value: 0
 +                                attr 1: scale value: 0.732421875
 +                                attr 2: scale_available value: 0.732421875 1.464843750
                         voltage2:  (input)                         voltage2:  (input)
-                        1 channel-specific attributes found:+                        3 channel-specific attributes found: 
 +                                attr 0: raw value: 1 
 +                                attr 1: scale value: 0.732421875 
 +                                attr 2: scale_available value: 0.732421875 1.464843750 
 +                        voltage3:  (input) 
 +                        3 channel-specific attributes found:
                                 attr 0: raw value: 0                                 attr 0: raw value: 0
 +                                attr 1: scale value: 0.732421875
 +                                attr 2: scale_available value: 0.732421875 1.464843750
 +                        temp:  (input)
 +                        3 channel-specific attributes found:
 +                                attr 0: offset value: -628
 +                                attr 1: raw value: 680
 +                                attr 2: scale value: 452.147700000
 +
 </code> </code>
resources/tools-software/linux-drivers/iio-dac/ad5593r.txt · Last modified: 19 Jan 2018 10:12 by Alexandru Ardelean