diff --git a/glade/cf_axi_tdd_v2.glade b/glade/cf_axi_tdd_v2.glade
new file mode 100644
index 00000000..effad467
--- /dev/null
+++ b/glade/cf_axi_tdd_v2.glade
@@ -0,0 +1,1436 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+ 1
+
+
+
+
diff --git a/plugins/cf_axi_tdd.c b/plugins/cf_axi_tdd.c
index fc8b892c..f64f4ff3 100644
--- a/plugins/cf_axi_tdd.c
+++ b/plugins/cf_axi_tdd.c
@@ -8,6 +8,7 @@
**/
#include
#include
+#include
#include
#include
#include
@@ -22,13 +23,13 @@
#define NUM_MAX_WIDGETS 32
struct plugin_private {
- /* Associated GTK builder */
+ /* Associated GTK builder */
GtkBuilder *builder;
- /* plugin context */
+ /* plugin context */
struct osc_plugin_context plugin_ctx;
/* iio */
struct iio_context *ctx;
- /* misc */
+ /* misc */
gboolean plugin_detached;
gint this_page;
/* widgets */
@@ -99,8 +100,63 @@ static int cf_axi_tdd_chann_widgets_init(struct plugin_private *priv, struct iio
return 0;
}
+static int cf_axi_tdd_v2_widgets_init(struct plugin_private *priv, struct iio_device *dev)
+{
+ const unsigned int n_channels = iio_device_get_channels_count(dev);
+ struct iio_channel *chan;
+ unsigned int i;
+ char widget_str[32];
+ GtkButton *reload_btn;
+
+ iio_spin_button_int_init_from_builder(&priv->w[priv->n_w++], dev, NULL, "burst_count",
+ priv->builder, "burst_count", NULL);
+ iio_spin_button_int_init_from_builder(&priv->w[priv->n_w++], dev, NULL, "frame_length_ms",
+ priv->builder, "frame_length", NULL);
+ iio_spin_button_int_init_from_builder(&priv->w[priv->n_w++], dev, NULL, "startup_delay_ms",
+ priv->builder, "startup_delay", NULL);
+ iio_toggle_button_init_from_builder(&priv->w[priv->n_w++], dev, NULL, "enable",
+ priv->builder, "global_enable", false);
+ iio_toggle_button_init_from_builder(&priv->w[priv->n_w++], dev, NULL, "sync_external",
+ priv->builder, "external_sync_enable", false);
+ iio_toggle_button_init_from_builder(&priv->w[priv->n_w++], dev, NULL, "sync_external",
+ priv->builder, "external_sync_enable", false);
+
+ if (!n_channels) {
+ printf("Could not find any iio channel\n");
+ return -ENODEV;
+ }
+
+ for (i = 0; i < n_channels; i++) {
+ chan = iio_device_get_channel(dev, i);
+ if (!chan)
+ return -ENODEV;
+
+ sprintf(widget_str, "%s_on", iio_channel_get_id(chan));
+ iio_spin_button_int_init_from_builder(&priv->w[priv->n_w++], dev, chan,
+ "on_ms", priv->builder, widget_str, NULL);
+ sprintf(widget_str, "%s_off", iio_channel_get_id(chan));
+ iio_spin_button_int_init_from_builder(&priv->w[priv->n_w++], dev, chan,
+ "off_ms", priv->builder, widget_str, NULL);
+ sprintf(widget_str, "%s_polarity", iio_channel_get_id(chan));
+ iio_toggle_button_init_from_builder(&priv->w[priv->n_w++], dev, chan,
+ "polarity", priv->builder, widget_str, false);
+ sprintf(widget_str, "%s_enable", iio_channel_get_id(chan));
+ iio_toggle_button_init_from_builder(&priv->w[priv->n_w++], dev, chan,
+ "enable", priv->builder, widget_str, false);
+ }
+
+ reload_btn = GTK_BUTTON(gtk_builder_get_object(priv->builder, "settings_reload"));
+ g_signal_connect(G_OBJECT(reload_btn), "clicked", G_CALLBACK(reload_settings),
+ priv);
+ iio_update_widgets(priv->w, priv->n_w);
+ iio_make_widgets_update_signal_based(priv->w, priv->n_w,
+ G_CALLBACK(iio_widget_save_block_signals_by_data_cb));
+
+ return 0;
+}
+
static GtkWidget *cf_axi_tdd_init(struct osc_plugin *plugin, GtkWidget *notebook,
- const char *ini_fn)
+ const char *ini_fn)
{
GtkWidget *cf_axi_tdd_panel;
struct plugin_private *priv = plugin->priv;
@@ -123,70 +179,93 @@ static GtkWidget *cf_axi_tdd_init(struct osc_plugin *plugin, GtkWidget *notebook
if (!dev)
goto context_destroy;
- if (osc_load_glade_file(priv->builder, "cf_axi_tdd") < 0)
- goto context_destroy;
+ /*check for version device attribute , this only exists in v2 of the tdd driver
+ * if the attribute is not found , load the previous version of the tdd plugin */
+
+ if(!iio_device_find_attr(dev, "version")) {
+ if (osc_load_glade_file(priv->builder, "cf_axi_tdd") < 0)
+ goto context_destroy;
+
+ cf_axi_tdd_panel = GTK_WIDGET(gtk_builder_get_object(priv->builder, "cf_axi_tdd_panel"));
+ if (!cf_axi_tdd_panel)
+ goto context_destroy;
+
+ /* init device widgets */
+ iio_spin_button_int_init_from_builder(&priv->w[priv->n_w++], dev, NULL, "burst_count",
+ priv->builder, "burst_count", NULL);
+ iio_spin_button_int_init_from_builder(&priv->w[priv->n_w++], dev, NULL, "frame_length_ms",
+ priv->builder, "frame_length", NULL);
+ iio_spin_button_int_init_from_builder(&priv->w[priv->n_w++], dev, NULL, "counter_int",
+ priv->builder, "counter_int", NULL);
+ iio_combo_box_init_no_avail_flush_from_builder(&priv->w[priv->n_w++], dev, NULL,"dma_gateing_mode",
+ "dma_gateing_mode_available", priv->builder,
+ "dma_gateing_mode", NULL);
+ iio_combo_box_init_no_avail_flush_from_builder(&priv->w[priv->n_w++], dev, NULL, "en_mode",
+ "en_mode_available", priv->builder, "enable_mode", NULL);
+ iio_toggle_button_init_from_builder(&priv->w[priv->n_w++], dev, NULL, "sync_terminal_type",
+ priv->builder, "sync_terminal_type", false);
+ iio_toggle_button_init_from_builder(&priv->w[priv->n_w++], dev, NULL, "en", priv->builder,
+ "enable", false);
+ iio_toggle_button_init_from_builder(&priv->secondary, dev, NULL, "secondary", priv->builder,
+ "secondary_frame", false);
+ /* init channel widgets */
+ ret = cf_axi_tdd_chann_widgets_init(priv, dev);
+ if (ret)
+ goto context_destroy;
+
+ /* handle sections buttons and reload settings */
+ global = GTK_WIDGET(gtk_builder_get_object(priv->builder, "global_settings"));
+ global_btn = GTK_TOGGLE_TOOL_BUTTON(gtk_builder_get_object(priv->builder,
+ "global_settings_toggle"));
+ primary = GTK_WIDGET(gtk_builder_get_object(priv->builder, "tdd_primary"));
+ primary_btn = GTK_TOGGLE_TOOL_BUTTON(gtk_builder_get_object(priv->builder,
+ "tdd_primary_toggle"));
+ secondary = GTK_WIDGET(gtk_builder_get_object(priv->builder, "tdd_secondary"));
+ secondary_btn = GTK_TOGGLE_TOOL_BUTTON(gtk_builder_get_object(priv->builder,
+ "tdd_secondary_toggle"));
+
+ reload_btn = GTK_BUTTON(gtk_builder_get_object(priv->builder, "settings_reload"));
+ priv->secondary_frame = GTK_WIDGET(gtk_builder_get_object(priv->builder,
+ "tdd_secondary_frame"));
+
+ g_signal_connect(G_OBJECT(global_btn), "clicked", G_CALLBACK(handle_toggle_section_cb),
+ global);
+ g_signal_connect(G_OBJECT(primary_btn), "clicked", G_CALLBACK(handle_toggle_section_cb),
+ primary);
+ g_signal_connect(G_OBJECT(secondary_btn), "clicked", G_CALLBACK(handle_toggle_section_cb),
+ secondary);
+ g_signal_connect(G_OBJECT(reload_btn), "clicked", G_CALLBACK(reload_settings),
+ priv);
+
+ iio_update_widgets(priv->w, priv->n_w);
+ iio_widget_update(&priv->secondary);
+ if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->secondary.widget)))
+ gtk_widget_set_sensitive(priv->secondary_frame, false);
+
+ iio_make_widgets_update_signal_based(priv->w, priv->n_w,
+ G_CALLBACK(iio_widget_save_block_signals_by_data_cb));
+ iio_make_widget_update_signal_based(&priv->secondary, G_CALLBACK(save_secondary), priv);
+
+ return cf_axi_tdd_panel;
+ }
+ else {
- cf_axi_tdd_panel = GTK_WIDGET(gtk_builder_get_object(priv->builder, "cf_axi_tdd_panel"));
- if (!cf_axi_tdd_panel)
- goto context_destroy;
+ if (osc_load_glade_file(priv->builder, "cf_axi_tdd_v2") < 0)
+ goto context_destroy;
- /* init device widgets */
- iio_spin_button_int_init_from_builder(&priv->w[priv->n_w++], dev, NULL, "burst_count",
- priv->builder, "burst_count", NULL);
- iio_spin_button_int_init_from_builder(&priv->w[priv->n_w++], dev, NULL, "frame_length_ms",
- priv->builder, "frame_length", NULL);
- iio_spin_button_int_init_from_builder(&priv->w[priv->n_w++], dev, NULL, "counter_int",
- priv->builder, "counter_int", NULL);
- iio_combo_box_init_no_avail_flush_from_builder(&priv->w[priv->n_w++], dev, NULL,"dma_gateing_mode",
- "dma_gateing_mode_available", priv->builder,
- "dma_gateing_mode", NULL);
- iio_combo_box_init_no_avail_flush_from_builder(&priv->w[priv->n_w++], dev, NULL, "en_mode",
- "en_mode_available", priv->builder, "enable_mode", NULL);
- iio_toggle_button_init_from_builder(&priv->w[priv->n_w++], dev, NULL, "sync_terminal_type",
- priv->builder, "sync_terminal_type", false);
- iio_toggle_button_init_from_builder(&priv->w[priv->n_w++], dev, NULL, "en", priv->builder,
- "enable", false);
- iio_toggle_button_init_from_builder(&priv->secondary, dev, NULL, "secondary", priv->builder,
- "secondary_frame", false);
- /* init channel widgets */
- ret = cf_axi_tdd_chann_widgets_init(priv, dev);
- if (ret)
- goto context_destroy;
+ cf_axi_tdd_panel = GTK_WIDGET(gtk_builder_get_object(priv->builder, "cf_axi_tdd_panel_v2"));
+ if (!cf_axi_tdd_panel)
+ goto context_destroy;
- /* handle sections buttons and reload settings */
- global = GTK_WIDGET(gtk_builder_get_object(priv->builder, "global_settings"));
- global_btn = GTK_TOGGLE_TOOL_BUTTON(gtk_builder_get_object(priv->builder,
- "global_settings_toggle"));
- primary = GTK_WIDGET(gtk_builder_get_object(priv->builder, "tdd_primary"));
- primary_btn = GTK_TOGGLE_TOOL_BUTTON(gtk_builder_get_object(priv->builder,
- "tdd_primary_toggle"));
- secondary = GTK_WIDGET(gtk_builder_get_object(priv->builder, "tdd_secondary"));
- secondary_btn = GTK_TOGGLE_TOOL_BUTTON(gtk_builder_get_object(priv->builder,
- "tdd_secondary_toggle"));
+ /* init widgets */
- reload_btn = GTK_BUTTON(gtk_builder_get_object(priv->builder, "settings_reload"));
- priv->secondary_frame = GTK_WIDGET(gtk_builder_get_object(priv->builder,
- "tdd_secondary_frame"));
-
- g_signal_connect(G_OBJECT(global_btn), "clicked", G_CALLBACK(handle_toggle_section_cb),
- global);
- g_signal_connect(G_OBJECT(primary_btn), "clicked", G_CALLBACK(handle_toggle_section_cb),
- primary);
- g_signal_connect(G_OBJECT(secondary_btn), "clicked", G_CALLBACK(handle_toggle_section_cb),
- secondary);
- g_signal_connect(G_OBJECT(reload_btn), "clicked", G_CALLBACK(reload_settings),
- priv);
+ ret = cf_axi_tdd_v2_widgets_init(priv, dev);
+ if (ret)
+ goto context_destroy;
- iio_update_widgets(priv->w, priv->n_w);
- iio_widget_update(&priv->secondary);
- if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->secondary.widget)))
- gtk_widget_set_sensitive(priv->secondary_frame, false);
-
- iio_make_widgets_update_signal_based(priv->w, priv->n_w,
- G_CALLBACK(iio_widget_save_block_signals_by_data_cb));
- iio_make_widget_update_signal_based(&priv->secondary, G_CALLBACK(save_secondary), priv);
+ return cf_axi_tdd_panel;
- return cf_axi_tdd_panel;
+ }
context_destroy:
osc_destroy_context(priv->ctx);