|
| 1 | +# Copyright (C) 2022-2025 Analog Devices, Inc. |
| 2 | +# |
| 3 | +# SPDX short identifier: ADIBSD |
| 4 | + |
| 5 | +from adi.attribute import attribute |
| 6 | +from adi.context_manager import context_manager |
| 7 | + |
| 8 | + |
| 9 | +class adf4350(attribute, context_manager): |
| 10 | + """ADF4350 Microwave Wideband Synthesizer with Integrated VCO |
| 11 | +
|
| 12 | + parameters: |
| 13 | + uri: type=string |
| 14 | + URI of IIO context with ADF4350 |
| 15 | + """ |
| 16 | + |
| 17 | + _device_name = "" |
| 18 | + |
| 19 | + def __init__(self, uri="", device_name="adf4350"): |
| 20 | + context_manager.__init__(self, uri, self._device_name) |
| 21 | + |
| 22 | + # Find the device |
| 23 | + for device in self._ctx.devices: |
| 24 | + if device.name == device_name: |
| 25 | + self._ctrl = device |
| 26 | + self._rxadc = device |
| 27 | + break |
| 28 | + |
| 29 | + # Raise an exception if the device isn't found |
| 30 | + if not self._ctrl: |
| 31 | + raise Exception("ADF4350 device not found") |
| 32 | + |
| 33 | + @property |
| 34 | + def frequency_altvolt0(self): |
| 35 | + return self._get_iio_attr("altvoltage0", "frequency", True, self._ctrl) |
| 36 | + |
| 37 | + @frequency_altvolt0.setter |
| 38 | + def frequency_altvolt0(self, value): |
| 39 | + self._set_iio_attr("altvoltage0", "frequency", True, value, self._ctrl) |
| 40 | + |
| 41 | + @property |
| 42 | + def frequency_resolution_altvolt0(self): |
| 43 | + return self._get_iio_attr( |
| 44 | + "altvoltage0", "frequency_resolution", True, self._ctrl |
| 45 | + ) |
| 46 | + |
| 47 | + @frequency_resolution_altvolt0.setter |
| 48 | + def frequency_resolution_altvolt0(self, value): |
| 49 | + self._set_iio_attr( |
| 50 | + "altvoltage0", "frequency_resolution", True, value, self._ctrl |
| 51 | + ) |
| 52 | + |
| 53 | + @property |
| 54 | + def refin_frequency_altvolt0(self): |
| 55 | + return self._get_iio_attr("altvoltage0", "refin_frequency", True, self._ctrl) |
| 56 | + |
| 57 | + @refin_frequency_altvolt0.setter |
| 58 | + def refin_frequency_altvolt0(self, value): |
| 59 | + self._set_iio_attr("altvoltage0", "refin_frequency", True, value, self._ctrl) |
| 60 | + |
| 61 | + @property |
| 62 | + def powerdown_altvolt0(self): |
| 63 | + self._get_iio_attr("altvoltage0", "powerdown", True, self._ctrl) |
| 64 | + |
| 65 | + @powerdown_altvolt0.setter |
| 66 | + def powerdown_altvolt0(self, value): |
| 67 | + self._set_iio_attr("altvoltage0", "powerdown", True, value, self._ctrl) |
| 68 | + |
| 69 | + def reg_read(self, reg): |
| 70 | + """Direct Register Access via debugfs""" |
| 71 | + self._set_iio_debug_attr_str("direct_reg_access", reg, self._ctrl) |
| 72 | + return self._get_iio_debug_attr_str("direct_reg_access", self._ctrl) |
| 73 | + |
| 74 | + def reg_write(self, reg, value): |
| 75 | + """Direct Register Access via debugfs""" |
| 76 | + self._set_iio_debug_attr_str("direct_reg_access", f"{reg} {value}", self._ctrl) |
0 commit comments