diff options
Diffstat (limited to 'mpm/python/usrp_mpm/dboard_manager')
-rw-r--r-- | mpm/python/usrp_mpm/dboard_manager/__init__.py | 28 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/dboard_manager/base.py | 37 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/dboard_manager/eiscat.py | 31 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/dboard_manager/magnesium.py | 50 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/dboard_manager/unknown.py | 32 |
5 files changed, 178 insertions, 0 deletions
diff --git a/mpm/python/usrp_mpm/dboard_manager/__init__.py b/mpm/python/usrp_mpm/dboard_manager/__init__.py new file mode 100644 index 000000000..774f348d4 --- /dev/null +++ b/mpm/python/usrp_mpm/dboard_manager/__init__.py @@ -0,0 +1,28 @@ +# +# Copyright 2017 Ettus Research (National Instruments) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +""" +dboards module __init__.py +""" +from .. import libpyusrp_periphs as lib +from magnesium import magnesium +from eiscat import eiscat +from unknown import unknown + +hw_pids = { + eiscat.hw_pid: eiscat, + magnesium.hw_pid: magnesium, +} diff --git a/mpm/python/usrp_mpm/dboard_manager/base.py b/mpm/python/usrp_mpm/dboard_manager/base.py new file mode 100644 index 000000000..bf0a115cc --- /dev/null +++ b/mpm/python/usrp_mpm/dboard_manager/base.py @@ -0,0 +1,37 @@ +# +# Copyright 2017 Ettus Research (National Instruments) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +""" +dboard base implementation module +""" +from . import lib +import logging +import struct + +log = logging.Logger("usrp_mpm.dboards") + + +class dboard_manager(object): + """ + Holds shared pointer to wrapped C++ implementation. + Sanitizes arguments before calling C++ functions. + Ties various constants to specific daughterboard class + """ + def __init__(self, eeprom={}): + self._eeprom = eeprom + + 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 new file mode 100644 index 000000000..f536d307b --- /dev/null +++ b/mpm/python/usrp_mpm/dboard_manager/eiscat.py @@ -0,0 +1,31 @@ +# +# Copyright 2017 Ettus Research (National Instruments) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +""" +EISCAT rx board implementation module +""" +from base import dboard_manager +from base import lib +from base import log + + +class eiscat(dboard_manager): + hw_pid = 3 + special_eeprom_addrs = {"special0": "something"} + + def __init__(self, spidevs=[], *args, **kwargs): + # Do own init + super(eiscat, self).__init__(*args, **kwargs) diff --git a/mpm/python/usrp_mpm/dboard_manager/magnesium.py b/mpm/python/usrp_mpm/dboard_manager/magnesium.py new file mode 100644 index 000000000..2201064ad --- /dev/null +++ b/mpm/python/usrp_mpm/dboard_manager/magnesium.py @@ -0,0 +1,50 @@ +# +# Copyright 2017 Ettus Research (National Instruments) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +""" +magnesium dboard implementation module +""" +from base import dboard_manager +from base import lib +from base import log + +class magnesium(dboard_manager): + hw_pid = 2 + special_eeprom_addrs = {"special0": "something"} + spi_chipselect = {"0": "lmk", "1": "mykonos", "2": "random"} + spidevs = {} + + def __init__(self, spi_devices, eeprom_data, *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))) + 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) + setattr(self, device, spi) + super(magnesium, self).__init__(*args, **kwargs) + + def init_device(self): + self._device = lib.db.magnesium(self.lmk, self.mykonos, self.random) + + def read_eeprom_v1(self, data): + # magnesium eeprom contains + # nothing + return struct.unpack_from("x", data) + diff --git a/mpm/python/usrp_mpm/dboard_manager/unknown.py b/mpm/python/usrp_mpm/dboard_manager/unknown.py new file mode 100644 index 000000000..f33bacc46 --- /dev/null +++ b/mpm/python/usrp_mpm/dboard_manager/unknown.py @@ -0,0 +1,32 @@ +# +# Copyright 2017 Ettus Research (National Instruments) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +""" +EISCAT rx board implementation module +""" +from base import dboard_manager +from base import lib +from base import log + + +class unknown(dboard_manager): + hw_pid = 0 + special_eeprom_addrs = {} + + def __init__(self, spi_devices, eeprom_data): + self._eeprom = eeprom_data[0] # save eeprom header + # Do own init + super(unknown, self).__init__() |