]> sigrok.org Git - libsigrok.git/commitdiff
pipistrello-ols: Disable unused trigger stages.
authorBert Vermeulen <redacted>
Sun, 24 Aug 2014 23:00:00 +0000 (01:00 +0200)
committerBert Vermeulen <redacted>
Sun, 24 Aug 2014 23:00:55 +0000 (01:00 +0200)
Thanks to Magnus Karlsson for this fix.

src/hardware/pipistrello-ols/api.c
src/hardware/pipistrello-ols/protocol.c

index 8a1fa5dca59a813ec547d432eb9055656fe931be..01d82a6f217a1a7fc848caf14f0dfdc6274ee804 100644 (file)
@@ -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. */
index 750303d019eba164cb3fb608d3691a0851c96bf2..53ab5324c03c24a0400e2c405de8b37650823739 100644 (file)
@@ -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);