Skip to content

Commit

Permalink
ad937x: updated dec8/int8 implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Trecia Agoylo <[email protected]>
  • Loading branch information
tagoylo committed Oct 22, 2024
1 parent 77136ed commit 2a58df2
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions adi/ad937x.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,60 +170,68 @@ def tx_rf_bandwidth(self):
@property
def rx_enable_dec8(self):
"""rx_enable_dec8: Enable x8 decimation filter in RX path"""
val = self._get_iio_attr_str(
"voltage0_i", "sampling_frequency", False, self._rxadc
)
avail = None
try:
avail = self._get_iio_attr_str(
"voltage0_i", "sampling_frequency_available", False, self._rxadc
)
except KeyError:
return False
else:
avail = avail.strip().split(" ")
val = self._get_iio_attr_str(
"voltage0_i", "sampling_frequency", False, self._rxadc
)
return val == avail[1]
except KeyError:
return val == avail

@rx_enable_dec8.setter
def rx_enable_dec8(self, value):
try:
avail = self._get_iio_attr_str(
"voltage0_i", "sampling_frequency_available", False, self._rxadc
)
except KeyError:
if value:
print(
"x8 decimation filter is not supported. Using default sampling frequency."
)
else:
avail = sorted(avail.strip().split(" "))
val = int(avail[1] if value else avail[0])
self._set_iio_attr(
"voltage0_i", "sampling_frequency", False, val, self._rxadc
)
except KeyError:
print("x8 decimation filter is not supported.")

@property
def tx_enable_int8(self):
"""tx_enable_int8: Enable x8 interpolation filter in TX path"""
val = self._get_iio_attr_str(
"voltage0", "sampling_frequency", True, self._txdac
)
avail = None
try:
avail = self._get_iio_attr_str(
"voltage0", "sampling_frequency_available", True, self._txdac
)
except KeyError:
return False
else:
avail = avail.strip().split(" ")
val = self._get_iio_attr_str(
"voltage0", "sampling_frequency", True, self._txdac
)
return val == avail[1]
except KeyError:
return val == avail

@tx_enable_int8.setter
def tx_enable_int8(self, value):
try:
avail = self._get_iio_attr_str(
"voltage0", "sampling_frequency_available", True, self._txdac
)
except KeyError:
if value:
print(
"x8 interpolation filter is not supported. Using default sampling frequency."
)
else:
avail = sorted(avail.strip().split(" "))
val = int(avail[1] if value else avail[0])
self._set_iio_attr("voltage0", "sampling_frequency", True, val, self._txdac)
except KeyError:
print("x8 decimation filter is not supported.")

@property
def rx_sample_rate(self):
Expand Down

0 comments on commit 2a58df2

Please sign in to comment.