Wiki

Differences

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


Previous revision
Next revision
resources:tools-software:linux-drivers:iio-adc:ad7998 [15 Nov 2012 14:58] – [Reference Circuit Notes] Add more Circuit Notes Lars-Peter Clausen
Line 1: Line 1:
 +====== AD7998 IIO ADC Linux Driver ======
  
 +===== Supported Devices =====
 +
 +  * [[adi>AD7991]]
 +  * [[adi>AD7992]]
 +  * [[adi>AD7993]]
 +  * [[adi>AD7994]]
 +  * [[adi>AD7995]]
 +  * [[adi>AD7997]]
 +  * [[adi>AD7998]]
 +  * [[adi>AD7999]]
 +
 +
 +===== Reference Circuit Notes =====
 +
 +  * [[adi>CN0043]]
 +  * [[adi>CN0044]]
 +  * [[adi>CN0045]]
 +
 +===== Evaluation Boards =====
 +
 +  * [[adi>EVAL-AD7991EBZ]]
 +  * [[adi>EVAL-AD7992EBZ]]
 +  * [[adi>EVAL-AD7993EBZ]]
 +  * [[adi>EVAL-AD7994EBZ]]
 +  * [[adi>EVAL-AD7995EBZ]]
 +  * [[adi>EVAL-AD7997EBZ]]
 +  * [[adi>EVAL-AD7998EBZ]]
 +
 +===== Description =====
 +
 +This is a Linux industrial I/O ([[software:linux:docs:iio:iio|IIO]]) subsystem driver, targeting multi 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 [[software:linux:docs:iio:iio|IIO]] for more information.
 +
 +====== Source Code ======
 +
 +===== Status =====
 +
 +^  Source  ^  Mainlined?  ^
 +| [[git.linux.org>drivers/staging/iio/adc/ad799x_core.c|git]] |  [[git.linux.org>drivers/staging/iio/adc/ad799x_core.c|Yes]]  |
 +===== Files =====
 +
 +^ Function ^ File ^
 +| driver  | [[git.linux.org>drivers/staging/iio/adc/ad799x_core.c]] |
 +| driver  | [[git.linux.org>drivers/staging/iio/adc/ad799x_ring.c]] |
 +| include | [[git.linux.org>drivers/staging/iio/adc/ad799x.h]] |
 +
 +====== Example platform device initialization ======
 +
 +{{page>software/linux/docs/platform_and_bus_model#Platform Data&noheader&firstseconly&noeditbtn}}
 +
 +The reference voltage may vary between boards and models. The platform_data for the device's "struct device" holds this information.
 +
 +<source trunk/drivers/staging/iio/adc/ad799x.h:ad799x_platform_data{} c linux-kernel>
 +
 +<code c>
 +static struct ad799x_platform_data ad7998_pdata = {
 + .vref_mv = 2500,
 +};
 +</code>
 +
 +<note tip>
 +In case platform_data is not present or set to NULL, the driver will use the AD7998 internal reference.
 +</note>
 +
 +{{page>software/linux/docs/platform_and_bus_model#Declaring I2C devices&firstseconly&noeditbtn}}
 +
 +Depending on the converter IC used, you may need to set the I2C_BOARD_INFO name accordingly, matching your part name.
 +
 +<code c>
 +static struct i2c_board_info __initdata board_i2c_board_info[] = {
 +#if defined(CONFIG_AD799X) || defined(CONFIG_AD799X_MODULE)
 + {
 + I2C_BOARD_INFO("ad7998", 0x24),
 + .platform_data = &ad799x_pdata,
 + .irq = IRQ_PG0,
 + },
 +#endif
 +};
 +</code>
 +
 +<code c>
 +static int __init board_init(void)
 +{
 + [--snip--]
 +
 + i2c_register_board_info(0, board_i2c_board_info,
 + ARRAY_SIZE(board_i2c_board_info));
 + [--snip--]
 +
 + return 0;
 +}
 +arch_initcall(board_init);
 +</code>
 +
 +====== Adding Linux drive
 +r support ======
 +
 +Configure kernel with "make menuconfig" (alternatively use "make xconfig" or
 +"make qconfig")
 +
 +<note>
 +The AD7998 Driver depends on **CONFIG_I2C**
 +</note>
 +
 +<code>
 +Linux Kernel Configuration
 + Device Drivers  --->
 + [*] Staging drivers  --->
 + <*>     Industrial I/O support --->
 +     --- Industrial I/O support
 +     -*-   Enable ring buffer support within IIO
 +     -*-     Industrial I/O lock free software ring
 +     -*-   Enable triggered sampling support
 +
 +           *** Analog to digital converters ***
 +     [--snip--]
 +
 +     <*>   Analog Devices AD799x ADC driver
 +     -*-     Analog Devices AD799x: use ring buffer
 +
 +     [--snip--]
 +
 +</code>
 +
 +====== Hardware configuration ======
 +
 +
 +====== Driver testing ======
 +
 +{{page>software:linux:docs:iio:iio_snippets#iio device files&noheader&firstseconly&noeditbtn}}
 +
 +<box 100% green|shell prompt running on the target>
 +<xterm>
 +root:/> **cd /sys/bus/iio/devices/**
 +root:/sys/bus/iio/devices> ls
 +iio:device0                  trigger0
 +
 +
 +root:/sys/bus/iio/devices> **cd device0**
 +
 +root:/sys/devices/platform/i2c-bfin-twi.0/i2c-0/0-0024/iio:device0> **ls -l**
 +drwxr-xr-x    5 root     root             0 Jan  1 00:00 buffer
 +drwxr-xr-x    2 root     root             0 Jan  1 00:00 events
 +-r--r--r--    1 root     root          4096 Jan  1 00:00 in_voltage0_raw
 +-r--r--r--    1 root     root          4096 Jan  1 00:00 in_voltage1_raw
 +-r--r--r--    1 root     root          4096 Jan  1 00:00 in_voltage2_raw
 +-r--r--r--    1 root     root          4096 Jan  1 00:00 in_voltage3_raw
 +-r--r--r--    1 root     root          4096 Jan  1 00:00 in_voltage4_raw
 +-r--r--r--    1 root     root          4096 Jan  1 00:00 in_voltage5_raw
 +-r--r--r--    1 root     root          4096 Jan  1 00:00 in_voltage6_raw
 +-r--r--r--    1 root     root          4096 Jan  1 00:00 in_voltage7_raw
 +-r--r--r--    1 root     root          4096 Jan  1 00:00 in_voltage_scale
 +-r--r--r--    1 root     root          4096 Jan  1 00:00 name
 +lrwxrwxrwx    1 root     root             0 Jan  1 00:00 subsystem -> ../../../../../../bus/iio
 +drwxr-xr-x    2 root     root             0 Jan  1 00:00 trigger
 +-rw-r--r--    1 root     root          4096 Jan  1 00:00 uevent
 +</xterm></box>
 +
 +=== Show device name ===
 +
 +<box 100% green|shell prompt running on the target>
 +<xterm>
 +root:/sys/devices/platform/i2c-bfin-twi.0/i2c-0/0-0024/iio:device0> **cat name**
 +ad7998
 +</xterm></box>
 +
 +=== Show scale ===
 +
 +**Description:**\\
 +scale to be applied to in_voltage0_raw in order to obtain the measured voltage in millivolts.
 +
 +<box 100% green|shell prompt running on the target>
 +<xterm>
 +root:/sys/devices/platform/i2c-bfin-twi.0/i2c-0/0-0024/iio:device0> **cat in_voltage_scale**
 +1.000
 +</xterm></box>
 +
 +=== Show channel 0 measurement ===
 +
 +**Description:**\\
 +Raw unscaled voltage measurement on channel 0
 +
 +<box 100% green|shell prompt running on the target>
 +<xterm>
 +root:/sys/devices/platform/i2c-bfin-twi.0/i2c-0/0-0024/iio:device0> **cat in_voltage0_raw**
 +1491
 +</xterm></box>
 +
 +**U** = //in_voltage0_raw * in_voltage_scale// = 1491 * 1.000 = **1491,00 //mV//**
 +
 +===== Trigger management =====
 +
 +{{page>software:linux:docs:iio:iio_snippets#iio devices with trigger consumer interface&noheader&firstseconly&noeditbtn}}
 +
 +==== Available standalone trigger drivers ====
 +
 +{{page>software:linux:docs:iio:iio_snippets#Standalone trigger drivers&noheader&firstseconly&noeditbtn}}
 +
 +===== Buffer management =====
 +
 +<box 100% green|shell prompt running on the target>
 +<xterm>
 +root:/sys/devices/platform/i2c-bfin-twi.0/i2c-0/0-0024/iio:device0/buffer> **ls**
 +**enable**  **length**
 +root:/sys/devices/platform/i2c-bfin-twi.0/i2c-0/0-0024/iio:device0/buffer>
 +</xterm></box>
 +
 +{{page>software:linux:docs:iio:iio_snippets#Buffer management&noheader&firstseconly&noeditbtn}}
 +
 +<box 100% green|shell prompt running on the target>
 +<xterm>
 +root:/sys/devices/platform/i2c-bfin-twi.0/i2c-0/0-0024/iio:device0/scan_elements> **ls**
 +in_voltage0_en           in_voltage2_index        in_voltage5_en           in_voltage7_index
 +in_voltage0_index        in_voltage3_en           in_voltage5_index        in_voltage_type
 +in_voltage1_en           in_voltage3_index        in_voltage6_en           timestamp_en
 +in_voltage1_index        in_voltage4_en           in_voltage6_index        timestamp_index
 +in_voltage2_en           in_voltage4_index        in_voltage7_en           timestamp_type
 +root:/sys/devices/platform/i2c-bfin-twi.0/i2c-0/0-0024/iio:device0/scan_elements>
 +</xterm></box>
 +
 +
 +{{page>software:linux:docs:iio:iio_snippets#Typical ADC scan elements&noheader&firstseconly&noeditbtn}}
 +
 +
 +====== More Information ======
 +
 +{{page>software:linux:docs:iio:iio_snippets#iio pointers&noheader&firstseconly&noeditbtn}}
resources/tools-software/linux-drivers/iio-adc/ad7998.txt · Last modified: 05 Jan 2021 16:01 by Ioana Chelaru