From 151ba5fb06dfdb6fcc46ccfdabf5f1e064236981 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 25 Apr 2017 17:00:34 -0700 Subject: mpm: Major refactoring - Created clean interfaces for SPI and registers - Severed most links to UHD - Added a lockable class which allows exposing mutexes into Python --- mpm/lib/types/CMakeLists.txt | 5 +++++ mpm/lib/types/lockable.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 mpm/lib/types/CMakeLists.txt create mode 100644 mpm/lib/types/lockable.cpp (limited to 'mpm/lib/types') diff --git a/mpm/lib/types/CMakeLists.txt b/mpm/lib/types/CMakeLists.txt new file mode 100644 index 000000000..d4f52f7ed --- /dev/null +++ b/mpm/lib/types/CMakeLists.txt @@ -0,0 +1,5 @@ +SET(TYPES_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/lockable.cpp +) + +USRP_PERIPHS_ADD_OBJECT(types ${TYPES_SOURCES}) diff --git a/mpm/lib/types/lockable.cpp b/mpm/lib/types/lockable.cpp new file mode 100644 index 000000000..75c3aa784 --- /dev/null +++ b/mpm/lib/types/lockable.cpp @@ -0,0 +1,53 @@ +// +// 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 . +// + +#include + +using namespace mpm::types; + +class lockable_impl : public lockable +{ +public: + lockable_impl( + std::shared_ptr spi_mutex + ) : _spi_mutex(spi_mutex) + { + /* nop */ + } + + void lock() + { + _spi_mutex->lock(); + } + + void unlock() + { + _spi_mutex->unlock(); + } + +private: + std::shared_ptr _spi_mutex; +}; + +lockable::sptr lockable::make( + std::shared_ptr spi_mutex +) { + return std::make_shared( + spi_mutex + ); +} + -- cgit v1.2.3