Skip to content

Commit 0928c6f

Browse files
committed
adi/ad7944: Add AD7944/AD7985/AD7986 PulSAR ADCs
- Add adi/ad7944.py module - Add ad7944 to index.rst - Add ad7944/85/86 to supported_parts.md - Add ad7944 doc stub - Add test/ad7944/85/86.py test, xml file - Add ad7944/85/86 to hardware_map.xml Signed-off-by: Florian Sylvestre <[email protected]> Signed-off-by: Trevor Gamblin <[email protected]>
1 parent bcadbe8 commit 0928c6f

File tree

12 files changed

+367
-0
lines changed

12 files changed

+367
-0
lines changed

adi/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from adi.ad7746 import ad7746
3434
from adi.ad7768 import ad7768, ad7768_4
3535
from adi.ad7799 import ad7799
36+
from adi.ad7944 import ad7944, ad7985, ad7986
3637
from adi.ad9081 import ad9081
3738
from adi.ad9081_mc import QuadMxFE, ad9081_mc
3839
from adi.ad9083 import ad9083

adi/ad7944.py

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Copyright (C) 2020-2025 Analog Devices, Inc.
2+
#
3+
# SPDX short identifier: ADIBSD
4+
5+
import numpy as np
6+
7+
from adi.context_manager import context_manager
8+
from adi.rx_tx import rx
9+
10+
11+
class ad7944(rx, context_manager):
12+
"""AD7944, 14-bit, successive approximation analog-to-digital
13+
converter (SAR ADC) with sample rates up to 2.5 MSPS"""
14+
15+
_compatible_parts = ["ad7944"]
16+
_device_name = ""
17+
18+
def __init__(self, uri="ip:analog.local", device_name="ad7944"):
19+
"""Initialize."""
20+
context_manager.__init__(self, uri, self._device_name)
21+
22+
self._ctrl = None
23+
24+
if not device_name:
25+
device_name = self._compatible_parts[0]
26+
else:
27+
if device_name not in self._compatible_parts:
28+
raise Exception(f"Not a compatible device: {device_name}")
29+
30+
self._rxadc = self._ctrl = self._ctx.find_device(device_name)
31+
32+
if not self._rxadc:
33+
raise Exception(f"Error in selecting matching device {device_name}")
34+
35+
if not self._ctrl:
36+
raise Exception(f"Error in selecting matching device {device_name}")
37+
38+
self._rx_channel_names = []
39+
for ch in self._rxadc.channels:
40+
name = ch._id
41+
self._rx_channel_names.append(name)
42+
43+
# The data type depends on whether or not SPI offload support is
44+
# available. We can check this by testing for the
45+
# sampling_frequency_available attribute, as this only exists in that
46+
# case.
47+
try:
48+
self._get_iio_attr(
49+
self.rx_channel_names[0], "sampling_frequency_available", False
50+
)
51+
self._rx_data_type = np.uint32
52+
except KeyError:
53+
self._rx_data_type = np.uint16
54+
55+
rx.__init__(self)
56+
57+
@property
58+
def sampling_frequency(self):
59+
"""Get sampling frequency."""
60+
return self._get_iio_attr(self.rx_channel_names[0], "sampling_frequency", False)
61+
62+
@property
63+
def sampling_frequency_available(self):
64+
"""Get available sampling frequency values. This property only exists if
65+
SPI offload is enabled for the driver."""
66+
if isinstance(self._rx_data_type, np.uint32):
67+
return self._get_iio_attr(
68+
self.rx_channel_names[0], "sampling_frequency_available", False
69+
)
70+
else:
71+
pass
72+
73+
@sampling_frequency.setter
74+
def sampling_frequency(self, rate):
75+
"""Set sampling frequency."""
76+
self._set_iio_attr(
77+
self.rx_channel_names[0], "sampling_frequency", value=rate, output=False
78+
)
79+
80+
81+
class ad7985(ad7944):
82+
"""AD7985, 16-bit, successive approximation analog-to-digital
83+
converter (SAR ADC) with sample rates up to 2.5 MSPS"""
84+
85+
_compatible_parts = ["ad7985"]
86+
87+
def __init__(self, uri="ip:analog.local", device_name="ad7985"):
88+
super().__init__(uri, device_name)
89+
90+
91+
class ad7986(ad7944):
92+
"""AD7986, 18-bit, successive approximation analog-to-digital
93+
converter (SAR ADC) with sample rates up to 2 MSPS"""
94+
95+
_compatible_parts = ["ad7986"]
96+
97+
def __init__(self, uri="ip:analog.local", device_name="ad7986"):
98+
super().__init__(uri, device_name)
99+
self._rx_data_type = np.int32

doc/source/devices/adi.ad7944.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ad7944
2+
=================
3+
4+
.. automodule:: adi.ad7944
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:

doc/source/devices/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Supported Devices
3737
adi.ad7768
3838
adi.ad777x
3939
adi.ad7799
40+
adi.ad7944
4041
adi.ad9081
4142
adi.ad9081_mc
4243
adi.ad9083

supported_parts.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@
9696
- AD7771
9797
- AD7779
9898
- AD7799
99+
- AD7944
100+
- AD7985
101+
- AD7986
99102
- AD9081
100103
- AD9083
101104
- AD9084

test/emu/devices/ad7944.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="10.2.5.203 Linux zed-2 6.13.0-rc6-next-20250110-ad7986-07882-g636b57f41deb #3 SMP PREEMPT Tue Feb 11 10:00:44 EST 2025 armv7l" ><context-attribute name="hw_carrier" value="Xilinx Zynq ZED" /><context-attribute name="hw_model" value="EVAL-AD7985FMCZ on Xilinx Zynq ZED" /><context-attribute name="hw_mezzanine" value="EVAL-AD7985FMCZ" /><context-attribute name="hw_name" value="Empty Field" /><context-attribute name="hw_vendor" value="Analog Devices" /><context-attribute name="hw_serial" value="Empty Field" /><context-attribute name="local,kernel" value="6.13.0-rc6-next-20250110-ad7986-07882-g636b57f41deb" /><context-attribute name="uri" value="ip:10.2.5.203" /><context-attribute name="ip,ip-addr" value="10.2.5.203" /><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="41000" /><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="2057" /><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="1396" /><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="2461" /><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="2617" /><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="14" /><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="2458" /><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="1392" /><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="1389" /><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="1717" /><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="ad7944" ><channel id="voltage0" type="input" ><scan-element index="0" format="le:u14/32&gt;&gt;0" scale="0.305176" /><attribute name="raw" filename="in_voltage0_raw" value="6007" /><attribute name="sampling_frequency" filename="in_voltage0_sampling_frequency" value="2463055" /><attribute name="sampling_frequency_available" filename="in_voltage0_sampling_frequency_available" value="[1 1 2500000]" /><attribute name="scale" filename="in_voltage0_scale" value="0.305175781" /></channel><attribute name="waiting_for_supplier" value="0" /><buffer-attribute name="data_available" value="131072" /><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/devices/ad7985.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="10.2.5.203 Linux zed-2 6.13.0-rc2-next-20241210-ad7944-mainline #508 SMP PREEMPT Tue Dec 10 16:55:10 CST 2024 armv7l" ><context-attribute name="hw_carrier" value="Xilinx Zynq ZED" /><context-attribute name="hw_model" value="EVAL-AD7985FMCZ on Xilinx Zynq ZED" /><context-attribute name="hw_mezzanine" value="EVAL-AD7985FMCZ" /><context-attribute name="hw_name" value="Empty Field" /><context-attribute name="hw_vendor" value="Analog Devices" /><context-attribute name="hw_serial" value="Empty Field" /><context-attribute name="local,kernel" value="6.13.0-rc2-next-20241210-ad7944-mainline" /><context-attribute name="uri" value="ip:10.2.5.203" /><context-attribute name="ip,ip-addr" value="10.2.5.203" /><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="41000" /><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="2054" /><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="1393" /><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="2462" /><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="2601" /><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="12" /><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="2461" /><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="1395" /><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="1390" /><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="1713" /><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="ad7985" ><channel id="voltage0" type="input" ><scan-element index="0" format="le:u16/32&gt;&gt;0" scale="0.076294" /><attribute name="raw" filename="in_voltage0_raw" value="28616" /><attribute name="sampling_frequency" filename="in_voltage0_sampling_frequency" value="2463055" /><attribute name="sampling_frequency_available" filename="in_voltage0_sampling_frequency_available" value="[1 1 2500000]" /><attribute name="scale" filename="in_voltage0_scale" value="0.076293945" /></channel><attribute name="waiting_for_supplier" value="0" /><buffer-attribute name="data_available" value="524288" /><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>

0 commit comments

Comments
 (0)