Skip to content

Commit a91a862

Browse files
committed
adi/ad7625: add support for AD762x/AD796x
Signed-off-by: Trevor Gamblin <[email protected]>
1 parent c7c4ca6 commit a91a862

File tree

8 files changed

+118
-0
lines changed

8 files changed

+118
-0
lines changed

adi/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from adi.ad7134 import ad7134
2929
from adi.ad7291 import ad7291
3030
from adi.ad7606 import ad7606
31+
from adi.ad7625 import ad7625
3132
from adi.ad7689 import ad7689
3233
from adi.ad7746 import ad7746
3334
from adi.ad7768 import ad7768, ad7768_4

adi/ad7625.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright (C) 2024-2025 Analog Devices, Inc.
2+
#
3+
# SPDX short identifier: ADIBSD
4+
5+
from adi.context_manager import context_manager
6+
from adi.rx_tx import rx
7+
8+
9+
class ad7625(rx, context_manager):
10+
"""AD7625 device"""
11+
12+
_compatible_parts = [
13+
"ad7625",
14+
"ad7626",
15+
"ad7960",
16+
"ad7961",
17+
]
18+
19+
_device_name = ""
20+
_complex_data = False
21+
_rx_channel_names = ["voltage0-voltage1"]
22+
23+
def __init__(self, uri="", device_name="ad7625"):
24+
if not device_name:
25+
_device_name = self._compatible_parts[0]
26+
elif device_name not in self._compatible_parts:
27+
raise Exception(f"Not a compatible device: {device_name}")
28+
else:
29+
_device_name = device_name
30+
31+
context_manager.__init__(self, uri, self._device_name)
32+
33+
self._rxadc = self._ctx.find_device(_device_name)
34+
self._ctrl = self._ctx.find_device(_device_name)
35+
rx.__init__(self)
36+
37+
@property
38+
def sampling_frequency(self):
39+
"""Get and set the sampling frequency."""
40+
return self._get_iio_dev_attr("sampling_frequency")
41+
42+
@sampling_frequency.setter
43+
def sampling_frequency(self, value):
44+
"""Set the sampling frequency."""
45+
self._set_iio_dev_attr("sampling_frequency", str(value))

doc/source/devices/adi.ad7625.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
+ad7625
2+
+=================
3+
+
4+
+By default, the device_name parameter in the class constructor is the
5+
+same as the class name. To use the class with another supported model,
6+
+the name must be given when instantiating the object. For example, if
7+
+working with an ad7626 with a URI of "10.2.5.222", use the ad7625 class,
8+
+but specify the device_name parameter explicitly:
9+
+
10+
+.. code-block:: bash
11+
+
12+
+ import adi
13+
+ adc = adi.ad7625(uri="ip:10.2.5.222", device_name="ad7626")
14+
+ ...
15+
+
16+
+
17+
+.. automodule:: adi.ad7625
18+
+ :members:
19+
+ :undoc-members:
20+
+ :show-inheritance:

doc/source/devices/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Supported Devices
3131
adi.ad7291
3232
adi.ad738x
3333
adi.ad7606
34+
adi.ad7625
3435
adi.ad7689
3536
adi.ad7746
3637
adi.ad7768

supported_parts.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@
8888
- AD7194
8989
- AD7195
9090
- AD7291
91+
- AD7625
92+
- AD7626
93+
- AD7960
94+
- AD7961
9195
- AD7768
9296
- AD7768-4
9397
- AD7770

test/emu/devices/ad7625.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE context [<!ELEMENT context (device | context-attribute)*><!ELEMENT context-attribute EMPTY><!ELEMENT device (channel | attribute | debug-attribute | buffer-attribute)*><!ELEMENT channel (scan-element?, attribute*)><!ELEMENT attribute EMPTY><!ELEMENT scan-element EMPTY><!ELEMENT debug-attribute EMPTY><!ELEMENT buffer-attribute EMPTY><!ATTLIST context name CDATA #REQUIRED description CDATA #IMPLIED><!ATTLIST context-attribute name CDATA #REQUIRED value CDATA #REQUIRED><!ATTLIST device id CDATA #REQUIRED name CDATA #IMPLIED><!ATTLIST channel id CDATA #REQUIRED type (input|output) #REQUIRED name CDATA #IMPLIED><!ATTLIST scan-element index CDATA #REQUIRED format CDATA #REQUIRED scale CDATA #IMPLIED><!ATTLIST attribute name CDATA #REQUIRED filename CDATA #IMPLIED value CDATA #IMPLIED><!ATTLIST debug-attribute name CDATA #REQUIRED value CDATA #IMPLIED><!ATTLIST buffer-attribute name CDATA #REQUIRED value CDATA #IMPLIED>]><context name="network" description="192.168.40.140 Linux zed-tg 6.11.0-rc1-ad7625-mainline-00027-g26f7e74e040d #62 SMP PREEMPT Tue Sep 17 11:22:20 EDT 2024 armv7l" ><context-attribute name="hw_carrier" value="Xilinx Zynq ZED" /><context-attribute name="hw_model" value="EVAL-AD7625FMCZ on Xilinx Zynq ZED" /><context-attribute name="hw_mezzanine" value="EVAL-AD7625FMCZ" /><context-attribute name="hw_name" value="AD7625" /><context-attribute name="hw_vendor" value="Analog Devices" /><context-attribute name="hw_serial" value="Empty Field" /><context-attribute name="local,kernel" value="6.11.0-rc1-ad7625-mainline-00027-g26f7e74e040d" /><context-attribute name="uri" value="ip:192.168.40.140" /><context-attribute name="ip,ip-addr" value="192.168.40.140" /><device id="hwmon0" name="e000b000ethernetffffffff00" ><channel id="temp1" type="input" ><attribute name="crit" filename="temp1_crit" value="100000" /><attribute name="input" filename="temp1_input" value="39000" /><attribute name="max_alarm" filename="temp1_max_alarm" value="0" /></channel></device><device id="iio:device0" name="xadc" ><channel id="voltage5" name="vccoddr" type="input" ><attribute name="label" filename="in_voltage5_vccoddr_label" value="vccoddr" /><attribute name="raw" filename="in_voltage5_vccoddr_raw" value="2042" /><attribute name="scale" filename="in_voltage5_vccoddr_scale" value="0.732421875" /></channel><channel id="voltage0" name="vccint" type="input" ><attribute name="label" filename="in_voltage0_vccint_label" value="vccint" /><attribute name="raw" filename="in_voltage0_vccint_raw" value="1397" /><attribute name="scale" filename="in_voltage0_vccint_scale" value="0.732421875" /></channel><channel id="voltage4" name="vccpaux" type="input" ><attribute name="label" filename="in_voltage4_vccpaux_label" value="vccpaux" /><attribute name="raw" filename="in_voltage4_vccpaux_raw" value="2464" /><attribute name="scale" filename="in_voltage4_vccpaux_scale" value="0.732421875" /></channel><channel id="temp0" type="input" ><attribute name="offset" filename="in_temp0_offset" value="-2219" /><attribute name="raw" filename="in_temp0_raw" value="2615" /><attribute name="scale" filename="in_temp0_scale" value="123.040771484" /></channel><channel id="voltage7" name="vrefn" type="input" ><attribute name="label" filename="in_voltage7_vrefn_label" value="vrefn" /><attribute name="raw" filename="in_voltage7_vrefn_raw" value="8" /><attribute name="scale" filename="in_voltage7_vrefn_scale" value="0.732421875" /></channel><channel id="voltage1" name="vccaux" type="input" ><attribute name="label" filename="in_voltage1_vccaux_label" value="vccaux" /><attribute name="raw" filename="in_voltage1_vccaux_raw" value="2475" /><attribute name="scale" filename="in_voltage1_vccaux_scale" value="0.732421875" /></channel><channel id="voltage2" name="vccbram" type="input" ><attribute name="label" filename="in_voltage2_vccbram_label" value="vccbram" /><attribute name="raw" filename="in_voltage2_vccbram_raw" value="1396" /><attribute name="scale" filename="in_voltage2_vccbram_scale" value="0.732421875" /></channel><channel id="voltage3" name="vccpint" type="input" ><attribute name="label" filename="in_voltage3_vccpint_label" value="vccpint" /><attribute name="raw" filename="in_voltage3_vccpint_raw" value="1395" /><attribute name="scale" filename="in_voltage3_vccpint_scale" value="0.732421875" /></channel><channel id="voltage6" name="vrefp" type="input" ><attribute name="label" filename="in_voltage6_vrefp_label" value="vrefp" /><attribute name="raw" filename="in_voltage6_vrefp_raw" value="1715" /><attribute name="scale" filename="in_voltage6_vrefp_scale" value="0.732421875" /></channel><attribute name="sampling_frequency" value="961538" /><attribute name="waiting_for_supplier" value="0" /></device><device id="iio:device1" name="ad7625" ><channel id="voltage0-voltage1" type="input" ><scan-element index="0" format="le:S16/16&gt;&gt;0" scale="0.125000" /><attribute name="scale" filename="in_voltage0-voltage1_scale" value="0.125000000" /></channel><attribute name="sampling_frequency" value="5952381" /><attribute name="waiting_for_supplier" value="0" /><buffer-attribute name="data_available" value="0" /><buffer-attribute name="direction" value="in" /><buffer-attribute name="length_align_bytes" value="8" /></device><device id="iio_sysfs_trigger" ><attribute name="add_trigger" value="ERROR" /><attribute name="remove_trigger" value="ERROR" /></device></context>

test/emu/hardware_map.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,18 @@ ad4170:
662662
- data_devices:
663663
- iio:device0
664664

665+
ad7625:
666+
- ad7625
667+
- ad7626
668+
- ad7960
669+
- ad7961
670+
- pyadi_iio_class_support:
671+
- ad7625
672+
- emulate:
673+
- filename: ad7625.xml
674+
- data_devices:
675+
- iio:device1
676+
665677
ad738x:
666678
- ad738x
667679
- pyadi_iio_class_support:

test/test_ad7625.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import pytest
2+
3+
hardware = "ad7625"
4+
classname = "adi.ad7625"
5+
6+
#########################################
7+
@pytest.mark.iio_hardware(hardware)
8+
@pytest.mark.parametrize("classname", [(classname)])
9+
@pytest.mark.parametrize(
10+
"attr, start, stop, step, tol, repeats",
11+
[("sampling_frequency", 1000000, 6000000, 100000, 50000, 1),],
12+
)
13+
def test_ad7625_attr(
14+
test_attribute_single_value,
15+
iio_uri,
16+
classname,
17+
attr,
18+
start,
19+
stop,
20+
step,
21+
tol,
22+
repeats,
23+
):
24+
test_attribute_single_value(
25+
iio_uri, classname, attr, start, stop, step, tol, repeats
26+
)
27+
28+
29+
#########################################
30+
@pytest.mark.iio_hardware(hardware, True)
31+
@pytest.mark.parametrize("classname", [(classname)])
32+
@pytest.mark.parametrize("channel", [0])
33+
def test_ad7625_rx_data(test_dma_rx, iio_uri, classname, channel):
34+
test_dma_rx(iio_uri, classname, channel, buffer_size=2 ** 15)

0 commit comments

Comments
 (0)