aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/python/usrp_mpm/dboard_manager/base.py
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 /mpm/python/usrp_mpm/dboard_manager/base.py
parent13cd22e86763f4bfd9419a573ae96b4748b6781b (diff)
downloaduhd-e6858a61a81d0ff1762e4b8434fe781acf2fc1ab.tar.gz
uhd-e6858a61a81d0ff1762e4b8434fe781acf2fc1ab.tar.bz2
uhd-e6858a61a81d0ff1762e4b8434fe781acf2fc1ab.zip
mpm: Moved some SPI setup code to dboard base
Diffstat (limited to 'mpm/python/usrp_mpm/dboard_manager/base.py')
-rw-r--r--mpm/python/usrp_mpm/dboard_manager/base.py22
1 files changed, 22 insertions, 0 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", "")