Skip to content

Commit a759fc2

Browse files
committed
ad4880: add pyadi support
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
1 parent 80796c5 commit a759fc2

File tree

6 files changed

+136
-0
lines changed

6 files changed

+136
-0
lines changed

adi/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from adi.ad4170 import ad4170
2121
from adi.ad4630 import ad4630, adaq42xx
2222
from adi.ad4858 import ad4858
23+
from adi.ad4880 import ad4880
2324
from adi.ad5592r import ad5592r
2425
from adi.ad5686 import ad5686
2526
from adi.ad5754r import ad5754r

adi/ad4880.py

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Copyright (C) 2022-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 ad4880(rx, context_manager):
10+
11+
""" AD4880 ADC """
12+
13+
_complex_data = False
14+
channel = [] # type: ignore
15+
_device_name = ""
16+
17+
def __init__(self, uri="", device_name="ad4880"):
18+
19+
"""Initialize."""
20+
context_manager.__init__(self, uri, self._device_name)
21+
22+
compatible_part = "ad4880"
23+
self._ctrl = None
24+
25+
if not device_name:
26+
device_name = compatible_parts
27+
else:
28+
if device_name != compatible_part:
29+
raise Exception(f"Not a compatible device: {device_name}")
30+
31+
# Select the device matching device_name as working device
32+
for device in self._ctx.devices:
33+
if device.name == device_name:
34+
self._ctrl = device
35+
self._rxadc = device
36+
break
37+
38+
if not self._ctrl:
39+
raise Exception("Error in selecting matching device")
40+
41+
if not self._rxadc:
42+
raise Exception("Error in selecting matching device")
43+
44+
self._rx_channel_names = []
45+
self.channel = []
46+
for ch in self._ctrl.channels:
47+
name = ch._id
48+
self._rx_channel_names.append(name)
49+
self.channel.append(self._channel(self._ctrl, name))
50+
51+
rx.__init__(self)
52+
53+
class _channel(attribute):
54+
def __init__(self, ctrl, channel_name):
55+
self.name = channel_name
56+
self._ctrl = ctrl
57+
58+
@property
59+
def scale(self):
60+
"""scale: Scale value"""
61+
return self._get_iio_attr(self.name, "scale", False)
62+
63+
@property
64+
def lvds_cnv(self):
65+
"""scale: Scale value"""
66+
return self._get_iio_attr(self.name, "lvds_cnv", False)
67+
68+
@lvds_cnv.setter
69+
def lvds_cnv(self, calibscale):
70+
""""""
71+
self._set_iio_attr(self.name, "lvds_cnv", False, calibscale, self._ctrl)
72+
73+
@property
74+
def lvds_sync(self):
75+
""""""
76+
return self._get_iio_attr(self.name, "lvds_sync", False)
77+
78+
@lvds_sync.setter
79+
def calibscale(self, calibscale):
80+
"""Set calibration scale value."""
81+
self._set_iio_attr(self.name, "lvds_sync", False, calibscale, self._ctrl)
82+
83+
@property
84+
def sampling_frequency(self):
85+
"""sampling_frequency: Sampling frequency value"""
86+
return self._get_iio_dev_attr("sampling_frequency", False)
87+
88+
@property
89+
def sinc_dec_rate_available(self):
90+
""""""
91+
return self._get_iio_dev_attr("sinc_dec_rate_available", False)
92+
93+
@property
94+
def sinc_dec_rate(self):
95+
""""""
96+
return self._get_iio_dev_attr("sinc_dec_rate", False)
97+
98+
@sinc_dec_rate.setter
99+
def sinc_dec_rate(self, value):
100+
self._set_iio_dev_attr("sinc_dec_rate", value)
101+
102+
@property
103+
def filter_sel_available(self):
104+
""""""
105+
return self._get_iio_dev_attr_str("filter_sel_available", False)
106+
107+
@property
108+
def filter_sel(self):
109+
""""""
110+
return self._get_iio_dev_attr_str("filter_sel", False)
111+
112+
@filter_sel.setter
113+
def filter_sel(self, value):
114+
self._set_iio_dev_attr_str("filter_sel", value)

doc/source/devices/adi.ad4880.rst

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ad4880
2+
=================
3+
4+
.. automodule:: adi.ad4880
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:

doc/source/devices/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Supported Devices
1818
adi.ad4170
1919
adi.ad4630
2020
adi.ad469x
21+
adi.ad4880
2122
adi.ad5592r
2223
adi.ad5627
2324
adi.ad5686

supported_parts.md

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
- AD4696
3535
- AD4697
3636
- AD4698
37+
- AD4880
3738
- AD5310R
3839
- AD5311R
3940
- AD5592R

test/test_ad4880.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import pytest
2+
3+
hardware = ["ad4880"]
4+
classname = ["adi.ad4880"]
5+
6+
7+
#########################################
8+
@pytest.mark.iio_hardware(hardware, True)
9+
@pytest.mark.parametrize("classname", [(classname)])
10+
@pytest.mark.parametrize("channel", [0, 1])
11+
def test_ad4880_rx_data(test_dma_rx, iio_uri, classname, channel):
12+
test_dma_rx(iio_uri, classname, channel)

0 commit comments

Comments
 (0)