pipistrello-ols: Disable unused trigger stages.

Thanks to Magnus Karlsson for this fix.
This commit is contained in:
Bert Vermeulen 2014-08-25 01:00:00 +02:00
parent acc885c755
commit 84cbaf77b4
2 changed files with 41 additions and 5 deletions

View File

@ -519,6 +519,35 @@ static int set_trigger(const struct sr_dev_inst *sdi, int stage)
return SR_OK; 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, static int dev_acquisition_start(const struct sr_dev_inst *sdi,
void *cb_data) void *cb_data)
{ {
@ -583,14 +612,22 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
sr_err("Failed to configure channels."); sr_err("Failed to configure channels.");
return SR_ERR; return SR_ERR;
} }
if (devc->num_stages > 0) { if (devc->num_stages > 0) {
delaycount = readcount * (1 - devc->capture_ratio / 100.0); delaycount = readcount * (1 - devc->capture_ratio / 100.0);
devc->trigger_at = (readcount - delaycount) * samplespercount - devc->num_stages; devc->trigger_at = (readcount - delaycount) * samplespercount - devc->num_stages;
for (i = 0; i <= devc->num_stages; i++) { for (i = 0; i < NUM_TRIGGER_STAGES; i++) {
if (i <= devc->num_stages) {
sr_dbg("Setting p-ols stage %d trigger.", i); sr_dbg("Setting p-ols stage %d trigger.", i);
if ((ret = set_trigger(sdi, i)) != SR_OK) if ((ret = set_trigger(sdi, i)) != SR_OK)
return ret; return ret;
} }
else {
sr_dbg("Disabling p-ols stage %d trigger.", i);
if ((ret = disable_trigger(sdi, i)) != SR_OK)
return ret;
}
}
} else { } else {
/* No triggers configured, force trigger on first stage. */ /* No triggers configured, force trigger on first stage. */
sr_dbg("Forcing trigger at stage 0."); sr_dbg("Forcing trigger at stage 0.");

View File

@ -428,7 +428,6 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data)
num_channels++; num_channels++;
} }
} }
sr_dbg("num_channels = %d", num_channels);
/* Get a block of data. */ /* Get a block of data. */
bytes_read = ftdi_read_data(devc->ftdic, devc->ftdi_buf, FTDI_BUF_SIZE); bytes_read = ftdi_read_data(devc->ftdic, devc->ftdi_buf, FTDI_BUF_SIZE);