Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adi:ad5592r: Added Rx method #625

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion adi/ad5592r.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

from adi.attribute import attribute
from adi.context_manager import context_manager
from adi.rx_tx import rx


class ad5592r(context_manager):
class ad5592r(rx, context_manager):
"""AD5592R and AD5593R SPI / I2C interface, 8-channel, 12-bit Confiburable ADC/DAC, digital GPIO

Analog I/O pins are configured in the device tree and can be ADC, DAC, or both. Channel attributes are as follows, where X corresponds to device channel number:
Expand All @@ -25,6 +26,8 @@ class ad5592r(context_manager):
"""

_device_name = ""
_complex_data = False
channel = []

def __repr__(self):
retstr = f"""
Expand Down Expand Up @@ -56,11 +59,16 @@ def __init__(self, uri="", device_name=""):
for device in self._ctx.devices:
if device.name in device_name:
self._ctrl = device
self._rxadc = device
break

self.channel = []
self._rx_channel_names = []

# Dynamically get channels after the index
for ch in self._ctrl.channels:
name = ch._id
print(name)
output = ch._output
if name == "temp":
setattr(self, name, self.channel_temp(self._ctrl, name, output))
Expand All @@ -70,9 +78,12 @@ def __init__(self, uri="", device_name=""):
self, name + "_dac", self.channel_dac(self._ctrl, name, output)
)
else:
self._rx_channel_names.append(name)
self.channel.append(self.channel_adc(self._ctrl, name, output))
setattr(
self, name + "_adc", self.channel_adc(self._ctrl, name, output)
)
rx.__init__(self)

class channel_adc(attribute):
"""AD5592R Input Voltage Channels"""
Expand Down
Loading