aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2017-05-10 18:34:19 -0700
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:03:53 -0800
commite6858a61a81d0ff1762e4b8434fe781acf2fc1ab (patch)
treed34d53d78d40ffc67908f9ae63f216544557366f
parent13cd22e86763f4bfd9419a573ae96b4748b6781b (diff)
downloaduhd-e6858a61a81d0ff1762e4b8434fe781acf2fc1ab.tar.gz
uhd-e6858a61a81d0ff1762e4b8434fe781acf2fc1ab.tar.bz2
uhd-e6858a61a81d0ff1762e4b8434fe781acf2fc1ab.zip
mpm: Moved some SPI setup code to dboard base
-rw-r--r--mpm/python/usrp_mpm/dboard_manager/base.py22
-rw-r--r--mpm/python/usrp_mpm/dboard_manager/eiscat.py14
-rw-r--r--mpm/python/usrp_mpm/dboard_manager/magnesium.py10
3 files changed, 23 insertions, 23 deletions
diff --git a/mpm/python/usrp_mpm/dboard_manager/base.py b/mpm/python/usrp_mpm/dboard_manager/base.py
index 985c20484..5bf31784f 100644
--- a/mpm/python/usrp_mpm/dboard_manager/base.py
+++ b/mpm/python/usrp_mpm/dboard_manager/base.py
@@ -18,6 +18,7 @@
dboard base implementation module
"""
+from six import iteritems
from ..mpmlog import get_logger
class DboardManagerBase(object):
@@ -32,10 +33,31 @@ class DboardManagerBase(object):
# Very important: A list of PIDs that apply to the current device. Must be
# list, even if there's only one entry.
pids = []
+ # A dictionary that maps chips or components to chip selects for SPI.
+ # If this is given, a dictionary called self._spi_nodes is created which
+ # maps these keys to actual spidev paths. Also throws a warning/error if
+ # the SPI configuration is invalid.
+ spi_chipselect = {}
def __init__(self, slot_idx, **kwargs):
self.log = get_logger('dboardManager')
self.slot_idx = slot_idx
+ self._init_spi_nodes(kwargs.get('spi_nodes', []))
+
+
+ def _init_spi_nodes(self, spi_devices):
+ """
+ docstring for _init_spi_nodes
+ """
+ if len(spi_devices) < len(self.spi_chipselect):
+ self.log.error("Expected {0} spi devices, found {1} spi devices".format(
+ len(self.spi_chipselect), len(spi_devices),
+ ))
+ raise RuntimeError("Not enough SPI devices found.")
+ self._spi_nodes = {}
+ for k, v in iteritems(self.spi_chipselect):
+ self._spi_nodes[k] = spi_devices[v]
+ self.log.debug("spidev device node map: {}".format(self._spi_nodes))
def get_serial(self):
return self._eeprom.get("serial", "")
diff --git a/mpm/python/usrp_mpm/dboard_manager/eiscat.py b/mpm/python/usrp_mpm/dboard_manager/eiscat.py
index 0ba6ce115..98aab2a03 100644
--- a/mpm/python/usrp_mpm/dboard_manager/eiscat.py
+++ b/mpm/python/usrp_mpm/dboard_manager/eiscat.py
@@ -344,7 +344,6 @@ class EISCAT(DboardManagerBase):
# See DboardManagerBase for documentation on these fields
#########################################################################
pids = [0x180]
-
spi_chipselect = {
"lmk": 0,
"adc0": 1,
@@ -357,20 +356,9 @@ class EISCAT(DboardManagerBase):
self.log.trace("Initializing EISCAT daughterboard, slot index {}".format(self.slot_idx))
self.initialized = False
self.ref_clock_freq = 10e6
- spi_devices = kwargs['spi_nodes']
- if len(spi_devices) < len(self.spi_chipselect):
- self.log.error("Expected {0} spi devices, found {1} spi devices".format(
- len(self.spi_chipselect), len(spi_devices),
- ))
- raise RuntimeError("Not enough SPI devices found.")
- self._spi_nodes = {}
- self._spi_ifaces = {}
self.log.trace("Loading SPI interfaces...")
- for k, v in iteritems(self.spi_chipselect):
- self._spi_nodes[k] = spi_devices[v]
- self._spi_ifaces[k] = create_spidev_iface(self._spi_nodes[k])
+ self._spi_ifaces = {key: create_spidev_iface(self._spi_nodes[key]) for key in self._spi_nodes}
self.log.info("Loaded SPI interfaces!")
- self.log.debug("spidev device node map: {}".format(self._spi_nodes))
# Define some attributes so that PyLint stays quiet:
self.radio_regs = None
self.jesd_cores = None
diff --git a/mpm/python/usrp_mpm/dboard_manager/magnesium.py b/mpm/python/usrp_mpm/dboard_manager/magnesium.py
index 612705ce4..eb07864df 100644
--- a/mpm/python/usrp_mpm/dboard_manager/magnesium.py
+++ b/mpm/python/usrp_mpm/dboard_manager/magnesium.py
@@ -63,17 +63,7 @@ class Magnesium(DboardManagerBase):
def __init__(self, slot_idx, **kwargs):
super(Magnesium, self).__init__(*args, **kwargs)
self.log = get_logger("Magnesium")
- spi_devices = kwargs['spi_nodes']
# eeprom_data is a tuple (head_dict, raw_data)
- if len(spi_devices) != len(self.spi_chipselect):
- self.log.error("Expected {0} spi devices, found {1} spi devices".format(
- len(self.spi_chipselect), len(spi_devices),
- ))
- raise RuntimeError("Not enough SPI devices found.")
- self._spi_nodes = {}
- for k, v in iteritems(self.spi_chipselect):
- self._spi_nodes[k] = spi_devices[v]
- self.log.debug("spidev device node map: {}".format(self._spi_nodes))
def init_device(self):
"""