diff options
Diffstat (limited to 'mpm/python/usrp_mpm/dboard_manager')
-rw-r--r-- | mpm/python/usrp_mpm/dboard_manager/base.py | 6 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/dboard_manager/eiscat.py | 2 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/dboard_manager/magnesium.py | 101 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/dboard_manager/test.py | 7 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/dboard_manager/unknown.py | 3 |
5 files changed, 89 insertions, 30 deletions
diff --git a/mpm/python/usrp_mpm/dboard_manager/base.py b/mpm/python/usrp_mpm/dboard_manager/base.py index 37e7dd2b8..0e8d1b7e4 100644 --- a/mpm/python/usrp_mpm/dboard_manager/base.py +++ b/mpm/python/usrp_mpm/dboard_manager/base.py @@ -17,11 +17,8 @@ """ dboard base implementation module """ -import logging import struct - -LOG = logging.Logger(__name__) - +from ..mpmlog import get_logger class DboardManagerBase(object): """ @@ -33,6 +30,7 @@ class DboardManagerBase(object): def __init__(self, eeprom=None): self._eeprom = eeprom or {} + self.log = get_logger('dboardManager') 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 101290574..436307c1e 100644 --- a/mpm/python/usrp_mpm/dboard_manager/eiscat.py +++ b/mpm/python/usrp_mpm/dboard_manager/eiscat.py @@ -19,8 +19,6 @@ EISCAT rx board implementation module """ from . import lib from .base import DboardManagerBase -from .base import LOG - class eiscat(DboardManagerBase): hw_pid = 3 diff --git a/mpm/python/usrp_mpm/dboard_manager/magnesium.py b/mpm/python/usrp_mpm/dboard_manager/magnesium.py index f13f1de77..45a19ded6 100644 --- a/mpm/python/usrp_mpm/dboard_manager/magnesium.py +++ b/mpm/python/usrp_mpm/dboard_manager/magnesium.py @@ -17,13 +17,13 @@ """ magnesium dboard implementation module """ -from . import lib -from .base import DboardManagerBase -import struct -from logging import getLogger - -LOG = getLogger(__name__) +import struct +import time +from . import lib # Pulls in everything from C++-land +from .base import DboardManagerBase +from .. import nijesdcore +from ..uio import uio class magnesium(DboardManagerBase): """ @@ -31,33 +31,104 @@ class magnesium(DboardManagerBase): """ hw_pid = 2 special_eeprom_addrs = {"special0": "something"} - spi_chipselect = {"0": "lmk", "1": "mykonos", "2": "random"} + spi_chipselect = {"0": "lmk", "1": "mykonos",} spidevs = {} lmk = "" mykonos = "" random = "" def __init__(self, spi_devices, eeprom_data, *args, **kwargs): + super(magnesium, self).__init__(*args, **kwargs) # eeprom_data is a tuple (head_dict, raw_data) if len(spi_devices) != len(self.spi_chipselect): - LOG.error("Expected {0} spi devices, found {1} spi devices".format(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), + )) exit(1) for spi in spi_devices: device = self.spi_chipselect.get(spi[-1], None) - if self.chipselect is None: - LOG.error("Unexpected chipselect {0}".format(spi[-1])) - exit(1) + # if self.chipselect is None: + # self.log.error("Unexpected chipselect {0}".format(spi[-1])) + # exit(1) setattr(self, device, spi) - super(magnesium, self).__init__(*args, **kwargs) + self.log.debug("Setting spi device for {device}: {spidev}".format( + device=device, spidev=spi + )) def init_device(self): """ Execute necessary init dance to bring up dboard """ - LOG.debug("initialize hardware") + self.log.debug("initialize hardware") + self._device = lib.dboards.magnesium_periph_manager( + # self.lmk.encode('ascii'), self.mykonos.encode('ascii') + '/dev/spidev0.0', + '/dev/spidev0.1', + ) + self.lmk = self._device.get_clock_ctrl() + self.mykonos = self._device.get_radio_ctrl() + + # uio_path, uio_size = get_uio_node("misc-enet-regs0") + self.log.debug("getting Mg A uio") + uio_path = "/dev/uio2" # TODO use labels + uio_size = 0x4000 + self.log.debug("got uio_path and size") + self.uio = uio(uio_path, uio_size, read_only=False) + self.log.info("got my uio") + self.init_jesd(self.uio) + + def init_jesd(self, uio): + """ + Bring up the JESD link between Mykonos and the N310 + """ + self.log.trace("Creating jesdcore object") + self.jesdcore = nijesdcore.NIMgJESDCore(uio) + + self.log.trace("Checking JESD core...") + self.jesdcore.check_core() + self.log.trace("Initializing LMK...") + self.lmk.init() + self.lmk.verify_chip_id() + self.log.trace("Enabling SYSREF pulses...") + self.lmk.enable_sysref_pulse() + + self.jesdcore.unreset_mmcm() + + self.jesdcore.init() + self.log.trace("Resetting Mykonos...") + self.reset_mykonos() #not sure who owns the reset + + self.log.trace("Initializing Mykonos...") + self.mykonos.begin_initialization() + self.jesdcore.send_sysref_pulse() + self.jesdcore.send_sysref_pulse() + self.mykonos.finish_initialization() + + self.log.trace("Stargin Mykonos JESD framing...") + self.mykonos.start_jesd_rx() + self.jesdcore.init_deframer() + self.jesdcore.init_framer() + self.mykonos.start_jesd_tx() + + #TODO add function for Enable FPGA LMFC Generator + self.jesdcore.send_sysref_pulse() + time.sleep(0.2) + if not self.jesdcore.get_framer_status(): + raise Exception('JESD Core Framer is not synced!') + if not self.jesdcore.get_deframer_status(): + raise Exception('JESD Core Deframer is not synced!') + #if (!self.mykonos.get_framer_status()) + # raise Exception('Mykonos Framer is not synced!') + #if (!self.mykonos.get_deframer_status()) + # raise Exception('Mykonos Deframer is not synced!') - self._device = lib.dboards.magnesium( - self.lmk, self.mykonos, self.random) + def reset_mykonos(self): + " Toggle reset line on Mykonos " + # SUPER GHETTO FIXME + import os + os.system('devmem2 0x4001000C w 2') # Active low reset + time.sleep(0.001) + os.system('devmem2 0x4001000C w 10') def read_eeprom_v1(self, data): """ diff --git a/mpm/python/usrp_mpm/dboard_manager/test.py b/mpm/python/usrp_mpm/dboard_manager/test.py index 80299ee41..da7b34c7a 100644 --- a/mpm/python/usrp_mpm/dboard_manager/test.py +++ b/mpm/python/usrp_mpm/dboard_manager/test.py @@ -21,9 +21,6 @@ from . import lib from .base import DboardManagerBase from logging import getLogger -LOG = getLogger(__name__) - - class fake_spi(object): def __init__(self, addr): self.addr = addr @@ -54,8 +51,6 @@ class test(DboardManagerBase): self.dev3 = "2" def init_device(self): - LOG.debug("initialize hardware") + self.log.debug("initialize hardware") self._device = test_device(self.dev1, self.dev2, self.dev3) - - diff --git a/mpm/python/usrp_mpm/dboard_manager/unknown.py b/mpm/python/usrp_mpm/dboard_manager/unknown.py index de2354f3d..d954154f9 100644 --- a/mpm/python/usrp_mpm/dboard_manager/unknown.py +++ b/mpm/python/usrp_mpm/dboard_manager/unknown.py @@ -20,9 +20,6 @@ EISCAT rx board implementation module from .base import DboardManagerBase from logging import getLogger -LOG = getLogger(__name__) - - class unknown(DboardManagerBase): hw_pid = 0 special_eeprom_addrs = {} |