Skip to content

Commit f54c570

Browse files
committed
adi:ad5592r: Added Rx method
Added rx method for data capture Updated emu file. Signed-off-by: Disha D <[email protected]>
1 parent 77c5ed2 commit f54c570

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

adi/ad5592r.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
from adi.attribute import attribute
66
from adi.context_manager import context_manager
7+
from adi.rx_tx import rx
78

89

9-
class ad5592r(context_manager):
10+
class ad5592r(rx, context_manager):
1011
"""AD5592R and AD5593R SPI / I2C interface, 8-channel, 12-bit Confiburable ADC/DAC, digital GPIO
1112
1213
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:
@@ -25,6 +26,8 @@ class ad5592r(context_manager):
2526
"""
2627

2728
_device_name = ""
29+
_complex_data = False
30+
channel = []
2831

2932
def __repr__(self):
3033
retstr = f"""
@@ -56,8 +59,15 @@ def __init__(self, uri="", device_name=""):
5659
for device in self._ctx.devices:
5760
if device.name in device_name:
5861
self._ctrl = device
62+
self._rxadc = device
63+
buffers_avail = any([c.scan_element for c in self._rxadc.channels])
64+
if not buffers_avail:
65+
delattr(self, "rx")
5966
break
6067

68+
self.channel = []
69+
self._rx_channel_names = []
70+
6171
# Dynamically get channels after the index
6272
for ch in self._ctrl.channels:
6373
name = ch._id
@@ -70,9 +80,12 @@ def __init__(self, uri="", device_name=""):
7080
self, name + "_dac", self.channel_dac(self._ctrl, name, output)
7181
)
7282
else:
83+
self._rx_channel_names.append(name)
84+
self.channel.append(self.channel_adc(self._ctrl, name, output))
7385
setattr(
7486
self, name + "_adc", self.channel_adc(self._ctrl, name, output)
7587
)
88+
rx.__init__(self)
7689

7790
class channel_adc(attribute):
7891
"""AD5592R Input Voltage Channels"""

test/emu/devices/ad5592r.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE context [<!ELEMENT context (device | context-attribute)*><!ELEMENT context-attribute EMPTY><!ELEMENT device (channel | attribute | debug-attribute | buffer-attribute)*><!ELEMENT channel (scan-element?, attribute*)><!ELEMENT attribute EMPTY><!ELEMENT scan-element EMPTY><!ELEMENT debug-attribute EMPTY><!ELEMENT buffer-attribute EMPTY><!ATTLIST context name CDATA #REQUIRED description CDATA #IMPLIED><!ATTLIST context-attribute name CDATA #REQUIRED value CDATA #REQUIRED><!ATTLIST device id CDATA #REQUIRED name CDATA #IMPLIED><!ATTLIST channel id CDATA #REQUIRED type (input|output) #REQUIRED name CDATA #IMPLIED><!ATTLIST scan-element index CDATA #REQUIRED format CDATA #REQUIRED scale CDATA #IMPLIED><!ATTLIST attribute name CDATA #REQUIRED filename CDATA #IMPLIED value CDATA #IMPLIED><!ATTLIST debug-attribute name CDATA #REQUIRED value CDATA #IMPLIED><!ATTLIST buffer-attribute name CDATA #REQUIRED value CDATA #IMPLIED>]><context name="network" description="192.168.86.20 Linux analog 5.10.63-v7l+ #1 SMP Fri Oct 21 08:20:48 UTC 2022 armv7l" ><context-attribute name="hw_carrier" value="Raspberry Pi 4 Model B Rev 1.1" /><context-attribute name="dtoverlay" value="gpio-shutdown,rpi-ad5592r" /><context-attribute name="hw_model" value="0x0001 on Raspberry Pi 4 Model B Rev 1.1" /><context-attribute name="hw_mezzanine" value="0x0001" /><context-attribute name="hw_name" value="Raspberry Pi to Pmod/QuikEval/PSM Adapter" /><context-attribute name="hw_vendor" value="Analog Devices, Inc." /><context-attribute name="hw_serial" value="99ed8c67-7357-4c38-9721-b1723abbaa81" /><context-attribute name="local,kernel" value="5.10.63-v7l+" /><context-attribute name="uri" value="ip:analog.local" /><context-attribute name="ip,ip-addr" value="192.168.86.20" /><device id="hwmon0" name="cpu_thermal" ><channel id="temp1" type="input" ><attribute name="input" filename="temp1_input" value="33589" /></channel></device><device id="hwmon1" name="rpi_volt" ><channel id="in0" type="input" ><attribute name="lcrit_alarm" filename="in0_lcrit_alarm" value="0" /></channel></device><device id="iio:device0" name="ad5592r" ><channel id="voltage3" type="input" ><attribute name="raw" filename="in_voltage3_raw" value="0" /><attribute name="scale" filename="in_voltage_scale" value="0.610351562" /><attribute name="scale_available" filename="in_voltage_scale_available" value="0.610351562 1.220703124" /></channel><channel id="voltage2" type="output" ><attribute name="raw" filename="out_voltage2_raw" value="0" /><attribute name="scale" filename="out_voltage_scale" value="0.610351562" /><attribute name="scale_available" filename="out_voltage_scale_available" value="0.610351562 1.220703124" /></channel><channel id="voltage3" type="output" ><attribute name="raw" filename="out_voltage3_raw" value="0" /><attribute name="scale" filename="out_voltage_scale" value="0.610351562" /><attribute name="scale_available" filename="out_voltage_scale_available" value="0.610351562 1.220703124" /></channel><channel id="voltage1" type="input" ><attribute name="raw" filename="in_voltage1_raw" value="0" /><attribute name="scale" filename="in_voltage_scale" value="0.610351562" /><attribute name="scale_available" filename="in_voltage_scale_available" value="0.610351562 1.220703124" /></channel><channel id="voltage0" type="output" ><attribute name="raw" filename="out_voltage0_raw" value="0" /><attribute name="scale" filename="out_voltage_scale" value="0.610351562" /><attribute name="scale_available" filename="out_voltage_scale_available" value="0.610351562 1.220703124" /></channel><channel id="voltage2" type="input" ><attribute name="raw" filename="in_voltage2_raw" value="0" /><attribute name="scale" filename="in_voltage_scale" value="0.610351562" /><attribute name="scale_available" filename="in_voltage_scale_available" value="0.610351562 1.220703124" /></channel><channel id="temp" type="input" ><attribute name="offset" filename="in_temp_offset" value="-753" /><attribute name="raw" filename="in_temp_raw" value="813" /><attribute name="scale" filename="in_temp_scale" value="376.789750000" /></channel></device><device id="iio_sysfs_trigger" ><attribute name="add_trigger" value="ERROR" /><attribute name="remove_trigger" value="ERROR" /></device></context>
1+
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE context [<!ELEMENT context (device | context-attribute)*><!ELEMENT context-attribute EMPTY><!ELEMENT device (channel | attribute | debug-attribute | buffer-attribute)*><!ELEMENT channel (scan-element?, attribute*)><!ELEMENT attribute EMPTY><!ELEMENT scan-element EMPTY><!ELEMENT debug-attribute EMPTY><!ELEMENT buffer-attribute EMPTY><!ATTLIST context name CDATA #REQUIRED description CDATA #IMPLIED><!ATTLIST context-attribute name CDATA #REQUIRED value CDATA #REQUIRED><!ATTLIST device id CDATA #REQUIRED name CDATA #IMPLIED><!ATTLIST channel id CDATA #REQUIRED type (input|output) #REQUIRED name CDATA #IMPLIED><!ATTLIST scan-element index CDATA #REQUIRED format CDATA #REQUIRED scale CDATA #IMPLIED><!ATTLIST attribute name CDATA #REQUIRED filename CDATA #IMPLIED value CDATA #IMPLIED><!ATTLIST debug-attribute name CDATA #REQUIRED value CDATA #IMPLIED><!ATTLIST buffer-attribute name CDATA #REQUIRED value CDATA #IMPLIED>]><context name="serial" description="no-OS/projects/NO_OS_PROJECT 1" ><context-attribute name="hw_carrier" value="SDP-K1" /><context-attribute name="hw_mezzanine" value="PMD-ARD-INT-LCZ" /><context-attribute name="hw_name" value="Arduino to Pmod Interposer" /><context-attribute name="uri" value="serial:/dev/ttyS0,230400,8n1n" /><context-attribute name="serial,port" value="/dev/ttyS0" /><context-attribute name="serial,description" value="ttyS0" /><device id="iio:device0" name="ad5592r" ><channel id="voltage0" name="voltage0" type="output" ><scan-element index="0" format="le:u12/16&gt;&gt;0" /><attribute name="raw" filename="in_voltage0_raw" value="2" /><attribute name="scale" filename="in_voltage0_scale" value="0.61035156" /><attribute name="offset" filename="in_voltage0_offset" value="0" /></channel><channel id="voltage1" name="voltage1" type="input" ><scan-element index="1" format="le:u12/16&gt;&gt;0" /><attribute name="raw" filename="in_voltage1_raw" value="313" /><attribute name="scale" filename="in_voltage1_scale" value="0.61035156" /><attribute name="offset" filename="in_voltage1_offset" value="0" /></channel><channel id="voltage2" name="voltage2" type="output" ><scan-element index="2" format="le:u12/16&gt;&gt;0" /><attribute name="raw" filename="in_voltage2_raw" value="4095" /><attribute name="scale" filename="in_voltage2_scale" value="0.61035156" /><attribute name="offset" filename="in_voltage2_offset" value="0" /></channel><channel id="voltage3" name="voltage3" type="output" ><scan-element index="3" format="le:u12/16&gt;&gt;0" /><attribute name="raw" filename="in_voltage3_raw" value="4095" /><attribute name="scale" filename="in_voltage3_scale" value="0.61035156" /><attribute name="offset" filename="in_voltage3_offset" value="0" /></channel><channel id="voltage4" name="voltage4" type="input" ><scan-element index="4" format="le:u12/16&gt;&gt;0" /><attribute name="raw" filename="in_voltage4_raw" value="4095" /><attribute name="scale" filename="in_voltage4_scale" value="0.61035156" /><attribute name="offset" filename="in_voltage4_offset" value="0" /></channel><channel id="voltage5" name="voltage5" type="input" ><scan-element index="5" format="le:u12/16&gt;&gt;0" /><attribute name="raw" filename="in_voltage5_raw" value="4095" /><attribute name="scale" filename="in_voltage5_scale" value="0.61035156" /><attribute name="offset" filename="in_voltage5_offset" value="0" /></channel><channel id="voltage6" name="voltage6" type="input" ><scan-element index="6" format="le:u12/16&gt;&gt;0" /><attribute name="raw" filename="in_voltage6_raw" value="4095" /><attribute name="scale" filename="in_voltage6_scale" value="0.61035156" /><attribute name="offset" filename="in_voltage6_offset" value="0" /></channel><channel id="voltage7" name="voltage7" type="input" ><scan-element index="7" format="le:u12/16&gt;&gt;0" /><attribute name="raw" filename="in_voltage7_raw" value="18" /><attribute name="scale" filename="in_voltage7_scale" value="0.61035156" /><attribute name="offset" filename="in_voltage7_offset" value="0" /></channel><attribute name="sampling_frequency" value="1" /><attribute name="die_temperature" value="27.110022" /><attribute name="adc_buffer" value="enabled" /><attribute name="adc_buffer_available" value="disabled enabled" /><attribute name="ldac_mode" value="sync" /><attribute name="ldac_mode_available" value="sync async trigger" /><attribute name="set_repetition_bit" value="repeating" /><attribute name="set_repetition_bit_available" value="non-repeating repeating" /><debug-attribute name="direct_reg_access" value="0" /></device></context>

0 commit comments

Comments
 (0)