diff options
-rw-r--r-- | mpm/CMakeLists.txt | 17 | ||||
-rw-r--r-- | mpm/dboards/CMakeLists.txt (renamed from mpm/n310/CMakeLists.txt) | 7 | ||||
-rw-r--r-- | mpm/dboards/magnesium_manager.cpp | 32 | ||||
-rw-r--r-- | mpm/dboards/magnesium_manager.hpp | 50 | ||||
-rw-r--r-- | mpm/lib/mykonos/CMakeLists.txt | 1 | ||||
-rw-r--r-- | mpm/lib/spi/spi_lock.cpp | 2 | ||||
-rw-r--r-- | mpm/lib/spi/spi_lock.h | 4 | ||||
-rw-r--r-- | mpm/n310/periph_manager.cpp | 38 | ||||
-rw-r--r-- | mpm/n310/periph_manager.hpp | 82 |
9 files changed, 96 insertions, 137 deletions
diff --git a/mpm/CMakeLists.txt b/mpm/CMakeLists.txt index 0610a967d..73ec07657 100644 --- a/mpm/CMakeLists.txt +++ b/mpm/CMakeLists.txt @@ -30,15 +30,8 @@ ENDMACRO(USRP_PERIPHS_ADD_OBJECT) MESSAGE(STATUS "") MESSAGE(STATUS "Configuring Boost C++ Libraries...") SET(BOOST_REQUIRED_COMPONENTS - chrono - date_time - filesystem - program_options - python - regex - system - unit_test_framework - serialization + python + system ) IF(MINGW) LIST(APPEND BOOST_REQUIRED_COMPONENTS thread_win32) @@ -77,8 +70,8 @@ MESSAGE(STATUS "Boost libraries: ${Boost_LIBRARIES}") # Setup library configuration ######################################################################## SET(CMAKE_CXX_STANDARD 11) -SET(MPM_DEVICE "tests" CACHE STRING "Choose a MPM device to build") -SET_PROPERTY(CACHE MPM_DEVICE PROPERTY STRINGS tests n310) +# SET(MPM_DEVICE "tests" CACHE STRING "Choose a MPM device to build") +# SET_PROPERTY(CACHE MPM_DEVICE PROPERTY STRINGS tests) SET(UHD_HOST_ROOT ${CMAKE_SOURCE_DIR}/../host) @@ -89,6 +82,7 @@ INCLUDE_DIRECTORIES( ${UHD_HOST_ROOT}/include ) +ADD_SUBDIRECTORY(dboards) ADD_SUBDIRECTORY(lib) IF(MPM_DEVICE STREQUAL tests) ADD_SUBDIRECTORY(tests) @@ -98,6 +92,7 @@ ENDIF(MPM_DEVICE STREQUAL tests) MESSAGE("usrp_periphs objects: ${usrp_periphs_objects}") ADD_LIBRARY(usrp-periphs SHARED ${usrp_periphs_objects}) +TARGET_LINK_LIBRARIES(usrp-periphs udev) ######################################################################## # Setup Python API ######################################################################## diff --git a/mpm/n310/CMakeLists.txt b/mpm/dboards/CMakeLists.txt index 3177dd5b5..9947d8656 100644 --- a/mpm/n310/CMakeLists.txt +++ b/mpm/dboards/CMakeLists.txt @@ -20,7 +20,8 @@ ######################################################################## -USRP_PERIPHS_ADD_OBJECT(n310 - ${CMAKE_CURRENT_SOURCE_DIR}/periph_manager.cpp) +USRP_PERIPHS_ADD_OBJECT(dboards + magnesium_manager.cpp + ) -TARGET_INCLUDE_DIRECTORIES(n310 PUBLIC ${UHD_HOST_ROOT}/lib/usrp/common) +TARGET_INCLUDE_DIRECTORIES(dboards PUBLIC ${UHD_HOST_ROOT}/lib/usrp/common) diff --git a/mpm/dboards/magnesium_manager.cpp b/mpm/dboards/magnesium_manager.cpp new file mode 100644 index 000000000..2411ef558 --- /dev/null +++ b/mpm/dboards/magnesium_manager.cpp @@ -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/>. +// + +#include "magnesium_manager.hpp" +#include "mpm/spi/spidev_iface.hpp" +#include <boost/make_shared.hpp> + +using namespace mpm::dboards; + +magnesium_periph_manager::magnesium_periph_manager( + std::string lmk_spidev, std::string mykonos_spidev + ): _spi_lock(spi_lock::make(std::rand())) +{ + _clock_spi = lmk04828_spi_iface::make(mpm::spi::spidev_iface::make(lmk_spidev)); + _clock_ctrl = lmk04828_iface::make(_clock_spi->get_write_fn(), _clock_spi->get_read_fn()); + _mykonos_spi = mpm::spi::spidev_iface::make(mykonos_spidev); + _mykonos_ctrl = ad937x_ctrl::make(_spi_lock, _mykonos_spi); +}; diff --git a/mpm/dboards/magnesium_manager.hpp b/mpm/dboards/magnesium_manager.hpp new file mode 100644 index 000000000..ca8a7e123 --- /dev/null +++ b/mpm/dboards/magnesium_manager.hpp @@ -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/>. +// + +#pragma once + +#include "../lib/spi/spi_lock.h" +#include "mpm/spi/spidev_iface.hpp" +#include "lmk/lmk04828_spi_iface.hpp" +#include "../lib/mykonos/ad937x_ctrl.hpp" +#include <memory> + +namespace mpm { namespace dboards { + class magnesium_periph_manager// : public dboard_periph_manager + { + public: + magnesium_periph_manager(std::string lmk_spidev, std::string mykonos_spidev); + + /*! Return a reference to the clock chip + */ + lmk04828_iface::sptr get_clock_ctrl(){return _clock_ctrl;}; + + /*! Return a reference to the radio chip + */ + ad937x_ctrl::sptr get_radio_ctrl(){return _mykonos_ctrl;}; + + private: + //cpld control + spi_lock::sptr _spi_lock; + lmk04828_spi_iface::sptr _clock_spi; + lmk04828_iface::sptr _clock_ctrl; + mpm::spi::spidev_iface::sptr _mykonos_spi; + ad937x_ctrl::sptr _mykonos_ctrl; + }; + +}}; + diff --git a/mpm/lib/mykonos/CMakeLists.txt b/mpm/lib/mykonos/CMakeLists.txt index 182058405..f5e64064e 100644 --- a/mpm/lib/mykonos/CMakeLists.txt +++ b/mpm/lib/mykonos/CMakeLists.txt @@ -29,6 +29,7 @@ SET(mykonos_sources ${CMAKE_CURRENT_SOURCE_DIR}/ad937x_ctrl.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ad937x_device.cpp ${CMAKE_CURRENT_SOURCE_DIR}/adi_ctrl.cpp + ${UHD_HOST_ROOT}/lib/types/ranges.cpp ) ADD_SUBDIRECTORY(adi) diff --git a/mpm/lib/spi/spi_lock.cpp b/mpm/lib/spi/spi_lock.cpp index 1796de46a..5077053e7 100644 --- a/mpm/lib/spi/spi_lock.cpp +++ b/mpm/lib/spi/spi_lock.cpp @@ -23,4 +23,4 @@ void spi_lock::unlock() spi_lock::sptr spi_lock::make(uint8_t spidev_index) { return std::make_shared<spi_lock>(spidev_index); -}
\ No newline at end of file +} diff --git a/mpm/lib/spi/spi_lock.h b/mpm/lib/spi/spi_lock.h index 55ddb0baf..9ad4e20fe 100644 --- a/mpm/lib/spi/spi_lock.h +++ b/mpm/lib/spi/spi_lock.h @@ -1,8 +1,8 @@ #pragma once #include <boost/noncopyable.hpp> -#include <memory> #include <mutex> +#include <memory> class spi_lock : public boost::noncopyable { @@ -22,4 +22,4 @@ private: friend class std::lock_guard<spi_lock>; void lock(); void unlock(); -};
\ No newline at end of file +}; diff --git a/mpm/n310/periph_manager.cpp b/mpm/n310/periph_manager.cpp deleted file mode 100644 index a7941774e..000000000 --- a/mpm/n310/periph_manager.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// -// 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/>. -// - -#include "periph_manager.hpp" - -using namespace mpm::n3xx; - -n3xx_dboard_periph_manager::n3xx_dboard_periph_manager( - uhd::spi_iface::sptr lmk_spi - //uhd::spi_iface::sptr myk_spi - //uhd::spi_iface::sptr cpld_spi - ) - { - _clock_spi = std::make_shared<lmk04828_spi_iface>(lmk04828_spi_iface(lmk_spi)); - _clock_gen = lmk04828_iface::make(_clock_spi->get_write_fn(), _clock_spi->get_read_fn()); - }; - -lmk04828_iface::sptr n3xx_dboard_periph_manager::get_clock_gen() { return _clock_gen; } - -n3xx_dboard_periph_manager periph_manager::get_dboard_A(){ - return dboard_A_manager; -} - -lmk04828_iface::sptr periph_manager::get_clock_gen(){ return dboard_A_manager.get_clock_gen(); } diff --git a/mpm/n310/periph_manager.hpp b/mpm/n310/periph_manager.hpp deleted file mode 100644 index 3df9aa72b..000000000 --- a/mpm/n310/periph_manager.hpp +++ /dev/null @@ -1,82 +0,0 @@ -// -// 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 "mpm/spi/spidev_iface.hpp" -#include "lmk/lmk04828_spi_iface.hpp" -#include <memory> - -namespace mpm { namespace n3xx { - /* - class dboard_periph_manager - { - //.... - }; - */ - /************************************************************************** - * Daughterboard peripherals - *************************************************************************/ - - /*! Encapsulates all peripherals stored on the regular N300/N310 - * daughterboard. - */ - class n3xx_dboard_periph_manager// : public dboard_periph_manager - { - public: - n3xx_dboard_periph_manager( - uhd::spi_iface::sptr lmk_spi - // uhd::spi_iface::sptr myk_spi - // uhd::spi_iface::sptr cpld_spi - - ); - - /*! Return a reference to the clock chip - */ - lmk04828_iface::sptr get_clock_gen(); - - private: - //ad937x_ctrl::sptr _rfic; - //cpld control - lmk04828_iface::sptr _clock_gen; - std::shared_ptr<lmk04828_spi_iface> _clock_spi; - }; - - /************************************************************************** - * Motherboard peripherals - *************************************************************************/ - class periph_manager - { - public: - - periph_manager(std::string spi_path): dboard_A_manager(mpm::spi::spidev_iface::make(spi_path)) - { - - }; - - n3xx_dboard_periph_manager get_dboard_A(); - lmk04828_iface::sptr get_clock_gen(); - - // virtual void set_clock_source(); - - private: - n3xx_dboard_periph_manager dboard_A_manager; - // n3xx_dboard_periph_manager dboard_B_manager; - }; - -}}; /* namespace mpm::n310 */ - |