Skip to content

Commit 3c91481

Browse files
committed
Add support for AD353xr
Add ad353xr.py driver Add example code, test script Update index.rst, init.py, supported_parts.md files Add xml emu context file Update hardware_map.yml file for test emulation Signed-off-by: SGudla <[email protected]>
1 parent 39a62ea commit 3c91481

File tree

9 files changed

+476
-0
lines changed

9 files changed

+476
-0
lines changed

adi/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# SPDX short identifier: ADIBSD
44

55
from adi.ad2s1210 import ad2s1210
6+
from adi.ad353xr import ad353xr
67
from adi.ad405x import ad405x
78
from adi.ad469x import ad469x
89
from adi.ad579x import ad579x

adi/ad353xr.py

+298
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,298 @@
1+
# Copyright (C) 2025 Analog Devices, Inc.
2+
#
3+
# SPDX short identifier: ADIBSD
4+
# Copyright (C) 2025 Analog Devices, Inc.
5+
#
6+
# All rights reserved.
7+
#
8+
# Redistribution and use in source and binary forms, with or without modification,
9+
# are permitted provided that the following conditions are met:
10+
# - Redistributions of source code must retain the above copyright
11+
# notice, this list of conditions and the following disclaimer.
12+
# - Redistributions in binary form must reproduce the above copyright
13+
# notice, this list of conditions and the following disclaimer in
14+
# the documentation and/or other materials provided with the
15+
# distribution.
16+
# - Neither the name of Analog Devices, Inc. nor the names of its
17+
# contributors may be used to endorse or promote products derived
18+
# from this software without specific prior written permission.
19+
# - The use of this software may or may not infringe the patent rights
20+
# of one or more patent holders. This license does not release you
21+
# from the requirement that you obtain separate licenses from these
22+
# patent holders to use this software.
23+
# - Use of the software either in source or binary form, must be run
24+
# on or directly connected to an Analog Devices Inc. component.
25+
#
26+
# THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
27+
# INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A
28+
# PARTICULAR PURPOSE ARE DISCLAIMED.
29+
#
30+
# IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY
32+
# RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
33+
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
35+
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36+
37+
from decimal import Decimal
38+
39+
from adi.attribute import attribute
40+
from adi.context_manager import context_manager
41+
from adi.rx_tx import tx
42+
43+
44+
class ad353xr(tx, context_manager):
45+
""" AD353xr DAC """
46+
47+
_complex_data = False
48+
channel = [] # type: ignore
49+
_device_name = ""
50+
51+
def __init__(self, uri="", device_name=""):
52+
"""Constructor for AD353xr class."""
53+
context_manager.__init__(self, uri, self._device_name)
54+
55+
compatible_parts = ["ad3530r"]
56+
57+
self._ctrl = None
58+
59+
if not device_name:
60+
device_name = compatible_parts[0]
61+
else:
62+
if device_name not in compatible_parts:
63+
raise Exception(
64+
f"Not a compatible device: {device_name}. Supported device names "
65+
f"are: {','.join(compatible_parts)}"
66+
)
67+
68+
# Select the device matching device_name as working device
69+
for device in self._ctx.devices:
70+
if device.name == device_name:
71+
self._ctrl = device
72+
self._txdac = device
73+
break
74+
75+
if not self._ctrl:
76+
raise Exception("Error in selecting matching device")
77+
78+
if not self._txdac:
79+
raise Exception("Error in selecting matching device")
80+
81+
self.output_bits = []
82+
for ch in self._ctrl.channels:
83+
name = ch.id
84+
self.output_bits.append(ch.data_format.bits)
85+
self._tx_channel_names.append(name)
86+
self.channel.append(self._channel(self._ctrl, name))
87+
setattr(self, name, self._channel(self._ctrl, name))
88+
89+
tx.__init__(self)
90+
91+
### Add device attributes here ###
92+
93+
@property
94+
def sampling_frequency(self):
95+
"""AD353xr sampling frequency config"""
96+
return self._get_iio_dev_attr_str("sampling_frequency")
97+
98+
@sampling_frequency.setter
99+
def sampling_frequency(self, value):
100+
self._set_iio_dev_attr_str("sampling_frequency", value)
101+
102+
@property
103+
def all_ch_operating_mode_avail(self):
104+
"""AD353xr all channels operating mode available"""
105+
return self._get_iio_dev_attr_str("all_ch_operating_mode_available")
106+
107+
@property
108+
def all_ch_operating_mode(self):
109+
"""AD353xr all channels operating mode config"""
110+
return self._get_iio_dev_attr_str("all_ch_operating_mode")
111+
112+
@all_ch_operating_mode.setter
113+
def all_ch_operating_mode(self, value):
114+
if value in self.all_ch_operating_mode_avail:
115+
self._set_iio_dev_attr_str("all_ch_operating_mode", value)
116+
else:
117+
raise ValueError(
118+
"Error: Operating mode not supported \nUse one of: "
119+
+ str(self.all_ch_operating_mode_avail)
120+
)
121+
122+
@property
123+
def all_ch_input_registers(self):
124+
"""AD353xr all input registers config"""
125+
return self._get_iio_dev_attr_str("all_ch_input_registers")
126+
127+
@all_ch_input_registers.setter
128+
def all_input_registers(self, value):
129+
self._set_iio_dev_attr_str("all_ch_input_registers", value)
130+
131+
@property
132+
def all_ch_raw(self):
133+
"""AD353xr all dac registers config"""
134+
return self._get_iio_dev_attr_str("all_ch_raw")
135+
136+
@all_ch_raw.setter
137+
def all_ch_raw(self, value):
138+
self._set_iio_dev_attr_str("all_ch_raw", value)
139+
140+
@property
141+
def reference_select_available(self):
142+
"""AD353xr reference voltage available"""
143+
return self._get_iio_dev_attr_str("reference_select_available")
144+
145+
@property
146+
def reference_select(self):
147+
"""AD353xr reference voltage config"""
148+
return self._get_iio_dev_attr_str("reference_select")
149+
150+
@reference_select.setter
151+
def reference_select(self, value):
152+
if value in self.reference_select_available:
153+
self._set_iio_dev_attr_str("reference_select", value)
154+
else:
155+
raise ValueError(
156+
"Error: Reference select not supported \nUse one of: "
157+
+ str(self.reference_select_available)
158+
)
159+
160+
@property
161+
def sw_ldac_trigger_avail(self):
162+
"""AD353xr sw_ldac_trigger available"""
163+
return self._get_iio_dev_attr_str("sw_ldac_trigger_available")
164+
165+
@property
166+
def sw_ldac_trigger(self):
167+
"""AD353xr software ldac trigger config"""
168+
return self._get_iio_dev_attr_str("sw_ldac_trigger")
169+
170+
@sw_ldac_trigger.setter
171+
def sw_ldac_trigger(self, value):
172+
if value in self.sw_ldac_trigger_avail:
173+
self._set_iio_dev_attr_str("sw_ldac_trigger", value)
174+
else:
175+
raise ValueError(
176+
"Error: Trigger value not supported \nUse one of: "
177+
+ str(self.sw_ldac_trigger_avail)
178+
)
179+
180+
@property
181+
def hw_ldac_trigger_avail(self):
182+
"""AD353xr hw_ldac_trigger available"""
183+
return self._get_iio_dev_attr_str("hw_ldac_trigger_available")
184+
185+
@property
186+
def hw_ldac_trigger(self):
187+
"""AD353xr hardware ldac trigger config"""
188+
return self._get_iio_dev_attr_str("hw_ldac_trigger")
189+
190+
@hw_ldac_trigger.setter
191+
def hw_ldac_trigger(self, value):
192+
if value in self.hw_ldac_trigger_avail:
193+
self._set_iio_dev_attr_str("hw_ldac_trigger", value)
194+
else:
195+
raise ValueError(
196+
"Error: Trigger value not supported \nUse one of: "
197+
+ str(self.hw_ldac_trigger_avail)
198+
)
199+
200+
@property
201+
def range_avail(self):
202+
"""AD353xr range available"""
203+
return self._get_iio_dev_attr_str("range_available")
204+
205+
@property
206+
def range(self):
207+
"""AD353xr range config"""
208+
return self._get_iio_dev_attr_str("range")
209+
210+
@range.setter
211+
def range(self, value):
212+
if value in self.range_avail:
213+
self._set_iio_dev_attr_str("range", value)
214+
else:
215+
raise ValueError(
216+
"Error: Range option not supported \nUse one of: "
217+
+ str(self.range_avail)
218+
)
219+
220+
@property
221+
def mux_out_select_avail(self):
222+
"""AD353xr mux_out_select available"""
223+
return self._get_iio_dev_attr_str("mux_out_select_available")
224+
225+
@property
226+
def mux_out_select(self):
227+
"""AD353xr mux out select"""
228+
return self._get_iio_dev_attr_str("mux_out_select")
229+
230+
@mux_out_select.setter
231+
def mux_out_select(self, value):
232+
if value in self.mux_out_select_avail:
233+
self._set_iio_dev_attr_str("mux_out_select", value)
234+
else:
235+
raise ValueError(
236+
"Error: Mux output option not supported \nUse one of: "
237+
+ str(self.mux_out_select_avail)
238+
)
239+
240+
############################################################################
241+
242+
class _channel(attribute):
243+
"""AD353xr channel"""
244+
245+
def __init__(self, ctrl, channel_name):
246+
self.name = channel_name
247+
self._ctrl = ctrl
248+
249+
### Add channel attributes here ###
250+
@property
251+
def input_register(self):
252+
"""AD353xr channel input register value"""
253+
return self._get_iio_attr(self.name, "input_register", True)
254+
255+
@input_register.setter
256+
def input_register(self, value):
257+
self._set_iio_attr(self.name, "input_register", True, str(int(value)))
258+
259+
@property
260+
def raw(self):
261+
"""AD353xr channel raw value"""
262+
return self._get_iio_attr(self.name, "raw", True)
263+
264+
@raw.setter
265+
def raw(self, value):
266+
self._set_iio_attr(self.name, "raw", True, str(int(value)))
267+
268+
@property
269+
def offset(self):
270+
"""AD353xr channel offset"""
271+
return self._get_iio_attr(self.name, "offset", True)
272+
273+
@property
274+
def scale(self):
275+
"""AD353xr channel scale"""
276+
return self._get_iio_attr(self.name, "scale", True)
277+
278+
@property
279+
def operating_mode_avail(self):
280+
"""AD353xr channel operating mode settings"""
281+
return self._get_iio_attr_str(self.name, "operating_mode_available", True)
282+
283+
@property
284+
def operating_mode(self):
285+
"""AD353xr channel operating mode"""
286+
return self._get_iio_attr_str(self.name, "operating_mode", True)
287+
288+
@operating_mode.setter
289+
def operating_mode(self, value):
290+
if value in self.operating_mode_avail:
291+
self._set_iio_attr(self.name, "operating_mode", True, value)
292+
else:
293+
raise ValueError(
294+
"Error: Operating mode not supported \nUse one of: "
295+
+ str(self.operating_mode_avail)
296+
)
297+
298+
#####################################################################

doc/source/devices/adi.ad353xr.rst

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

doc/source/devices/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Supported Devices
99

1010
adi.QuadMxFE_multi
1111
adi.ad2s1210
12+
adi.ad353xr
1213
adi.ad3552r
1314
adi.ad4020
1415
adi.ad405x

0 commit comments

Comments
 (0)