-
Notifications
You must be signed in to change notification settings - Fork 110
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
Add pyadi support for ADAQ4001 and ADAQ4003 #571
base: main
Are you sure you want to change the base?
Changes from all commits
6be440a
2e563cd
fd2fb99
912e230
e08f1c8
bb790e3
4279d54
19fc95b
e4155e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,6 +116,8 @@ | |
- AD4858 | ||
- AD9739A | ||
- ADA4961 | ||
- ADAQ4001 | ||
- ADAQ4003 | ||
- ADAQ4216 | ||
- ADAQ4220 | ||
- ADAQ4224 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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.1.7 Linux raspberrypi 6.9.0-rc6-v8+ #10 SMP PREEMPT Fri May 10 11:46:32 -03 2024 aarch64" ><context-attribute name="local,kernel" value="6.9.0-rc6-v8+" /><context-attribute name="uri" value="ip:192.168.1.7" /><context-attribute name="ip,ip-addr" value="192.168.1.7" /><device id="iio:device0" name="adaq4003" ><channel id="voltage0-voltage1" type="input" ><scan-element index="0" format="be:s18/32>>14" scale="0.084024" /><attribute name="raw" filename="in_voltage0-voltage1_raw" value="98432" /><attribute name="scale" filename="in_voltage0-voltage1_scale" value="0.084024162" /><attribute name="scale_available" filename="in_voltage0-voltage1_scale_available" value="0.084024162 0.067219330" /></channel><attribute name="waiting_for_supplier" value="0" /><buffer-attribute name="data_available" value="0" /><buffer-attribute name="direction" value="in" /><debug-attribute name="direct_reg_access" value="0x5CE1" /></device></context> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import adi | ||
import pytest | ||
|
||
hardware = "adaq4003" | ||
classname = "adi.adaq4003" | ||
|
||
######################################### | ||
@pytest.mark.iio_hardware(hardware) | ||
@pytest.mark.parametrize("classname", [(classname)]) | ||
@pytest.mark.parametrize( | ||
"attr, val", | ||
[ | ||
( | ||
"sampling_frequency", | ||
[10000, 50000, 100000, 200000, 500000, 1000000, 2000000], | ||
), | ||
], | ||
) | ||
def test_adaq4003_attr(test_attribute_multiple_values, iio_uri, classname, attr, val): | ||
|
||
# Setting the sampling frequency is only possible through FPGA implemented | ||
# hardware (SPI-Engine offload) so the attribute might not exist if the | ||
# the platform is not set with proper FPGA bitstream or doesn't have | ||
# a integrated FPGA. | ||
|
||
try: | ||
test_attribute_multiple_values(iio_uri, classname, attr, val, 1) | ||
except KeyError: | ||
pytest.skip("sampling_frequency attribute not available on test platform.") | ||
|
||
|
||
######################################### | ||
@pytest.mark.iio_hardware(hardware) | ||
@pytest.mark.parametrize("classname", [(classname)]) | ||
@pytest.mark.parametrize( | ||
"attr, avail_attr, tol, repeats, sub_channel", | ||
[("scale", "scale_available", 0, 1, "voltage0-voltage1",),], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As noted above, there is no scale_available. Also this is a single-channel device with a single differential input, voltage0. The voltage0-voltage-1 nomenclature is typical of multichannel devices that can be arbitrarily configured. |
||
) | ||
def test_adaq4003_scale_attr( | ||
test_attribute_multiple_values, | ||
iio_uri, | ||
classname, | ||
attr, | ||
avail_attr, | ||
tol, | ||
repeats, | ||
sub_channel, | ||
): | ||
# Get the device | ||
sdr = eval(classname + "(uri='" + iio_uri + "')") | ||
|
||
# Check hardware | ||
if not hasattr(sdr, sub_channel): | ||
raise AttributeError(sub_channel + " not defined in " + classname) | ||
if not hasattr(getattr(sdr, sub_channel), avail_attr): | ||
raise AttributeError(avail_attr + " not defined in " + classname) | ||
|
||
# Get the list of available scale values | ||
val = getattr(getattr(sdr, sub_channel), avail_attr) | ||
|
||
test_attribute_multiple_values( | ||
iio_uri, classname, attr, val, tol, repeats, sub_channel=sub_channel | ||
) | ||
|
||
|
||
######################################### | ||
@pytest.mark.iio_hardware(hardware, True) | ||
@pytest.mark.parametrize("classname", [(classname)]) | ||
@pytest.mark.parametrize("channel", [0]) | ||
def test_adaq4003_rx_data(test_dma_rx, iio_uri, classname, channel): | ||
test_dma_rx(iio_uri, classname, channel, buffer_size=2 ** 15) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@machschmitt I believe these are all fixed-scale devices. Accessing the scale_available property throws a KeyError.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well yes, at least what is in ADI Linux right now.
Though, the driver will provide a scale_available attribute in the future for configuring span compression.
Some explanation taken from commit log:
AD4000 series of devices have a span compression feature that allows
reducing the ADC input range while keeping the same range of raw output
codes, thus providing a slight increase in measurement precision.
The span compression selection (enable/disable) is done by writing to
the scale attribute. The list of valid scale values is listed by the
scale_available attribute.
@tfcollins, can we have
scale_available
attribute (even if it is not working right now) or would you prefer to only introduce it when the changes get to ADI Linux?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@machschmitt noted - although has the decision been made whether the compression will be changeable at run time, or set in the device tree? Typically the decision would be made as the analog front end circuit is being designed, then "set and forget" in software / device tree.
But if it will be run-time adjustable, this makes perfect sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mthoren-adi, I was developing this as a runtime feature but it could definitely be set in device tree as you said so that's indeed a good question. Who can I ask about this configuration decision? Part application engineer?