This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
resources:tools-software:linux-drivers:iio-dac:ad5593r [20 Nov 2015 15:11] – [Reference Circuits] Lars-Peter Clausen | resources:tools-software:linux-drivers:iio-dac:ad5593r [22 Feb 2016 17:52] – [Device tree example] Michael Hennerich | ||
---|---|---|---|
Line 66: | Line 66: | ||
* " | * " | ||
* **reg**: I2C address of the chip (generally 0x10). | * **reg**: I2C address of the chip (generally 0x10). | ||
- | * **channel-modes**: | + | * **channel-modes**: |
- | * 0 = unused | + | * 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) |
- | * 6 = tri-state | + | * CH_MODE_UNUSED_PULL_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**: | ||
==== 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. |
+ | |||
< | < | ||
- | ad5593r@0 { | + | #include < |
- | compatible = " | + | |
- | reg = < | + | vref: regulator-vref { |
- | channel-modes = /bits/ 8 <1 2 2 0 0 0 0 0>; | + | compatible = " |
+ | regulator-name = " | ||
+ | regulator-min-microvolt = < | ||
+ | regulator-max-microvolt = < | ||
+ | regulator-always-on; | ||
+ | }; | ||
+ | |||
+ | &i2c0 { | ||
+ | status = " | ||
+ | clock-frequency = < | ||
+ | |||
+ | ad5593r@10 { | ||
+ | compatible = " | ||
+ | reg = < | ||
+ | |||
+ | 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 = <& | ||
+ | reset-gpios = <& | ||
+ | }; | ||
}; | }; | ||
</ | </ | ||
Line 89: | Line 125: | ||
root@linaro-ubuntu-desktop: | root@linaro-ubuntu-desktop: | ||
IIO context created: local | IIO context created: local | ||
- | IIO context has 1 devices: | + | IIO context has 3 devices: |
- | iio:device1: ad5593r | + | iio:device2: ad5593r |
- | | + | |
voltage0: | voltage0: | ||
- | | + | |
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: | ||
+ | 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: | ||
+ | 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: | voltage1: | ||
- | | + | |
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: | voltage2: | ||
- | 1 channel-specific attributes found: | + | |
+ | attr 0: raw value: | ||
+ | attr 1: scale value: 0.732421875 | ||
+ | attr 2: scale_available value: 0.732421875 1.464843750 | ||
+ | voltage3: | ||
+ | 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 | ||
+ | |||
</ | </ |