From e6fcb492ad2f2f0af556d0c3ea6fb30aeafed6cf Mon Sep 17 00:00:00 2001 From: Dominykas Date: Thu, 1 Feb 2024 09:32:29 +0200 Subject: [PATCH 01/10] Change std::min std::max pair to std::clamp --- amarisoft-plugin/trx_limesuite.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/amarisoft-plugin/trx_limesuite.cpp b/amarisoft-plugin/trx_limesuite.cpp index 4cafcd915..b40b9163f 100644 --- a/amarisoft-plugin/trx_limesuite.cpp +++ b/amarisoft-plugin/trx_limesuite.cpp @@ -1044,7 +1044,7 @@ int __attribute__((visibility("default"))) trx_driver_init(TRXState* hostState) { if (val < 0 || val > 1) { - val = std::min(std::max(0.0, val), 1.0); + val = std::clamp(val, 0.0, 1.0); Log(LogLevel::WARNING, "%s out of range, clamping to %g", varname, val); } s->rxGainNorm[p] = val; @@ -1056,7 +1056,7 @@ int __attribute__((visibility("default"))) trx_driver_init(TRXState* hostState) { if (val < 0 || val > 1) { - val = std::min(std::max(0.0, val), 1.0); + val = std::clamp(val, 0.0, 1.0); Log(LogLevel::WARNING, "%s out of range, clamping to %g", varname, val); } s->txGainNorm[p] = val; From 216de85b3638aee3da386ed5a665c15b8df0aba1 Mon Sep 17 00:00:00 2001 From: Dominykas Date: Mon, 5 Feb 2024 10:27:08 +0200 Subject: [PATCH 02/10] Clean up double spaces in LMS7002M's parameter descriptions --- src/include/limesuite/LMS7002M_parameters.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/include/limesuite/LMS7002M_parameters.h b/src/include/limesuite/LMS7002M_parameters.h index 6c5623a40..42dc75bfc 100644 --- a/src/include/limesuite/LMS7002M_parameters.h +++ b/src/include/limesuite/LMS7002M_parameters.h @@ -136,7 +136,7 @@ static const struct LMS7Parameter LMS7_MODE_INTERLEAVE_AFE = { 0x0082, 12, 12, 0 static const struct LMS7Parameter LMS7_MUX_AFE_1 = { 0x0082, 11, 10, 0, "MUX_AFE_1", "Controls the MUX at the input of the ADC channel 1" }; static const struct LMS7Parameter LMS7_MUX_AFE_2 = { 0x0082, 9, 8, 0, "MUX_AFE_2", "Controls the MUX at the input of the ADC channel 2" }; static const struct LMS7Parameter LMS7_PD_AFE = { 0x0082, 5, 5, 0, "PD_AFE", "Power down control for the AFE current mirror in BIAS_TOP" }; -static const struct LMS7Parameter LMS7_PD_RX_AFE1 = { 0x0082, 4, 4, 0, "PD_RX_AFE1", "Power down control for the ADC of channel 1" }; +static const struct LMS7Parameter LMS7_PD_RX_AFE1 = { 0x0082, 4, 4, 0, "PD_RX_AFE1", "Power down control for the ADC of channel 1" }; static const struct LMS7Parameter LMS7_PD_RX_AFE2 = { 0x0082, 3, 3, 1, "PD_RX_AFE2", "Power down control for the ADC of channel 2" }; static const struct LMS7Parameter LMS7_PD_TX_AFE1 = { 0x0082, 2, 2, 0, "PD_TX_AFE1", "Power down control for the DAC of channel 1" }; static const struct LMS7Parameter LMS7_PD_TX_AFE2 = { 0x0082, 1, 1, 1, "PD_TX_AFE2", "Power down control for the DAC of channel 2" }; @@ -389,7 +389,7 @@ static const struct LMS7Parameter LMS7_EN_G_TRF = { 0x0100, 0, 0, 1, "EN_G_TRF", static const struct LMS7Parameter LMS7_F_TXPAD_TRF = { 0x0101, 15, 13, 3, "F_TXPAD_TRF", "Controls the switched capacitor at the TXPAD output. Is used for fine tuning of the TXPAD output" }; static const struct LMS7Parameter LMS7_L_LOOPB_TXPAD_TRF = { 0x0101, 12, 11, 3, "L_LOOPB_TXPAD_TRF", "Controls the loss of the of the loopback path at the TX side" }; static const struct LMS7Parameter LMS7_LOSS_LIN_TXPAD_TRF = { 0x0101, 10, 6, 0, "LOSS_LIN_TXPAD_TRF", "Controls the gain of the linearizing part of of the TXPAD" }; -static const struct LMS7Parameter LMS7_LOSS_MAIN_TXPAD_TRF = { 0x0101, 5, 1, 0, "LOSS_MAIN_TXPAD_TRF", "Controls the gain output power of the TXPAD" }; +static const struct LMS7Parameter LMS7_LOSS_MAIN_TXPAD_TRF = { 0x0101, 5, 1, 0, "LOSS_MAIN_TXPAD_TRF", "Controls the gain output power of the TXPAD" }; static const struct LMS7Parameter LMS7_EN_LOOPB_TXPAD_TRF = { 0x0101, 0, 0, 0, "EN_LOOPB_TXPAD_TRF", "Enables the TXPAD loopback path" }; static const struct LMS7Parameter LMS7_GCAS_GNDREF_TXPAD_TRF = { 0x0102, 15, 15, 0, "GCAS_GNDREF_TXPAD_TRF", "Controls if the TXPAD cascode transistor gate bias is referred to VDD or GND" }; static const struct LMS7Parameter LMS7_ICT_LIN_TXPAD_TRF = { 0x0102, 14, 10, 12, "ICT_LIN_TXPAD_TRF", "Control the bias current of the linearization section of the TXPAD" }; @@ -435,11 +435,11 @@ static const struct LMS7Parameter LMS7_PD_TIA_RFE = { 0x010C, 1, 1, 0, "PD_TIA_R static const struct LMS7Parameter LMS7_EN_G_RFE = { 0x010C, 0, 0, 1, "EN_G_RFE", "Enable control for all the RFE_1 power downs" }; static const struct LMS7Parameter LMS7_SEL_PATH_RFE = { 0x010D, 8, 7, 1, "SEL_PATH_RFE", "Selects the active path of the RXFE" }; static const struct LMS7Parameter LMS7_EN_DCOFF_RXFE_RFE = { 0x010D, 6, 6, 0, "EN_DCOFF_RXFE_RFE", "Enables the DCOFFSET block for the RXFE" }; -static const struct LMS7Parameter LMS7_EN_INSHSW_LB1_RFE = { 0x010D, 4, 4, 1, "EN_INSHSW_LB1_RFE", "Enables the input shorting switch at the input of the loopback 1 (in parallel with LNAL mixer)" }; -static const struct LMS7Parameter LMS7_EN_INSHSW_LB2_RFE = { 0x010D, 3, 3, 1, "EN_INSHSW_LB2_RFE", "Enables the input shorting switch at the input of the loopback 2 (in parallel with LNAW mixer)" }; -static const struct LMS7Parameter LMS7_EN_INSHSW_L_RFE = { 0x010D, 2, 2, 1, "EN_INSHSW_L_RFE", "Enables the input shorting switch at the input of the LNAL" }; -static const struct LMS7Parameter LMS7_EN_INSHSW_W_RFE = { 0x010D, 1, 1, 1, "EN_INSHSW_W_RFE", "Enables the input shorting switch at the input of the LNAW" }; -static const struct LMS7Parameter LMS7_EN_NEXTRX_RFE = { 0x010D, 0, 0, 0, "EN_NEXTRX_RFE", "Enables the daisy chain LO buffer going from RXFE1 to RXFE2" }; +static const struct LMS7Parameter LMS7_EN_INSHSW_LB1_RFE = { 0x010D, 4, 4, 1, "EN_INSHSW_LB1_RFE", "Enables the input shorting switch at the input of the loopback 1 (in parallel with LNAL mixer)" }; +static const struct LMS7Parameter LMS7_EN_INSHSW_LB2_RFE = { 0x010D, 3, 3, 1, "EN_INSHSW_LB2_RFE", "Enables the input shorting switch at the input of the loopback 2 (in parallel with LNAW mixer)" }; +static const struct LMS7Parameter LMS7_EN_INSHSW_L_RFE = { 0x010D, 2, 2, 1, "EN_INSHSW_L_RFE", "Enables the input shorting switch at the input of the LNAL" }; +static const struct LMS7Parameter LMS7_EN_INSHSW_W_RFE = { 0x010D, 1, 1, 1, "EN_INSHSW_W_RFE", "Enables the input shorting switch at the input of the LNAW" }; +static const struct LMS7Parameter LMS7_EN_NEXTRX_RFE = { 0x010D, 0, 0, 0, "EN_NEXTRX_RFE", "Enables the daisy chain LO buffer going from RXFE1 to RXFE2" }; static const struct LMS7Parameter LMS7_DCOFFI_RFE = { 0x010E, 13, 7, 64, "DCOFFI_RFE", "Controls DC offset at the output of the TIA by injecting current to the input of the TIA (I side)" }; static const struct LMS7Parameter LMS7_DCOFFQ_RFE = { 0x010E, 6, 0, 64, "DCOFFQ_RFE", "Controls DC offset at the output of the TIA by injecting current to the input of the TIA (Q side)" }; static const struct LMS7Parameter LMS7_ICT_LOOPB_RFE = { 0x010F, 14, 10, 12, "ICT_LOOPB_RFE", "Controls the reference current of the RXFE loopback amplifier" }; @@ -635,7 +635,7 @@ static const struct LMS7Parameter LMS7_CMIX_GAIN_RXTSP_R3 = { 0x040C, 12, 12, 0, static const struct LMS7Parameter LMS7_R5_LPF_BYP_TBB = { 0x010B, 0, 0, 0, "R5_LPF_BYP_TBB", "Bypasses LPFS5_TBB low pass real-pole filter capacitor banks" }; static const struct LMS7Parameter LMS7_CG_IAMP_TBB_R3 = { 0x0125, 15, 10, 37, "CG_IAMP_TBB_R3", "[Alternative control] This controls the reference bias current of the IAMP's cascode transistors gate voltages that set the IAMP's input voltage level. The IAMP's input is connected to the DAC output"}; static const struct LMS7Parameter LMS7_LOSS_LIN_TXPAD_R3 = { 0x0125, 9, 5, 0, "LOSS_LIN_TXPAD_R3", "[Alternative control] Controls the gain of the linearizing part of of the TXPAD"}; -static const struct LMS7Parameter LMS7_LOSS_MAIN_TXPAD_R3 = { 0x0125, 4, 0, 0, "LOSS_MAIN_TXPAD_R3", "[Alternative control] Controls the gain output power of the TXPAD"}; +static const struct LMS7Parameter LMS7_LOSS_MAIN_TXPAD_R3 = { 0x0125, 4, 0, 0, "LOSS_MAIN_TXPAD_R3", "[Alternative control] Controls the gain output power of the TXPAD"}; static const struct LMS7Parameter LMS7_C_CTL_PGA_RBB_R3 = { 0x0126, 12, 11, 2, "C_CTL_PGA_RBB_R3", "[Alternative control] Control the value of the feedback capacitor of the PGA that is used to help against the parasitic cap at the virtual node for stability"}; static const struct LMS7Parameter LMS7_G_PGA_RBB_R3 = { 0x0126, 10, 6, 11, "G_PGA_RBB_R3", "[Alternative control] Gain of the PGA"}; static const struct LMS7Parameter LMS7_G_LNA_RFE_R3 = { 0x0126, 5, 2, 15, "G_LNA_RFE_R3", "[Alternative control] Controls the gain of the LNA"}; From 3b2614f76cb71106179e733367b76da6d9ae1e7c Mon Sep 17 00:00:00 2001 From: Dominykas Date: Tue, 6 Feb 2024 10:45:52 +0200 Subject: [PATCH 03/10] Use std::filesystem for checking if a directory exists and creating it --- src/SystemResources.in.cpp | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/SystemResources.in.cpp b/src/SystemResources.in.cpp index fac4ec4f4..fcc1ea400 100644 --- a/src/SystemResources.in.cpp +++ b/src/SystemResources.in.cpp @@ -8,6 +8,7 @@ #include "Logger.h" #include //getenv, system +#include #include #include #include @@ -28,9 +29,6 @@ #include #endif -#include -#include //stat - std::string lime::getLimeSuiteRoot(void) { //first check the environment variable @@ -173,27 +171,20 @@ int lime::downloadImageResource(const std::string& name) const std::string destFile(destDir + "/" + name); const std::string sourceUrl("https://downloads.myriadrf.org/project/limesuite/@VERSION_MAJOR@.@VERSION_MINOR@/" + name); - //check if the directory already exists - struct stat s; - if (stat(destDir.c_str(), &s) == 0) + if (std::filesystem::exists(destDir)) { - if ((s.st_mode & S_IFDIR) == 0) + if (!std::filesystem::is_directory(destDir)) { return lime::ReportError("Not a directory: %s", destDir.c_str()); } } - - //create images directory else { -#ifdef __unix__ - const std::string mkdirCmd("mkdir -p \"" + destDir + "\""); -#else - const std::string mkdirCmd("md.exe \"" + destDir + "\""); -#endif - int result = std::system(mkdirCmd.c_str()); - if (result != 0) + bool result = std::filesystem::create_directories(destDir); + if (!result) + { return lime::ReportError(result, "Failed to create directory: %s", destDir.c_str()); + } } //check for write access From c823bd50d38c397dbeab573ae4fd0b0a2a0a3de2 Mon Sep 17 00:00:00 2001 From: Dominykas Date: Fri, 23 Feb 2024 12:34:23 +0200 Subject: [PATCH 04/10] Change some arrays to std::arrays --- src/FPGA_common/FPGA_common.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/FPGA_common/FPGA_common.cpp b/src/FPGA_common/FPGA_common.cpp index e65cd46dd..d01dfb6c3 100644 --- a/src/FPGA_common/FPGA_common.cpp +++ b/src/FPGA_common/FPGA_common.cpp @@ -141,7 +141,8 @@ int FPGA::WriteRegisters(const uint32_t* addrs, const uint32_t* data, unsigned c std::vector spiBuffer; if (useCache) { - static const int readonly_regs[] = { 0x000, + static constexpr std::array readonly_regs = { + 0x000, 0x001, 0x002, 0x003, @@ -185,12 +186,12 @@ int FPGA::WriteRegisters(const uint32_t* addrs, const uint32_t* data, unsigned c 0x10F, 0x110, 0x111, - 0x114 }; + 0x114, + }; for (unsigned i = 0; i < cnt; i++) { - auto endptr = readonly_regs + sizeof(readonly_regs) / sizeof(*readonly_regs); - if (std::find(readonly_regs, endptr, addrs[i]) != endptr) + if (std::find(readonly_regs.begin(), readonly_regs.end(), addrs[i]) != readonly_regs.end()) continue; auto result = regsCache.find(addrs[i]); @@ -231,7 +232,8 @@ int FPGA::ReadRegisters(const uint32_t* addrs, uint32_t* data, unsigned cnt) std::vector spiBuffer; if (useCache) { - static const int volatile_regs[] = { 0x021, + static constexpr std::array volatile_regs = { + 0x021, 0x022, 0x060, 0x065, @@ -272,13 +274,13 @@ int FPGA::ReadRegisters(const uint32_t* addrs, uint32_t* data, unsigned cnt) 0x10F, 0x110, 0x111, - 0x114 }; + 0x114, + }; std::vector reg_addr; for (unsigned i = 0; i < cnt; i++) { - auto endptr = volatile_regs + sizeof(volatile_regs) / sizeof(*volatile_regs); - if (std::find(volatile_regs, endptr, addrs[i]) == endptr) + if (std::find(volatile_regs.begin(), volatile_regs.end(), addrs[i]) == volatile_regs.end()) { auto result = regsCache.find(addrs[i]); if (result != regsCache.end()) @@ -1190,7 +1192,7 @@ double FPGA::DetectRefClk(double fx3Clk) { verbose_printf("FPGA::DetectRefClk fx3Clk:%g\n", fx3Clk); const double fx3Cnt = 16777210; //fixed fx3 counter in FPGA - const double clkTbl[] = { 10e6, 30.72e6, 38.4e6, 40e6, 52e6 }; + const std::array clkTbl = { 10e6, 30.72e6, 38.4e6, 40e6, 52e6 }; const uint32_t addr[] = { 0x61, 0x63 }; const uint32_t vals[] = { 0x0, 0x0 }; if (WriteRegisters(addr, vals, 2) != 0) @@ -1222,10 +1224,10 @@ double FPGA::DetectRefClk(double fx3Clk) double count = (vals2[0] | (vals2[1] << 16)); //cock counter count *= fx3Clk / fx3Cnt; //estimate ref clock based on FX3 Clock lime::debug("Estimated reference clock %1.4f MHz", count / 1e6); - unsigned i = 0; + std::size_t i = 0; double delta = 100e6; - while (i < sizeof(clkTbl) / sizeof(*clkTbl)) + while (i < clkTbl.size()) if (delta < fabs(count - clkTbl[i])) break; else From 0c4eb60c1a9ced368d43153c37395ac092b46531 Mon Sep 17 00:00:00 2001 From: Dominykas Date: Fri, 23 Feb 2024 14:54:14 +0200 Subject: [PATCH 05/10] Clean up class declarations of non-existent classes --- src/boards_wxgui/pnlGPIO.h | 4 ---- src/boards_wxgui/pnlLimeSDR.h | 4 ---- src/lms7suiteApp.h | 2 -- 3 files changed, 10 deletions(-) diff --git a/src/boards_wxgui/pnlGPIO.h b/src/boards_wxgui/pnlGPIO.h index 877aed43a..935b00fb0 100644 --- a/src/boards_wxgui/pnlGPIO.h +++ b/src/boards_wxgui/pnlGPIO.h @@ -7,10 +7,6 @@ class wxStaticText; class wxCheckBox; -namespace lime { -class IConnection; -} - class pnlGPIO : public wxPanel { public: diff --git a/src/boards_wxgui/pnlLimeSDR.h b/src/boards_wxgui/pnlLimeSDR.h index 421c973b3..a2b89f6e0 100644 --- a/src/boards_wxgui/pnlLimeSDR.h +++ b/src/boards_wxgui/pnlLimeSDR.h @@ -7,10 +7,6 @@ class wxFlexGridSizer; class wxCheckBox; -namespace lime { -class IConnection; -} - class pnlGPIO; class pnlLimeSDR : public wxPanel diff --git a/src/lms7suiteApp.h b/src/lms7suiteApp.h index 129b17121..6d4626e6d 100644 --- a/src/lms7suiteApp.h +++ b/src/lms7suiteApp.h @@ -12,8 +12,6 @@ #include -class ConnectionManager; - class lms7suiteApp : public wxApp { public: From 9e4bbf2d8b2d296d4eee0c572de411d61efb7b8c Mon Sep 17 00:00:00 2001 From: Dominykas Date: Fri, 23 Feb 2024 15:10:49 +0200 Subject: [PATCH 06/10] Clean up unused CMake option --- .github/workflows/cmake.yml | 4 ++-- .github/workflows/gtest.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index e51b1cec7..940acaf64 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -57,11 +57,11 @@ jobs: - name: Configure CMake (windows) if: matrix.os == 'windows-latest' - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_EVB7COM=ON -DCMAKE_INSTALL_PREFIX=${{env.INSTALL_PREFIX}} -DwxWidgets_ROOT_DIR=${{github.workspace}}/deps/wxWidgets -DFX3_SDK_PATH=${{github.workspace}}/deps/FX3SDK + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX=${{env.INSTALL_PREFIX}} -DwxWidgets_ROOT_DIR=${{github.workspace}}/deps/wxWidgets -DFX3_SDK_PATH=${{github.workspace}}/deps/FX3SDK - name: Configure CMake (linux) if: matrix.os != 'windows-latest' - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_EVB7COM=ON -DCMAKE_INSTALL_PREFIX=${{env.INSTALL_PREFIX}} + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX=${{env.INSTALL_PREFIX}} - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} diff --git a/.github/workflows/gtest.yml b/.github/workflows/gtest.yml index 42b8106b5..4d178bc56 100644 --- a/.github/workflows/gtest.yml +++ b/.github/workflows/gtest.yml @@ -42,11 +42,11 @@ jobs: - name: Configure CMake (windows) if: matrix.os == 'windows-latest' - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_EVB7COM=ON -DCMAKE_INSTALL_PREFIX=${{env.INSTALL_PREFIX}} -DFX3_SDK_PATH=${{github.workspace}}/deps/FX3SDK -DBUILD_SHARED_LIBS=OFF + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX=${{env.INSTALL_PREFIX}} -DFX3_SDK_PATH=${{github.workspace}}/deps/FX3SDK -DBUILD_SHARED_LIBS=OFF - name: Configure CMake (linux) if: matrix.os != 'windows-latest' - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_EVB7COM=ON -DCMAKE_INSTALL_PREFIX=${{env.INSTALL_PREFIX}} -DBUILD_SHARED_LIBS=OFF -DBINARY_OUTPUT_DIR=${{github.workspace}}/build/bin/ + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX=${{env.INSTALL_PREFIX}} -DBUILD_SHARED_LIBS=OFF -DBINARY_OUTPUT_DIR=${{github.workspace}}/build/bin/ - name: Build tests run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target LimeSuite2Test From 58a842387608528551a471e8abb9ca0f1fca8f22 Mon Sep 17 00:00:00 2001 From: Dominykas Date: Fri, 23 Feb 2024 15:19:00 +0200 Subject: [PATCH 07/10] Clean up double spaces --- src/cli/CMakeLists.txt | 2 +- src/lms7002_wxgui/lms7002_pnlAFE_view.cpp | 2 +- src/lms7002_wxgui/lms7002_pnlBIST_view.cpp | 2 +- src/lms7002_wxgui/lms7002_pnlGains_view.cpp | 4 ++-- src/lms7002_wxgui/lms7002_pnlRFE_view.cpp | 10 +++++----- src/lms7002_wxgui/lms7002_pnlTRF_view.cpp | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt index ce619189b..c1b544eca 100644 --- a/src/cli/CMakeLists.txt +++ b/src/cli/CMakeLists.txt @@ -1,6 +1,6 @@ include(FeatureSummary) include(CMakeDependentOption) -cmake_dependent_option(ENABLE_CLI "Enable command line programs" ON "ENABLE_LIBRARY" ON) +cmake_dependent_option(ENABLE_CLI "Enable command line programs" ON "ENABLE_LIBRARY" ON) add_feature_info(ENABLE_CLI ENABLE_CLI "LimeSuite command line interface tools") if (NOT ENABLE_CLI) return() diff --git a/src/lms7002_wxgui/lms7002_pnlAFE_view.cpp b/src/lms7002_wxgui/lms7002_pnlAFE_view.cpp index a5223b675..59b515563 100644 --- a/src/lms7002_wxgui/lms7002_pnlAFE_view.cpp +++ b/src/lms7002_wxgui/lms7002_pnlAFE_view.cpp @@ -28,7 +28,7 @@ lms7002_pnlAFE_view::lms7002_pnlAFE_view(wxWindow* parent, wxWindowID id, const chkPD_RX_AFE1 = new wxCheckBox(sbSizerPowerDowns->GetStaticBox(), ID_PD_RX_AFE1, wxT("ADC ch. 1"), wxDefaultPosition, wxDefaultSize, 0); - chkPD_RX_AFE1->SetToolTip(wxT("Power down control for the ADC of channel 1")); + chkPD_RX_AFE1->SetToolTip(wxT("Power down control for the ADC of channel 1")); fgSizer64->Add(chkPD_RX_AFE1, 0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 0); diff --git a/src/lms7002_wxgui/lms7002_pnlBIST_view.cpp b/src/lms7002_wxgui/lms7002_pnlBIST_view.cpp index bd9e30681..045287c59 100644 --- a/src/lms7002_wxgui/lms7002_pnlBIST_view.cpp +++ b/src/lms7002_wxgui/lms7002_pnlBIST_view.cpp @@ -41,7 +41,7 @@ lms7002_pnlBIST_view::lms7002_pnlBIST_view(wxWindow* parent, wxWindowID id, cons fgSizer194->Add(chkSDM_TSTO_SXR, 0, 0, 5); chkBENT = new wxCheckBox(sbSizer123->GetStaticBox(), ID_BENT, wxT("Enable SXT BIST"), wxDefaultPosition, wxDefaultSize, 0); - chkBENT->SetToolTip(wxT("enables transmitter BIST")); + chkBENT->SetToolTip(wxT("enables transmitter BIST")); fgSizer194->Add(chkBENT, 0, flags, 0); diff --git a/src/lms7002_wxgui/lms7002_pnlGains_view.cpp b/src/lms7002_wxgui/lms7002_pnlGains_view.cpp index 61afa4866..8e553a94a 100644 --- a/src/lms7002_wxgui/lms7002_pnlGains_view.cpp +++ b/src/lms7002_wxgui/lms7002_pnlGains_view.cpp @@ -23,7 +23,7 @@ lms7002_pnlGains_view::lms7002_pnlGains_view(wxWindow* parent, wxWindowID id, co chkTRX_GAIN_SRC = new wxCheckBox(this, ID_EN_NEXTRX_RFE, wxT("Alternative TRX gain source"), wxDefaultPosition, wxDefaultSize, 0); - chkTRX_GAIN_SRC->SetToolTip(wxT("Enables the daisy chain LO buffer going from RXFE1 to RXFE2")); + chkTRX_GAIN_SRC->SetToolTip(wxT("Enables the daisy chain LO buffer going from RXFE1 to RXFE2")); fgSizer309->Add(chkTRX_GAIN_SRC, 0, wxALL, 5); @@ -115,7 +115,7 @@ lms7002_pnlGains_view::lms7002_pnlGains_view(wxWindow* parent, wxWindowID id, co cmbLOSS_MAIN_TXPAD_TRF = new wxComboBox( sbSizer148->GetStaticBox(), ID_LOSS_MAIN_TXPAD_TRF, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0); - cmbLOSS_MAIN_TXPAD_TRF->SetToolTip(wxT("Controls the gain output power of the TXPAD")); + cmbLOSS_MAIN_TXPAD_TRF->SetToolTip(wxT("Controls the gain output power of the TXPAD")); txSizer->Add(cmbLOSS_MAIN_TXPAD_TRF, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL | wxEXPAND, 0); diff --git a/src/lms7002_wxgui/lms7002_pnlRFE_view.cpp b/src/lms7002_wxgui/lms7002_pnlRFE_view.cpp index 0330c5184..ea6970a72 100644 --- a/src/lms7002_wxgui/lms7002_pnlRFE_view.cpp +++ b/src/lms7002_wxgui/lms7002_pnlRFE_view.cpp @@ -123,16 +123,16 @@ lms7002_pnlRFE_view::lms7002_pnlRFE_view(wxWindow* parent, wxWindowID id, const auto rows = { make_tuple(LMS7param(EN_INSHSW_LB1_RFE), wxT("input of loopback 1"), - wxT("Enables the input shorting switch at the input of the loopback 1 (in parallel with LNAL mixer)")), + wxT("Enables the input shorting switch at the input of the loopback 1 (in parallel with LNAL mixer)")), make_tuple(LMS7param(EN_INSHSW_LB2_RFE), wxT("input of loopback 2"), - wxT("Enables the input shorting switch at the input of the loopback 2 (in parallel with LNAW mixer)")), + wxT("Enables the input shorting switch at the input of the loopback 2 (in parallel with LNAW mixer)")), make_tuple(LMS7param(EN_INSHSW_L_RFE), wxT("input of LNAL"), - wxT("Enables the input shorting switch at the input of the LNAL")), + wxT("Enables the input shorting switch at the input of the LNAL")), make_tuple(LMS7param(EN_INSHSW_W_RFE), wxT("input of LNAW"), - wxT("Enables the input shorting switch at the input of the LNAW")) + wxT("Enables the input shorting switch at the input of the LNAW")) }; for (const auto& row : rows) sbSizerInputShorting->Add( @@ -183,7 +183,7 @@ lms7002_pnlRFE_view::lms7002_pnlRFE_view(wxWindow* parent, wxWindowID id, const fgSizer43->Add(chkEN_NEXTRX_RFE = NewCheckBox(this, LMS7param(EN_NEXTRX_RFE), wxT("Enable Rx MIMO mode"), - wxT("Enables the daisy chain LO buffer going from RXFE1 to RXFE2")), + wxT("Enables the daisy chain LO buffer going from RXFE1 to RXFE2")), 1, wxALIGN_LEFT | wxALIGN_TOP, 5); diff --git a/src/lms7002_wxgui/lms7002_pnlTRF_view.cpp b/src/lms7002_wxgui/lms7002_pnlTRF_view.cpp index 2724318a7..fdb505cdc 100644 --- a/src/lms7002_wxgui/lms7002_pnlTRF_view.cpp +++ b/src/lms7002_wxgui/lms7002_pnlTRF_view.cpp @@ -279,7 +279,7 @@ lms7002_pnlTRF_view::lms7002_pnlTRF_view(wxWindow* parent, wxWindowID id, const cmbLOSS_MAIN_TXPAD_TRF = new wxComboBox(this, ID_LOSS_MAIN_TXPAD_TRF, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0); - cmbLOSS_MAIN_TXPAD_TRF->SetToolTip(wxT("Controls the gain output power of the TXPAD")); + cmbLOSS_MAIN_TXPAD_TRF->SetToolTip(wxT("Controls the gain output power of the TXPAD")); fgSizer34->Add(cmbLOSS_MAIN_TXPAD_TRF, 0, wxEXPAND, 0); From bcdb91227bc9039c19b89df5827b4d9e5ec0a26c Mon Sep 17 00:00:00 2001 From: Dominykas Date: Mon, 26 Feb 2024 13:26:19 +0200 Subject: [PATCH 08/10] Move a header outside the no-no-old-style-cast zone --- src/lms7002m/LMS7002M.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lms7002m/LMS7002M.cpp b/src/lms7002m/LMS7002M.cpp index cbe1a5c81..42279da7e 100644 --- a/src/lms7002m/LMS7002M.cpp +++ b/src/lms7002m/LMS7002M.cpp @@ -24,11 +24,11 @@ #pragma GCC diagnostic ignored "-Wold-style-cast" #endif #include "cpp-feather-ini-parser/INI.h" -#include "lms_gfir.h" #ifdef __GNUC__ #pragma GCC diagnostic pop #endif +#include "lms_gfir.h" #include "limesuite/commonTypes.h" #include "limesuite/IComms.h" #include "LMS7002M_RegistersMap.h" From 8e2d70e8e92199c59d1e124582ee436e84b1e98a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominykas=20Petkevi=C4=8Dius?= Date: Mon, 26 Feb 2024 15:53:00 +0200 Subject: [PATCH 09/10] Fix a bug where the wrong ProgramWrite target would be used --- src/boards/LimeSDR/LimeSDR.cpp | 2 +- src/boards/LimeSDR_X3/LimeSDR_X3.cpp | 2 +- src/boards/LimeSDR_XTRX/LimeSDR_XTRX.cpp | 2 +- src/boards/MMX8/MM_X8.cpp | 2 +- src/protocols/LMS64CProtocol.cpp | 12 +++--- src/protocols/LMS64CProtocol.h | 48 ++++++++++++------------ 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/boards/LimeSDR/LimeSDR.cpp b/src/boards/LimeSDR/LimeSDR.cpp index c3237cbb0..ef209221e 100644 --- a/src/boards/LimeSDR/LimeSDR.cpp +++ b/src/boards/LimeSDR/LimeSDR.cpp @@ -744,7 +744,7 @@ OpStatus LimeSDR::UploadMemory( return OpStatus::INVALID_VALUE; } - return mfpgaPort->ProgramWrite(data, length, progMode, target, callback); + return mfpgaPort->ProgramWrite(data, length, progMode, static_cast(target), callback); } OpStatus LimeSDR::MemoryWrite(std::shared_ptr storage, Region region, const void* data) diff --git a/src/boards/LimeSDR_X3/LimeSDR_X3.cpp b/src/boards/LimeSDR_X3/LimeSDR_X3.cpp index 59f9c411b..61d98ca0c 100644 --- a/src/boards/LimeSDR_X3/LimeSDR_X3.cpp +++ b/src/boards/LimeSDR_X3/LimeSDR_X3.cpp @@ -1248,7 +1248,7 @@ OpStatus LimeSDR_X3::UploadMemory( return OpStatus::INVALID_VALUE; } - return mfpgaPort->ProgramWrite(data, length, progMode, target, callback); + return mfpgaPort->ProgramWrite(data, length, progMode, static_cast(target), callback); } OpStatus LimeSDR_X3::MemoryWrite(std::shared_ptr storage, Region region, const void* data) diff --git a/src/boards/LimeSDR_XTRX/LimeSDR_XTRX.cpp b/src/boards/LimeSDR_XTRX/LimeSDR_XTRX.cpp index 006d22fb7..d9fd0d799 100644 --- a/src/boards/LimeSDR_XTRX/LimeSDR_XTRX.cpp +++ b/src/boards/LimeSDR_XTRX/LimeSDR_XTRX.cpp @@ -571,7 +571,7 @@ OpStatus LimeSDR_XTRX::UploadMemory( return OpStatus::INVALID_VALUE; } - return fpgaPort->ProgramWrite(data, length, progMode, target, callback); + return fpgaPort->ProgramWrite(data, length, progMode, static_cast(target), callback); } OpStatus LimeSDR_XTRX::MemoryWrite(std::shared_ptr storage, Region region, const void* data) diff --git a/src/boards/MMX8/MM_X8.cpp b/src/boards/MMX8/MM_X8.cpp index 2f2955502..f36ada46d 100644 --- a/src/boards/MMX8/MM_X8.cpp +++ b/src/boards/MMX8/MM_X8.cpp @@ -710,7 +710,7 @@ OpStatus LimeSDR_MMX8::UploadMemory( int progMode = 1; LMS64CProtocol::ProgramWriteTarget target; target = LMS64CProtocol::ProgramWriteTarget::FPGA; - return mMainFPGAcomms->ProgramWrite(data, length, progMode, target, callback); + return mMainFPGAcomms->ProgramWrite(data, length, progMode, static_cast(target), callback); } SDRDevice* dev = mSubDevices.at(moduleIndex); diff --git a/src/protocols/LMS64CProtocol.cpp b/src/protocols/LMS64CProtocol.cpp index d494c3a1c..0c4147cb4 100644 --- a/src/protocols/LMS64CProtocol.cpp +++ b/src/protocols/LMS64CProtocol.cpp @@ -60,10 +60,12 @@ void LMS64CPacketMemoryWriteView::SetAddress(int addr) packet->payload[9] = addr & 0xFF; } -void LMS64CPacketMemoryWriteView::SetDevice(int device) +void LMS64CPacketMemoryWriteView::SetDevice(LMS64CProtocol::ProgramWriteTarget device) { - packet->payload[10] = (device >> 8) & 0xFF; - packet->payload[11] = device & 0xFF; + auto targetAsInteger = static_cast(device); + + packet->payload[10] = (targetAsInteger >> 8) & 0xFF; + packet->payload[11] = targetAsInteger & 0xFF; } void LMS64CPacketMemoryWriteView::SetData(const uint8_t* src, size_t len) @@ -435,7 +437,7 @@ OpStatus ProgramWrite(ISerialPort& port, eCMD_LMS cmd; if (device == ProgramWriteTarget::HPM || device == ProgramWriteTarget::FX3) cmd = CMD_MEMORY_WR; - else if (device == FPGA) + else if (device == ProgramWriteTarget::FPGA) cmd = CMD_ALTERA_FPGA_GW_WR; else { @@ -514,7 +516,7 @@ OpStatus ProgramWrite(ISerialPort& port, } #ifndef NDEBUG auto t2 = std::chrono::high_resolution_clock::now(); - if ((device == 2 && prog_mode == 2) == false) + if ((device == ProgramWriteTarget::FPGA && prog_mode == 2) == false) lime::log(LogLevel::INFO, "Programming finished, %li bytes sent! %li ms", length, diff --git a/src/protocols/LMS64CProtocol.h b/src/protocols/LMS64CProtocol.h index dc742baac..461250b30 100644 --- a/src/protocols/LMS64CProtocol.h +++ b/src/protocols/LMS64CProtocol.h @@ -28,26 +28,6 @@ struct LMS64CPacket { uint8_t payload[payloadSize]; }; -/** @brief Class for interacting with the EEPROM management packets */ -class LMS64CPacketMemoryWriteView -{ - public: - LMS64CPacketMemoryWriteView(LMS64CPacket* pkt); - void SetMode(int mode); - void SetChunkIndex(int index); - void SetChunkSize(int size); - void SetAddress(int size); - void SetDevice(int device); - void SetData(const uint8_t* src, size_t len); - - void GetData(uint8_t* dest, size_t len) const; - static constexpr size_t GetMaxDataSize(); - - private: - LMS64CPacketMemoryWriteView() = delete; - LMS64CPacket* packet; -}; - namespace LMS64CProtocol { enum eCMD_LMS { @@ -125,12 +105,10 @@ enum eCMD_STATUS { STATUS_COUNT }; -enum ProgramWriteTarget { +enum class ProgramWriteTarget : uint8_t { HPM, - FX3, // - FPGA, // prog_modes: 0-bitstream to FPGA, 1-to FLASH, 2-bitstream from FLASH - - PROGRAM_WRITE_TARGET_COUNT + FX3, + FPGA = 3u, }; struct FirmwareInfo { @@ -175,4 +153,24 @@ OpStatus MemoryRead(ISerialPort& port, uint32_t address, void* data, size_t data } // namespace LMS64CProtocol +/** @brief Class for interacting with the EEPROM management packets */ +class LMS64CPacketMemoryWriteView +{ + public: + LMS64CPacketMemoryWriteView(LMS64CPacket* pkt); + void SetMode(int mode); + void SetChunkIndex(int index); + void SetChunkSize(int size); + void SetAddress(int size); + void SetDevice(LMS64CProtocol::ProgramWriteTarget device); + void SetData(const uint8_t* src, size_t len); + + void GetData(uint8_t* dest, size_t len) const; + static constexpr size_t GetMaxDataSize(); + + private: + LMS64CPacketMemoryWriteView() = delete; + LMS64CPacket* packet; +}; + } // namespace lime From f0d3333779f0b8448a6a10b29ecd99b4daeec317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominykas=20Petkevi=C4=8Dius?= Date: Mon, 26 Feb 2024 17:00:04 +0200 Subject: [PATCH 10/10] Fix temperature reading in the GUI --- src/lms7002_wxgui/lms7002_mainPanel.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lms7002_wxgui/lms7002_mainPanel.cpp b/src/lms7002_wxgui/lms7002_mainPanel.cpp index 955889886..b7d2ea713 100644 --- a/src/lms7002_wxgui/lms7002_mainPanel.cpp +++ b/src/lms7002_wxgui/lms7002_mainPanel.cpp @@ -415,9 +415,8 @@ void lms7002_mainPanel::OnUploadAll(wxCommandEvent& event) void lms7002_mainPanel::OnReadTemperature(wxCommandEvent& event) { - double t = 0.0; - int status = -1; // TODO: LMS_GetChipTemperature(sdrDevice, 0, &t); - if (status != 0) + double t = soc->GetTemperature(); + if (t == 0) wxMessageBox(_("Failed to read chip temperature"), _("Warning")); txtTemperature->SetLabel(wxString::Format("Temperature: %.0f C", t)); }