×

AD7303 IIO DAC Linux驱动程序

消耗积分:2 | 格式:pdf | 大小:61.23KB | 2021-05-23

分享资料个

This version (11 Mar 2015 10:13) was approved by Lars-Peter Clausen.The Previously approved version (12 Feb 2014 14:02) is available.Diff

AD7303 IIO DAC Linux Driver

Supported Devices

Evaluation Boards

Description

This is a Linux industrial I/O (IIO) subsystem driver, targeting single-channel serial interface DACs. 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 IIO for more information.

Source Code

Status

Source Mainlined?
git Yes

Files

Function File
driver drivers/iio/dac/ad7303.c

Example platform device initialization

Devicetree

Required devicetree properties:

  • compatible: Needs to be “adi,” followed by the name of the device. E.g. “adi,ad5541a”
  • reg: The chipselect number used for the device
  • spi-max-frequency: Maximum SPI clock frequency
  • Vdd-supply: VDD voltage supply regulator

Optional devicetree properties:

  • REF-supply: external reference voltage supply regulator. This should only be set if there is an external reference voltage connected to the REF pin. If not set, Vdd/2 is used as the reference voltage.
       dac_vdd: fixedregulator@0 {
              compatible = "regulator-fixed";
              regulator-name = "fixed-supply";
              regulator-min-microvolt = <3300000>;
              regulator-max-microvolt = <3300000>;
              regulator-boot-on;
       };

       axi_spi_0: spi@42000000 {
              #address-cells = <1>;
              #size-cells = <0>;
              compatible = "xlnx,axi-spi-1.02.a", "xlnx,xps-spi-2.00.a";
               ...
              ad7303@0 {
                     compatible = "adi,ad7303";
                     reg = <0>;
                     spi-max-frequency = <1000000>;
                     Vdd-supply = <&dac_vdd>;
              };
        };

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.

02 Mar 2011 15:16

This specifies any shell prompt running on the target

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
drwxr-xr-x 2 root root    0 Jul  5 05:10 buffer
-r--r--r-- 1 root root 4096 Jul  5 05:10 dev
-r--r--r-- 1 root root 4096 Jul  5 05:10 name
-rw-r--r-- 1 root root 4096 Jul  5 05:10 out_voltage0_powerdown
-rw-r--r-- 1 root root 4096 Jul  5 05:10 out_voltage0_raw
-rw-r--r-- 1 root root 4096 Jul  5 05:10 out_voltage1_powerdown
-rw-r--r-- 1 root root 4096 Jul  5 05:10 out_voltage1_raw
-rw-r--r-- 1 root root 4096 Jul  5 05:10 out_voltage_scale
drwxr-xr-x 2 root root    0 Jul  5 05:10 power
drwxr-xr-x 2 root root    0 Jul  5 05:10 scan_elements
lrwxrwxrwx 1 root root    0 Jan  1  1970 subsystem -> ../../../../../../../bus/iio
drwxr-xr-x 2 root root    0 Jul  5 05:10 trigger
-rw-r--r-- 1 root root 4096 Jan  1  1970 uevent

Show device name

This specifies any shell prompt running on the target

root:/sys/bus/iio/devices/iio:device0> cat name
ad7303

Show scale

Description:
scale to be applied to out_voltage0_raw and out_voltage1_raw in order to obtain the measured voltage in millivolts.

This specifies any shell prompt running on the target

root:/sys/bus/iio/devices/iio:device0> cat out_voltage_scale
12.890625

Set channel Y output voltage

Description:
/sys/bus/iio/devices/iio:deviceX/out_voltageY_raw

Raw (unscaled, no bias etc.) output voltage for channel Y.

This specifies any shell prompt running on the target

root:/sys/bus/iio/devices/iio:device0> echo 100 > out_voltage0_raw

U = out_voltage0_raw * out_voltage_scale = 100 * 12.890625 mV = 1289.0625 mV

Enable power down mode on output Y

/sys/bus/iio/devices/iio:deviceX/out_voltageY_powerdown

Description:
Writing 1 causes output Y to enter the power down mode. Clearing returns to normal operation.

This specifies any shell prompt running on the target

root:/sys/bus/iio/devices/iio:device0> echo 1 > out_voltage0_powerdown
root:/sys/bus/iio/devices/iio:device0> cat out_voltage0_powerdown
1
root:/sys/bus/iio/devices/iio:device0> echo 0 > out_voltage0_powerdown
root:/sys/bus/iio/devices/iio:device0> cat out_voltage0_powerdown
0

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

评论(0)
发评论

下载排行榜

全部0条评论

快来发表一下你的评论吧 !