From fcf8715eab6d3d06526e1ef1398e0e684711daad Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Sat, 29 Apr 2017 18:56:22 -0700 Subject: mpm: Exposed spi regs iface factory to Python --- mpm/include/mpm/spi/spi_python.hpp | 27 +++++++++++++++++++++++++++ mpm/include/mpm/spi/spi_regs_iface.hpp | 11 +++++++++++ 2 files changed, 38 insertions(+) create mode 100644 mpm/include/mpm/spi/spi_python.hpp (limited to 'mpm/include') 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 . +// + +#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 */ -- cgit v1.2.3