From a801d6b046743140e9a50c7788dd17dd71f5540a Mon Sep 17 00:00:00 2001 From: Sugandha Gupta Date: Tue, 15 Oct 2019 11:52:46 -0700 Subject: examples: Add example out-of-tree module for RFNoC modules This subdirectory is its own, self-contained project. It is supposed to work against the UHD version it is shipped with. Co-Authored-By: Martin Braun Co-Authored-By: Wade Fife --- host/examples/rfnoc-example/lib/CMakeLists.txt | 83 ++++++++++++++++++++++ .../rfnoc-example/lib/gain_block_control.cpp | 41 +++++++++++ 2 files changed, 124 insertions(+) create mode 100644 host/examples/rfnoc-example/lib/CMakeLists.txt create mode 100644 host/examples/rfnoc-example/lib/gain_block_control.cpp (limited to 'host/examples/rfnoc-example/lib') diff --git a/host/examples/rfnoc-example/lib/CMakeLists.txt b/host/examples/rfnoc-example/lib/CMakeLists.txt new file mode 100644 index 000000000..45b5c9b03 --- /dev/null +++ b/host/examples/rfnoc-example/lib/CMakeLists.txt @@ -0,0 +1,83 @@ +# +# Copyright 2019 Ettus Research, a National Instruments Brand +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +######################################################################## +# Setup library +######################################################################## +#include(GrPlatform) #define LIB_SUFFIX + +# List any C++ sources here. If there are no sources (e.g., because there +# is no block controller), then this directory will be skipped. +list(APPEND rfnoc_example_sources + gain_block_control.cpp +) +if(NOT rfnoc_example_sources) + MESSAGE(STATUS "No C++ sources... skipping lib/") + return() +endif() + +######################################################################## +# Setup the include and linker paths +######################################################################## +include_directories( + ${CMAKE_SOURCE_DIR}/lib + ${CMAKE_SOURCE_DIR}/include + ${CMAKE_BINARY_DIR}/lib + ${CMAKE_BINARY_DIR}/include + ${UHD_INCLUDE_DIRS} + ${Boost_INCLUDE_DIR} +) + +link_directories( + ${Boost_LIBRARY_DIRS} +) + +add_library(rfnoc-example SHARED + ${rfnoc_example_sources} +) +target_link_libraries(rfnoc-example + ${UHD_LIBRARIES} + ${Boost_LIBRARIES} + ${GNURADIO_ALL_LIBRARIES} + ${ETTUS_LIBRARIES} +) +set_target_properties(rfnoc-example + PROPERTIES DEFINE_SYMBOL "rfnoc_example_EXPORTS") + +######################################################################## +# Install built library files +######################################################################## +install(TARGETS rfnoc-example + LIBRARY DESTINATION lib${LIB_SUFFIX} # .so/.dylib file + ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file + RUNTIME DESTINATION bin # .dll file +) + +######################################################################## +# Build and register unit test +######################################################################## +#include(GrTest) +# +#include_directories(${CPPUNIT_INCLUDE_DIRS}) +# +#list(APPEND test_gain_sources +# ${CMAKE_CURRENT_SOURCE_DIR}/test_gain.cc +# ${CMAKE_CURRENT_SOURCE_DIR}/qa_gain.cc +#) +# +#add_executable(test-gain ${test_gain_sources}) +# +#target_link_libraries( +# test-gain +# ${GNURADIO_RUNTIME_LIBRARIES} +# ${Boost_LIBRARIES} +# ${CPPUNIT_LIBRARIES} +# ${ETTUS_LIBRARIES} +# ${PC_ETTUS_LIBDIR} +# gnuradio-gain +#) +# +#GR_ADD_TEST(test_gain test-gain) diff --git a/host/examples/rfnoc-example/lib/gain_block_control.cpp b/host/examples/rfnoc-example/lib/gain_block_control.cpp new file mode 100644 index 000000000..d53bafc8b --- /dev/null +++ b/host/examples/rfnoc-example/lib/gain_block_control.cpp @@ -0,0 +1,41 @@ +// +// Copyright 2019 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +// Include our own header: +#include + +// These two includes are the minimum required to implement a block: +#include +#include + +using namespace rfnoc::example; +using namespace uhd::rfnoc; + +const uint32_t gain_block_control::REG_GAIN_VALUE = 0x00; + +class gain_block_control_impl : public gain_block_control +{ +public: + RFNOC_BLOCK_CONSTRUCTOR(gain_block_control) + { + } + + void set_gain_value(const uint32_t gain) + { + regs().poke32(REG_GAIN_VALUE, gain); + } + + uint32_t get_gain_value() + { + return regs().peek32(REG_GAIN_VALUE); + } + +private: + +}; + +UHD_RFNOC_BLOCK_REGISTER_DIRECT( + gain_block_control, 0xb16, "Gain", CLOCK_KEY_GRAPH, "bus_clk") -- cgit v1.2.3