diff options
-rw-r--r-- | mpm/include/mpm/spi/spi_python.hpp | 27 | ||||
-rw-r--r-- | mpm/include/mpm/spi/spi_regs_iface.hpp | 11 | ||||
-rw-r--r-- | mpm/lib/spi/spi_regs_iface.cpp | 20 | ||||
-rw-r--r-- | mpm/python/pyusrp_periphs.cpp | 3 |
4 files changed, 60 insertions, 1 deletions
diff --git a/mpm/include/mpm/spi/spi_python.hpp b/mpm/include/mpm/spi/spi_python.hpp new file mode 100644 index 000000000..4386e1f1b --- /dev/null +++ b/mpm/include/mpm/spi/spi_python.hpp @@ -0,0 +1,27 @@ +// +// 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/>. +// + +#pragma once + +#include "spi_regs_iface.hpp" + +void export_spi() { + LIBMPM_BOOST_PREAMBLE("spi") + + bp::def("make_spidev_regs_iface", &mpm::spi::make_spidev_regs_iface); +} + diff --git a/mpm/include/mpm/spi/spi_regs_iface.hpp b/mpm/include/mpm/spi/spi_regs_iface.hpp index 87f398db1..072e15dc4 100644 --- a/mpm/include/mpm/spi/spi_regs_iface.hpp +++ b/mpm/include/mpm/spi/spi_regs_iface.hpp @@ -30,5 +30,16 @@ namespace mpm { namespace spi { uint32_t write_flags = 0 ); + /*! Convenience factory for regs_iface based on SPI based on spidev + */ + mpm::types::regs_iface::sptr make_spidev_regs_iface( + const std::string &device, + const int speed_hz, + uint32_t addr_shift, + uint32_t data_shift, + uint32_t read_flags, + uint32_t write_flags = 0 + ); + }}; /* namespace mpm::spi */ diff --git a/mpm/lib/spi/spi_regs_iface.cpp b/mpm/lib/spi/spi_regs_iface.cpp index eb6e229f9..a84a14997 100644 --- a/mpm/lib/spi/spi_regs_iface.cpp +++ b/mpm/lib/spi/spi_regs_iface.cpp @@ -98,3 +98,23 @@ regs_iface::sptr mpm::spi::make_spi_regs_iface( write_flags ); } + +mpm::types::regs_iface::sptr mpm::spi::make_spidev_regs_iface( + const std::string &device, + const int speed_hz, + uint32_t addr_shift, + uint32_t data_shift, + uint32_t read_flags, + uint32_t write_flags +) { + auto spi_iface_sptr = mpm::spi::spi_iface::make_spidev( + device, speed_hz + ); + return std::make_shared<spi_regs_iface_impl>( + spi_iface_sptr, + addr_shift, + data_shift, + read_flags, + write_flags + ); +} diff --git a/mpm/python/pyusrp_periphs.cpp b/mpm/python/pyusrp_periphs.cpp index 2c6ea869b..5aac12088 100644 --- a/mpm/python/pyusrp_periphs.cpp +++ b/mpm/python/pyusrp_periphs.cpp @@ -29,6 +29,7 @@ #include "converters.hpp" #include <mpm/xbar_iface.hpp> #include <mpm/types/types_python.hpp> +#include <mpm/spi/spi_python.hpp> #include <mpm/ad937x/ad937x_ctrl.hpp> #include <mpm/chips/lmk04828_spi_iface.hpp> #include <mpm/dboards/magnesium_manager.hpp> @@ -42,7 +43,7 @@ BOOST_PYTHON_MODULE(libpyusrp_periphs) package.attr("__path__") = "libpyusrp_periphs"; export_converter(); export_types(); - //export_spi(); + export_spi(); export_mykonos(); export_xbar(); export_magnesium(); |