From: Bert Vermeulen Date: Sun, 24 Aug 2014 23:00:00 +0000 (+0200) Subject: pipistrello-ols: Disable unused trigger stages. X-Git-Tag: libsigrok-0.4.0~1121 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=84cbaf77b4a74f55bd6e9a5dcfbb2c4d5bcf7c27;p=libsigrok.git pipistrello-ols: Disable unused trigger stages. Thanks to Magnus Karlsson for this fix. --- diff --git a/src/hardware/pipistrello-ols/api.c b/src/hardware/pipistrello-ols/api.c index 8a1fa5dc..01d82a6f 100644 --- a/src/hardware/pipistrello-ols/api.c +++ b/src/hardware/pipistrello-ols/api.c @@ -519,6 +519,35 @@ static int set_trigger(const struct sr_dev_inst *sdi, int stage) return SR_OK; } +static int disable_trigger(const struct sr_dev_inst *sdi, int stage) +{ + struct dev_context *devc; + uint8_t cmd, arg[4]; + + devc = sdi->priv; + + cmd = CMD_SET_TRIGGER_MASK + stage * 4; + arg[0] = arg[1] = arg[2] = arg[3] = 0x00; + if (write_longcommand(devc, cmd, arg) != SR_OK) + return SR_ERR; + + cmd = CMD_SET_TRIGGER_VALUE + stage * 4; + if (write_longcommand(devc, cmd, arg) != SR_OK) + return SR_ERR; + + cmd = CMD_SET_TRIGGER_CONFIG + stage * 4; + arg[2] = 0x03; + if (write_longcommand(devc, cmd, arg) != SR_OK) + return SR_ERR; + + cmd = CMD_SET_TRIGGER_EDGE + stage * 4; + arg[2] = 0x00; + if (write_longcommand(devc, cmd, arg) != SR_OK) + return SR_ERR; + + return SR_OK; +} + static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) { @@ -583,13 +612,21 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, sr_err("Failed to configure channels."); return SR_ERR; } + if (devc->num_stages > 0) { delaycount = readcount * (1 - devc->capture_ratio / 100.0); devc->trigger_at = (readcount - delaycount) * samplespercount - devc->num_stages; - for (i = 0; i <= devc->num_stages; i++) { - sr_dbg("Setting p-ols stage %d trigger.", i); - if ((ret = set_trigger(sdi, i)) != SR_OK) - return ret; + for (i = 0; i < NUM_TRIGGER_STAGES; i++) { + if (i <= devc->num_stages) { + sr_dbg("Setting p-ols stage %d trigger.", i); + if ((ret = set_trigger(sdi, i)) != SR_OK) + return ret; + } + else { + sr_dbg("Disabling p-ols stage %d trigger.", i); + if ((ret = disable_trigger(sdi, i)) != SR_OK) + return ret; + } } } else { /* No triggers configured, force trigger on first stage. */ diff --git a/src/hardware/pipistrello-ols/protocol.c b/src/hardware/pipistrello-ols/protocol.c index 750303d0..53ab5324 100644 --- a/src/hardware/pipistrello-ols/protocol.c +++ b/src/hardware/pipistrello-ols/protocol.c @@ -428,7 +428,6 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data) num_channels++; } } - sr_dbg("num_channels = %d", num_channels); /* Get a block of data. */ bytes_read = ftdi_read_data(devc->ftdic, devc->ftdi_buf, FTDI_BUF_SIZE);