From ef6326a174e6880be5e2eaeac26a2c5de0768807 Mon Sep 17 00:00:00 2001 From: Andrej Rode Date: Tue, 21 Mar 2017 19:46:50 -0700 Subject: mpm: python refactoring --- mpm/include/lmk/lmk04828_spi_iface.hpp | 13 +++++++++++++ mpm/include/mpm/spi/spidev_iface.hpp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) (limited to 'mpm/include') diff --git a/mpm/include/lmk/lmk04828_spi_iface.hpp b/mpm/include/lmk/lmk04828_spi_iface.hpp index 013271af1..fa11029a8 100644 --- a/mpm/include/lmk/lmk04828_spi_iface.hpp +++ b/mpm/include/lmk/lmk04828_spi_iface.hpp @@ -25,3 +25,16 @@ private: void spi_write(std::vector writes); uint8_t spi_read(uint32_t addr); }; + +#ifdef LIBMPM_PYTHON +void export_lmk(){ + LIBMPM_BOOST_PREAMBLE("lmk04828") + bp::class_, boost::noncopyable >("lmk04828_iface", bp::no_init) + .def("make", &lmk04828_iface::make) + .def("verify_chip_id", &lmk04828_iface::verify_chip_id) + .def("get_chip_id", &lmk04828_iface::get_chip_id) + .def("init", &lmk04828_iface::init) + .def("send_sysref_pulse", &lmk04828_iface::send_sysref_pulse) + ; +} +#endif diff --git a/mpm/include/mpm/spi/spidev_iface.hpp b/mpm/include/mpm/spi/spidev_iface.hpp index fb82ffade..ef5303f7b 100644 --- a/mpm/include/mpm/spi/spidev_iface.hpp +++ b/mpm/include/mpm/spi/spidev_iface.hpp @@ -57,3 +57,36 @@ namespace mpm { namespace spi { }}; /* namespace mpm */ +//void export_spi(){ + //// Register submodule spi + //bp::object spi_module(bp::handle<>(bp::borrowed(PyImport_AddModule("libpyusrp_periphs.spi")))); + //bp::scope().attr("spi") = spi_module; + //bp::scope io_scope = spi_module; + + //bp::class_ >("spi_lock", bp::no_init) + //.def("make", &spi_lock::make) + //.def("get_spidev", &spi_lock::get_spidev) + //; + + //bp::class_("spi_iface", bp::no_init) + //.def("write_byte", &mpm::spi_iface::write_byte) + //.def("write_bytes", &mpm::spi_iface::write_bytes) + //.def("read_byte", &mpm::spi_iface::read_byte) + //.def("write_field", &mpm::spi_iface::write_field) + //.def("read_field", &mpm::spi_iface::read_field) + //.def("get_wire_mode", &mpm::spi_iface::get_wire_mode) + //.def("get_endianness", &mpm::spi_iface::get_endianness) + //.def("get_chip_select", &mpm::spi_iface::get_chip_select) + //; + + //bp::enum_("spi_endianness") + //.value("lsb_first", mpm::spi_iface::spi_endianness_t::LSB_FIRST) + //.value("msb_first", mpm::spi_iface::spi_endianness_t::MSB_FIRST) + //; + + //bp::enum_("spi_wire_mode") + //.value("three_wire_mode", mpm::spi_iface::spi_wire_mode_t::THREE_WIRE_MODE) + //.value("four_wire_mode", mpm::spi_iface::spi_wire_mode_t::FOUR_WIRE_MODE) + //; +//} + -- cgit v1.2.3