Skip to content

Commit

Permalink
Merge pull request analogdevicesinc#147 from analogdevicesinc/fix-dep…
Browse files Browse the repository at this point in the history
…endency

Fix dependency
  • Loading branch information
tfcollins authored Nov 23, 2020
2 parents 7a5af49 + 523f3e6 commit f1bedee
Show file tree
Hide file tree
Showing 4 changed files with 278 additions and 23 deletions.
47 changes: 26 additions & 21 deletions adi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,51 +31,56 @@
# 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.ad936x import *
from adi.ad936x import ad9361, ad9363, ad9364, Pluto

from adi.fmcomms5 import *
from adi.fmcomms5 import FMComms5

from adi.ad9371 import *
from adi.ad9371 import ad9371

from adi.adrv9002 import adrv9002

from adi.adrv9009 import *
from adi.adrv9009 import adrv9009

from adi.adrv9009_zu11eg import *
from adi.adrv9009_zu11eg import adrv9009_zu11eg

from adi.adrv9009_zu11eg_multi import *
from adi.adrv9009_zu11eg_multi import adrv9009_zu11eg_multi

from adi.adrv9009_zu11eg_fmcomms8 import *
from adi.adrv9009_zu11eg_fmcomms8 import adrv9009_zu11eg_fmcomms8

from adi.ad9680 import *
from adi.ad9094 import ad9094

from adi.ad9144 import *
from adi.ad9680 import ad9680

from adi.ad9152 import *
from adi.ad9144 import ad9144

from adi.cn0532 import *
from adi.ad9152 import ad9152

from adi.daq2 import *
from adi.cn0532 import cn0532

from adi.daq3 import *
from adi.daq2 import DAQ2

from adi.adis16460 import *
from adi.daq3 import DAQ3

from adi.adis16507 import *
from adi.adis16460 import adis16460

from adi.ad7124 import *
from adi.adis16507 import adis16507

from adi.adxl345 import *
from adi.ad7124 import ad7124

from adi.fmclidar1 import *
from adi.adxl345 import adxl345

from adi.jesd import *
from adi.fmclidar1 import fmclidar1

from adi.ad5686 import *
from adi.ad5686 import ad5686

from adi.adar1000 import adar1000

from adi.ltc2983 import *
from adi.ltc2983 import ltc2983

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

__version__ = "0.0.7"
name = "Analog Devices Hardware Interfaces"
11 changes: 9 additions & 2 deletions adi/adrv9009.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,17 @@
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from adi.context_manager import context_manager
from adi.jesd import jesd as jesdadi
from adi.rx_tx import rx_tx


def _import_jesd(uri):
try:
from adi.jesd import jesd as jesdadi
except ImportError:
raise Exception("JESD interfaces require fs package")
return jesdadi(uri)


class adrv9009(rx_tx, context_manager):
""" ADRV9009 Transceiver
Expand Down Expand Up @@ -63,7 +70,7 @@ def __init__(self, uri="", jesd_monitor=False, jesd=None):
self._rxobs = self._ctx.find_device("axi-adrv9009-rx-obs-hpc")
self._txdac = self._ctx.find_device("axi-adrv9009-tx-hpc")
self._ctx.set_timeout(30000) # Needed for loading profiles
self._jesd = jesd or jesdadi(uri) if jesd_monitor else None
self._jesd = jesd or _import_jesd(uri) if jesd_monitor else None
rx_tx.__init__(self)

@property
Expand Down
1 change: 1 addition & 0 deletions adi/jesd.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import fs
import fs.sshfs


class jesd:
Expand Down
242 changes: 242 additions & 0 deletions test/test_adrv9009_p.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
import pytest

try:
import adi.jesd

skip_jesd = False
except:
skip_jesd = True


hardware = "adrv9009"
classname = "adi.adrv9009"


#########################################
@pytest.mark.iio_hardware(hardware)
@pytest.mark.parametrize("classname", [(classname)])
@pytest.mark.parametrize(
"attr, start, stop, step, tol",
[
("tx_hardwaregain_chan0", -41.95, 0.0, 0.05, 0.05),
("tx_hardwaregain_chan1", -41.95, 0.0, 0.05, 0.05),
("trx_lo", 70000000, 6000000000, 1000, 0),
],
)
def test_adrv9009_attr(
test_attribute_single_value, iio_uri, classname, attr, start, stop, step, tol
):
test_attribute_single_value(iio_uri, classname, attr, start, stop, step, tol)


#########################################
@pytest.mark.iio_hardware(hardware)
@pytest.mark.parametrize("classname", [(classname)])
@pytest.mark.parametrize("channel", range(2))
def test_adrv9009_rx_data(test_dma_rx, iio_uri, classname, channel):
test_dma_rx(iio_uri, classname, channel)


#########################################
@pytest.mark.iio_hardware(hardware)
@pytest.mark.parametrize("classname", [(classname)])
@pytest.mark.parametrize("channel", [0, 1])
@pytest.mark.parametrize(
"param_set",
[
dict(
trx_lo=1000000000,
gain_control_mode_chan0="slow_attack",
gain_control_mode_chan1="slow_attack",
tx_hardwaregain_chan0=-10,
tx_hardwaregain_chan1=-10,
calibrate_rx_qec_en=1,
calibrate_tx_qec_en=1,
calibrate=1,
),
dict(
trx_lo=3000000000,
gain_control_mode_chan0="slow_attack",
gain_control_mode_chan1="slow_attack",
tx_hardwaregain_chan0=-10,
tx_hardwaregain_chan1=-10,
calibrate_rx_qec_en=1,
calibrate_tx_qec_en=1,
calibrate=1,
),
dict(
trx_lo=5000000000,
gain_control_mode_chan0="slow_attack",
gain_control_mode_chan1="slow_attack",
tx_hardwaregain_chan0=-10,
tx_hardwaregain_chan1=-10,
calibrate_rx_qec_en=1,
calibrate_tx_qec_en=1,
calibrate=1,
),
],
)
@pytest.mark.parametrize("sfdr_min", [45])
def test_adrv9009_sfdr(test_sfdr, iio_uri, classname, channel, param_set, sfdr_min):
test_sfdr(iio_uri, classname, channel, param_set, sfdr_min)


#########################################
@pytest.mark.iio_hardware(hardware)
@pytest.mark.parametrize("classname", [(classname)])
@pytest.mark.parametrize("channel", [0, 1])
@pytest.mark.parametrize(
"param_set",
[
dict(
trx_lo=1000000000,
gain_control_mode_chan0="slow_attack",
gain_control_mode_chan1="slow_attack",
tx_hardwaregain_chan0=-10,
tx_hardwaregain_chan1=-10,
calibrate_rx_qec_en=1,
calibrate_tx_qec_en=1,
calibrate=1,
),
dict(
trx_lo=3000000000,
gain_control_mode_chan0="slow_attack",
gain_control_mode_chan1="slow_attack",
tx_hardwaregain_chan0=-10,
tx_hardwaregain_chan1=-10,
calibrate_rx_qec_en=1,
calibrate_tx_qec_en=1,
calibrate=1,
),
dict(
trx_lo=5000000000,
gain_control_mode_chan0="slow_attack",
gain_control_mode_chan1="slow_attack",
tx_hardwaregain_chan0=-10,
tx_hardwaregain_chan1=-10,
calibrate_rx_qec_en=1,
calibrate_tx_qec_en=1,
calibrate=1,
),
],
)
@pytest.mark.parametrize("dds_scale, min_rssi, max_rssi", [(0, 35, 60), (0.9, 0, 22)])
def test_adrv9009_dds_gain_check_agc(
test_gain_check,
iio_uri,
classname,
channel,
param_set,
dds_scale,
min_rssi,
max_rssi,
):
test_gain_check(
iio_uri, classname, channel, param_set, dds_scale, min_rssi, max_rssi
)


#########################################
@pytest.mark.iio_hardware(hardware)
@pytest.mark.parametrize("classname", [(classname)])
@pytest.mark.parametrize("channel", [0, 1, 2, 3])
@pytest.mark.parametrize(
"param_set, dds_scale, min_rssi, max_rssi",
[
(
dict(
trx_lo=1000000000,
gain_control_mode_chan0="manual",
gain_control_mode_chan1="manual",
rx_hardwaregain_chan0=0,
rx_hardwaregain_chan1=0,
tx_hardwaregain_chan0=-10,
tx_hardwaregain_chan1=-10,
calibrate_tx_qec_en=1,
calibrate=1,
),
0.5,
20,
60,
),
(
dict(
trx_lo=1000000000,
gain_control_mode_chan0="manual",
gain_control_mode_chan1="manual",
rx_hardwaregain_chan0=30,
rx_hardwaregain_chan1=30,
tx_hardwaregain_chan0=-10,
tx_hardwaregain_chan1=-10,
calibrate_tx_qec_en=1,
calibrate=1,
),
0.5,
0,
15,
),
],
)
def test_adrv9009_dds_gain_check_vary_power(
test_gain_check,
iio_uri,
classname,
channel,
param_set,
dds_scale,
min_rssi,
max_rssi,
):
test_gain_check(classname, channel, param_set, dds_scale, min_rssi, max_rssi)


#########################################
@pytest.mark.iio_hardware(hardware)
@pytest.mark.parametrize("classname", [(classname)])
@pytest.mark.parametrize("channel", [0, 1, 2, 3])
@pytest.mark.parametrize(
"param_set",
[
dict(
trx_lo=1000000000,
gain_control_mode_chan0="slow_attack",
gain_control_mode_chan1="slow_attack",
tx_hardwaregain_chan0=-20,
tx_hardwaregain_chan1=-20,
calibrate_tx_qec_en=1,
calibrate=1,
),
dict(
trx_lo=3000000000,
gain_control_mode_chan0="slow_attack",
gain_control_mode_chan1="slow_attack",
tx_hardwaregain_chan0=-20,
tx_hardwaregain_chan1=-20,
calibrate_tx_qec_en=1,
calibrate=1,
),
dict(
trx_lo=5000000000,
trx_lo_chip_b=1000000000,
gain_control_mode_chan0="slow_attack",
gain_control_mode_chan1="slow_attack",
tx_hardwaregain_chan0=-20,
tx_hardwaregain_chan1=-20,
calibrate_tx_qec_en=1,
calibrate=1,
),
],
)
def test_adrv9009_iq_loopback(test_iq_loopback, iio_uri, classname, channel, param_set):
test_iq_loopback(iio_uri, classname, channel, param_set)


#########################################
@pytest.mark.skipif(skip_jesd, reason="JESD module not importable")
@pytest.mark.iio_hardware(hardware)
def test_adrv9009_jesd(iio_uri):
import adi

sdr = adi.adrv9009(uri=iio_uri, jesd_monitor=True)
info = sdr._jesd.get_all_statuses()
assert info

0 comments on commit f1bedee

Please sign in to comment.