Skip to content

Commit

Permalink
adi/ad7944: use the sampling_frequency attribute provided by iio:device
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Sylvestre <[email protected]>
  • Loading branch information
fsylvestre committed May 13, 2024
1 parent fb83ff6 commit a49a8f0
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions adi/ad7944.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,7 @@ def __init__(self, uri="ip:analog.local", device_name="ad7944"):
if device_name not in self._compatible_parts:
raise Exception(f"Not a compatible device: {device_name}")

# TODO: if/when pyadi-iio and libiio get refactored, this could
# be done more gracefully. The device object should have a
# trigger property that is directly accessible for the sampling
# frequency, but this is broken in libiio 0.25.
trigger_name = "trigger0"
self._rxadc = self._ctrl = self._ctx.find_device(device_name)
self._trigger = self._ctx.find_device(trigger_name)

if not self._ctrl:
raise Exception(f"Error in selecting matching device {device_name}")
Expand All @@ -49,12 +43,12 @@ def __init__(self, uri="ip:analog.local", device_name="ad7944"):
@property
def sampling_frequency(self):
"""Get sampling frequency."""
return self._trigger.frequency
return self._get_iio_dev_attr("sampling_frequency")

@sampling_frequency.setter
def sampling_frequency(self, rate):
"""Set sampling frequency."""
self._trigger.frequency = rate
self._set_iio_dev_attr("sampling_frequency", rate)


class ad7985(ad7944):
Expand Down

0 comments on commit a49a8f0

Please sign in to comment.