Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/ad936x/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ message(STATUS "building package: " ${SCOPY_MODULE})
project(scopy-package-${SCOPY_MODULE} VERSION 0.1 LANGUAGES CXX)

configure_file(manifest.json.cmakein ${SCOPY_PACKAGE_BUILD_PATH}/${SCOPY_MODULE}/MANIFEST.json @ONLY)
include_emu_xml(${CMAKE_CURRENT_SOURCE_DIR}/emu-xml ${SCOPY_PACKAGE_BUILD_PATH}/${SCOPY_MODULE}/emu-xml)
include_resources(${CMAKE_CURRENT_SOURCE_DIR}/resources ${SCOPY_PACKAGE_BUILD_PATH}/${SCOPY_MODULE}/resources)
message("Including plugins")
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/plugins)
Expand Down
7 changes: 7 additions & 0 deletions packages/ad936x/emu-xml/emu_setup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"device": "fmcomms5",
"xml_path": "fmcomms5.xml",
"uri": "ip:127.0.0.1"
}
]
5 changes: 5 additions & 0 deletions packages/ad936x/emu-xml/fmcomms5.xml

Large diffs are not rendered by default.

26 changes: 24 additions & 2 deletions packages/ad936x/plugins/ad936x/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,26 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN TRUE)

file(GLOB SRC_LIST src/*.cpp src/*.cc)
file(GLOB HEADER_LIST include/${SCOPY_MODULE}/*.h include/${SCOPY_MODULE}/*.hpp)
file(
GLOB
SRC_LIST
src/*.cpp
src/*.cc
src/ad936x/*.cpp
src/ad936x/*.cc
src/fmcomms5/*.cpp
src/ad936x/*.cc
)
file(
GLOB
HEADER_LIST
include/${SCOPY_MODULE}/*.h
include/${SCOPY_MODULE}/*.hpp
include/${SCOPY_MODULE}/ad936x/*.h
include/${SCOPY_MODULE}/ad936x/*.hpp
include/${SCOPY_MODULE}/fmcomms5/*.h
include/${SCOPY_MODULE}/fmcomms5/*.hpp
)
file(GLOB UI_LIST ui/*.ui)

set(ENABLE_TESTING ON)
Expand All @@ -59,6 +77,9 @@ endif()
set(PROJECT_SOURCES ${SRC_LIST} ${HEADER_LIST} ${UI_LIST})
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS REQUIRED Widgets Core)

find_library(AD9361_LIBRARIES NAMES ad9361 libad9361 REQUIRED)
find_path(AD9361_INCLUDE_DIRS ad9361.h REQUIRED)

set(AD936X_FILTERS_BUILD_PATH ${CMAKE_CURRENT_BINARY_DIR}/resources/ad936x-filters)

file(GLOB FIR_FILTERS ${CMAKE_CURRENT_SOURCE_DIR}/resources/ad936x-filters/*)
Expand Down Expand Up @@ -92,6 +113,7 @@ target_link_libraries(
scopy-iioutil
scopy-iio-widgets
scopy-pkg-manager
${AD9361_LIBRARIES}
)

set(PLUTO_TARGET_NAME ${PROJECT_NAME} PARENT_SCOPE)
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
#include <iio-widgets/iiowidgetbuilder.h>

#include <animatedrefreshbtn.h>
#include <ad936xhelper.h>

namespace scopy {
namespace ad936x {

class SCOPY_AD936X_EXPORT AD936X : public QWidget
{
Q_OBJECT
Expand All @@ -51,13 +53,10 @@ class SCOPY_AD936X_EXPORT AD936X : public QWidget
QWidget *m_blockDiagramWidget;
AnimatedRefreshBtn *m_refreshButton;

QWidget *generateGlobalSettingsWidget(QWidget *parent);

QWidget *generateRxChainWidget(QWidget *parent);
QWidget *generateRxWidget(iio_channel *chn, QString title, QWidget *parent);
QWidget *generateRxChainWidget(iio_device *dev, QString title, QWidget *parent);
QWidget *generateTxChainWidget(iio_device *dev, QString title, QWidget *parent);

QWidget *generateTxChainWidget(QWidget *parent);
QWidget *generateTxWidget(iio_channel *chn, QString title, QWidget *parent);
AD936xHelper *m_helper;
};
} // namespace ad936x
} // namespace scopy
Expand Down
File renamed without changes.
51 changes: 51 additions & 0 deletions packages/ad936x/plugins/ad936x/include/ad936x/ad936xhelper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2025 Analog Devices Inc.
*
* This file is part of Scopy
* (see https://www.github.com/analogdevicesinc/scopy).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/

#ifndef AD936X_HELPER_H
#define AD936X_HELPER_H

#include "scopy-ad936x_export.h"
#include <QWidget>
#include <iio-widgets/iiowidgetbuilder.h>

namespace scopy {
namespace ad936x {

class SCOPY_AD936X_EXPORT AD936xHelper : public QWidget
{
Q_OBJECT
public:
AD936xHelper(QWidget *parent = nullptr);

QWidget *generateGlobalSettingsWidget(iio_device *dev, QString title, QWidget *parent);

QWidget *generateRxDeviceWidget(iio_device *dev, QString title, QWidget *parent);
QWidget *generateRxChannelWidget(iio_channel *chn, QString title, QWidget *parent);

QWidget *generateTxDeviceWidget(iio_device *dev, QString title, QWidget *parent);
QWidget *generateTxChannelWidget(iio_channel *chn, QString title, QWidget *parent);

Q_SIGNALS:
void readRequested();
};
} // namespace ad936x
} // namespace scopy
#endif // AD936X_HELPER_H
62 changes: 62 additions & 0 deletions packages/ad936x/plugins/ad936x/include/ad936x/fmcomms5/fmcomms5.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2025 Analog Devices Inc.
*
* This file is part of Scopy
* (see https://www.github.com/analogdevicesinc/scopy).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/

#ifndef FMCOMMS5_H
#define FMCOMMS5_H

#include "scopy-ad936x_export.h"
#include <QBoxLayout>
#include <QWidget>
#include <tooltemplate.h>

#include <iio-widgets/iiowidgetbuilder.h>

#include <animatedrefreshbtn.h>
#include <ad936xhelper.h>

namespace scopy {
namespace ad936x {
class SCOPY_AD936X_EXPORT FMCOMMS5 : public QWidget
{
Q_OBJECT
public:
explicit FMCOMMS5(iio_context *ctx, QWidget *parent = nullptr);
~FMCOMMS5();

Q_SIGNALS:
void readRequested();

private:
iio_context *m_ctx = nullptr;
ToolTemplate *m_tool;
QVBoxLayout *m_mainLayout;
QWidget *m_controlsWidget;
QWidget *m_blockDiagramWidget;
AnimatedRefreshBtn *m_refreshButton;

QWidget *generateRxChainWidget(iio_device *dev, QString title, QWidget *parent);
QWidget *generateTxChainWidget(iio_device *dev, QString title, QWidget *parent);

AD936xHelper *m_helper;
};
} // namespace ad936x
} // namespace scopy
#endif // FMCOMMS5_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Copyright (c) 2025 Analog Devices Inc.
*
* This file is part of Scopy
* (see https://www.github.com/analogdevicesinc/scopy).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/

#ifndef FMCOMMS5ADVANCED_H
#define FMCOMMS5ADVANCED_H

#include "scopy-ad936x_export.h"
#include <QWidget>
#include <animatedrefreshbtn.h>
#include <tooltemplate.h>
#include <iio.h>

#include "auxadcdaciowidget.h"
#include "elnawidget.h"
#include "ensmmodeclockswidget.h"
#include "gainwidget.h"
#include "rssiwidget.h"
#include "txmonitorwidget.h"
#include "miscwidget.h"
#include "bistwidget.h"
#include "fmcomms5/fmcomms5tab.h"

namespace scopy {
namespace ad936x {
class SCOPY_AD936X_EXPORT Fmcomms5Advanced : public QWidget
{
Q_OBJECT
public:
explicit Fmcomms5Advanced(iio_context *ctx, QWidget *parent = nullptr);
~Fmcomms5Advanced();

Q_SIGNALS:
void readRequested();

private:
void init();

QPushButton *m_ensmModeClocksBtn = nullptr;
QPushButton *m_eLnaBtn = nullptr;
QPushButton *m_rssiBtn = nullptr;
QPushButton *m_gainBtn = nullptr;
QPushButton *m_txMonitorBtn = nullptr;
QPushButton *m_auxAdcDacIioBtn = nullptr;
QPushButton *m_miscBtn = nullptr;
QPushButton *m_bistBtn = nullptr;
QPushButton *m_fmcomms5Btn = nullptr;

QPushButton *m_syncBtn = nullptr;
void ad9361MultichipSync();

iio_context *m_ctx = nullptr;
ToolTemplate *m_tool;
QVBoxLayout *m_mainLayout;
AnimatedRefreshBtn *m_refreshButton;

EnsmModeClocksWidget *m_ensmModeClocks;
ElnaWidget *m_elna;
RssiWidget *m_rssi;
GainWidget *m_gainWidget;
TxMonitorWidget *m_txMonitor;
AuxAdcDacIoWidget *m_auxAdcDacIo;
MiscWidget *m_misc;
BistWidget *m_bist;
Fmcomms5Tab *m_fmcomms5;

iio_device *m_mainDevice = nullptr;
iio_device *m_secondDevice = nullptr;
QStackedWidget *m_centralWidget = nullptr;

bool m_isToolInitialized;
void showEvent(QShowEvent *event) override;
};

} // namespace ad936x
} // namespace scopy
#endif // FMCOMMS5ADVANCED_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Copyright (c) 2025 Analog Devices Inc.
*
* This file is part of Scopy
* (see https://www.github.com/analogdevicesinc/scopy).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/

#ifndef FMCOMMS5CALIBRATION_H
#define FMCOMMS5CALIBRATION_H

#include <QObject>
#include <iio.h>

namespace scopy {
namespace ad936x {

struct MarkerResult
{
double magnitude;
double offset;
int chA;
int chB;
};

// used devices
#define CAP_DEVICE "cf-ad9361-lpc"
#define CAP_DEVICE_ALT "cf-ad9361-A"
#define CAP_SLAVE_DEVICE "cf-ad9361-B"
#define DDS_DEVICE "cf-ad9361-dds-core-lpc"
#define DDS_SLAVE_DEVICE "cf-ad9361-dds-core-B"

/* 1MHZ tone */
#define CAL_TONE 1000000
#define CAL_SCALE 0.12500
#define MARKER_AVG 3

class Fmcomms5Calibration : public QObject
{
Q_OBJECT
public:
explicit Fmcomms5Calibration(iio_context *ctx, QObject *parent = nullptr);

void calibrate();
void resetCalibration();
void callSwitchPortsEnableCb(int val);

Q_SIGNALS:
void calibrationFailed();
void updateCalibrationProgress(double progress);

private:
iio_context *m_ctx;
iio_device *m_mainDevice = nullptr;
iio_device *m_secondDevice = nullptr;
iio_device *m_cf_ad9361_lpc = nullptr;
iio_device *m_cf_ad9361_hpc = nullptr;

void calibrationFail(int ret);

double tuneTrxPhaseOffset(iio_device *ldev, int *ret, long long cal_freq, long long cal_tone, double sign,
std::function<void(iio_device *, double)> tune);

void getMarkers(double *offset, double *mag);
std::vector<MarkerResult> getMarkersFromCrossCorrelation();
double calcPhaseOffset(double fsample, double dds_freq, double offset, double mag);
double scalePhase0360(double val);

int defaultDds(long long freq, double scale);
void ddsTxPhaseRotation(struct iio_device *dev, double val);
void trxPhaseRottation(iio_device *dev, double val);
unsigned int getCalTone();

int getCalSamples(long long calTone, long long calFreq);

void nearEndLoopbackCtrl(unsigned channel, bool enable);
};
} // namespace ad936x
} // namespace scopy
#endif // FMCOMMS5CALIBRATION_H
Loading
Loading