diff --git a/DSView/pv/dock/dsotriggerdock.cpp b/DSView/pv/dock/dsotriggerdock.cpp index 4750f85c..f825695d 100644 --- a/DSView/pv/dock/dsotriggerdock.cpp +++ b/DSView/pv/dock/dsotriggerdock.cpp @@ -57,13 +57,29 @@ DsoTriggerDock::DsoTriggerDock(QWidget *parent, SigSession &session) : connect(position_spinBox, SIGNAL(valueChanged(int)), position_slider, SLOT(setValue(int))); connect(position_slider, SIGNAL(valueChanged(int)), this, SLOT(pos_changed(int))); + QLabel *holdoff_label = new QLabel(tr("Trigger Hold Off Time: "), _widget); + holdoff_comboBox = new QComboBox(_widget); + holdoff_comboBox->addItem(tr("uS"), qVariantFromValue(1000)); + holdoff_comboBox->addItem(tr("mS"), qVariantFromValue(1000000)); + holdoff_comboBox->addItem(tr("S"), qVariantFromValue(1000000000)); + holdoff_spinBox = new QSpinBox(_widget); + holdoff_spinBox->setRange(0, 999); + holdoff_spinBox->setButtonSymbols(QAbstractSpinBox::NoButtons); + holdoff_slider = new QSlider(Qt::Horizontal, _widget); + holdoff_slider->setRange(0, 999); + connect(holdoff_slider, SIGNAL(valueChanged(int)), holdoff_spinBox, SLOT(setValue(int))); + connect(holdoff_spinBox, SIGNAL(valueChanged(int)), holdoff_slider, SLOT(setValue(int))); + connect(holdoff_slider, SIGNAL(valueChanged(int)), this, SLOT(hold_changed(int))); + connect(holdoff_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(hold_changed(int))); + + QLabel *tSource_labe = new QLabel(tr("Trigger Sources: "), _widget); QRadioButton *auto_radioButton = new QRadioButton(tr("Auto")); auto_radioButton->setChecked(true); QRadioButton *ch0_radioButton = new QRadioButton(tr("Channel 0")); QRadioButton *ch1_radioButton = new QRadioButton(tr("Channel 1")); - QRadioButton *ch0a1_radioButton = new QRadioButton(tr("Channel 0 && Channel 1")); - QRadioButton *ch0o1_radioButton = new QRadioButton(tr("Channel 0 | Channel 1")); + QRadioButton *ch0a1_radioButton = new QRadioButton(tr("Channel 0 && 1")); + QRadioButton *ch0o1_radioButton = new QRadioButton(tr("Channel 0 | 1")); connect(auto_radioButton, SIGNAL(clicked()), this, SLOT(source_changed())); connect(ch0_radioButton, SIGNAL(clicked()), this, SLOT(source_changed())); connect(ch1_radioButton, SIGNAL(clicked()), this, SLOT(source_changed())); @@ -100,22 +116,28 @@ DsoTriggerDock::DsoTriggerDock(QWidget *parent, SigSession &session) : QGridLayout *gLayout = new QGridLayout(); gLayout->addWidget(position_label, 0, 0); gLayout->addWidget(position_spinBox, 0, 1); - gLayout->addWidget(new QLabel(_widget), 0, 2); - gLayout->addWidget(position_slider, 1, 0, 1, 3); + gLayout->addWidget(new QLabel(tr("%"), _widget), 0, 2); + gLayout->addWidget(position_slider, 1, 0, 1, 4); gLayout->addWidget(new QLabel(_widget), 2, 0); gLayout->addWidget(tSource_labe, 3, 0); gLayout->addWidget(auto_radioButton, 4, 0); gLayout->addWidget(ch0_radioButton, 5, 0); - gLayout->addWidget(ch1_radioButton, 5, 1); + gLayout->addWidget(ch1_radioButton, 5, 1, 1, 3); gLayout->addWidget(ch0a1_radioButton, 6, 0); - gLayout->addWidget(ch0o1_radioButton, 6, 1); + gLayout->addWidget(ch0o1_radioButton, 6, 1, 1, 3); gLayout->addWidget(new QLabel(_widget), 7, 0); gLayout->addWidget(tType_labe, 8, 0); gLayout->addWidget(rising_radioButton, 9, 0); gLayout->addWidget(falling_radioButton, 10, 0); + gLayout->addWidget(new QLabel(_widget), 11, 0); + gLayout->addWidget(holdoff_label, 12, 0); + gLayout->addWidget(holdoff_spinBox, 12, 1); + gLayout->addWidget(holdoff_comboBox, 12, 2); + gLayout->addWidget(holdoff_slider, 13, 0, 1, 4); + gLayout->setColumnStretch(3, 1); layout->addLayout(gLayout); @@ -159,6 +181,31 @@ void DsoTriggerDock::pos_changed(int pos) set_trig_pos(trig_pos); } +void DsoTriggerDock::hold_changed(int hold) +{ + (void)hold; + int ret; + uint64_t holdoff; + if (holdoff_comboBox->currentData().toDouble() == 1000000000) { + holdoff_slider->setRange(0, 10); + } else { + holdoff_slider->setRange(0, 999); + } + holdoff = holdoff_slider->value() * holdoff_comboBox->currentData().toDouble() / 10; + ret = _session.get_device()->set_config(NULL, NULL, + SR_CONF_TRIGGER_HOLDOFF, + g_variant_new_uint64(holdoff)); + + if (!ret) { + QMessageBox msg(this); + msg.setText(tr("Trigger Setting Issue")); + msg.setInformativeText(tr("Change trigger hold off time failed!")); + msg.setStandardButtons(QMessageBox::Ok); + msg.setIcon(QMessageBox::Warning); + msg.exec(); + } +} + void DsoTriggerDock::source_changed() { int id = source_group->checkedId(); diff --git a/DSView/pv/dock/dsotriggerdock.h b/DSView/pv/dock/dsotriggerdock.h index 4640394c..f5c4ac17 100644 --- a/DSView/pv/dock/dsotriggerdock.h +++ b/DSView/pv/dock/dsotriggerdock.h @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -59,6 +60,7 @@ signals: private slots: void pos_changed(int pos); + void hold_changed(int hold); void source_changed(); void type_changed(); @@ -69,6 +71,10 @@ private: QWidget *_widget; + QComboBox *holdoff_comboBox; + QSpinBox *holdoff_spinBox; + QSlider *holdoff_slider; + QSpinBox *position_spinBox; QSlider *position_slider; diff --git a/DSView/pv/dock/measuredock.cpp b/DSView/pv/dock/measuredock.cpp index 3c5a3982..a3497695 100644 --- a/DSView/pv/dock/measuredock.cpp +++ b/DSView/pv/dock/measuredock.cpp @@ -120,7 +120,7 @@ MeasureDock::MeasureDock(QWidget *parent, View &view, SigSession &session) : _cursor_layout->addWidget(_cnt_label_t1t3, 5, 3); _cursor_layout->addWidget(new QLabel(tr("Cursors"), _widget), 6, 0); - _cursor_layout->addWidget(new QLabel(tr("Time/Samples"), _widget), 6, 1); + _cursor_layout->addWidget(new QLabel(tr("Time/Samples"), _widget), 6, 1, 1, 4); _cursor_layout->addWidget(new QLabel(_widget), 0, 4); _cursor_layout->addWidget(new QLabel(_widget), 1, 4); @@ -206,7 +206,7 @@ void MeasureDock::cursor_update() _space_label_list.push_back(_space_label); _cursor_layout->addWidget(_cursor_pushButton, 6 + index, 0); - _cursor_layout->addWidget(_curpos_label, 6 + index, 1); + _cursor_layout->addWidget(_curpos_label, 6 + index, 1, 1, 4); _cursor_layout->addWidget(_space_label, 6 + index, 2); connect(_cursor_pushButton, SIGNAL(clicked()), this, SLOT(goto_cursor())); diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index bf36cf78..91bf3055 100644 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -945,8 +945,8 @@ void SigSession::feed_in_dso(const sr_datafeed_dso &dso) receive_data(dso.num_samples); data_updated(); - if (!_instant) - start_timer(ViewTime); + //if (!_instant) + // start_timer(ViewTime); } void SigSession::feed_in_analog(const sr_datafeed_analog &analog) diff --git a/libsigrok4DSL/hardware/DSL/dscope.c b/libsigrok4DSL/hardware/DSL/dscope.c index 3c16d18c..3059667d 100644 --- a/libsigrok4DSL/hardware/DSL/dscope.c +++ b/libsigrok4DSL/hardware/DSL/dscope.c @@ -88,6 +88,7 @@ static const int32_t sessions[] = { SR_CONF_TRIGGER_SLOPE, SR_CONF_TRIGGER_SOURCE, SR_CONF_HORIZ_TRIGGERPOS, + SR_CONF_TRIGGER_HOLDOFF, }; static const char *probe_names[] = { @@ -584,6 +585,7 @@ static struct DSL_context *DSCope_dev_new(void) devc->timebase = 10000; devc->trigger_slope = DSO_TRIGGER_RISING; devc->trigger_source = DSO_TRIGGER_AUTO; + devc->trigger_holdoff = 0; devc->trigger_hpos = 0x0; devc->trigger_hrate = 0; devc->zero = FALSE; @@ -902,6 +904,10 @@ static uint64_t dso_cmd_gen(struct sr_dev_inst *sdi, struct sr_channel* ch, int case SR_CONF_ZERO_OVER: cmd += 0x50; break; + case SR_CONF_TRIGGER_HOLDOFF: + cmd += 0x58; + cmd += ((uint64_t)devc->trigger_holdoff << 8); + break; case SR_CONF_DSO_SYNC: cmd = 0xa5a5a500; break; @@ -1020,6 +1026,11 @@ static int dev_open(struct sr_dev_inst *sdi) sr_err("Set Horiz Trigger Position command failed!"); return ret; } + ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_HOLDOFF)); + if (ret != SR_OK) { + sr_err("Set Trigger Holdoff Time command failed!"); + return ret; + } ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_SLOPE)); if (ret != SR_OK) { sr_err("Set Trigger Slope command failed!"); @@ -1234,6 +1245,12 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, devc = sdi->priv; *data = g_variant_new_byte(devc->trigger_hrate); break; + case SR_CONF_TRIGGER_HOLDOFF: + if (!sdi) + return SR_ERR; + devc = sdi->priv; + *data = g_variant_new_uint64(devc->trigger_holdoff); + break; case SR_CONF_ZERO: if (!sdi) return SR_ERR; @@ -1509,6 +1526,17 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, else sr_dbg("%s: setting DSO Horiz Trigger Position to %d failed", __func__, devc->trigger_hpos); + } else if (id == SR_CONF_TRIGGER_HOLDOFF) { + devc->trigger_holdoff = g_variant_get_uint64(data); + if (sdi->mode == DSO) { + ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_HOLDOFF)); + } + if (ret == SR_OK) + sr_dbg("%s: setting Trigger Holdoff Time to %d", + __func__, devc->trigger_holdoff); + else + sr_dbg("%s: setting Trigger Holdoff Time to %d failed", + __func__, devc->trigger_holdoff); } else if (id == SR_CONF_ZERO) { devc->zero = g_variant_get_boolean(data); } else if (id == SR_CONF_ZERO_SET) { @@ -2059,7 +2087,11 @@ static int dev_transfer_start(const struct sr_dev_inst *sdi) // num_transfers = get_number_of_transfers(devc); // size = get_buffer_size(devc); timeout = 500; + #ifndef _WIN32 + num_transfers = 1; + #else num_transfers = buffer_cnt; + #endif uint16_t channel_en_cnt = 0; uint16_t channel_cnt = 0; GSList *l; diff --git a/libsigrok4DSL/hardware/DSL/dsl.h b/libsigrok4DSL/hardware/DSL/dsl.h index f5d6ca16..5ab6d88f 100644 --- a/libsigrok4DSL/hardware/DSL/dsl.h +++ b/libsigrok4DSL/hardware/DSL/dsl.h @@ -169,6 +169,7 @@ struct DSL_context { uint8_t trigger_source; uint8_t trigger_hrate; uint32_t trigger_hpos; + uint32_t trigger_holdoff; gboolean zero; gboolean stream; gboolean lock; diff --git a/libsigrok4DSL/hardware/DSL/dslogic.c b/libsigrok4DSL/hardware/DSL/dslogic.c index 7a45f358..b65e47b0 100644 --- a/libsigrok4DSL/hardware/DSL/dslogic.c +++ b/libsigrok4DSL/hardware/DSL/dslogic.c @@ -105,6 +105,7 @@ static const int32_t sessions[] = { SR_CONF_TRIGGER_SLOPE, SR_CONF_TRIGGER_SOURCE, SR_CONF_HORIZ_TRIGGERPOS, + SR_CONF_TRIGGER_HOLDOFF, }; static const int32_t sessions_pro[] = { @@ -118,6 +119,7 @@ static const int32_t sessions_pro[] = { SR_CONF_TRIGGER_SLOPE, SR_CONF_TRIGGER_SOURCE, SR_CONF_HORIZ_TRIGGERPOS, + SR_CONF_TRIGGER_HOLDOFF, }; static const int32_t ch_sessions[] = { @@ -649,6 +651,7 @@ static struct DSL_context *DSLogic_dev_new(void) devc->trigger_source = DSO_TRIGGER_AUTO; devc->trigger_hpos = 0x0; devc->trigger_hrate = 0; + devc->trigger_holdoff = 0; devc->zero = FALSE; devc->stream = FALSE; devc->mstatus_valid = FALSE; @@ -961,6 +964,10 @@ static uint64_t dso_cmd_gen(struct sr_dev_inst *sdi, struct sr_channel* ch, int case SR_CONF_ZERO_OVER: cmd += 0x50; break; + case SR_CONF_TRIGGER_HOLDOFF: + cmd += 0x58; + cmd += devc->trigger_holdoff << 8; + break; case SR_CONF_DSO_SYNC: cmd = 0xa5a5a500; break; @@ -1058,16 +1065,16 @@ static int dev_open(struct sr_dev_inst *sdi) sr_err("Configure FPGA failed!"); } } - - ret = command_vth(usb->devhdl, devc->vth); - if (ret == SR_OK) - sr_dbg("%s: setting threshold voltage to %d", - __func__, devc->vth); - else - sr_dbg("%s: setting threshold voltage to %d failed", - __func__, devc->vth); } + ret = command_vth(usb->devhdl, devc->vth); + if (ret == SR_OK) + sr_dbg("%s: setting threshold voltage to %d", + __func__, devc->vth); + else + sr_dbg("%s: setting threshold voltage to %d failed", + __func__, devc->vth); + return SR_OK; } @@ -1240,6 +1247,12 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, *data = g_variant_new_byte(devc->trigger_hpos); } break; + case SR_CONF_TRIGGER_HOLDOFF: + if (!sdi) + return SR_ERR; + devc = sdi->priv; + *data = g_variant_new_uint64(devc->trigger_holdoff); + break; case SR_CONF_ZERO: if (!sdi) return SR_ERR; @@ -1437,6 +1450,11 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, sr_err("Set Horiz Trigger Position command failed!"); return ret; } + ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_HOLDOFF)); + if (ret != SR_OK) { + sr_err("Set Trigger Holdoff Time command failed!"); + return ret; + } ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_SLOPE)); if (ret != SR_OK) { sr_err("Set Trigger Slope command failed!"); @@ -1624,6 +1642,17 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, else sr_dbg("%s: setting DSO Horiz Trigger Position to %d failed", __func__, devc->trigger_hpos); + } else if (id == SR_CONF_TRIGGER_HOLDOFF) { + devc->trigger_holdoff = g_variant_get_uint64(data); + if (sdi->mode == DSO) { + ret = command_dso_ctrl(usb->devhdl, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_HOLDOFF)); + } + if (ret == SR_OK) + sr_dbg("%s: setting Trigger Holdoff Time to %d", + __func__, devc->trigger_holdoff); + else + sr_dbg("%s: setting Trigger Holdoff Time to %d failed", + __func__, devc->trigger_holdoff); } else if (id == SR_CONF_ZERO) { devc->zero = g_variant_get_boolean(data); } else if (id == SR_CONF_ZERO_SET) { @@ -2167,13 +2196,14 @@ static int dev_transfer_start(const struct sr_dev_inst *sdi) else dso_buffer_size = devc->limit_samples * channel_en_cnt + 512; - if (sdi->mode == DSO) { - timeout = 500; - num_transfers = buffer_cnt; - } else { - timeout = get_timeout(devc); - num_transfers = get_number_of_transfers(devc); - } +// if (sdi->mode == DSO) { +// timeout = 500; +// num_transfers = buffer_cnt; +// } else { +// timeout = get_timeout(devc); +// num_transfers = get_number_of_transfers(devc); +// } + num_transfers = 1; size = (sdi->mode == ANALOG) ? cons_buffer_size : ((sdi->mode == DSO) ? dso_buffer_size : get_buffer_size(devc)); devc->submitted_transfers = 0; diff --git a/libsigrok4DSL/hardware/demo/demo.c b/libsigrok4DSL/hardware/demo/demo.c index 0623a0bf..39b4e32b 100644 --- a/libsigrok4DSL/hardware/demo/demo.c +++ b/libsigrok4DSL/hardware/demo/demo.c @@ -482,6 +482,10 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, sr_dbg("%s: setting INSTANT mode to %d", __func__, devc->instant); ret = SR_OK; + } else if (id == SR_CONF_HORIZ_TRIGGERPOS) { + ret = SR_OK; + } else if (id == SR_CONF_TRIGGER_HOLDOFF) { + ret = SR_OK; } else if (id == SR_CONF_EN_CH) { ch->enabled = g_variant_get_boolean(data); sr_dbg("%s: setting ENABLE of channel %d to %d", __func__, diff --git a/libsigrok4DSL/hwdriver.c b/libsigrok4DSL/hwdriver.c index 7300d8af..f37efbde 100644 --- a/libsigrok4DSL/hwdriver.c +++ b/libsigrok4DSL/hwdriver.c @@ -77,7 +77,9 @@ static struct sr_config_info sr_config_info_data[] = { "Trigger source", NULL}, {SR_CONF_HORIZ_TRIGGERPOS, SR_T_UINT8, "horiz_triggerpos", "Horizontal trigger position", NULL}, - {SR_CONF_BUFFERSIZE, SR_T_UINT64, "buffersize", + {SR_CONF_TRIGGER_HOLDOFF, SR_T_UINT64, "triggerholdoff", + "Trigger hold off", NULL}, + {SR_CONF_BUFFERSIZE, SR_T_UINT64, "buffersize", "Buffer size", NULL}, {SR_CONF_TIMEBASE, SR_T_UINT64, "timebase", "Time base", NULL}, diff --git a/libsigrok4DSL/libsigrok.h b/libsigrok4DSL/libsigrok.h index 527414ca..d6c8218f 100644 --- a/libsigrok4DSL/libsigrok.h +++ b/libsigrok4DSL/libsigrok.h @@ -731,6 +731,9 @@ enum { /** Horizontal trigger position. */ SR_CONF_HORIZ_TRIGGERPOS, + /** Trigger hold off time */ + SR_CONF_TRIGGER_HOLDOFF, + /** Buffer size. */ SR_CONF_BUFFERSIZE,