-
Notifications
You must be signed in to change notification settings - Fork 104
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
Fsylvestre/ad7944 #562
base: main
Are you sure you want to change the base?
Fsylvestre/ad7944 #562
Changes from all commits
3b35948
389c38e
1b0c6ef
95be456
8370a2a
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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Copyright (C) 2020-2024 Analog Devices, Inc. | ||
# | ||
# SPDX short identifier: ADIBSD | ||
|
||
import numpy as np | ||
from adi.context_manager import context_manager | ||
from adi.rx_tx import rx | ||
|
||
|
||
class ad7944(rx, context_manager): | ||
"""AD7944, 14-bit, successive approximation analog-to-digital | ||
converter (SAR ADC) with sample rates up to 2.5 MSPS""" | ||
|
||
_compatible_parts = ["ad7944"] | ||
_device_name = "" | ||
_rx_data_type = np.uint16 | ||
|
||
def __init__(self, uri="ip:analog.local", device_name="ad7944"): | ||
"""Initialize.""" | ||
context_manager.__init__(self, uri, self._device_name) | ||
|
||
self._ctrl = None | ||
|
||
if not device_name: | ||
device_name = self._compatible_parts[0] | ||
else: | ||
if device_name not in self._compatible_parts: | ||
raise Exception(f"Not a compatible device: {device_name}") | ||
|
||
self._rxadc = self._ctrl = self._ctx.find_device(device_name) | ||
|
||
if not self._ctrl: | ||
raise Exception(f"Error in selecting matching device {device_name}") | ||
|
||
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. Please add a check for self._ctrl as well 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. Do you mean 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. Sorry, meant self._rxadc 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. In this case I don't get it as |
||
self._rx_channel_names = [] | ||
for ch in self._rxadc.channels: | ||
name = ch._id | ||
self._rx_channel_names.append(name) | ||
|
||
rx.__init__(self) | ||
|
||
@property | ||
def sampling_frequency(self): | ||
"""Get sampling frequency.""" | ||
return self._get_iio_dev_attr("sampling_frequency") | ||
|
||
@sampling_frequency.setter | ||
def sampling_frequency(self, rate): | ||
"""Set sampling frequency.""" | ||
self._set_iio_dev_attr("sampling_frequency", rate) | ||
|
||
|
||
class ad7985(ad7944): | ||
"""AD7985, 16-bit, successive approximation analog-to-digital | ||
converter (SAR ADC) with sample rates up to 2.5 MSPS""" | ||
|
||
_compatible_parts = ["ad7985"] | ||
_rx_data_type = np.uint16 | ||
|
||
def __init__(self, uri="ip:analog.local", device_name="ad7985"): | ||
super().__init__(uri, device_name) | ||
|
||
|
||
class ad7986(ad7944): | ||
"""AD7986, 18-bit, successive approximation analog-to-digital | ||
converter (SAR ADC) with sample rates up to 2 MSPS""" | ||
|
||
_compatible_parts = ["ad7986"] | ||
_rx_data_type = np.int32 | ||
|
||
def __init__(self, uri="ip:analog.local", device_name="ad7986"): | ||
super().__init__(uri, device_name) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
ad7944 | ||
================= | ||
|
||
.. automodule:: adi.ad7944 | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ Supported Devices | |
adi.ad7768 | ||
adi.ad777x | ||
adi.ad7799 | ||
adi.ad7944 | ||
adi.ad9081 | ||
adi.ad9081_mc | ||
adi.ad9083 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,9 @@ | |
- AD7771 | ||
- AD7779 | ||
- AD7799 | ||
- AD7944 | ||
- AD7985 | ||
- AD7986 | ||
- AD9081 | ||
- AD9083 | ||
- AD9084 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?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="10.2.5.203 Linux zed-2 6.7.0-rc3-ad7944-00066-gcaa4d5f33137-dirty #4 SMP PREEMPT Tue Feb 6 16:31:26 EST 2024 armv7l" > | ||
<context-attribute name="hw_carrier" value="Xilinx Zynq ZED" /> | ||
<context-attribute name="hw_model" value="EVAL-AD7944FMCZ on Xilinx Zynq ZED" /> | ||
<context-attribute name="hw_mezzanine" value="EVAL-AD7944FMCZ" /> | ||
<context-attribute name="hw_name" value="Empty Field" /> | ||
<context-attribute name="hw_vendor" value="Analog Devices" /> | ||
<context-attribute name="hw_serial" value="Empty Field" /> | ||
<context-attribute name="local,kernel" value="6.7.0-rc3-ad7944-00066-gcaa4d5f33137-dirty" /> | ||
<context-attribute name="uri" value="ip:10.2.5.203" /> | ||
<context-attribute name="ip,ip-addr" value="10.2.5.203" /> | ||
<device id="hwmon0" name="e000b000ethernetffffffff00" > | ||
<channel id="temp1" type="input" > | ||
<attribute name="crit" filename="temp1_crit" value="100000" /> | ||
<attribute name="input" filename="temp1_input" value="41000" /> | ||
<attribute name="max_alarm" filename="temp1_max_alarm" value="0" /> | ||
</channel> | ||
</device> | ||
<device id="iio:device0" name="xadc" > | ||
<channel id="voltage5" name="vccoddr" type="input" > | ||
<attribute name="label" filename="in_voltage5_vccoddr_label" value="vccoddr" /> | ||
<attribute name="raw" filename="in_voltage5_vccoddr_raw" value="2054" /> | ||
<attribute name="scale" filename="in_voltage5_vccoddr_scale" value="0.732421875" /> | ||
</channel> | ||
<channel id="voltage0" name="vccint" type="input" > | ||
<attribute name="label" filename="in_voltage0_vccint_label" value="vccint" /> | ||
<attribute name="raw" filename="in_voltage0_vccint_raw" value="1395" /> | ||
<attribute name="scale" filename="in_voltage0_vccint_scale" value="0.732421875" /> | ||
</channel> | ||
<channel id="voltage4" name="vccpaux" type="input" > | ||
<attribute name="label" filename="in_voltage4_vccpaux_label" value="vccpaux" /> | ||
<attribute name="raw" filename="in_voltage4_vccpaux_raw" value="2462" /> | ||
<attribute name="scale" filename="in_voltage4_vccpaux_scale" value="0.732421875" /> | ||
</channel> | ||
<channel id="temp0" type="input" > | ||
<attribute name="offset" filename="in_temp0_offset" value="-2219" /> | ||
<attribute name="raw" filename="in_temp0_raw" value="2608" /> | ||
<attribute name="scale" filename="in_temp0_scale" value="123.040771484" /> | ||
</channel> | ||
<channel id="voltage7" name="vrefn" type="input" > | ||
<attribute name="label" filename="in_voltage7_vrefn_label" value="vrefn" /> | ||
<attribute name="raw" filename="in_voltage7_vrefn_raw" value="12" /> | ||
<attribute name="scale" filename="in_voltage7_vrefn_scale" value="0.732421875" /> | ||
</channel> | ||
<channel id="voltage1" name="vccaux" type="input" > | ||
<attribute name="label" filename="in_voltage1_vccaux_label" value="vccaux" /> | ||
<attribute name="raw" filename="in_voltage1_vccaux_raw" value="2462" /> | ||
<attribute name="scale" filename="in_voltage1_vccaux_scale" value="0.732421875" /> | ||
</channel> | ||
<channel id="voltage2" name="vccbram" type="input" > | ||
<attribute name="label" filename="in_voltage2_vccbram_label" value="vccbram" /> | ||
<attribute name="raw" filename="in_voltage2_vccbram_raw" value="1393" /> | ||
<attribute name="scale" filename="in_voltage2_vccbram_scale" value="0.732421875" /> | ||
</channel> | ||
<channeAl id="voltage3" name="vccpint" type="input" > | ||
<attribute name="label" filename="in_voltage3_vccpint_label" value="vccpint" /> | ||
<attribute name="raw" filename="in_voltage3_vccpint_raw" value="1393" /> | ||
<attribute name="scale" filename="in_voltage3_vccpint_scale" value="0.732421875" /> | ||
</channel> | ||
<channel id="voltage6" name="vrefp" type="input" > | ||
<attribute name="label" filename="in_voltage6_vrefp_label" value="vrefp" /> | ||
<attribute name="raw" filename="in_voltage6_vrefp_raw" value="1716" /> | ||
<attribute name="scale" filename="in_voltage6_vrefp_scale" value="0.732421875" /> | ||
</channel> | ||
<attribute name="sampling_frequency" value="961538" /> | ||
<attribute name="waiting_for_supplier" value="0" /> | ||
</device> | ||
<device id="iio:device1" name="ad7944" > | ||
<channel id="voltage0" type="input" > | ||
<scan-element index="0" format="le:u14/16>>0" scale="0.305176" /> | ||
<attribute name="raw" filename="in_voltage0_raw" value="0" /> | ||
<attribute name="scale" filename="in_voltage0_scale" value="0.305175781" /> | ||
</channel> | ||
<attribute name="waiting_for_supplier" value="0" /> | ||
<buffer-attribute name="data_available" value="0" /> | ||
<buffer-attribute name="direction" value="in" /> | ||
<buffer-attribute name="length_align_bytes" value="8" /> | ||
</device> | ||
<device id="iio_sysfs_trigger" > | ||
<attribute name="add_trigger" value="ERROR" /> | ||
<attribute name="remove_trigger" value="ERROR" /> | ||
</device> | ||
<device id="trigger0" name="44a00000.spi-offload.0-pwm-trigger" > | ||
<attribute name="sampling_frequency" value="1000" /> | ||
</device> | ||
</context> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?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="10.2.5.211 Linux zed-3 6.8.0-rc1-ad7944-mainline #114 SMP PREEMPT Mon Feb 5 18:33:07 CST 2024 armv7l" > | ||
<context-attribute name="hw_model" value="EVAL-AD7985FMCZ on Xilinx Zynq ZED" /> | ||
<context-attribute name="hw_carrier" value="Xilinx Zynq ZED" /> | ||
<context-attribute name="hw_mezzanine" value="EVAL-AD7985FMCZ" /> | ||
<context-attribute name="hw_name" value="Empty Field" /> | ||
<context-attribute name="hw_vendor" value="Analog Devices" /> | ||
<context-attribute name="hw_serial" value="Empty Field" /> | ||
<context-attribute name="local,kernel" value="6.8.0-rc1-ad7944-mainline" /> | ||
<context-attribute name="uri" value="ip:10.2.5.211" /> | ||
<context-attribute name="ip,ip-addr" value="10.2.5.211" /> | ||
<device id="hwmon0" name="e000b000ethernetffffffff00" > | ||
<channel id="temp1" type="input" > | ||
<attribute name="crit" filename="temp1_crit" value="100000" /> | ||
<attribute name="input" filename="temp1_input" value="31000" /> | ||
<attribute name="max_alarm" filename="temp1_max_alarm" value="0" /> | ||
</channel> | ||
</device> | ||
<device id="iio:device0" name="xadc" > | ||
<channel id="voltage5" name="vccoddr" type="input" > | ||
<attribute name="label" filename="in_voltage5_vccoddr_label" value="vccoddr" /> | ||
<attribute name="raw" filename="in_voltage5_vccoddr_raw" value="2038" /> | ||
<attribute name="scale" filename="in_voltage5_vccoddr_scale" value="0.732421875" /> | ||
</channel> | ||
<channel id="voltage0" name="vccint" type="input" > | ||
<attribute name="label" filename="in_voltage0_vccint_label" value="vccint" /> | ||
<attribute name="raw" filename="in_voltage0_vccint_raw" value="1384" /> | ||
<attribute name="scale" filename="in_voltage0_vccint_scale" value="0.732421875" /> | ||
</channel> | ||
<channel id="voltage4" name="vccpaux" type="input" > | ||
<attribute name="label" filename="in_voltage4_vccpaux_label" value="vccpaux" /> | ||
<attribute name="raw" filename="in_voltage4_vccpaux_raw" value="2451" /> | ||
<attribute name="scale" filename="in_voltage4_vccpaux_scale" value="0.732421875" /> | ||
</channel> | ||
<channel id="temp0" type="input" > | ||
<attribute name="offset" filename="in_temp0_offset" value="-2219" /> | ||
<attribute name="raw" filename="in_temp0_raw" value="2579" /> | ||
<attribute name="scale" filename="in_temp0_scale" value="123.040771484" /> | ||
</channel> | ||
<channel id="voltage7" name="vrefn" type="input" > | ||
<attribute name="label" filename="in_voltage7_vrefn_label" value="vrefn" /> | ||
<attribute name="raw" filename="in_voltage7_vrefn_raw" value="-4" /> | ||
<attribute name="scale" filename="in_voltage7_vrefn_scale" value="0.732421875" /> | ||
</channel> | ||
<channel id="voltage1" name="vccaux" type="input" > | ||
<attribute name="label" filename="in_voltage1_vccaux_label" value="vccaux" /> | ||
<attribute name="raw" filename="in_voltage1_vccaux_raw" value="2451" /> | ||
<attribute name="scale" filename="in_voltage1_vccaux_scale" value="0.732421875" /> | ||
</channel> | ||
<channel id="voltage2" name="vccbram" type="input" > | ||
<attribute name="label" filename="in_voltage2_vccbram_label" value="vccbram" /> | ||
<attribute name="raw" filename="in_voltage2_vccbram_raw" value="1378" /> | ||
<attribute name="scale" filename="in_voltage2_vccbram_scale" value="0.732421875" /> | ||
</channel> | ||
<channel id="voltage3" name="vccpint" type="input" > | ||
<attribute name="label" filename="in_voltage3_vccpint_label" value="vccpint" /> | ||
<attribute name="raw" filename="in_voltage3_vccpint_raw" value="1375" /> | ||
<attribute name="scale" filename="in_voltage3_vccpint_scale" value="0.732421875" /> | ||
</channel> | ||
<channel id="voltage6" name="vrefp" type="input" > | ||
<attribute name="label" filename="in_voltage6_vrefp_label" value="vrefp" /> | ||
<attribute name="raw" filename="in_voltage6_vrefp_raw" value="1702" /> | ||
<attribute name="scale" filename="in_voltage6_vrefp_scale" value="0.732421875" /> | ||
</channel> | ||
<attribute name="sampling_frequency" value="961538" /> | ||
<attribute name="waiting_for_supplier" value="0" /> | ||
</device> | ||
<device id="iio:device1" name="ad7985" > | ||
<channel id="voltage0" type="input" > | ||
<scan-element index="0" format="le:U16/16>>0" scale="0.076294" /> | ||
<attribute name="raw" filename="in_voltage0_raw" value="28624" /> | ||
<attribute name="scale" filename="in_voltage0_scale" value="0.076293945" /> | ||
</channel> | ||
<channel id="timestamp" type="input" > | ||
<scan-element index="1" format="le:S64/64>>0" /> | ||
</channel> | ||
<attribute name="current_timestamp_clock" value="realtime" /> | ||
<attribute name="waiting_for_supplier" value="0" /> | ||
<buffer-attribute name="data_available" value="1932" /> | ||
<buffer-attribute name="direction" value="in" /> | ||
</device> | ||
<device id="iio_sysfs_trigger" > | ||
<attribute name="add_trigger" value="ERROR" /> | ||
<attribute name="remove_trigger" value="ERROR" /> | ||
</device> | ||
</context> |
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.
FYI, the HDL team has decided to try to standardize on using 32-bit words for SPI offload support.
So this means that the data type will be 16-bit if not using SPI offload but 32-bit if using SPI offload.