Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugins/fmcomms2_adv: Reenable and update to libiio 1.x API #509

Draft
wants to merge 1 commit into
base: libiio-v1-support
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
set(PLUGINS
generic_dac
fmcomms2
#fmcomms2_adv
fmcomms2_adv
#fmcomms5
#fmcomms6
#fmcomms11
Expand Down
63 changes: 32 additions & 31 deletions plugins/fmcomms2_adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
#include <unistd.h>

#include <ad9361.h>
#include <iio.h>
#include <iio/iio.h>

#include "../libini2.h"
#include "../osc.h"
#include "../osc_plugin.h"
#include "../config.h"
#include "../iio_widget.h"
#include "../datatypes.h"
#include "../iio_utils.h"

#define PHY_DEVICE "ad9361-phy"
#define PHY_SLAVE_DEVICE "ad9361-phy-B"
Expand Down Expand Up @@ -452,27 +453,27 @@ static void signal_handler_cb (GtkWidget *widget, gpointer data)
if (ret != 2)
return;

iio_device_debug_attr_read_longlong(dev, str, &mask);
dev_debug_attr_read_longlong(dev, str, &mask);

if (val) {
mask |= (1 << bit);
} else {
mask &= ~(1 << bit);
}

iio_device_debug_attr_write_longlong(dev, str, mask);
dev_debug_attr_write_longlong(dev, str, mask);

if (dev_slave)
iio_device_debug_attr_write_longlong(dev_slave, str, mask);
dev_debug_attr_write_longlong(dev_slave, str, mask);
return;
default:
return;
}

iio_device_debug_attr_write_longlong(dev, item->name, val);
dev_debug_attr_write_longlong(dev, item->name, val);

if (dev_slave)
iio_device_debug_attr_write_longlong(dev_slave, item->name, val);
dev_debug_attr_write_longlong(dev_slave, item->name, val);

if (!strcmp(item->name, "initialize")) {
reload_settings();
Expand Down Expand Up @@ -549,10 +550,10 @@ static void trx_phase_rotation(struct iio_device *dev, gdouble val)
}

if (out1 && out0) {
iio_channel_attr_write_double(out0, "calibscale", (double) vcos);
iio_channel_attr_write_double(out0, "calibphase", (double) (-1.0 * vsin));
iio_channel_attr_write_double(out1, "calibscale", (double) vcos);
iio_channel_attr_write_double(out1, "calibphase", (double) vsin);
chn_attr_write_double(out0, "calibscale", (double) vcos);
chn_attr_write_double(out0, "calibphase", (double) (-1.0 * vsin));
chn_attr_write_double(out1, "calibscale", (double) vcos);
chn_attr_write_double(out1, "calibphase", (double) vsin);
}
}
}
Expand All @@ -579,10 +580,10 @@ static void dds_tx_phase_rotation(struct iio_device *dev, gdouble val)
case 1:
case 4:
case 5:
iio_channel_attr_write_longlong(dds_out[d][j], "phase", i);
chn_attr_write_longlong(dds_out[d][j], "phase", i);
break;
default:
iio_channel_attr_write_longlong(dds_out[d][j], "phase", q);
chn_attr_write_longlong(dds_out[d][j], "phase", q);
}
}

Expand All @@ -594,8 +595,8 @@ static int default_dds(long long freq, double scale)

for (i = 0; i < 2; i++) {
for (j = 0; j < 8; j++) {
ret |= iio_channel_attr_write_longlong(dds_out[i][j], "frequency", freq);
ret |= iio_channel_attr_write_double(dds_out[i][j], "scale", scale);
ret |= chn_attr_write_longlong(dds_out[i][j], "frequency", freq);
ret |= chn_attr_write_double(dds_out[i][j], "scale", scale);
}

dds_tx_phase_rotation(i ? dev_dds_slave : dev_dds_master, 0.0);
Expand Down Expand Up @@ -707,25 +708,25 @@ static void __cal_switch_ports_enable_cb (unsigned val)


#if 0
iio_device_debug_attr_write_bool(dev, "loopback", lp_master);
iio_device_debug_attr_write_bool(dev_slave, "loopback", lp_slave);
dev_debug_attr_write_string_bool(dev, "loopback", lp_master);
dev_debug_attr_write_string_bool(dev_slave, "loopback", lp_slave);
#else
near_end_loopback_ctrl(0, lp_slave); /* HPC */
near_end_loopback_ctrl(1, lp_slave); /* HPC */

near_end_loopback_ctrl(4, lp_master); /* LPC */
near_end_loopback_ctrl(5, lp_master); /* LPC */
#endif
iio_device_debug_attr_write_longlong(dev, "calibration_switch_control", sw);
iio_channel_attr_write(iio_device_find_channel(dev, "voltage0", false),
dev_debug_attr_write_longlong(dev, "calibration_switch_control", sw);
chn_attr_write_string(iio_device_find_channel(dev, "voltage0", false),
"rf_port_select", rx_port);
iio_channel_attr_write(iio_device_find_channel(dev, "voltage0", true),
chn_attr_write_string(iio_device_find_channel(dev, "voltage0", true),
"rf_port_select", tx_port);

if (dev_slave) {
iio_channel_attr_write(iio_device_find_channel(dev_slave, "voltage0", false),
chn_attr_write_string(iio_device_find_channel(dev_slave, "voltage0", false),
"rf_port_select", rx_port);
iio_channel_attr_write(iio_device_find_channel(dev_slave, "voltage0", true),
chn_attr_write_string(iio_device_find_channel(dev_slave, "voltage0", true),
"rf_port_select", tx_port);
}

Expand Down Expand Up @@ -870,8 +871,8 @@ static void calibrate (gpointer button)
goto calibrate_fail;
}

iio_channel_attr_read_longlong(dds_out[0][0], "frequency", &cal_tone);
iio_channel_attr_read_longlong(dds_out[0][0], "sampling_frequency", &cal_freq);
chn_attr_read_longlong(dds_out[0][0], "frequency", &cal_tone);
chn_attr_read_longlong(dds_out[0][0], "sampling_frequency", &cal_freq);

samples = get_cal_samples(cal_tone, cal_freq);

Expand All @@ -883,8 +884,8 @@ static void calibrate (gpointer button)
gdk_threads_leave();

/* Turn off quadrature tracking while the sync is going on */
iio_channel_attr_write(in0, "quadrature_tracking_en", "0");
iio_channel_attr_write(in0_slave, "quadrature_tracking_en", "0");
chn_attr_write_string(in0, "quadrature_tracking_en", "0");
chn_attr_write_string(in0_slave, "quadrature_tracking_en", "0");

/* reset any Tx rotation to zero */
trx_phase_rotation(cf_ad9361_lpc, 0.0);
Expand Down Expand Up @@ -953,8 +954,8 @@ static void calibrate (gpointer button)
__cal_switch_ports_enable_cb(0);

if (in0 && in0_slave) {
iio_channel_attr_write(in0, "quadrature_tracking_en", "1");
iio_channel_attr_write(in0_slave, "quadrature_tracking_en", "1");
chn_attr_write_string(in0, "quadrature_tracking_en", "1");
chn_attr_write_string(in0_slave, "quadrature_tracking_en", "1");
}

gdk_threads_enter();
Expand Down Expand Up @@ -1089,10 +1090,10 @@ static void bist_tone_cb (GtkWidget *widget, gpointer data)
sprintf(temp, "%u %u %u %u", mode, freq, level * 6,
(c2q << 3) | (c2i << 2) | (c1q << 1) | c1i);

iio_device_debug_attr_write(dev, "bist_tone", temp);
dev_debug_attr_write_string(dev, "bist_tone", temp);

if (dev_slave)
iio_device_debug_attr_write(dev_slave, "bist_tone", temp);
dev_debug_attr_write_string(dev_slave, "bist_tone", temp);

}

Expand Down Expand Up @@ -1188,12 +1189,12 @@ static int __update_widget(struct iio_device *dev, const char *attr,

static int connect_widgets(GtkBuilder *builder)
{
return iio_device_debug_attr_read_all(dev, __connect_widget, builder);
return dev_debug_attr_read_all(dev, __connect_widget, builder);
}

static int update_widgets(GtkBuilder *builder)
{
return iio_device_debug_attr_read_all(dev, __update_widget, builder);
return dev_debug_attr_read_all(dev, __update_widget, builder);
}

static void change_page_cb (GtkNotebook *notebook, GtkNotebookTab *page,
Expand Down
Loading