Skip to content

Commit

Permalink
API to configure RF properties on 2-24 GHz XMW TX/RX Platform
Browse files Browse the repository at this point in the history
Adding python classes (with tests and examples) for all digitally controlled RF components on platform: ADRF5020, ADRF5730, ADRF5740 as well as for complete TX/RX Front End Platforms

Signed-off-by: Reema Saleem <[email protected]>
  • Loading branch information
reemasaleem committed Aug 23, 2023
1 parent 01ef46a commit f552c77
Show file tree
Hide file tree
Showing 23 changed files with 1,627 additions and 19 deletions.
48 changes: 40 additions & 8 deletions adi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
# Copyright (C) 2019-2023 Analog Devices, Inc.
# Copyright (C) 2023 Analog Devices, Inc.
#
# SPDX short identifier: ADIBSD
# Copyright (C) 2019 Analog Devices, Inc.
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
# - Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# - Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# - Neither the name of Analog Devices, Inc. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
# - The use of this software may or may not infringe the patent rights
# of one or more patent holders. This license does not release you
# from the requirement that you obtain separate licenses from these
# patent holders to use this software.
# - Use of the software either in source or binary form, must be run
# on or directly connected to an Analog Devices Inc. component.
#
# THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A
# PARTICULAR PURPOSE ARE DISCLAIMED.
#
# IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY
# RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from adi.ad469x import ad469x
from adi.ad717x import ad717x
Expand All @@ -11,7 +43,6 @@
from adi.ad4110 import ad4110
from adi.ad4130 import ad4130
from adi.ad4630 import ad4630
from adi.ad4858 import ad4858
from adi.ad5592r import ad5592r
from adi.ad5686 import ad5686
from adi.ad5940 import ad5940
Expand All @@ -21,13 +52,11 @@
from adi.ad7606 import ad7606
from adi.ad7689 import ad7689
from adi.ad7746 import ad7746
from adi.ad7768 import ad7768, ad7768_4
from adi.ad7768 import ad7768
from adi.ad7799 import ad7799
from adi.ad9081 import ad9081
from adi.ad9081_mc import QuadMxFE, ad9081_mc
from adi.ad9083 import ad9083
from adi.ad9084 import ad9084
from adi.ad9084_mc import Triton, ad9084_mc
from adi.ad9094 import ad9094
from adi.ad9136 import ad9136
from adi.ad9144 import ad9144
Expand Down Expand Up @@ -59,7 +88,10 @@
from adi.adpd188 import adpd188
from adi.adpd410x import adpd410x
from adi.adpd1080 import adpd1080
from adi.adrf5020 import adrf5020
from adi.adrf5720 import adrf5720
from adi.adrf5730 import adrf5730
from adi.adrf5740 import adrf5740
from adi.adrv9002 import adrv9002
from adi.adrv9009 import adrv9009
from adi.adrv9009_zu11eg import adrv9009_zu11eg
Expand All @@ -73,9 +105,7 @@
from adi.cn0511 import cn0511
from adi.cn0532 import cn0532
from adi.cn0554 import cn0554
from adi.cn0566 import CN0566
from adi.cn0575 import cn0575
from adi.cn0579 import cn0579
from adi.daq2 import DAQ2
from adi.daq3 import DAQ3
from adi.fmc_vna import fmcvna
Expand All @@ -99,11 +129,13 @@
from adi.one_bit_adc_dac import one_bit_adc_dac
from adi.QuadMxFE_multi import QuadMxFE_multi
from adi.tdd import tdd
from adi.xmw_rx_platform import xmw_rx_platform
from adi.xmw_tx_platform import xmw_tx_platform

try:
from adi.jesd import jesd
except ImportError:
pass

__version__ = "0.0.17"
__version__ = "0.0.16"
name = "Analog Devices Hardware Interfaces"
69 changes: 69 additions & 0 deletions adi/adrf5020.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright (C) 2023 Analog Devices, Inc.
#
# SPDX short identifier: ADIBSD
# Copyright (C) 2023 Analog Devices, Inc.
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
# - Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# - Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# - Neither the name of Analog Devices, Inc. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
# - The use of this software may or may not infringe the patent rights
# of one or more patent holders. This license does not release you
# from the requirement that you obtain separate licenses from these
# patent holders to use this software.
# - Use of the software either in source or binary form, must be run
# on or directly connected to an Analog Devices Inc. component.
#
# THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A
# PARTICULAR PURPOSE ARE DISCLAIMED.
#
# IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY
# RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from adi.attribute import attribute
from adi.context_manager import context_manager
from adi.one_bit_adc_dac import one_bit_adc_dac


class adrf5020(attribute, context_manager):
"""ADRF5020, Digital Switch
parameters:
uri: type=string
URI of IIO context with ADRF5020
dev_name: type=string
label of ADRF5020 as defined in device tree
"""

def __init__(self, uri="", dev_name=""):
context_manager.__init__(self, uri, dev_name)
# Default device for attribute writes
self._ctrl = self._ctx.find_device(dev_name)
# Raise an exception if the device isn't found
if not self._ctrl:
raise Exception("ADRF5020 device not found")

@property
def control_signal_value(self):
"""control_signal_value: Get/Set the Control voltage signal.
Valid options are 1 or 0.
"""
return self._get_iio_attr("voltage0", "raw", True, self._ctrl)

@control_signal_value.setter
def control_signal_value(self, value):
print(f"Setting control signal input for RF switch to {value}.")
self._set_iio_attr("voltage0", "raw", True, value, self._ctrl)
143 changes: 143 additions & 0 deletions adi/adrf5730.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# Copyright (C) 2023 Analog Devices, Inc.
#
# SPDX short identifier: ADIBSD
# Copyright (C) 2023 Analog Devices, Inc.
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
# - Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# - Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# - Neither the name of Analog Devices, Inc. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
# - The use of this software may or may not infringe the patent rights
# of one or more patent holders. This license does not release you
# from the requirement that you obtain separate licenses from these
# patent holders to use this software.
# - Use of the software either in source or binary form, must be run
# on or directly connected to an Analog Devices Inc. component.
#
# THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A
# PARTICULAR PURPOSE ARE DISCLAIMED.
#
# IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY
# RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from adi.attribute import attribute
from adi.context_manager import context_manager
from adi.one_bit_adc_dac import one_bit_adc_dac


class adrf5730(attribute, context_manager):
"""ADRF5730, Digital Signal Attenuator with parallel GPIO control
parameters:
uri: type=string
URI of IIO context with ADRF5730
dev_name: type=string
label of ADRF5730 as defined in device tree
"""

def __init__(self, uri="", dev_name="adrf5730_control"):
context_manager.__init__(self, uri, dev_name)
# Default device for attribute writes
self._ctrl = self._ctx.find_device("adrf5730_control")
# Raise an exception if the device isn't found
if not self._ctrl:
raise Exception("ADRF5730 device not found")

self._atten_decimal = 0
self._atten_dB = 0
self._D5 = 0
self._D4 = 0
self._D3 = 0
self._D2 = 0
self._D1 = 0
self._D0 = 0

@property
def GPIO_attenuation(self):
"""GPIO_attenuation: Get/Set the Attenuation Decimal value when
ADRF5730 is controlled by 6 GPIO channels D5-D0.
Valid options are 0-63 with a step size of 1.
"""
atten_D5_dB = 0
atten_D4_dB = 0
atten_D3_dB = 0
atten_D2_dB = 0
atten_D1_dB = 0
atten_D0_dB = 0
self._D5 = self._get_iio_attr("voltage5", "raw", True, self._ctrl)
self._D4 = self._get_iio_attr("voltage4", "raw", True, self._ctrl)
self._D3 = self._get_iio_attr("voltage3", "raw", True, self._ctrl)
self._D2 = self._get_iio_attr("voltage2", "raw", True, self._ctrl)
self._D1 = self._get_iio_attr("voltage1", "raw", True, self._ctrl)
self._D0 = self._get_iio_attr("voltage0", "raw", True, self._ctrl)
if self._D5 == 1:
atten_D5_dB = 16
if self._D4 == 1:
atten_D4_dB = 8
if self._D3 == 1:
atten_D3_dB = 4
if self._D2 == 1:
atten_D2_dB = 2
if self._D1 == 1:
atten_D1_dB = 1
if self._D0 == 1:
atten_D0_dB = 0.5
self._atten_dB = (
atten_D5_dB
+ atten_D4_dB
+ atten_D3_dB
+ atten_D2_dB
+ atten_D1_dB
+ atten_D0_dB
)
self._atten_decimal = self._atten_dB * 2
print(f"Attenuation for GPIO controlled DSA is {self._atten_dB} dB.")
print("*** Attenuation Decimal = 2 * Attenuation (dB) ***")
print(
f"Attenuation Decimal (0~63) for GPIO controlled DSA is {self._atten_decimal}."
)
return self._atten_decimal

@GPIO_attenuation.setter
def GPIO_attenuation(self, value):
if value < 0 or value >= 64:
print("Please choose a valid value for Attenuation Decimal (0~63)")
return
self._atten_decimal = value
self._atten_dB = value / 2
print(
f"Setting Attenuation Decimal (0~63) for GPIO controlled DSA to {self._atten_decimal}."
)
print("*** Attenuation (dB) = 0.5 * Attenuation Decimal ***")
print(f"Setting attenuation for GPIO controlled DSA to {self._atten_dB} dB.")
# Set D0 based on whether or not the Attenuation Decimal value is odd
# (since odd Attenuation Decimal value / 2 gives an Attenuation dB value ending in 0.5)
if value % 2 != 0:
self._D0 = 1
else:
self._D0 = 0
# Mask out each of the remaining bits from the Attenuation Decimal value to determine D5-D1
self._D5 = (self._atten_decimal & (1 << 5)) >> 5
self._D4 = (self._atten_decimal & (1 << 4)) >> 4
self._D3 = (self._atten_decimal & (1 << 3)) >> 3
self._D2 = (self._atten_decimal & (1 << 2)) >> 2
self._D1 = (self._atten_decimal & (1 << 1)) >> 1
self._set_iio_attr("voltage5", "raw", True, self._D5, self._ctrl)
self._set_iio_attr("voltage4", "raw", True, self._D4, self._ctrl)
self._set_iio_attr("voltage3", "raw", True, self._D3, self._ctrl)
self._set_iio_attr("voltage2", "raw", True, self._D2, self._ctrl)
self._set_iio_attr("voltage1", "raw", True, self._D1, self._ctrl)
self._set_iio_attr("voltage0", "raw", True, self._D0, self._ctrl)
Loading

0 comments on commit f552c77

Please sign in to comment.