diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 5e1f7da6..e00155a2 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -26,10 +26,14 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install GNURadio + - name: Add GNURadio PPA if: ${{ matrix.os == 'ubuntu-22.04'}} run: | sudo add-apt-repository ppa:gnuradio/gnuradio-releases + + - name: Install GNURadio + if: ${{ matrix.os != 'ubuntu-20.04'}} + run: | sudo apt-get update sudo apt-get install -qq gnuradio-dev python3-packaging @@ -39,7 +43,7 @@ jobs: sudo ${{github.workspace}}/install_dependencies.sh - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_COMPILER=${{ matrix.compiler.cpp }} -DCMAKE_C_COMPILER=${{ matrix.compiler.c }} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{env.CMAKE_OPTIONS}} + run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_COMPILER=${{ matrix.compiler.cpp }} -DCMAKE_C_COMPILER=${{ matrix.compiler.c }} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{env.CMAKE_OPTIONS}} -DCMAKE_UNITY_BUILD=false - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel ${{env.CMAKE_BUILD_PARALLEL_LEVEL}} @@ -78,11 +82,10 @@ jobs: - name: Install dependencies # GNURadio plugin fails to build due to issues with spdlog dependency - # gnuradio pybind11 castxml - run: brew install wxwidgets soapysdr + run: brew install wxwidgets soapysdr gnuradio pybind11 castxml - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{env.CMAKE_OPTIONS}} + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{env.CMAKE_OPTIONS}} -DCMAKE_UNITY_BUILD=false - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel ${{env.CMAKE_BUILD_PARALLEL_LEVEL}} diff --git a/CMakeLists.txt b/CMakeLists.txt index 54a659ec..ca34000f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -251,6 +251,34 @@ if(APPLE) set(CMAKE_MACOSX_RPATH ON) endif() +set(CPP_STL_PCH + + + + + + + + + + + + + + + + + + + + + + + + + +) + ######################################################################### # externals ######################################################################### diff --git a/GUI/CMakeLists.txt b/GUI/CMakeLists.txt index c25b0d23..19079f6d 100644 --- a/GUI/CMakeLists.txt +++ b/GUI/CMakeLists.txt @@ -71,7 +71,34 @@ endif() include(${wxWidgets_USE_FILE}) +set(WXWIDGETS_PCH + + + + + + + + + + + + + + + + + + + + + +) + add_executable(limeGUI resources/resource.rc) +target_precompile_headers(limeGUI + PRIVATE ${CPP_STL_PCH} ${WXWIDGETS_PCH} +) set(BINARY_OUTPUT_DIR "${CMAKE_BINARY_DIR}/bin") set_target_properties(limeGUI PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BINARY_OUTPUT_DIR}) @@ -96,6 +123,9 @@ target_sources( SDRConfiguration_view.cpp parsers/CoefficientFileParser.cpp) +set_source_files_properties(fftviewer_wxgui/fftviewer_wxgui.cpp fftviewer_wxgui/fftviewer_frFFTviewer.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION true) +set_source_files_properties(oglGraph/dlgMarkers.cpp oglGraph//GLFont.cpp oglGraph/OpenGLGraph.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION true) + target_include_directories( limeGUI PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/GUI/chips/LMS7002M/lms7002_mainPanel.cpp b/GUI/chips/LMS7002M/lms7002_mainPanel.cpp index ce06ff72..b8b75651 100644 --- a/GUI/chips/LMS7002M/lms7002_mainPanel.cpp +++ b/GUI/chips/LMS7002M/lms7002_mainPanel.cpp @@ -1,4 +1,4 @@ -#include +#include #include "commonWxHeaders.h" #include "lms7002_mainPanel.h" #include "lms7002_pnlAFE_view.h" diff --git a/GUI/chips/LMS7002M/lms7002_pnlRFE_view.cpp b/GUI/chips/LMS7002M/lms7002_pnlRFE_view.cpp index 40d15c19..a80eb450 100644 --- a/GUI/chips/LMS7002M/lms7002_pnlRFE_view.cpp +++ b/GUI/chips/LMS7002M/lms7002_pnlRFE_view.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include "lms7002_gui_utilities.h" #include "numericSlider.h" #include diff --git a/GUI/chips/LMS7002M/lms7002_pnlSX_view.cpp b/GUI/chips/LMS7002M/lms7002_pnlSX_view.cpp index 4cb7edc8..f8149cd1 100644 --- a/GUI/chips/LMS7002M/lms7002_pnlSX_view.cpp +++ b/GUI/chips/LMS7002M/lms7002_pnlSX_view.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include "numericSlider.h" #include "lms7002_gui_utilities.h" #include "events.h" diff --git a/GUI/chips/Si5351C/Si5351C_wxgui.h b/GUI/chips/Si5351C/Si5351C_wxgui.h index 3253bb91..57408262 100644 --- a/GUI/chips/Si5351C/Si5351C_wxgui.h +++ b/GUI/chips/Si5351C/Si5351C_wxgui.h @@ -14,7 +14,6 @@ #include #include #include -#include "limesuiteng/SDRDevice.h" namespace lime { class SDRDevice; diff --git a/GUI/commonWxHeaders.h b/GUI/commonWxHeaders.h index fce9bb25..0bc25d48 100644 --- a/GUI/commonWxHeaders.h +++ b/GUI/commonWxHeaders.h @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/GUI/oglGraph/OpenGLGraph.cpp b/GUI/oglGraph/OpenGLGraph.cpp index 63d0b737..833431d3 100644 --- a/GUI/oglGraph/OpenGLGraph.cpp +++ b/GUI/oglGraph/OpenGLGraph.cpp @@ -30,7 +30,7 @@ const int OpenGLGraph::GLCanvasAttributes[8] = { bool OpenGLGraph::hasNotRecentEnoughOpenGLVersionWarningBeenThrownYet = false; -static bool IsGlew1_5() +static bool CanUseVBO() { #ifdef __GNUC__ #pragma GCC diagnostic push @@ -700,7 +700,7 @@ void OpenGLGraph::Draw() switchToDataView(); - if (settings.useVBO && IsGlew1_5()) + if (settings.useVBO && CanUseVBO()) { for (std::size_t i = 0; i < series.size(); i++) { diff --git a/GUI/oglGraph/OpenGLGraph.h b/GUI/oglGraph/OpenGLGraph.h index 84b8d237..1a4f2e40 100644 --- a/GUI/oglGraph/OpenGLGraph.h +++ b/GUI/oglGraph/OpenGLGraph.h @@ -7,7 +7,11 @@ #ifndef OPENGL_GRAPH #define OPENGL_GRAPH +#include "GL/glew.h" // must be included before wx/glcanvas.h #include +#ifdef __unix__ + #undef Success // somewhere in X11 headers is defined Success 0, it pollutes global scope +#endif #include class wxTimer; diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt index 4d9453fe..d9b2052f 100644 --- a/cli/CMakeLists.txt +++ b/cli/CMakeLists.txt @@ -9,30 +9,38 @@ endif() # common functionality among cli tools add_library(cli-shared STATIC common.cpp) target_include_directories(cli-shared PUBLIC ${CMAKE_CURRENT_LIST_DIR}) -target_link_libraries(cli-shared PUBLIC limesuiteng) +target_link_libraries(cli-shared PUBLIC limesuiteng taywee::args) + +target_precompile_headers(cli-shared PRIVATE ${CPP_STL_PCH} \"args.hxx\") add_executable(limeDevice limeDevice.cpp) set_target_properties(limeDevice PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") -target_link_libraries(limeDevice PRIVATE cli-shared taywee::args) +target_link_libraries(limeDevice PRIVATE cli-shared) +target_precompile_headers(limeDevice REUSE_FROM cli-shared) add_executable(limeSPI limeSPI.cpp) set_target_properties(limeSPI PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") -target_link_libraries(limeSPI PRIVATE cli-shared taywee::args) +target_link_libraries(limeSPI PRIVATE cli-shared) +target_precompile_headers(limeSPI REUSE_FROM cli-shared) add_executable(limeConfig limeConfig.cpp) set_target_properties(limeConfig PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") -target_link_libraries(limeConfig PRIVATE cli-shared taywee::args) +target_link_libraries(limeConfig PRIVATE cli-shared) +target_precompile_headers(limeConfig REUSE_FROM cli-shared) add_executable(limeFLASH limeFLASH.cpp) set_target_properties(limeFLASH PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") -target_link_libraries(limeFLASH PRIVATE cli-shared taywee::args) +target_link_libraries(limeFLASH PRIVATE cli-shared) +target_precompile_headers(limeFLASH REUSE_FROM cli-shared) add_executable(limeTRX limeTRX.cpp) set_target_properties(limeTRX PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") -target_link_libraries(limeTRX PRIVATE cli-shared kissfft taywee::args) +target_link_libraries(limeTRX PRIVATE cli-shared kissfft) +target_precompile_headers(limeTRX REUSE_FROM cli-shared) add_executable(limeOEM limeOEM.cpp) set_target_properties(limeOEM PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") -target_link_libraries(limeOEM PRIVATE cli-shared taywee::args) +target_link_libraries(limeOEM PRIVATE cli-shared) +target_precompile_headers(limeOEM REUSE_FROM cli-shared) install(TARGETS limeDevice limeSPI limeFLASH limeTRX limeConfig limeOEM DESTINATION bin) diff --git a/cli/common.cpp b/cli/common.cpp index e6c183bb..2261ca4c 100644 --- a/cli/common.cpp +++ b/cli/common.cpp @@ -1,5 +1,7 @@ #include "common.h" +#include "limesuiteng/SDRDevice.h" + using namespace lime; using namespace std::literals::string_literals; using namespace std::literals::string_view_literals; diff --git a/cli/common.h b/cli/common.h index 5fd4a68b..43180d86 100644 --- a/cli/common.h +++ b/cli/common.h @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include #include @@ -15,9 +15,8 @@ #include "limesuiteng/DeviceHandle.h" #include "limesuiteng/DeviceRegistry.h" -#include "limesuiteng/SDRDevice.h" -#include "limesuiteng/SDRDescriptor.h" #include "limesuiteng/Logger.h" +#include "limesuiteng/SDRDevice.h" lime::SDRDevice* ConnectToFilteredOrDefaultDevice(const std::string_view argument); diff --git a/cli/limeConfig.cpp b/cli/limeConfig.cpp index cc56abe8..b7ee4710 100644 --- a/cli/limeConfig.cpp +++ b/cli/limeConfig.cpp @@ -1,7 +1,9 @@ #include "common.h" +#include "limesuiteng/SDRDescriptor.h" #include "limesuiteng/LMS7002M.h" #include "limesuiteng/Logger.h" + #include #include #include diff --git a/cli/limeDevice.cpp b/cli/limeDevice.cpp index 9744e261..c7346db8 100644 --- a/cli/limeDevice.cpp +++ b/cli/limeDevice.cpp @@ -1,6 +1,8 @@ #include "common.h" #include "args.hxx" +#include "limesuiteng/SDRDescriptor.h" + using namespace std; using namespace lime; using namespace std::literals::string_literals; diff --git a/cli/limeFLASH.cpp b/cli/limeFLASH.cpp index f7aa57d7..3bef1e39 100644 --- a/cli/limeFLASH.cpp +++ b/cli/limeFLASH.cpp @@ -2,6 +2,8 @@ #include #include "args.hxx" +#include "limesuiteng/SDRDescriptor.h" + using namespace std; using namespace lime; diff --git a/cli/limeOEM.cpp b/cli/limeOEM.cpp index 0723a67f..454c1796 100644 --- a/cli/limeOEM.cpp +++ b/cli/limeOEM.cpp @@ -1,6 +1,8 @@ #include "common.h" + +#include "limesuiteng/SDRDescriptor.h" #include "limesuiteng/OpStatus.h" -#include "OEMTesting.h" + #include #include #include @@ -10,6 +12,8 @@ #include "utilities/toString.h" #include "args.hxx" +#include "OEMTesting.h" + using namespace std; using namespace lime; using namespace std::literals::string_literals; diff --git a/cli/limeSPI.cpp b/cli/limeSPI.cpp index 284f8ecc..58f06e95 100644 --- a/cli/limeSPI.cpp +++ b/cli/limeSPI.cpp @@ -1,5 +1,7 @@ #include "common.h" +#include "limesuiteng/SDRDescriptor.h" + #include #include #include diff --git a/cli/limeTRX.cpp b/cli/limeTRX.cpp index 12df99f1..01cafb38 100644 --- a/cli/limeTRX.cpp +++ b/cli/limeTRX.cpp @@ -1,4 +1,7 @@ #include "common.h" + +#include "limesuiteng/SDRDescriptor.h" + #include "limesuiteng/StreamConfig.h" #include "limesuiteng/StreamComposite.h" #include diff --git a/embedded/include/limesuiteng/embedded/types.h b/embedded/include/limesuiteng/embedded/types.h index a7a3229e..af8ae340 100644 --- a/embedded/include/limesuiteng/embedded/types.h +++ b/embedded/include/limesuiteng/embedded/types.h @@ -8,4 +8,4 @@ #include #endif -#endif // LIMESUITENG_EMBEDDED_TYPES_H \ No newline at end of file +#endif // LIMESUITENG_EMBEDDED_TYPES_H diff --git a/plugins/Soapy_limesuiteng/Settings.cpp b/plugins/Soapy_limesuiteng/Settings.cpp index 6224ade4..bb26440f 100644 --- a/plugins/Soapy_limesuiteng/Settings.cpp +++ b/plugins/Soapy_limesuiteng/Settings.cpp @@ -18,6 +18,7 @@ #include "limesuiteng/DeviceHandle.h" #include "limesuiteng/Logger.h" +#include "limesuiteng/SDRDevice.h" #include "limesuiteng/SDRDescriptor.h" #include "utilities/toString.h" diff --git a/plugins/Soapy_limesuiteng/Soapy_limesuiteng.h b/plugins/Soapy_limesuiteng/Soapy_limesuiteng.h index a2c60add..155c3f1c 100644 --- a/plugins/Soapy_limesuiteng/Soapy_limesuiteng.h +++ b/plugins/Soapy_limesuiteng/Soapy_limesuiteng.h @@ -1,3 +1,4 @@ +#pragma once /** @file Soapy_limesuiteng.h @brief Header for Soapy SDR + IConnection bindings. @@ -7,7 +8,6 @@ #include #include "limesuiteng/DeviceRegistry.h" -#include "limesuiteng/SDRDevice.h" #include "limesuiteng/StreamConfig.h" #include @@ -19,6 +19,10 @@ struct IConnectionStream; +namespace lime { +class SDRDevice; +} + class Soapy_limesuiteng : public SoapySDR::Device { public: diff --git a/plugins/Soapy_limesuiteng/Streaming.cpp b/plugins/Soapy_limesuiteng/Streaming.cpp index 237a7e5d..c6851db8 100644 --- a/plugins/Soapy_limesuiteng/Streaming.cpp +++ b/plugins/Soapy_limesuiteng/Streaming.cpp @@ -14,6 +14,7 @@ #include #include +#include "limesuiteng/SDRDevice.h" #include "limesuiteng/Logger.h" using namespace lime; @@ -309,12 +310,18 @@ int Soapy_limesuiteng::readStream( { case DataFormat::I16: case DataFormat::I12: - samplesReceived = - icstream->ownerDevice->StreamRx(0, reinterpret_cast(buffs), samplesToSkip, &metadata); + samplesReceived = icstream->ownerDevice->StreamRx(0, + reinterpret_cast(buffs), + samplesToSkip, + &metadata, + std::chrono::microseconds(timeoutUs)); break; case DataFormat::F32: - samplesReceived = - icstream->ownerDevice->StreamRx(0, reinterpret_cast(buffs), samplesToSkip, &metadata); + samplesReceived = icstream->ownerDevice->StreamRx(0, + reinterpret_cast(buffs), + samplesToSkip, + &metadata, + std::chrono::microseconds(timeoutUs)); break; } if (samplesReceived <= 0) @@ -336,10 +343,12 @@ int Soapy_limesuiteng::readStream( { case DataFormat::I16: case DataFormat::I12: - samplesReceived = icstream->ownerDevice->StreamRx(0, reinterpret_cast(buffs), numElems, &metadata); + samplesReceived = icstream->ownerDevice->StreamRx( + 0, reinterpret_cast(buffs), numElems, &metadata, std::chrono::microseconds(timeoutUs)); break; case DataFormat::F32: - samplesReceived = icstream->ownerDevice->StreamRx(0, reinterpret_cast(buffs), numElems, &metadata); + samplesReceived = icstream->ownerDevice->StreamRx( + 0, reinterpret_cast(buffs), numElems, &metadata, std::chrono::microseconds(timeoutUs)); break; } @@ -383,7 +392,7 @@ int Soapy_limesuiteng::writeStream(SoapySDR::Stream* stream, const size_t numElems, int& flags, const long long timeNs, - [[maybe_unused]] const long timeoutUs) + const long timeoutUs) { if ((flags & SOAPY_SDR_HAS_TIME) && (timeNs < 0)) { @@ -404,10 +413,12 @@ int Soapy_limesuiteng::writeStream(SoapySDR::Stream* stream, { case DataFormat::I16: case DataFormat::I12: - samplesSent = ownerDevice->StreamTx(0, reinterpret_cast(buffs), numElems, &metadata); + samplesSent = ownerDevice->StreamTx( + 0, reinterpret_cast(buffs), numElems, &metadata, std::chrono::microseconds(timeoutUs)); break; case DataFormat::F32: - samplesSent = ownerDevice->StreamTx(0, reinterpret_cast(buffs), numElems, &metadata); + samplesSent = ownerDevice->StreamTx( + 0, reinterpret_cast(buffs), numElems, &metadata, std::chrono::microseconds(timeoutUs)); break; } diff --git a/plugins/gr-limesdr/lib/device_handler.cc b/plugins/gr-limesdr/lib/device_handler.cc index 4d8f00ea..24292496 100644 --- a/plugins/gr-limesdr/lib/device_handler.cc +++ b/plugins/gr-limesdr/lib/device_handler.cc @@ -25,6 +25,7 @@ #include "limesuiteng/DeviceRegistry.h" #include "limesuiteng/VersionInfo.h" +#include "limesuiteng/limesuiteng.hpp" #include #include diff --git a/plugins/gr-limesdr/lib/device_handler.h b/plugins/gr-limesdr/lib/device_handler.h index 68d39b80..3a6198f5 100644 --- a/plugins/gr-limesdr/lib/device_handler.h +++ b/plugins/gr-limesdr/lib/device_handler.h @@ -21,7 +21,6 @@ #ifndef DEVICE_HANDLER_H #define DEVICE_HANDLER_H -#include "limesuiteng/limesuiteng.hpp" #ifdef ENABLE_RFE #include #endif @@ -31,6 +30,13 @@ #include #include +#include "limesuiteng/StreamConfig.h" + +namespace lime { +class SDRDevice; +class DeviceHandle; +} // namespace lime + class device_handler { private: diff --git a/plugins/gr-limesdr/lib/logging.cc b/plugins/gr-limesdr/lib/logging.cc index a669d859..16ad8bbb 100644 --- a/plugins/gr-limesdr/lib/logging.cc +++ b/plugins/gr-limesdr/lib/logging.cc @@ -20,13 +20,12 @@ #include "logging.h" -#include - #include - #include #include +#include "limesuiteng/Logger.h" + static gr::logger_ptr logger; static gr::logger_ptr debug_logger; diff --git a/plugins/gr-limesdr/lib/logging.h b/plugins/gr-limesdr/lib/logging.h index 1a984f09..a943fcab 100644 --- a/plugins/gr-limesdr/lib/logging.h +++ b/plugins/gr-limesdr/lib/logging.h @@ -21,8 +21,6 @@ #ifndef LOGGING_H #define LOGGING_H -#include - #include #include #include diff --git a/plugins/gr-limesdr/lib/sink_impl.cc b/plugins/gr-limesdr/lib/sink_impl.cc index d5019dcd..ebc3953f 100644 --- a/plugins/gr-limesdr/lib/sink_impl.cc +++ b/plugins/gr-limesdr/lib/sink_impl.cc @@ -22,16 +22,22 @@ #include "config.h" #endif +#include +#include + +#include "device_handler.h" #include "logging.h" #include "sink_impl.h" -#include -#include +#include "limesuiteng/SDRDevice.h" using namespace std::literals::string_literals; namespace gr { namespace limesdr { + +static const pmt::pmt_t TX_TIME_TAG = pmt::string_to_symbol(std::string("tx_time")); + sink::sptr sink::make(std::string serial, int channel_mode, const std::string& filename, @@ -220,7 +226,7 @@ void sink_impl::work_tags(int noutput_items) // Go through the tags for (tag_t cTag : tags) { // Found tx_time tag - if (pmt::eq(cTag.key, TIME_TAG)) { + if (pmt::eq(cTag.key, TX_TIME_TAG)) { // Convert time to sample timestamp uint64_t secs = pmt::to_uint64(pmt::tuple_ref(cTag.value, 0)); double fracs = pmt::to_double(pmt::tuple_ref(cTag.value, 1)); diff --git a/plugins/gr-limesdr/lib/sink_impl.h b/plugins/gr-limesdr/lib/sink_impl.h index 1cea01ce..87bfccc4 100644 --- a/plugins/gr-limesdr/lib/sink_impl.h +++ b/plugins/gr-limesdr/lib/sink_impl.h @@ -21,13 +21,12 @@ #ifndef INCLUDED_LIMESDR_SINK_IMPL_H #define INCLUDED_LIMESDR_SINK_IMPL_H -#include "device_handler.h" -#include +#include "limesdr/sink.h" +#include "limesuiteng/StreamConfig.h" + #include #include -static const pmt::pmt_t TIME_TAG = pmt::string_to_symbol(std::string("tx_time")); - namespace gr { namespace limesdr { class sink_impl : public sink diff --git a/plugins/gr-limesdr/lib/source_impl.cc b/plugins/gr-limesdr/lib/source_impl.cc index fc05722c..74609d9d 100644 --- a/plugins/gr-limesdr/lib/source_impl.cc +++ b/plugins/gr-limesdr/lib/source_impl.cc @@ -22,16 +22,22 @@ #include "config.h" #endif +#include +#include + +#include "device_handler.h" #include "logging.h" #include "source_impl.h" -#include -#include +#include "limesuiteng/SDRDevice.h" + using namespace std::literals::string_literals; namespace gr { namespace limesdr { +static const pmt::pmt_t RX_TIME_TAG = pmt::string_to_symbol(std::string("rx_time")); + source::sptr source::make(std::string serial, int channel_mode, const std::string& filename, @@ -273,7 +279,7 @@ void source_impl::add_time_tag(int channel, lime::StreamMeta meta) const pmt::pmt_t ID = pmt::string_to_symbol(stored.serial); const pmt::pmt_t t_val = pmt::make_tuple(pmt::from_uint64(intpart), pmt::from_double(fracpart)); - add_item_tag(channel, nitems_written(channel), TIME_TAG, t_val, ID); + add_item_tag(channel, nitems_written(channel), RX_TIME_TAG, t_val, ID); } // Return io_signature to manage module output count diff --git a/plugins/gr-limesdr/lib/source_impl.h b/plugins/gr-limesdr/lib/source_impl.h index cd156f88..b6715201 100644 --- a/plugins/gr-limesdr/lib/source_impl.h +++ b/plugins/gr-limesdr/lib/source_impl.h @@ -21,13 +21,11 @@ #ifndef INCLUDED_LIMESDR_SOURCE_IMPL_H #define INCLUDED_LIMESDR_SOURCE_IMPL_H -#include - -#include "device_handler.h" +#include "limesdr/source.h" #include -static const pmt::pmt_t TIME_TAG = pmt::string_to_symbol(std::string("rx_time")); +#include "limesuiteng/StreamConfig.h" namespace gr { namespace limesdr { diff --git a/plugins/gr-limesdr/python/bindings/.gitignore b/plugins/gr-limesdr/python/bindings/.gitignore deleted file mode 100644 index c3cf3838..00000000 --- a/plugins/gr-limesdr/python/bindings/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*_python.cc -docstrings/*_pydoc_template.h diff --git a/plugins/gr-limesdr/python/bindings/CMakeLists.txt b/plugins/gr-limesdr/python/bindings/CMakeLists.txt index a3990958..a3d7377d 100644 --- a/plugins/gr-limesdr/python/bindings/CMakeLists.txt +++ b/plugins/gr-limesdr/python/bindings/CMakeLists.txt @@ -26,9 +26,11 @@ include(GrPybind) list(APPEND limesdr_python_files sink_python.cc source_python.cc python_bindings.cc) -execute_process(COMMAND gr_modtool bind source WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) - -execute_process(COMMAND gr_modtool bind sink WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) +# Generates the *_python.cc files, they could be generated with each CMake config run and not require Git tracking. +# But because the bindings rarely change and bindings generation script can have issues when crawling though system header includes, +# the generated bindings files are added to Git tracking, and marked to auto re-generate if needed. +# execute_process(COMMAND gr_modtool bind source WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) +# execute_process(COMMAND gr_modtool bind sink WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) if(ENABLE_RFE) list(APPEND limesdr_python_files rfe_python.cc) diff --git a/plugins/gr-limesdr/python/bindings/docstrings/sink_pydoc_template.h b/plugins/gr-limesdr/python/bindings/docstrings/sink_pydoc_template.h new file mode 100644 index 00000000..c1927738 --- /dev/null +++ b/plugins/gr-limesdr/python/bindings/docstrings/sink_pydoc_template.h @@ -0,0 +1,72 @@ +/* + * Copyright 2024 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ +#include "pydoc_macros.h" +#define D(...) DOC(gr, limesdr, __VA_ARGS__) +/* + This file contains placeholders for docstrings for the Python bindings. + Do not edit! These were automatically extracted during the binding process + and will be overwritten during the build process + */ + + +static const char* __doc_gr_limesdr_sink = R"doc()doc"; + + +static const char* __doc_gr_limesdr_sink_sink_0 = R"doc()doc"; + + +static const char* __doc_gr_limesdr_sink_sink_1 = R"doc()doc"; + + +static const char* __doc_gr_limesdr_sink_make = R"doc()doc"; + + +static const char* __doc_gr_limesdr_sink_set_center_freq = R"doc()doc"; + + +static const char* __doc_gr_limesdr_sink_set_antenna = R"doc()doc"; + + +static const char* __doc_gr_limesdr_sink_set_nco = R"doc()doc"; + + +static const char* __doc_gr_limesdr_sink_set_bandwidth = R"doc()doc"; + + +static const char* __doc_gr_limesdr_sink_set_digital_filter = R"doc()doc"; + + +static const char* __doc_gr_limesdr_sink_set_gain = R"doc()doc"; + + +static const char* __doc_gr_limesdr_sink_set_sample_rate = R"doc()doc"; + + +static const char* __doc_gr_limesdr_sink_set_oversampling = R"doc()doc"; + + +static const char* __doc_gr_limesdr_sink_calibrate = R"doc()doc"; + + +static const char* __doc_gr_limesdr_sink_set_buffer_size = R"doc()doc"; + + +static const char* __doc_gr_limesdr_sink_set_tcxo_dac = R"doc()doc"; + + +static const char* __doc_gr_limesdr_sink_write_lms_reg = R"doc()doc"; + + +static const char* __doc_gr_limesdr_sink_set_gpio_dir = R"doc()doc"; + + +static const char* __doc_gr_limesdr_sink_write_gpio = R"doc()doc"; + + +static const char* __doc_gr_limesdr_sink_read_gpio = R"doc()doc"; diff --git a/plugins/gr-limesdr/python/bindings/docstrings/source_pydoc_template.h b/plugins/gr-limesdr/python/bindings/docstrings/source_pydoc_template.h new file mode 100644 index 00000000..414e3379 --- /dev/null +++ b/plugins/gr-limesdr/python/bindings/docstrings/source_pydoc_template.h @@ -0,0 +1,72 @@ +/* + * Copyright 2024 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ +#include "pydoc_macros.h" +#define D(...) DOC(gr, limesdr, __VA_ARGS__) +/* + This file contains placeholders for docstrings for the Python bindings. + Do not edit! These were automatically extracted during the binding process + and will be overwritten during the build process + */ + + +static const char* __doc_gr_limesdr_source = R"doc()doc"; + + +static const char* __doc_gr_limesdr_source_source_0 = R"doc()doc"; + + +static const char* __doc_gr_limesdr_source_source_1 = R"doc()doc"; + + +static const char* __doc_gr_limesdr_source_make = R"doc()doc"; + + +static const char* __doc_gr_limesdr_source_set_center_freq = R"doc()doc"; + + +static const char* __doc_gr_limesdr_source_set_antenna = R"doc()doc"; + + +static const char* __doc_gr_limesdr_source_set_nco = R"doc()doc"; + + +static const char* __doc_gr_limesdr_source_set_bandwidth = R"doc()doc"; + + +static const char* __doc_gr_limesdr_source_set_digital_filter = R"doc()doc"; + + +static const char* __doc_gr_limesdr_source_set_gain = R"doc()doc"; + + +static const char* __doc_gr_limesdr_source_set_sample_rate = R"doc()doc"; + + +static const char* __doc_gr_limesdr_source_set_oversampling = R"doc()doc"; + + +static const char* __doc_gr_limesdr_source_calibrate = R"doc()doc"; + + +static const char* __doc_gr_limesdr_source_set_buffer_size = R"doc()doc"; + + +static const char* __doc_gr_limesdr_source_set_tcxo_dac = R"doc()doc"; + + +static const char* __doc_gr_limesdr_source_write_lms_reg = R"doc()doc"; + + +static const char* __doc_gr_limesdr_source_set_gpio_dir = R"doc()doc"; + + +static const char* __doc_gr_limesdr_source_write_gpio = R"doc()doc"; + + +static const char* __doc_gr_limesdr_source_read_gpio = R"doc()doc"; diff --git a/plugins/gr-limesdr/python/bindings/sink_python.cc b/plugins/gr-limesdr/python/bindings/sink_python.cc new file mode 100644 index 00000000..232833fc --- /dev/null +++ b/plugins/gr-limesdr/python/bindings/sink_python.cc @@ -0,0 +1,136 @@ +/* + * Copyright 2024 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +/***********************************************************************************/ +/* This file is automatically generated using bindtool and can be manually edited */ +/* The following lines can be configured to regenerate this file during cmake */ +/* If manual edits are made, the following tags should be modified accordingly. */ +/* BINDTOOL_GEN_AUTOMATIC(1) */ +/* BINDTOOL_USE_PYGCCXML(0) */ +/* BINDTOOL_HEADER_FILE(sink.h) */ +/* BINDTOOL_HEADER_FILE_HASH(f2afded25eae99fdd12ae231bd440d70) */ +/***********************************************************************************/ + +#include +#include +#include + +namespace py = pybind11; + +#include +// pydoc.h is automatically generated in the build directory +#include + +void bind_sink(py::module& m) +{ + + using sink = ::gr::limesdr::sink; + + + py::class_>( + m, "sink", D(sink)) + + .def(py::init(&sink::make), + py::arg("serial"), + py::arg("channel_mode"), + py::arg("filename"), + py::arg("length_tag_name"), + D(sink, make)) + + + .def("set_center_freq", + &sink::set_center_freq, + py::arg("freq"), + py::arg("chan") = 0, + D(sink, set_center_freq)) + + + .def("set_antenna", + &sink::set_antenna, + py::arg("antenna"), + py::arg("channel") = 0, + D(sink, set_antenna)) + + + .def("set_nco", + &sink::set_nco, + py::arg("nco_freq"), + py::arg("channel"), + D(sink, set_nco)) + + + .def("set_bandwidth", + &sink::set_bandwidth, + py::arg("analog_bandw"), + py::arg("channel") = 0, + D(sink, set_bandwidth)) + + + .def("set_digital_filter", + &sink::set_digital_filter, + py::arg("digital_bandw"), + py::arg("channel"), + D(sink, set_digital_filter)) + + + .def("set_gain", + &sink::set_gain, + py::arg("gain_dB"), + py::arg("channel") = 0, + D(sink, set_gain)) + + + .def("set_sample_rate", + &sink::set_sample_rate, + py::arg("rate"), + D(sink, set_sample_rate)) + + + .def("set_oversampling", + &sink::set_oversampling, + py::arg("oversample"), + D(sink, set_oversampling)) + + + .def("calibrate", + &sink::calibrate, + py::arg("bandw"), + py::arg("channel") = 0, + D(sink, calibrate)) + + + .def("set_buffer_size", + &sink::set_buffer_size, + py::arg("size"), + D(sink, set_buffer_size)) + + + .def("set_tcxo_dac", + &sink::set_tcxo_dac, + py::arg("dacVal") = 125, + D(sink, set_tcxo_dac)) + + + .def("write_lms_reg", + &sink::write_lms_reg, + py::arg("address"), + py::arg("val"), + D(sink, write_lms_reg)) + + + .def("set_gpio_dir", &sink::set_gpio_dir, py::arg("dir"), D(sink, set_gpio_dir)) + + + .def("write_gpio", &sink::write_gpio, py::arg("out"), D(sink, write_gpio)) + + + .def("read_gpio", &sink::read_gpio, D(sink, read_gpio)) + + ; +} diff --git a/plugins/gr-limesdr/python/bindings/source_python.cc b/plugins/gr-limesdr/python/bindings/source_python.cc new file mode 100644 index 00000000..2b4fab28 --- /dev/null +++ b/plugins/gr-limesdr/python/bindings/source_python.cc @@ -0,0 +1,142 @@ +/* + * Copyright 2024 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +/***********************************************************************************/ +/* This file is automatically generated using bindtool and can be manually edited */ +/* The following lines can be configured to regenerate this file during cmake */ +/* If manual edits are made, the following tags should be modified accordingly. */ +/* BINDTOOL_GEN_AUTOMATIC(1) */ +/* BINDTOOL_USE_PYGCCXML(0) */ +/* BINDTOOL_HEADER_FILE(source.h) */ +/* BINDTOOL_HEADER_FILE_HASH(513c2396631d13233148b0f4738adf16) */ +/***********************************************************************************/ + +#include +#include +#include + +namespace py = pybind11; + +#include +// pydoc.h is automatically generated in the build directory +#include + +void bind_source(py::module& m) +{ + + using source = ::gr::limesdr::source; + + + py::class_>(m, "source", D(source)) + + .def(py::init(&source::make), + py::arg("serial"), + py::arg("channel_mode"), + py::arg("filename"), + py::arg("align_ch_phase"), + D(source, make)) + + + .def("set_center_freq", + &source::set_center_freq, + py::arg("freq"), + py::arg("chan") = 0, + D(source, set_center_freq)) + + + .def("set_antenna", + &source::set_antenna, + py::arg("antenna"), + py::arg("channel") = 0, + D(source, set_antenna)) + + + .def("set_nco", + &source::set_nco, + py::arg("nco_freq"), + py::arg("channel"), + D(source, set_nco)) + + + .def("set_bandwidth", + &source::set_bandwidth, + py::arg("analog_bandw"), + py::arg("channel") = 0, + D(source, set_bandwidth)) + + + .def("set_digital_filter", + &source::set_digital_filter, + py::arg("digital_bandw"), + py::arg("channel"), + D(source, set_digital_filter)) + + + .def("set_gain", + &source::set_gain, + py::arg("gain_dB"), + py::arg("channel") = 0, + D(source, set_gain)) + + + .def("set_sample_rate", + &source::set_sample_rate, + py::arg("rate"), + D(source, set_sample_rate)) + + + .def("set_oversampling", + &source::set_oversampling, + py::arg("oversample"), + D(source, set_oversampling)) + + + .def("calibrate", + &source::calibrate, + py::arg("bandw"), + py::arg("channel") = 0, + D(source, calibrate)) + + + .def("set_buffer_size", + &source::set_buffer_size, + py::arg("size"), + D(source, set_buffer_size)) + + + .def("set_tcxo_dac", + &source::set_tcxo_dac, + py::arg("dacVal") = 125, + D(source, set_tcxo_dac)) + + + .def("write_lms_reg", + &source::write_lms_reg, + py::arg("address"), + py::arg("val"), + D(source, write_lms_reg)) + + + .def("set_gpio_dir", + &source::set_gpio_dir, + py::arg("dir"), + D(source, set_gpio_dir)) + + + .def("write_gpio", &source::write_gpio, py::arg("out"), D(source, write_gpio)) + + + .def("read_gpio", &source::read_gpio, D(source, read_gpio)) + + ; +} diff --git a/src/API/LimePlugin.cpp b/src/API/LimePlugin.cpp index ebed990a..3b8d07bb 100644 --- a/src/API/LimePlugin.cpp +++ b/src/API/LimePlugin.cpp @@ -2,7 +2,7 @@ #include "gainTable.h" #include -#include +#include #include #include #include diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1da8c905..118c4e10 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -37,7 +37,7 @@ set(LIME_SUITE_SOURCES set_source_files_properties(mcu_program/common_src/lms7002m_controls.c PROPERTIES LANGUAGE CXX) -set(LIME_SUITE_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} include boards protocols lms7002m external threadHelper memory) +set(LIME_SUITE_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} include boards lms7002m external threadHelper memory) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/include/limesuiteng/VersionInfo.in.cpp @@ -61,6 +61,9 @@ if(NOT ENABLE_LIBRARY) endif(NOT ENABLE_LIBRARY) add_library(limesuiteng ${LIME_SUITE_SOURCES}) + +target_precompile_headers(limesuiteng PRIVATE ${CPP_STL_CPH}) + set_target_properties( limesuiteng PROPERTIES POSITION_INDEPENDENT_CODE TRUE diff --git a/src/DSP/CFR/CrestFactorReduction.cpp b/src/DSP/CFR/CrestFactorReduction.cpp index d6efa1ed..97cbdf98 100644 --- a/src/DSP/CFR/CrestFactorReduction.cpp +++ b/src/DSP/CFR/CrestFactorReduction.cpp @@ -1,10 +1,10 @@ #define _USE_MATH_DEFINES -#include -#include #include -#include -#include +#include +#include +#include #include +#include #include "comms/ISPI.h" #include "CrestFactorReduction.h" diff --git a/src/DSP/CFR/CrestFactorReduction.h b/src/DSP/CFR/CrestFactorReduction.h index f5b3fb5d..718c2de1 100644 --- a/src/DSP/CFR/CrestFactorReduction.h +++ b/src/DSP/CFR/CrestFactorReduction.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include "registers.h" diff --git a/src/DSP/CFR/registers.h b/src/DSP/CFR/registers.h index 1973ff29..40cf715d 100644 --- a/src/DSP/CFR/registers.h +++ b/src/DSP/CFR/registers.h @@ -4,51 +4,51 @@ namespace lime { namespace CFR { -constexpr CSRegister EN_RXTSP = { 0x00A0, 0, 0, 0, 0 }; -constexpr CSRegister EN_TXTSP = { 0x0080, 0, 0, 0, 0 }; - -constexpr CSRegister RX_DCCORR_BYP = { 0x00AC, 2, 2, 0, 0 }; -constexpr CSRegister RX_PHCORR_BYP = { 0x00AC, 0, 0, 0, 0 }; -constexpr CSRegister RX_GCORR_BYP = { 0x00AC, 1, 1, 0, 0 }; - -constexpr CSRegister RX_EQU_BYP = { 0x00AC, 5, 5, 0, 0 }; - -constexpr CSRegister RX_DCLOOP_BYP = { 0x00AC, 8, 8, 0, 0 }; -constexpr CSRegister RX_DCLOOP_AVG = { 0x00A4, 2, 0, 0, 0 }; - -constexpr CSRegister TX_HB_BYP = { 0x0088, 0, 0, 1, 0 }; -constexpr CSRegister TX_HB_DEL = { 0x0088, 1, 1, 0, 0 }; -constexpr CSRegister SLEEP_CFR = { 0x0088, 2, 2, 1, 0 }; -constexpr CSRegister BYPASS_CFR = { 0x0088, 3, 3, 1, 0 }; -constexpr CSRegister ODD_CFR = { 0x0088, 4, 4, 1, 0 }; -constexpr CSRegister BYPASSGAIN_CFR = { 0x0088, 5, 5, 1, 0 }; -constexpr CSRegister SLEEP_FIR = { 0x0088, 6, 6, 1, 0 }; -constexpr CSRegister BYPASS_FIR = { 0x0088, 7, 7, 1, 0 }; - -constexpr CSRegister ODD_FIR = { 0x0088, 8, 8, 0, 0 }; -constexpr CSRegister TX_PHCORR_BYP = { 0x0088, 9, 9, 0, 0 }; -constexpr CSRegister TX_GCORR_BYP = { 0x0088, 10, 10, 0, 0 }; -constexpr CSRegister TX_DCCORR_BYP = { 0x0088, 11, 11, 0, 0 }; -constexpr CSRegister TX_ISINC_BYP = { 0x0088, 12, 12, 1, 0 }; -constexpr CSRegister TX_EQU_BYP = { 0x0088, 13, 13, 1, 0 }; -constexpr CSRegister TX_INVERTQ = { 0x0088, 15, 15, 0, 0 }; - -constexpr CSRegister TX_GCORRQ = { 0x0081, 11, 0, 2047, 0 }; -constexpr CSRegister TX_GCORRI = { 0x0082, 11, 0, 2047, 0 }; -constexpr CSRegister TX_PHCORR = { 0x0083, 11, 0, 0, 1 }; -constexpr CSRegister TX_DCCORRI = { 0x0084, 15, 0, 0, 0 }; -constexpr CSRegister TX_DCCORRQ = { 0x0085, 15, 0, 0, 0 }; -constexpr CSRegister thresholdSpin = { 0x0086, 15, 0, 0, 0 }; -constexpr CSRegister thresholdGain = { 0x0087, 15, 0, 0, 0 }; -constexpr CSRegister CFR_ORDER = { 0x008C, 7, 0, 0, 0 }; // dummy CSRegister - -constexpr CSRegister RX_GCORRQ = { 0x00A1, 11, 0, 2047, 0 }; -constexpr CSRegister RX_GCORRI = { 0x00A2, 11, 0, 2047, 0 }; -constexpr CSRegister RX_PHCORR = { 0x00A3, 11, 0, 0, 1 }; - -constexpr CSRegister cmbInsel = { 0x0080, 2, 2, 0, 0 }; - -constexpr CSRegister MAC = { 0xFFFF, 1, 0, 0, 0 }; +static constexpr lime::CSRegister EN_RXTSP = { 0x00A0, 0, 0, 0, 0 }; +static constexpr lime::CSRegister EN_TXTSP = { 0x0080, 0, 0, 0, 0 }; + +static constexpr lime::CSRegister RX_DCCORR_BYP = { 0x00AC, 2, 2, 0, 0 }; +static constexpr lime::CSRegister RX_PHCORR_BYP = { 0x00AC, 0, 0, 0, 0 }; +static constexpr lime::CSRegister RX_GCORR_BYP = { 0x00AC, 1, 1, 0, 0 }; + +static constexpr lime::CSRegister RX_EQU_BYP = { 0x00AC, 5, 5, 0, 0 }; + +static constexpr lime::CSRegister RX_DCLOOP_BYP = { 0x00AC, 8, 8, 0, 0 }; +static constexpr lime::CSRegister RX_DCLOOP_AVG = { 0x00A4, 2, 0, 0, 0 }; + +static constexpr lime::CSRegister TX_HB_BYP = { 0x0088, 0, 0, 1, 0 }; +static constexpr lime::CSRegister TX_HB_DEL = { 0x0088, 1, 1, 0, 0 }; +static constexpr lime::CSRegister SLEEP_CFR = { 0x0088, 2, 2, 1, 0 }; +static constexpr lime::CSRegister BYPASS_CFR = { 0x0088, 3, 3, 1, 0 }; +static constexpr lime::CSRegister ODD_CFR = { 0x0088, 4, 4, 1, 0 }; +static constexpr lime::CSRegister BYPASSGAIN_CFR = { 0x0088, 5, 5, 1, 0 }; +static constexpr lime::CSRegister SLEEP_FIR = { 0x0088, 6, 6, 1, 0 }; +static constexpr lime::CSRegister BYPASS_FIR = { 0x0088, 7, 7, 1, 0 }; + +static constexpr lime::CSRegister ODD_FIR = { 0x0088, 8, 8, 0, 0 }; +static constexpr lime::CSRegister TX_PHCORR_BYP = { 0x0088, 9, 9, 0, 0 }; +static constexpr lime::CSRegister TX_GCORR_BYP = { 0x0088, 10, 10, 0, 0 }; +static constexpr lime::CSRegister TX_DCCORR_BYP = { 0x0088, 11, 11, 0, 0 }; +static constexpr lime::CSRegister TX_ISINC_BYP = { 0x0088, 12, 12, 1, 0 }; +static constexpr lime::CSRegister TX_EQU_BYP = { 0x0088, 13, 13, 1, 0 }; +static constexpr lime::CSRegister TX_INVERTQ = { 0x0088, 15, 15, 0, 0 }; + +static constexpr lime::CSRegister TX_GCORRQ = { 0x0081, 11, 0, 2047, 0 }; +static constexpr lime::CSRegister TX_GCORRI = { 0x0082, 11, 0, 2047, 0 }; +static constexpr lime::CSRegister TX_PHCORR = { 0x0083, 11, 0, 0, 1 }; +static constexpr lime::CSRegister TX_DCCORRI = { 0x0084, 15, 0, 0, 0 }; +static constexpr lime::CSRegister TX_DCCORRQ = { 0x0085, 15, 0, 0, 0 }; +static constexpr lime::CSRegister thresholdSpin = { 0x0086, 15, 0, 0, 0 }; +static constexpr lime::CSRegister thresholdGain = { 0x0087, 15, 0, 0, 0 }; +static constexpr lime::CSRegister CFR_ORDER = { 0x008C, 7, 0, 0, 0 }; // dummy CSRegister + +static constexpr lime::CSRegister RX_GCORRQ = { 0x00A1, 11, 0, 2047, 0 }; +static constexpr lime::CSRegister RX_GCORRI = { 0x00A2, 11, 0, 2047, 0 }; +static constexpr lime::CSRegister RX_PHCORR = { 0x00A3, 11, 0, 0, 1 }; + +static constexpr lime::CSRegister cmbInsel = { 0x0080, 2, 2, 0, 0 }; + +static constexpr lime::CSRegister MAC = { 0xFFFF, 1, 0, 0, 0 }; } // namespace CFR } // namespace lime \ No newline at end of file diff --git a/src/FPGA/FPGA_common.cpp b/src/FPGA/FPGA_common.cpp index d2a4e274..da439e29 100644 --- a/src/FPGA/FPGA_common.cpp +++ b/src/FPGA/FPGA_common.cpp @@ -1,6 +1,6 @@ #include "FPGA/FPGA_common.h" #include "comms/ISPI.h" -#include "LMSBoards.h" +#include "protocols/LMSBoards.h" #include "limesuiteng/Logger.h" #include "limesuiteng/SDRDescriptor.h" #include "WriteRegistersBatch.h" diff --git a/src/StreamComposite.cpp b/src/StreamComposite.cpp index da419a4f..4ab5a834 100644 --- a/src/StreamComposite.cpp +++ b/src/StreamComposite.cpp @@ -1,11 +1,13 @@ #include "limesuiteng/StreamComposite.h" + #include +#include + #include "limesuiteng/types.h" #include "limesuiteng/StreamConfig.h" #include "limesuiteng/SDRDescriptor.h" #include "limesuiteng/RFSOCDescriptor.h" #include "limesuiteng/Logger.h" -#include using namespace std; diff --git a/src/boards/DeviceFactoryPCIe.cpp b/src/boards/DeviceFactoryPCIe.cpp index e6d8ca72..010801fb 100644 --- a/src/boards/DeviceFactoryPCIe.cpp +++ b/src/boards/DeviceFactoryPCIe.cpp @@ -6,7 +6,7 @@ #include "CommonFunctions.h" #include "limesuiteng/Logger.h" #include "comms/PCIe/LimePCIe.h" -#include "LMSBoards.h" +#include "protocols/LMSBoards.h" #include "comms/PCIe/LMS64C_FPGA_Over_PCIe.h" #include "comms/PCIe/LMS64C_LMS7002M_Over_PCIe.h" #include "MMX8/LMS64C_ADF_Over_PCIe_MMX8.h" diff --git a/src/boards/LMS7002M_SDRDevice.cpp b/src/boards/LMS7002M_SDRDevice.cpp index b2a5e836..311e8194 100644 --- a/src/boards/LMS7002M_SDRDevice.cpp +++ b/src/boards/LMS7002M_SDRDevice.cpp @@ -4,7 +4,6 @@ #include "limesuiteng/LMS7002M.h" #include "chips/LMS7002M/LMS7002MCSR_Data.h" #include "chips/LMS7002M/MCU_BD.h" -#include "LMSBoards.h" #include "limesuiteng/Logger.h" #include "streaming/TRXLooper.h" #include "utilities/toString.h" diff --git a/src/boards/LimeSDR/LimeSDR.cpp b/src/boards/LimeSDR/LimeSDR.cpp index 614023fb..7ef63b17 100644 --- a/src/boards/LimeSDR/LimeSDR.cpp +++ b/src/boards/LimeSDR/LimeSDR.cpp @@ -1,33 +1,37 @@ #include "LimeSDR.h" -#include "comms/USB/IUSB.h" -#include "LMSBoards.h" #include "limesuiteng/LMS7002M.h" -#include "chips/Si5351C/Si5351C.h" -#include "LMS64CProtocol.h" #include "limesuiteng/Logger.h" -#include "FPGA/FPGA_common.h" + +#include "comms/IComms.h" +#include "comms/ISerialPort.h" +#include "comms/USB/FX3/FX3.h" +#include "comms/USB/IUSB.h" #include "comms/USB/USBDMAEmulation.h" #include "chips/LMS7002M/LMS7002MCSR_Data.h" #include "chips/LMS7002M/validation.h" +#include "chips/Si5351C/Si5351C.h" +#include "FPGA/FPGA_common.h" +#include "protocols/LMS64CProtocol.h" +#include "protocols/LMSBoards.h" #include "protocols/LMS64CProtocol.h" -#include "DeviceTreeNode.h" -#include "comms/IComms.h" -#include "comms/USB/FX3/FX3.h" -#include "ISerialPort.h" -#include "utilities/toString.h" #include "streaming/TRXLooper.h" +#include "utilities/toString.h" + +#include "DeviceTreeNode.h" #include #include #include #include -using namespace lime; using namespace lime::LMS64CProtocol; using namespace lime::LMS7002MCSR_Data; using namespace std::literals::string_literals; +namespace lime { +namespace limesdrusb { + static const uint8_t SPI_LMS7002M = 0; static const uint8_t SPI_FPGA = 1; static const uint8_t SPI_ADF4002 = 2; @@ -84,6 +88,8 @@ static const std::vector> lms7002defaultsOverrides { 0x040C, 0x00FB } }; +} // namespace limesdrusb + /// @brief Constructs a new LimeSDR object /// @param spiLMS The communications port to the LMS7002M chip. /// @param spiFPGA The communications port to the device's FPGA. @@ -110,7 +116,7 @@ LimeSDR::LimeSDR(std::shared_ptr spiLMS, descriptor.rfSOC.push_back(soc); std::unique_ptr chip = std::make_unique(mlms7002mPort); - chip->ModifyRegistersDefaults(lms7002defaultsOverrides); + chip->ModifyRegistersDefaults(limesdrusb::lms7002defaultsOverrides); chip->SetConnection(mlms7002mPort); chip->SetOnCGENChangeCallback(UpdateFPGAInterface, this); mLMSChips.push_back(std::move(chip)); @@ -139,9 +145,9 @@ LimeSDR::LimeSDR(std::shared_ptr spiLMS, descriptor.memoryDevices[ToString(eMemoryDevice::EEPROM)] = std::make_shared(this, eMemoryDevice::EEPROM, eepromMap); - descriptor.customParameters.push_back(CP_VCTCXO_DAC); - descriptor.customParameters.push_back(CP_TEMPERATURE); - descriptor.spiSlaveIds = { { "LMS7002M"s, SPI_LMS7002M }, { "FPGA"s, SPI_FPGA } }; + descriptor.customParameters.push_back(limesdrusb::CP_VCTCXO_DAC); + descriptor.customParameters.push_back(limesdrusb::CP_TEMPERATURE); + descriptor.spiSlaveIds = { { "LMS7002M"s, limesdrusb::SPI_LMS7002M }, { "FPGA"s, limesdrusb::SPI_FPGA } }; mDeviceDescriptor = descriptor; @@ -371,7 +377,7 @@ SDRDescriptor LimeSDR::GetDeviceInfo(void) const uint32_t addrs[] = { 0x0000, 0x0001, 0x0002, 0x0003 }; uint32_t data[4]; - SPI(SPI_FPGA, addrs, data, 4); + SPI(limesdrusb::SPI_FPGA, addrs, data, 4); auto boardID = static_cast(data[0]); //(pkt.inBuffer[2] << 8) | pkt.inBuffer[3]; auto gatewareVersion = data[1]; //(pkt.inBuffer[6] << 8) | pkt.inBuffer[7]; auto gatewareRevision = data[2]; //(pkt.inBuffer[10] << 8) | pkt.inBuffer[11]; @@ -412,11 +418,11 @@ OpStatus LimeSDR::SPI(uint32_t chipSelect, const uint32_t* MOSI, uint32_t* MISO, { switch (chipSelect) { - case SPI_LMS7002M: + case limesdrusb::SPI_LMS7002M: return mlms7002mPort->SPI(0, MOSI, MISO, count); - case SPI_FPGA: + case limesdrusb::SPI_FPGA: return mfpgaPort->SPI(MOSI, MISO, count); - case SPI_ADF4002: + case limesdrusb::SPI_ADF4002: return LMS64CProtocol::ADF4002_SPI(*mSerialPort, MOSI, count); default: throw std::logic_error("LimeSDR SPI invalid SPI chip select"s); @@ -515,3 +521,5 @@ OpStatus LimeSDR::MemoryRead(std::shared_ptr storage, Region region return OpStatus::Error; return mfpgaPort->MemoryRead(region.address, data, region.size); } + +} // namespace lime diff --git a/src/boards/LimeSDR/USB_CSR_Pipe_SDR.cpp b/src/boards/LimeSDR/USB_CSR_Pipe_SDR.cpp index 2a9ba65a..df481944 100644 --- a/src/boards/LimeSDR/USB_CSR_Pipe_SDR.cpp +++ b/src/boards/LimeSDR/USB_CSR_Pipe_SDR.cpp @@ -4,7 +4,7 @@ #include #include "comms/USB/FX3/FX3.h" -#include "LMS64CProtocol.h" +#include "protocols/LMS64CProtocol.h" using namespace lime; diff --git a/src/boards/LimeSDR_Mini/LimeNET_Micro.cpp b/src/boards/LimeSDR_Mini/LimeNET_Micro.cpp index 14d7e207..d4d9af6f 100644 --- a/src/boards/LimeSDR_Mini/LimeNET_Micro.cpp +++ b/src/boards/LimeSDR_Mini/LimeNET_Micro.cpp @@ -1,36 +1,38 @@ #include "LimeNET_Micro.h" -#include "comms/USB/IUSB.h" -#include "LMSBoards.h" #include "limesuiteng/LMS7002M.h" -#include "chips/Si5351C/Si5351C.h" -#include "LMS64CProtocol.h" #include "limesuiteng/Logger.h" -#include "FPGA_Mini.h" -#include "comms/USB/USBDMAEmulation.h" + +#include "chips/Si5351C/Si5351C.h" #include "chips/LMS7002M/validation.h" #include "chips/LMS7002M/LMS7002MCSR_Data.h" -#include "protocols/LMS64CProtocol.h" -#include "DeviceTreeNode.h" #include "comms/IComms.h" -#include "ISerialPort.h" +#include "comms/ISerialPort.h" #include "comms/USB/FT601/FT601.h" +#include "comms/USB/IUSB.h" +#include "comms/USB/USBDMAEmulation.h" #include "comms/SPI_utilities.h" +#include "protocols/LMS64CProtocol.h" #include "streaming/TRXLooper.h" -#include +#include "FPGA_Mini.h" +#include "DeviceTreeNode.h" + +#include #include #include #include #include -using namespace lime; using namespace lime::LMS64CProtocol; using namespace lime::LMS7002MCSR_Data; using namespace std::literals::string_literals; // LimeNET Micro functionally is very similar to LimeSDR-Mini, could technically reuse it's code. +namespace lime { +namespace limenetmicro { + static const uint8_t SPI_LMS7002M = 0; static const uint8_t SPI_FPGA = 1; @@ -85,6 +87,8 @@ static const std::vector> lms7002defaultsOverrides { 0x040C, 0x00FB } }; +} // namespace limenetmicro + /// @brief Constructs a new LimeNET_Micro object /// @param spiLMS The communications port to the LMS7002M chip. /// @param spiFPGA The communications port to the device's FPGA. @@ -111,8 +115,8 @@ LimeNET_Micro::LimeNET_Micro(std::shared_ptr spiLMS, FPGA::GatewareInfo gw = mFPGA->GetGatewareInfo(); FPGA::GatewareToDescriptor(gw, descriptor); - descriptor.customParameters.push_back(CP_VCTCXO_DAC); - descriptor.customParameters.push_back(CP_TEMPERATURE); + descriptor.customParameters.push_back(limenetmicro::CP_VCTCXO_DAC); + descriptor.customParameters.push_back(limenetmicro::CP_TEMPERATURE); { RFSOCDescriptor soc{ GetDefaultLMS7002MDescriptor() }; @@ -125,7 +129,7 @@ LimeNET_Micro::LimeNET_Micro(std::shared_ptr spiLMS, descriptor.rfSOC.push_back(soc); std::unique_ptr chip = std::make_unique(mlms7002mPort); - chip->ModifyRegistersDefaults(lms7002defaultsOverrides); + chip->ModifyRegistersDefaults(limenetmicro::lms7002defaultsOverrides); chip->SetOnCGENChangeCallback(UpdateFPGAInterface, this); chip->SetReferenceClk_SX(TRXDir::Rx, refClk); @@ -142,7 +146,7 @@ LimeNET_Micro::LimeNET_Micro(std::shared_ptr spiLMS, std::static_pointer_cast(rxdma), std::static_pointer_cast(txdma), mFPGA.get(), mLMSChips.at(0).get(), 0)); } - descriptor.spiSlaveIds = { { "LMS7002M"s, SPI_LMS7002M }, { "FPGA"s, SPI_FPGA } }; + descriptor.spiSlaveIds = { { "LMS7002M"s, limenetmicro::SPI_LMS7002M }, { "FPGA"s, limenetmicro::SPI_FPGA } }; auto fpgaNode = std::make_shared("FPGA"s, eDeviceTreeNodeClass::FPGA_MINI, mFPGA.get()); fpgaNode->children.push_back( @@ -301,9 +305,9 @@ OpStatus LimeNET_Micro::SPI(uint32_t chipSelect, const uint32_t* MOSI, uint32_t* { switch (chipSelect) { - case SPI_LMS7002M: + case limenetmicro::SPI_LMS7002M: return mlms7002mPort->SPI(0, MOSI, MISO, count); - case SPI_FPGA: + case limenetmicro::SPI_FPGA: return mfpgaPort->SPI(MOSI, MISO, count); default: throw std::logic_error("LimeNET_Micro SPI invalid SPI chip select"s); @@ -557,3 +561,5 @@ OpStatus LimeNET_Micro::SetRFSwitch(TRXDir dir, uint8_t path) } return OpStatus::Success; } + +} // namespace lime diff --git a/src/boards/LimeSDR_Mini/LimeSDR_Mini.cpp b/src/boards/LimeSDR_Mini/LimeSDR_Mini.cpp index 10b6935e..a6ee4446 100644 --- a/src/boards/LimeSDR_Mini/LimeSDR_Mini.cpp +++ b/src/boards/LimeSDR_Mini/LimeSDR_Mini.cpp @@ -1,34 +1,39 @@ #include "LimeSDR_Mini.h" -#include "comms/USB/IUSB.h" -#include "LMSBoards.h" +#include +#include +#include +#include +#include + #include "limesuiteng/LMS7002M.h" -#include "chips/Si5351C/Si5351C.h" -#include "LMS64CProtocol.h" #include "limesuiteng/Logger.h" -#include "FPGA_Mini.h" -#include "comms/USB/USBDMAEmulation.h" + +#include "comms/IComms.h" +#include "chips/Si5351C/Si5351C.h" #include "chips/LMS7002M/validation.h" #include "chips/LMS7002M/LMS7002MCSR_Data.h" +#include "comms/ISerialPort.h" +#include "comms/SPI_utilities.h" +#include "comms/USB/IUSB.h" +#include "comms/USB/FT601/FT601.h" +#include "comms/USB/USBDMAEmulation.h" + +#include "protocols/LMSBoards.h" #include "protocols/LMS64CProtocol.h" + #include "DeviceTreeNode.h" -#include "comms/IComms.h" -#include "ISerialPort.h" -#include "comms/USB/FT601/FT601.h" -#include "comms/SPI_utilities.h" #include "streaming/TRXLooper.h" -#include -#include -#include -#include -#include +#include "FPGA_Mini.h" using namespace lime; using namespace lime::LMS64CProtocol; using namespace lime::LMS7002MCSR_Data; using namespace std::literals::string_literals; +namespace limesdrmini { + static const uint8_t SPI_LMS7002M = 0; static const uint8_t SPI_FPGA = 1; @@ -134,6 +139,8 @@ static const std::vector> lms7002defaultsOverrides { 0x040C, 0x00FB } }; +} // namespace limesdrmini + /// @brief Constructs a new LimeSDR_Mini object /// @param spiLMS The communications port to the LMS7002M chip. /// @param spiFPGA The communications port to the device's FPGA. @@ -160,10 +167,10 @@ LimeSDR_Mini::LimeSDR_Mini(std::shared_ptr spiLMS, FPGA::GatewareInfo gw = mFPGA->GetGatewareInfo(); FPGA::GatewareToDescriptor(gw, descriptor); - descriptor.customParameters.push_back(CP_VCTCXO_DAC); + descriptor.customParameters.push_back(limesdrmini::CP_VCTCXO_DAC); if (descriptor.name == GetDeviceName(LMS_DEV_LIMESDRMINI_V2)) { - descriptor.customParameters.push_back(CP_TEMPERATURE); + descriptor.customParameters.push_back(limesdrmini::CP_TEMPERATURE); } { @@ -178,9 +185,9 @@ LimeSDR_Mini::LimeSDR_Mini(std::shared_ptr spiLMS, std::unique_ptr chip = std::make_unique(mlms7002mPort); if (gw.hardwareVersion >= 2) - chip->ModifyRegistersDefaults(lms7002defaultsOverrides_1v2); + chip->ModifyRegistersDefaults(limesdrmini::lms7002defaultsOverrides_1v2); else - chip->ModifyRegistersDefaults(lms7002defaultsOverrides_1v0); + chip->ModifyRegistersDefaults(limesdrmini::lms7002defaultsOverrides_1v0); chip->SetOnCGENChangeCallback(UpdateFPGAInterface, this); chip->SetReferenceClk_SX(TRXDir::Rx, refClk); mLMSChips.push_back(std::move(chip)); @@ -196,7 +203,7 @@ LimeSDR_Mini::LimeSDR_Mini(std::shared_ptr spiLMS, std::static_pointer_cast(rxdma), std::static_pointer_cast(txdma), mFPGA.get(), mLMSChips.at(0).get(), 0)); } - descriptor.spiSlaveIds = { { "LMS7002M"s, SPI_LMS7002M }, { "FPGA"s, SPI_FPGA } }; + descriptor.spiSlaveIds = { { "LMS7002M"s, limesdrmini::SPI_LMS7002M }, { "FPGA"s, limesdrmini::SPI_FPGA } }; auto fpgaNode = std::make_shared("FPGA"s, eDeviceTreeNodeClass::FPGA_MINI, mFPGA.get()); fpgaNode->children.push_back( @@ -370,9 +377,9 @@ OpStatus LimeSDR_Mini::SPI(uint32_t chipSelect, const uint32_t* MOSI, uint32_t* { switch (chipSelect) { - case SPI_LMS7002M: + case limesdrmini::SPI_LMS7002M: return mlms7002mPort->SPI(0, MOSI, MISO, count); - case SPI_FPGA: + case limesdrmini::SPI_FPGA: return mfpgaPort->SPI(MOSI, MISO, count); default: throw std::logic_error("LimeSDR_Mini SPI invalid SPI chip select"s); diff --git a/src/boards/LimeSDR_Mini/LimeSDR_Mini.h b/src/boards/LimeSDR_Mini/LimeSDR_Mini.h index 39cf22c8..e0c07bc8 100644 --- a/src/boards/LimeSDR_Mini/LimeSDR_Mini.h +++ b/src/boards/LimeSDR_Mini/LimeSDR_Mini.h @@ -2,7 +2,6 @@ #define LIME_LIMESDR_MINI_H #include "LMS7002M_SDRDevice.h" -#include "protocols/LMS64CProtocol.h" #include #include @@ -10,6 +9,7 @@ namespace lime { class IComms; +class ISerialPort; class IUSB; /** @brief Class for managing the LimeSDR Mini device. */ diff --git a/src/boards/LimeSDR_X3/LimeSDR_X3.cpp b/src/boards/LimeSDR_X3/LimeSDR_X3.cpp index c0a81b89..2690802b 100644 --- a/src/boards/LimeSDR_X3/LimeSDR_X3.cpp +++ b/src/boards/LimeSDR_X3/LimeSDR_X3.cpp @@ -9,7 +9,7 @@ #include "limesuiteng/LMS7002M.h" #include "FPGA/FPGA_common.h" #include "FPGA_X3.h" -#include "LMS64CProtocol.h" +#include "protocols/LMS64CProtocol.h" #include "DSP/CFR/CrestFactorReduction.h" #include "DeviceTreeNode.h" #include "limesuiteng/SDRDescriptor.h" @@ -24,10 +24,11 @@ #include -namespace lime { +using namespace std::literals::string_literals; using namespace lime::LMS7002MCSR_Data; -using namespace std::literals::string_literals; +namespace lime { +namespace limesdrx3 { // X3 board specific subdevice ids static const uint8_t SPI_LMS7002M_1 = 0; @@ -140,11 +141,7 @@ static const std::vector> lms2and3defaultsOverride { 0x040C, 0x00FB }, }; -static inline void ValidateChannel(uint8_t channel) -{ - if (channel > 2) - throw std::logic_error("invalid channel index"s); -} +} // namespace limesdrx3 // Callback for updating FPGA's interface clocks when LMS7002M CGEN is manually modified OpStatus LimeSDR_X3::LMS1_UpdateFPGAInterface(void* userData) @@ -181,17 +178,17 @@ LimeSDR_X3::LimeSDR_X3(std::shared_ptr spiLMS7002M, LMS64CProtocol::GetFirmwareInfo(*control, fw); LMS64CProtocol::FirmwareToDescriptor(fw, desc); - mLMS7002Mcomms[0] = std::make_shared(spiLMS7002M, SPI_LMS7002M_1); + mLMS7002Mcomms[0] = std::make_shared(spiLMS7002M, limesdrx3::SPI_LMS7002M_1); mFPGA = std::make_unique(spiFPGA, mLMS7002Mcomms[0]); FPGA::GatewareInfo gw = mFPGA->GetGatewareInfo(); FPGA::GatewareToDescriptor(gw, desc); desc.spiSlaveIds = { - { "LMS7002M_1"s, SPI_LMS7002M_1 }, - { "LMS7002M_2"s, SPI_LMS7002M_2 }, - { "LMS7002M_3"s, SPI_LMS7002M_3 }, - { "FPGA"s, SPI_FPGA }, + { "LMS7002M_1"s, limesdrx3::SPI_LMS7002M_1 }, + { "LMS7002M_2"s, limesdrx3::SPI_LMS7002M_2 }, + { "LMS7002M_3"s, limesdrx3::SPI_LMS7002M_3 }, + { "FPGA"s, limesdrx3::SPI_FPGA }, }; const std::unordered_map eepromMap = { { "VCTCXO_DAC"s, { 16, 2 } } }; @@ -199,10 +196,10 @@ LimeSDR_X3::LimeSDR_X3(std::shared_ptr spiLMS7002M, desc.memoryDevices[ToString(eMemoryDevice::FPGA_FLASH)] = std::make_shared(this, eMemoryDevice::FPGA_FLASH); desc.memoryDevices[ToString(eMemoryDevice::EEPROM)] = std::make_shared(this, eMemoryDevice::EEPROM, eepromMap); - desc.customParameters.push_back(cp_vctcxo_dac); - desc.customParameters.push_back(cp_temperature); + desc.customParameters.push_back(limesdrx3::cp_vctcxo_dac); + desc.customParameters.push_back(limesdrx3::cp_temperature); - mEqualizer = std::make_unique(std::make_shared(spiFPGA, SPI_FPGA)); + mEqualizer = std::make_unique(std::make_shared(spiFPGA, limesdrx3::SPI_FPGA)); mClockGeneratorCDCM = std::make_unique(spiFPGA, CDCM2_BASE_ADDR); // TODO: read back cdcm values or mClockGeneratorCDCM->Reset(30.72e6, 25e6); @@ -213,7 +210,7 @@ LimeSDR_X3::LimeSDR_X3(std::shared_ptr spiLMS7002M, desc.rfSOC.push_back(soc); std::unique_ptr lms1 = std::make_unique(mLMS7002Mcomms[0]); - lms1->ModifyRegistersDefaults(lms1defaultsOverride); + lms1->ModifyRegistersDefaults(limesdrx3::lms1defaultsOverride); lms1->SetOnCGENChangeCallback(LMS1_UpdateFPGAInterface, this); mLMSChips.push_back(std::move(lms1)); } @@ -226,9 +223,9 @@ LimeSDR_X3::LimeSDR_X3(std::shared_ptr spiLMS7002M, soc.pathNames[TRXDir::Tx] = { "None"s, "TDD"s, "FDD"s }; desc.rfSOC.push_back(soc); - mLMS7002Mcomms[1] = std::make_shared(spiLMS7002M, SPI_LMS7002M_2); + mLMS7002Mcomms[1] = std::make_shared(spiLMS7002M, limesdrx3::SPI_LMS7002M_2); std::unique_ptr lms2 = std::make_unique(mLMS7002Mcomms[1]); - lms2->ModifyRegistersDefaults(lms2and3defaultsOverride); + lms2->ModifyRegistersDefaults(limesdrx3::lms2and3defaultsOverride); mLMSChips.push_back(std::move(lms2)); } @@ -239,9 +236,9 @@ LimeSDR_X3::LimeSDR_X3(std::shared_ptr spiLMS7002M, soc.pathNames[TRXDir::Rx] = { "None"s, "LNAH"s, "Calibration(LMS2)"s }; soc.pathNames[TRXDir::Tx] = { "None"s, "Band1"s }; desc.rfSOC.push_back(soc); - mLMS7002Mcomms[2] = std::make_shared(spiLMS7002M, SPI_LMS7002M_3); + mLMS7002Mcomms[2] = std::make_shared(spiLMS7002M, limesdrx3::SPI_LMS7002M_3); std::unique_ptr lms3 = std::make_unique(mLMS7002Mcomms[2]); - lms3->ModifyRegistersDefaults(lms2and3defaultsOverride); + lms3->ModifyRegistersDefaults(limesdrx3::lms2and3defaultsOverride); mLMSChips.push_back(std::move(lms3)); } @@ -285,7 +282,8 @@ OpStatus LimeSDR_X3::InitLMS1(bool skipTune) LMS1_PA_Enable(1, false); double dacVal = 65535; - const std::vector params{ { cp_lms1_tx1dac.id, dacVal, ""s }, { cp_lms1_tx2dac.id, dacVal, ""s } }; + const std::vector params{ { limesdrx3::cp_lms1_tx1dac.id, dacVal, ""s }, + { limesdrx3::cp_lms1_tx2dac.id, dacVal, ""s } }; CustomParameterWrite(params); OpStatus status; @@ -821,14 +819,12 @@ OpStatus LimeSDR_X3::SetSampleRate(uint8_t moduleIndex, TRXDir trx, uint8_t chan double LimeSDR_X3::GetClockFreq(uint8_t clk_id, uint8_t channel) { - ValidateChannel(channel); auto& chip = mLMSChips.at(channel / 2); return chip->GetClockFreq(static_cast(clk_id)); } OpStatus LimeSDR_X3::SetClockFreq(uint8_t clk_id, double freq, uint8_t channel) { - ValidateChannel(channel); auto& chip = mLMSChips.at(channel / 2); return chip->SetClockFreq(static_cast(clk_id), freq); } @@ -837,13 +833,13 @@ OpStatus LimeSDR_X3::SPI(uint32_t chipSelect, const uint32_t* MOSI, uint32_t* MI { switch (chipSelect) { - case SPI_LMS7002M_1: + case limesdrx3::SPI_LMS7002M_1: return mLMS7002Mcomms[0]->SPI(MOSI, MISO, count); - case SPI_LMS7002M_2: + case limesdrx3::SPI_LMS7002M_2: return mLMS7002Mcomms[1]->SPI(MOSI, MISO, count); - case SPI_LMS7002M_3: + case limesdrx3::SPI_LMS7002M_3: return mLMS7002Mcomms[2]->SPI(MOSI, MISO, count); - case SPI_FPGA: + case limesdrx3::SPI_FPGA: return mfpgaPort->SPI(MOSI, MISO, count); default: throw std::logic_error("invalid SPI chip select"s); @@ -913,17 +909,6 @@ void LimeSDR_X3::LMS1_SetSampleRate(double f_Hz, uint8_t rxDecimation, uint8_t t mLMSChip->SetInterfaceFrequency(cgenFreq, hbi_ovr, hbd_ovr); } -enum // TODO: replace -{ - LMS_PATH_NONE = 0, ///WriteRegister(sw_addr, sw_val); - lms->SetBandTRF(path); + lms->SetBandTRF(pathId); } else { - uint8_t path; switch (ePathLMS1_Rx(pathId)) { + case ePathLMS1_Rx::LNAW: + lime::warning("LNAW has no connection to RF ports"s); case ePathLMS1_Rx::NONE: - path = static_cast(LMS7002M::PathRFE::NONE); break; case ePathLMS1_Rx::LNAH: - path = static_cast(LMS7002M::PathRFE::LNAH); + sw_val |= 1 << (11 - chan); break; case ePathLMS1_Rx::LNAL: - path = static_cast(LMS7002M::PathRFE::LNAL); + sw_val &= ~(1UL << (11 - chan)); break; - // TODO: - //case ePathLMS1_Rx::LNAW : path = LMS7002M::LNAW; break; - default: - throw std::logic_error("Invalid LMS1 Rx path"s); } - - if (path == LMS_PATH_LNAW) - lime::warning("LNAW has no connection to RF ports"s); - else if (path == LMS_PATH_LNAH) - sw_val |= 1 << (11 - chan); - else if (path == LMS_PATH_LNAL) - sw_val &= ~(1UL << (11 - chan)); - mFPGA->WriteRegister(sw_addr, sw_val); - lms->SetPathRFE(lime::LMS7002M::PathRFE(path)); + lms->SetPathRFE(lime::LMS7002M::PathRFE(pathId)); } } @@ -1121,18 +1086,18 @@ void LimeSDR_X3::LMS3SetPath(TRXDir dir, uint8_t chan, uint8_t path) lms->SetBandTRF(path); else { - if (path == LMS_PATH_NONE || path > 2) + if (path == static_cast(ePathLMS3_Rx::NONE) || path > 2) { - lms->SetPathRFE(lime::LMS7002M::PathRFE(LMS_PATH_NONE)); + lms->SetPathRFE(lime::LMS7002M::PathRFE(path)); return; } - else if (path == LMS_PATH_LNAH) + else if (path == static_cast(ePathLMS3_Rx::LNAH)) sw_val &= ~(1 << (chan - 4)); else if (path == 2) // Calibration path sw_val |= 1 << (chan - 4); mFPGA->WriteRegister(sw_addr, sw_val); - lms->SetPathRFE(lime::LMS7002M::PathRFE(LMS_PATH_LNAH)); + lms->SetPathRFE(lime::LMS7002M::PathRFE(ePathLMS3_Rx::LNAH)); } } diff --git a/src/boards/LimeSDR_X3/LimeSDR_X3.h b/src/boards/LimeSDR_X3/LimeSDR_X3.h index d1f20721..c5fbbfd6 100644 --- a/src/boards/LimeSDR_X3/LimeSDR_X3.h +++ b/src/boards/LimeSDR_X3/LimeSDR_X3.h @@ -67,10 +67,11 @@ class LimeSDR_X3 : public LMS7002M_SDRDevice void LMS2_SetSampleRate(double f_Hz, uint8_t oversample); - enum class ePathLMS1_Rx : uint8_t { NONE, LNAH, LNAL }; + enum class ePathLMS1_Rx : uint8_t { NONE, LNAH, LNAL, LNAW }; enum class ePathLMS1_Tx : uint8_t { NONE, BAND1, BAND2 }; enum class ePathLMS2_Rx : uint8_t { NONE, TDD, FDD, CALIBRATION }; enum class ePathLMS2_Tx : uint8_t { NONE, TDD, FDD }; + enum class ePathLMS3_Rx : uint8_t { NONE, LNAH, LNAL, LNAW }; void ConfigureDirection(TRXDir dir, LMS7002M& chip, const SDRConfig& cfg, int ch, uint8_t socIndex); void SetLMSPath(const TRXDir dir, const ChannelConfig::Direction& trx, const int ch, const uint8_t socIndex); diff --git a/src/boards/LimeSDR_XTRX/LimeSDR_XTRX.cpp b/src/boards/LimeSDR_XTRX/LimeSDR_XTRX.cpp index 6ede4048..bc273eb2 100644 --- a/src/boards/LimeSDR_XTRX/LimeSDR_XTRX.cpp +++ b/src/boards/LimeSDR_XTRX/LimeSDR_XTRX.cpp @@ -1,31 +1,32 @@ #include "LimeSDR_XTRX.h" -#include +#include "limesuiteng/Logger.h" +#include "limesuiteng/LMS7002M.h" + #include +#include -#include "limesuiteng/Logger.h" +#include "chips/LMS7002M/validation.h" +#include "chips/LMS7002M/LMS7002MCSR_Data.h" +#include "comms/IComms.h" #include "comms/PCIe/LimePCIe.h" #include "comms/PCIe/LimePCIeDMA.h" #include "FPGA/FPGA_common.h" #include "FPGA_XTRX.h" -#include "LMS64CProtocol.h" -#include "CommonFunctions.h" +#include "protocols/LMS64CProtocol.h" +#include "streaming/TRXLooper.h" #include "utilities/toString.h" -#include "OEMTesting.h" +#include "CommonFunctions.h" #include "DeviceTreeNode.h" -#include "comms/IComms.h" -#include "chips/LMS7002M/validation.h" -#include "chips/LMS7002M/LMS7002MCSR_Data.h" -#include "streaming/TRXLooper.h" +#include "OEMTesting.h" -#include "limesuiteng/LMS7002M.h" +using namespace std::literals::string_literals; +using namespace lime::LMS7002MCSR_Data; namespace lime { -using namespace LMS7002MCSR_Data; - -using namespace std::literals::string_literals; +namespace limesdrxtrx { // XTRX board specific devices ids and data static const uint8_t SPI_LMS7002M = 0; static const uint8_t SPI_FPGA = 1; @@ -100,11 +101,7 @@ static const std::vector> lms7002defaultsOverrides { 0x040C, 0x01FF }, }; -static inline void ValidateChannel(uint8_t channel) -{ - if (channel > 2) - throw std::logic_error("invalid channel index"s); -} +} // namespace limesdrxtrx // Callback for updating FPGA's interface clocks when LMS7002M CGEN is manually modified OpStatus LimeSDR_XTRX::LMS1_UpdateFPGAInterface(void* userData) @@ -145,7 +142,7 @@ LimeSDR_XTRX::LimeSDR_XTRX(std::shared_ptr spiRFsoc, LMS64CProtocol::GetFirmwareInfo(*mSerialPort, fw); LMS64CProtocol::FirmwareToDescriptor(fw, desc); - desc.spiSlaveIds = { { "LMS7002M"s, SPI_LMS7002M }, { "FPGA"s, SPI_FPGA } }; + desc.spiSlaveIds = { { "LMS7002M"s, limesdrxtrx::SPI_LMS7002M }, { "FPGA"s, limesdrxtrx::SPI_FPGA } }; // const std::unordered_map flashMap = { { "VCTCXO_DAC"s, { 0x01FF0000, 2 } } }; desc.memoryDevices[ToString(eMemoryDevice::FPGA_FLASH)] = std::make_shared(this, eMemoryDevice::FPGA_FLASH); @@ -160,7 +157,7 @@ LimeSDR_XTRX::LimeSDR_XTRX(std::shared_ptr spiRFsoc, std::make_shared(this, eMemoryDevice::EEPROM, std::move(eepromMap)); } - desc.customParameters = { cp_vctcxo_dac, cp_temperature }; + desc.customParameters = { limesdrxtrx::cp_vctcxo_dac, limesdrxtrx::cp_temperature }; mFPGA = std::make_unique(spiFPGA, spiRFsoc); FPGA::GatewareInfo gw = mFPGA->GetGatewareInfo(); @@ -211,9 +208,9 @@ LimeSDR_XTRX::LimeSDR_XTRX(std::shared_ptr spiRFsoc, std::unique_ptr chip = std::make_unique(spiRFsoc); if (isFairwavesRev5) - chip->ModifyRegistersDefaults(lms7002defaultsOverrides_fairwaves_xtrx_rev5); + chip->ModifyRegistersDefaults(limesdrxtrx::lms7002defaultsOverrides_fairwaves_xtrx_rev5); else // LimeSDR XTRX - chip->ModifyRegistersDefaults(lms7002defaultsOverrides_limesdr_xtrx); + chip->ModifyRegistersDefaults(limesdrxtrx::lms7002defaultsOverrides_limesdr_xtrx); chip->SetOnCGENChangeCallback(LMS1_UpdateFPGAInterface, this); chip->SetReferenceClk_SX(TRXDir::Rx, refClk); chip->SetClockFreq(LMS7002M::ClockID::CLK_REFERENCE, refClk); @@ -380,14 +377,12 @@ OpStatus LimeSDR_XTRX::SetSampleRate(uint8_t moduleIndex, TRXDir trx, uint8_t ch double LimeSDR_XTRX::GetClockFreq(uint8_t clk_id, uint8_t channel) { - ValidateChannel(channel); auto& chip = mLMSChips.at(channel / 2); return chip->GetClockFreq(static_cast(clk_id)); } OpStatus LimeSDR_XTRX::SetClockFreq(uint8_t clk_id, double freq, uint8_t channel) { - ValidateChannel(channel); auto& chip = mLMSChips.at(channel / 2); return chip->SetClockFreq(static_cast(clk_id), freq); } @@ -396,9 +391,9 @@ OpStatus LimeSDR_XTRX::SPI(uint32_t chipSelect, const uint32_t* MOSI, uint32_t* { switch (chipSelect) { - case SPI_LMS7002M: + case limesdrxtrx::SPI_LMS7002M: return lms7002mPort->SPI(MOSI, MISO, count); - case SPI_FPGA: + case limesdrxtrx::SPI_FPGA: return fpgaPort->SPI(MOSI, MISO, count); default: throw std::logic_error("invalid SPI chip select"s); @@ -497,17 +492,6 @@ OpStatus LimeSDR_XTRX::LMS1_SetSampleRate(double f_Hz, uint8_t rxDecimation, uin return mLMSChip->SetInterfaceFrequency(cgenFreq, hbi_ovr, hbd_ovr); } -enum // TODO: replace -{ - LMS_PATH_NONE = 0, ///SetBandTRF(path); + lms->SetBandTRF(pathId); } else { @@ -563,6 +539,7 @@ void LimeSDR_XTRX::LMS1SetPath(bool tx, uint8_t chan, uint8_t pathId) else if (path == LMS7002M::PathRFE::LNAL) sw_val |= 1 << 2; } + // TODO: if MIMO use channel 0 as deciding factor, otherwise use active channel // RF switch controls are toggled for both channels, use channel 0 as the deciding source. if (chan == 0) mFPGA->WriteRegister(sw_addr, sw_val); @@ -700,7 +677,7 @@ OpStatus LimeSDR_XTRX::VCTCXOTest(OEMTestReporter& reporter, TestData& results) unsigned count1; unsigned count2; - std::vector params{ { cp_vctcxo_dac.id, 0, "" } }; + std::vector params{ { limesdrxtrx::cp_vctcxo_dac.id, 0, "" } }; try { @@ -708,7 +685,7 @@ OpStatus LimeSDR_XTRX::VCTCXOTest(OEMTestReporter& reporter, TestData& results) // Store current value, and restore it on return CustomParameterStash vctcxoStash(this, params); - params[0].value = cp_vctcxo_dac.minValue; + params[0].value = limesdrxtrx::cp_vctcxo_dac.minValue; status = CustomParameterWrite(params); if (status != OpStatus::Success) return status; @@ -729,7 +706,7 @@ OpStatus LimeSDR_XTRX::VCTCXOTest(OEMTestReporter& reporter, TestData& results) } count1 = vals[0] + (vals[1] << 16); - params[0].value = cp_vctcxo_dac.maxValue; + params[0].value = limesdrxtrx::cp_vctcxo_dac.maxValue; if (CustomParameterWrite(params) != OpStatus::Success) { reporter.OnFail(test, "IO failure"); diff --git a/src/boards/MMX8/MM_X8.cpp b/src/boards/MMX8/MM_X8.cpp index 3365b6f1..db367df3 100644 --- a/src/boards/MMX8/MM_X8.cpp +++ b/src/boards/MMX8/MM_X8.cpp @@ -4,27 +4,31 @@ #include #include "limesuiteng/Logger.h" -#include "comms/PCIe/LimePCIe.h" #include "limesuiteng/LMS7002M.h" -#include "chips/LMS7002M/validation.h" #include "FPGA/FPGA_common.h" #include "boards/LimeSDR_XTRX/LimeSDR_XTRX.h" +#include "chips/LMS7002M/validation.h" +#include "comms/IComms.h" +#include "comms/PCIe/LimePCIe.h" #include "DeviceTreeNode.h" #include "utilities/toString.h" #include -namespace lime { - using namespace std::literals::string_literals; +namespace lime { +namespace limemmx8 { + static const char DEVICE_NUMBER_SEPARATOR_SYMBOL = '@'; static const char PATH_SEPARATOR_SYMBOL = '/'; static CustomParameter cp_vctcxo_dac = { "VCTCXO DAC (volatile)"s, 0, 0, 65535, false }; static double X8ReferenceClock = 30.72e6; +} // namespace limemmx8 + /// @brief Constructs the LimeSDR_MMX8 object. /// /// @param spiLMS7002M The communications ports to the LMS7002M chips. @@ -70,31 +74,31 @@ LimeSDR_MMX8::LimeSDR_MMX8(std::vector>& spiLMS7002M, desc.memoryDevices[ToString(eMemoryDevice::FPGA_FLASH)] = std::make_shared(this, eMemoryDevice::FPGA_FLASH); desc.memoryDevices[ToString(eMemoryDevice::EEPROM)] = std::make_shared(this, eMemoryDevice::EEPROM, eepromMap); - desc.customParameters.push_back(cp_vctcxo_dac); + desc.customParameters.push_back(limemmx8::cp_vctcxo_dac); for (size_t i = 0; i < 8; ++i) { std::unique_ptr xtrx = - std::make_unique(spiLMS7002M[i], spiFPGA[i], trxStreams[i], control, X8ReferenceClock); + std::make_unique(spiLMS7002M[i], spiFPGA[i], trxStreams[i], control, limemmx8::X8ReferenceClock); const SDRDescriptor& subdeviceDescriptor = xtrx->GetDescriptor(); for (const auto& soc : subdeviceDescriptor.rfSOC) { RFSOCDescriptor temp = soc; - temp.name = soc.name + DEVICE_NUMBER_SEPARATOR_SYMBOL + std::to_string(i + 1); + temp.name = soc.name + limemmx8::DEVICE_NUMBER_SEPARATOR_SYMBOL + std::to_string(i + 1); desc.rfSOC.push_back(temp); } for (const auto& slaveId : subdeviceDescriptor.spiSlaveIds) { - const std::string slaveName = slaveId.first + DEVICE_NUMBER_SEPARATOR_SYMBOL + std::to_string(i + 1); + const std::string slaveName = slaveId.first + limemmx8::DEVICE_NUMBER_SEPARATOR_SYMBOL + std::to_string(i + 1); desc.spiSlaveIds[slaveName] = (i + 1) << 8 | slaveId.second; chipSelectToDevice[desc.spiSlaveIds[slaveName]] = xtrx.get(); } for (const auto& memoryDevice : subdeviceDescriptor.memoryDevices) { - const std::string indexName = subdeviceDescriptor.name + DEVICE_NUMBER_SEPARATOR_SYMBOL + std::to_string(i + 1) + - PATH_SEPARATOR_SYMBOL + memoryDevice.first; + const std::string indexName = subdeviceDescriptor.name + limemmx8::DEVICE_NUMBER_SEPARATOR_SYMBOL + + std::to_string(i + 1) + limemmx8::PATH_SEPARATOR_SYMBOL + memoryDevice.first; desc.memoryDevices[indexName] = memoryDevice.second; } @@ -103,7 +107,7 @@ LimeSDR_MMX8::LimeSDR_MMX8(std::vector>& spiLMS7002M, { CustomParameter parameter = customParameter; parameter.id |= (i + 1) << 8; - parameter.name = customParameter.name + DEVICE_NUMBER_SEPARATOR_SYMBOL + std::to_string(i + 1); + parameter.name = customParameter.name + limemmx8::DEVICE_NUMBER_SEPARATOR_SYMBOL + std::to_string(i + 1); desc.customParameters.push_back(parameter); customParameterToDevice[parameter.id] = xtrx.get(); } diff --git a/src/boards/MMX8/MM_X8.h b/src/boards/MMX8/MM_X8.h index d6105c8a..85575c0f 100644 --- a/src/boards/MMX8/MM_X8.h +++ b/src/boards/MMX8/MM_X8.h @@ -3,7 +3,6 @@ #include "chips/ADF4002/ADF4002.h" #include "chips/CDCM6208/CDCM6208.h" -#include "comms/IComms.h" #include "limesuiteng/SDRDevice.h" #include "limesuiteng/SDRDescriptor.h" #include "protocols/LMS64CProtocol.h" @@ -15,6 +14,7 @@ namespace lime { +class IComms; class LimePCIe; class LimeSDR_XTRX; diff --git a/src/boards/external/XSDR/XSDR.cpp b/src/boards/external/XSDR/XSDR.cpp index 061bd91d..03f41ac4 100644 --- a/src/boards/external/XSDR/XSDR.cpp +++ b/src/boards/external/XSDR/XSDR.cpp @@ -1,6 +1,6 @@ #include "XSDR.h" -#include "LMSBoards.h" +#include "protocols/LMSBoards.h" namespace lime { diff --git a/src/chips/LMS7002M/LMS7002MCSR_Data.h b/src/chips/LMS7002M/LMS7002MCSR_Data.h index 29ca19cb..89b351b4 100644 --- a/src/chips/LMS7002M/LMS7002MCSR_Data.h +++ b/src/chips/LMS7002M/LMS7002MCSR_Data.h @@ -1,5 +1,5 @@ #pragma once -#include +#include #include #include "limesuiteng/config.h" #include "limesuiteng/Register.h" diff --git a/src/chips/LMS7002M/MCU_BD.cpp b/src/chips/LMS7002M/MCU_BD.cpp index bda05e6e..fb2b1e36 100644 --- a/src/chips/LMS7002M/MCU_BD.cpp +++ b/src/chips/LMS7002M/MCU_BD.cpp @@ -10,7 +10,7 @@ using namespace std; #include "MCU_File.h" #include #include -#include +#include #include #include #include "limesuiteng/LMS7002M.h" diff --git a/src/chips/LMS7002M/MCU_File.h b/src/chips/LMS7002M/MCU_File.h index 59101538..a7063c75 100644 --- a/src/chips/LMS7002M/MCU_File.h +++ b/src/chips/LMS7002M/MCU_File.h @@ -4,7 +4,7 @@ #include "limesuiteng/config.h" #include -#include +#include #include #include diff --git a/src/chips/LMS7002M/filtersCalibration.cpp b/src/chips/LMS7002M/filtersCalibration.cpp index d228bbb4..16e9e0f0 100644 --- a/src/chips/LMS7002M/filtersCalibration.cpp +++ b/src/chips/LMS7002M/filtersCalibration.cpp @@ -10,7 +10,7 @@ #include "LMS7002MCSR_Data.h" #include #include -#include +#include #include "MCU_BD.h" #include "mcu_programs.h" diff --git a/src/chips/LMS7002M/gainCalibrations.cpp b/src/chips/LMS7002M/gainCalibrations.cpp index bf79c564..fc04770a 100644 --- a/src/chips/LMS7002M/gainCalibrations.cpp +++ b/src/chips/LMS7002M/gainCalibrations.cpp @@ -136,8 +136,7 @@ OpStatus LMS7002M::CalibrateTxGain() uint32_t previousRSSI = GetRSSI(); lime::debug("CG_IAMP_TBB(%i) RSSI:0x%08X approx. %+2.2f dBFS", cg_iamp, previousRSSI, chip_rssi_to_dbfs(previousRSSI)); - // while (GetRSSI() < 0x7FFF) - while(GetRSSI() < 0xFD00) + while (GetRSSI() < 0xFD00) { ++cg_iamp; if (cg_iamp > 63) diff --git a/src/chips/LMS7002M/mcu_programs.h b/src/chips/LMS7002M/mcu_programs.h index 62518a38..fd4cada5 100644 --- a/src/chips/LMS7002M/mcu_programs.h +++ b/src/chips/LMS7002M/mcu_programs.h @@ -2,7 +2,7 @@ #define LMS7_MCU_PROGRAMS_H #include "limesuiteng/config.h" -#include +#include #define MCU_PROGRAM_SIZE 16384 diff --git a/src/protocols/ISerialPort.h b/src/comms/ISerialPort.h similarity index 100% rename from src/protocols/ISerialPort.h rename to src/comms/ISerialPort.h diff --git a/src/comms/PCIe/LimePCIe.cpp b/src/comms/PCIe/LimePCIe.cpp index cb6560b9..1e972613 100644 --- a/src/comms/PCIe/LimePCIe.cpp +++ b/src/comms/PCIe/LimePCIe.cpp @@ -1,12 +1,12 @@ #include "comms/PCIe/LimePCIe.h" +#include "limesuiteng/Logger.h" + #include #include -#include +#include #include -#include -#include "limesuiteng/Logger.h" -#include "LMS64CProtocol.h" +#include "protocols/LMS64CProtocol.h" #ifdef __unix__ #include @@ -105,10 +105,8 @@ OpStatus LimePCIe::RunControlCommand(uint8_t* request, uint8_t* response, size_t return OpStatus::Busy; case ETIMEDOUT: case -ETIMEDOUT: - lime::error("control command timeout"); return OpStatus::Timeout; default: - lime::error("Unable to send control packet"); return OpStatus::IOFailure; } diff --git a/src/comms/PCIe/PCIE_CSR_Pipe.h b/src/comms/PCIe/PCIE_CSR_Pipe.h index f1c3731f..8b38d677 100644 --- a/src/comms/PCIe/PCIE_CSR_Pipe.h +++ b/src/comms/PCIe/PCIE_CSR_Pipe.h @@ -1,7 +1,7 @@ #ifndef PCIE_CSR_PIPE_H #define PCIE_CSR_PIPE_H -#include "ISerialPort.h" +#include "comms/ISerialPort.h" #include "comms/PCIe/LimePCIe.h" #include diff --git a/src/comms/USB/LMS64C_ADF4002_Over_USB.h b/src/comms/USB/LMS64C_ADF4002_Over_USB.h index b66ed180..8cc32fad 100644 --- a/src/comms/USB/LMS64C_ADF4002_Over_USB.h +++ b/src/comms/USB/LMS64C_ADF4002_Over_USB.h @@ -1,5 +1,4 @@ -#ifndef LIME_LMS64C_LMS7002M_OVER_USB_H -#define LIME_LMS64C_LMS7002M_OVER_USB_H +#pragma once #include "comms/IComms.h" #include "USB_CSR_Pipe.h" @@ -21,5 +20,3 @@ class LMS64C_ADF4002_Over_USB : public IComms }; } // namespace lime - -#endif // LIME_LMS64C_LMS7002M_OVER_USB_H diff --git a/src/comms/USB/USB_CSR_Pipe.h b/src/comms/USB/USB_CSR_Pipe.h index 22e52ed6..bdd7cfb5 100644 --- a/src/comms/USB/USB_CSR_Pipe.h +++ b/src/comms/USB/USB_CSR_Pipe.h @@ -1,7 +1,7 @@ #ifndef LIME_USB_CSR_PIPE_H #define LIME_USB_CSR_PIPE_H -#include "ISerialPort.h" +#include "comms/ISerialPort.h" namespace lime { diff --git a/src/comms/USB/UnixUsb.cpp b/src/comms/USB/UnixUsb.cpp index 17ab1729..d169f29d 100644 --- a/src/comms/USB/UnixUsb.cpp +++ b/src/comms/USB/UnixUsb.cpp @@ -302,7 +302,7 @@ int32_t UnixUsb::BulkTransfer(uint8_t endPointAddr, uint8_t* data, size_t length { assert(data); if (!IsConnected()) - throw std::runtime_error("BulkTransfer: USB device is not connected"s); + return static_cast(OpStatus::NotConnected); int actualTransferred = 0; int status = libusb_bulk_transfer(dev_handle, endPointAddr, data, length, &actualTransferred, timeout_ms); diff --git a/src/examples/CMakeLists.txt b/src/examples/CMakeLists.txt index 407e33de..d3e871e1 100644 --- a/src/examples/CMakeLists.txt +++ b/src/examples/CMakeLists.txt @@ -20,40 +20,40 @@ add_executable(basicRX basicRX.cpp) set_target_properties(basicRX PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${examplesOutputDir}) target_link_libraries( basicRX - PUBLIC limesuiteng - PRIVATE cli-shared kissfft taywee::args) + PRIVATE limesuiteng + PRIVATE cli-shared kissfft) add_executable(dualRXTX dualRXTX.cpp) set_target_properties(dualRXTX PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${examplesOutputDir}) -target_link_libraries(dualRXTX PUBLIC limesuiteng) +target_link_libraries(dualRXTX PRIVATE limesuiteng) add_executable(basicTX basicTX.cpp) set_target_properties(basicTX PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${examplesOutputDir}) target_link_libraries( basicTX - PUBLIC limesuiteng + PRIVATE limesuiteng PRIVATE cli-shared kissfft taywee::args) add_executable(legacyBasicRX legacy/basicRX.cpp) set_target_properties(legacyBasicRX PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${examplesOutputDir}/legacy RUNTIME_OUTPUT_NAME basicRX) -target_link_libraries(legacyBasicRX PUBLIC limesuiteng) +target_link_libraries(legacyBasicRX PRIVATE limesuiteng) add_executable(legacyBasicTX legacy/basicTX.cpp) set_target_properties(legacyBasicTX PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${examplesOutputDir}/legacy RUNTIME_OUTPUT_NAME basicTX) -target_link_libraries(legacyBasicTX PUBLIC limesuiteng) +target_link_libraries(legacyBasicTX PRIVATE limesuiteng) add_executable(legacyDualRXTX legacy/dualRXTX.cpp) set_target_properties(legacyDualRXTX PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${examplesOutputDir}/legacy RUNTIME_OUTPUT_NAME dualRXTX) -target_link_libraries(legacyDualRXTX PUBLIC limesuiteng) +target_link_libraries(legacyDualRXTX PRIVATE limesuiteng) add_executable(legacyGpio_example legacy/gpio_example.cpp) set_target_properties( legacyGpio_example PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${examplesOutputDir}/legacy RUNTIME_OUTPUT_NAME gpio_example) -target_link_libraries(legacyGpio_example PUBLIC limesuiteng) +target_link_libraries(legacyGpio_example PRIVATE limesuiteng) add_executable(legacySingleRX legacy/singleRX.cpp) set_target_properties(legacySingleRX PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${examplesOutputDir}/legacy RUNTIME_OUTPUT_NAME singleRX) -target_link_libraries(legacySingleRX PUBLIC limesuiteng) +target_link_libraries(legacySingleRX PRIVATE limesuiteng) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") target_compile_options(legacySingleRX PRIVATE -Wno-unused-but-set-variable) endif() diff --git a/src/examples/basicRX.cpp b/src/examples/basicRX.cpp index d13fa05d..fd2efe2a 100644 --- a/src/examples/basicRX.cpp +++ b/src/examples/basicRX.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include "kiss_fft.h" #include "args.hxx" #include "common.h" diff --git a/src/examples/basicTX.cpp b/src/examples/basicTX.cpp index c890d853..192a3cd7 100644 --- a/src/examples/basicTX.cpp +++ b/src/examples/basicTX.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include "args.hxx" #include "common.h" diff --git a/src/examples/dualRXTX.cpp b/src/examples/dualRXTX.cpp index 0e8bdebf..bad4ce08 100644 --- a/src/examples/dualRXTX.cpp +++ b/src/examples/dualRXTX.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #ifdef USE_GNU_PLOT #include "gnuPlotPipe.h" #endif diff --git a/src/include/limesuiteng/Logger.h b/src/include/limesuiteng/Logger.h index 663230e4..a8d6116f 100644 --- a/src/include/limesuiteng/Logger.h +++ b/src/include/limesuiteng/Logger.h @@ -9,16 +9,13 @@ #include "limesuiteng/config.h" #include "limesuiteng/OpStatus.h" -#include -#include -#include -#include #include +#include #include namespace lime { -enum class LogLevel : uint8_t { +enum class LogLevel : std::uint8_t { Critical, //!< A critical error. The application might not be able to continue running successfully. Error, //!< An error. An operation did not complete successfully, but the application as a whole is not affected. Warning, //!< A warning. An operation completed with an unexpected result. diff --git a/src/include/limesuiteng/OpStatus.h b/src/include/limesuiteng/OpStatus.h index 4277807a..7ae089c5 100644 --- a/src/include/limesuiteng/OpStatus.h +++ b/src/include/limesuiteng/OpStatus.h @@ -1,6 +1,10 @@ #ifndef LIME_OPSTATUS_H #define LIME_OPSTATUS_H +#ifdef Success + #error unix X11 header has preprocessor define of Success. It might be included through graphics headers. +#endif + namespace lime { /// @brief The possible status codes from operations. diff --git a/src/include/limesuiteng/StreamConfig.h b/src/include/limesuiteng/StreamConfig.h index 76370adf..1543618a 100644 --- a/src/include/limesuiteng/StreamConfig.h +++ b/src/include/limesuiteng/StreamConfig.h @@ -4,30 +4,32 @@ #include "limesuiteng/config.h" #include "limesuiteng/types.h" +#include +#include + namespace lime { /// @brief Structure for holding the statistics of a stream struct StreamStats { /// @brief Structure for storing the first in first out queue statistics struct FIFOStats { - std::size_t totalCount; ///< The total amount of samples that can be in the FIFO queue. - std::size_t usedCount; ///< The amount of samples that is currently in the FIFO queue. + std::size_t totalCount{ 0 }; ///< The total amount of samples that can be in the FIFO queue. + std::size_t usedCount{ 0 }; ///< The amount of samples that is currently in the FIFO queue. /// @brief Gets the ratio of the amount of FIFO filled up. /// @return The amount of FIFO filled up (0 - completely empty, 1 - completely full). constexpr float ratio() const { return static_cast(usedCount) / totalCount; } }; - StreamStats() { std::memset(this, 0, sizeof(StreamStats)); } - uint64_t timestamp; ///< The current timestamp of the stream. - int64_t bytesTransferred; ///< The total amount of bytes transferred. - int64_t packets; ///< The total amount of packets transferred. + uint64_t timestamp{ 0 }; ///< The current timestamp of the stream. + int64_t bytesTransferred{ 0 }; ///< The total amount of bytes transferred. + int64_t packets{ 0 }; ///< The total amount of packets transferred. FIFOStats FIFO; ///< The status of the FIFO queue. - float dataRate_Bps; ///< The current data transmission rate. - uint32_t overrun; ///< The amount of packets overrun. - uint32_t underrun; ///< The amount of packets underrun. - uint32_t loss; ///< The amount of packets that are lost. - uint32_t late; ///< The amount of packets that arrived late for transmitting and were dropped. + float dataRate_Bps{ 0 }; ///< The current data transmission rate. + uint32_t overrun{ 0 }; ///< The amount of packets overrun. + uint32_t underrun{ 0 }; ///< The amount of packets underrun. + uint32_t loss{ 0 }; ///< The amount of packets that are lost. + uint32_t late{ 0 }; ///< The amount of packets that arrived late for transmitting and were dropped. }; /// @brief Configuration settings for a stream. diff --git a/src/logger/LoggerCString.cpp b/src/logger/LoggerCString.cpp index bc2710e8..e4e3f14c 100644 --- a/src/logger/LoggerCString.cpp +++ b/src/logger/LoggerCString.cpp @@ -1,6 +1,9 @@ +#include "limesuiteng/Logger.h" + +#include + #include "rang.hpp" // terminal colors -#include "limesuiteng/Logger.h" #include "LoggerInternal.h" namespace lime { diff --git a/src/protocols/LMS64CProtocol.cpp b/src/protocols/LMS64CProtocol.cpp index 07bbfaaa..4e777b5f 100644 --- a/src/protocols/LMS64CProtocol.cpp +++ b/src/protocols/LMS64CProtocol.cpp @@ -6,7 +6,6 @@ #include "limesuiteng/Logger.h" #include "limesuiteng/SDRDescriptor.h" -#include "ISerialPort.h" #include "LMS64CProtocol.h" #include #include @@ -18,6 +17,8 @@ #include #include +#include "comms/ISerialPort.h" + using namespace std::literals::string_literals; using namespace std::literals::string_view_literals; diff --git a/src/streaming/TRXLooper.cpp b/src/streaming/TRXLooper.cpp index d1069b94..7c339be4 100644 --- a/src/streaming/TRXLooper.cpp +++ b/src/streaming/TRXLooper.cpp @@ -6,7 +6,7 @@ #include "limesuiteng/LMS7002M.h" #include "limesuiteng/Logger.h" #include "chips/LMS7002M/LMS7002MCSR_Data.h" -#include "LMSBoards.h" +#include "protocols/LMSBoards.h" #include "threadHelper.h" #include "TxBufferManager.h" #include "utilities/DeltaVariable.h" diff --git a/src/utilities/rfTest.cpp b/src/utilities/rfTest.cpp index c8cdf8d9..0bef4863 100644 --- a/src/utilities/rfTest.cpp +++ b/src/utilities/rfTest.cpp @@ -7,9 +7,9 @@ #include #include #include -#include +#include #include -#include +#include #include #include #undef USE_GNU_PLOT