Skip to content

Commit ac0676c

Browse files
committed
plugins/fmcomms2_adv: Reenable and update to libiio 1.x API
Signed-off-by: Dan <[email protected]>
1 parent 1fe3003 commit ac0676c

File tree

2 files changed

+33
-32
lines changed

2 files changed

+33
-32
lines changed

Diff for: plugins/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
set(PLUGINS
1919
generic_dac
2020
fmcomms2
21-
#fmcomms2_adv
21+
fmcomms2_adv
2222
#fmcomms5
2323
#fmcomms6
2424
#fmcomms11

Diff for: plugins/fmcomms2_adv.c

+32-31
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@
2424
#include <unistd.h>
2525

2626
#include <ad9361.h>
27-
#include <iio.h>
27+
#include <iio/iio.h>
2828

2929
#include "../libini2.h"
3030
#include "../osc.h"
3131
#include "../osc_plugin.h"
3232
#include "../config.h"
3333
#include "../iio_widget.h"
3434
#include "../datatypes.h"
35+
#include "../iio_utils.h"
3536

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

455-
iio_device_debug_attr_read_longlong(dev, str, &mask);
456+
dev_debug_attr_read_longlong(dev, str, &mask);
456457

457458
if (val) {
458459
mask |= (1 << bit);
459460
} else {
460461
mask &= ~(1 << bit);
461462
}
462463

463-
iio_device_debug_attr_write_longlong(dev, str, mask);
464+
dev_debug_attr_write_longlong(dev, str, mask);
464465

465466
if (dev_slave)
466-
iio_device_debug_attr_write_longlong(dev_slave, str, mask);
467+
dev_debug_attr_write_longlong(dev_slave, str, mask);
467468
return;
468469
default:
469470
return;
470471
}
471472

472-
iio_device_debug_attr_write_longlong(dev, item->name, val);
473+
dev_debug_attr_write_longlong(dev, item->name, val);
473474

474475
if (dev_slave)
475-
iio_device_debug_attr_write_longlong(dev_slave, item->name, val);
476+
dev_debug_attr_write_longlong(dev_slave, item->name, val);
476477

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

551552
if (out1 && out0) {
552-
iio_channel_attr_write_double(out0, "calibscale", (double) vcos);
553-
iio_channel_attr_write_double(out0, "calibphase", (double) (-1.0 * vsin));
554-
iio_channel_attr_write_double(out1, "calibscale", (double) vcos);
555-
iio_channel_attr_write_double(out1, "calibphase", (double) vsin);
553+
chn_attr_write_double(out0, "calibscale", (double) vcos);
554+
chn_attr_write_double(out0, "calibphase", (double) (-1.0 * vsin));
555+
chn_attr_write_double(out1, "calibscale", (double) vcos);
556+
chn_attr_write_double(out1, "calibphase", (double) vsin);
556557
}
557558
}
558559
}
@@ -579,10 +580,10 @@ static void dds_tx_phase_rotation(struct iio_device *dev, gdouble val)
579580
case 1:
580581
case 4:
581582
case 5:
582-
iio_channel_attr_write_longlong(dds_out[d][j], "phase", i);
583+
chn_attr_write_longlong(dds_out[d][j], "phase", i);
583584
break;
584585
default:
585-
iio_channel_attr_write_longlong(dds_out[d][j], "phase", q);
586+
chn_attr_write_longlong(dds_out[d][j], "phase", q);
586587
}
587588
}
588589

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

595596
for (i = 0; i < 2; i++) {
596597
for (j = 0; j < 8; j++) {
597-
ret |= iio_channel_attr_write_longlong(dds_out[i][j], "frequency", freq);
598-
ret |= iio_channel_attr_write_double(dds_out[i][j], "scale", scale);
598+
ret |= chn_attr_write_longlong(dds_out[i][j], "frequency", freq);
599+
ret |= chn_attr_write_double(dds_out[i][j], "scale", scale);
599600
}
600601

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

708709

709710
#if 0
710-
iio_device_debug_attr_write_bool(dev, "loopback", lp_master);
711-
iio_device_debug_attr_write_bool(dev_slave, "loopback", lp_slave);
711+
dev_debug_attr_write_string_bool(dev, "loopback", lp_master);
712+
dev_debug_attr_write_string_bool(dev_slave, "loopback", lp_slave);
712713
#else
713714
near_end_loopback_ctrl(0, lp_slave); /* HPC */
714715
near_end_loopback_ctrl(1, lp_slave); /* HPC */
715716

716717
near_end_loopback_ctrl(4, lp_master); /* LPC */
717718
near_end_loopback_ctrl(5, lp_master); /* LPC */
718719
#endif
719-
iio_device_debug_attr_write_longlong(dev, "calibration_switch_control", sw);
720-
iio_channel_attr_write(iio_device_find_channel(dev, "voltage0", false),
720+
dev_debug_attr_write_longlong(dev, "calibration_switch_control", sw);
721+
chn_attr_write_string(iio_device_find_channel(dev, "voltage0", false),
721722
"rf_port_select", rx_port);
722-
iio_channel_attr_write(iio_device_find_channel(dev, "voltage0", true),
723+
chn_attr_write_string(iio_device_find_channel(dev, "voltage0", true),
723724
"rf_port_select", tx_port);
724725

725726
if (dev_slave) {
726-
iio_channel_attr_write(iio_device_find_channel(dev_slave, "voltage0", false),
727+
chn_attr_write_string(iio_device_find_channel(dev_slave, "voltage0", false),
727728
"rf_port_select", rx_port);
728-
iio_channel_attr_write(iio_device_find_channel(dev_slave, "voltage0", true),
729+
chn_attr_write_string(iio_device_find_channel(dev_slave, "voltage0", true),
729730
"rf_port_select", tx_port);
730731
}
731732

@@ -870,8 +871,8 @@ static void calibrate (gpointer button)
870871
goto calibrate_fail;
871872
}
872873

873-
iio_channel_attr_read_longlong(dds_out[0][0], "frequency", &cal_tone);
874-
iio_channel_attr_read_longlong(dds_out[0][0], "sampling_frequency", &cal_freq);
874+
chn_attr_read_longlong(dds_out[0][0], "frequency", &cal_tone);
875+
chn_attr_read_longlong(dds_out[0][0], "sampling_frequency", &cal_freq);
875876

876877
samples = get_cal_samples(cal_tone, cal_freq);
877878

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

885886
/* Turn off quadrature tracking while the sync is going on */
886-
iio_channel_attr_write(in0, "quadrature_tracking_en", "0");
887-
iio_channel_attr_write(in0_slave, "quadrature_tracking_en", "0");
887+
chn_attr_write_string(in0, "quadrature_tracking_en", "0");
888+
chn_attr_write_string(in0_slave, "quadrature_tracking_en", "0");
888889

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

955956
if (in0 && in0_slave) {
956-
iio_channel_attr_write(in0, "quadrature_tracking_en", "1");
957-
iio_channel_attr_write(in0_slave, "quadrature_tracking_en", "1");
957+
chn_attr_write_string(in0, "quadrature_tracking_en", "1");
958+
chn_attr_write_string(in0_slave, "quadrature_tracking_en", "1");
958959
}
959960

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

1092-
iio_device_debug_attr_write(dev, "bist_tone", temp);
1093+
dev_debug_attr_write_string(dev, "bist_tone", temp);
10931094

10941095
if (dev_slave)
1095-
iio_device_debug_attr_write(dev_slave, "bist_tone", temp);
1096+
dev_debug_attr_write_string(dev_slave, "bist_tone", temp);
10961097

10971098
}
10981099

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

11891190
static int connect_widgets(GtkBuilder *builder)
11901191
{
1191-
return iio_device_debug_attr_read_all(dev, __connect_widget, builder);
1192+
return dev_debug_attr_read_all(dev, __connect_widget, builder);
11921193
}
11931194

11941195
static int update_widgets(GtkBuilder *builder)
11951196
{
1196-
return iio_device_debug_attr_read_all(dev, __update_widget, builder);
1197+
return dev_debug_attr_read_all(dev, __update_widget, builder);
11971198
}
11981199

11991200
static void change_page_cb (GtkNotebook *notebook, GtkNotebookTab *page,

0 commit comments

Comments
 (0)