asix-sigma: track whether triggers were specified when acquisition started

There are several separate conditions which the driver needs to tell
apart. There is a compile time switch whether trigger support shall be
built in. There is the condition whether acquisition start involved a
user provided trigger spec. And there is the hardware flag whether a
previously configured trigger condition matched and where its position
is.

Only accept user provided trigger specs when trigger support is builtin.
(The get/set/list availability and spec passing is done in applications
outside of the library, we better check just to make sure.) Only setup
the trigger related hardware parameters when a spec was provided. Only
check for trigger positions when the hardware detected a match.
This commit is contained in:
Gerhard Sittig 2020-05-17 16:15:54 +02:00
parent 8a57728d0e
commit fb65ca09b7
2 changed files with 21 additions and 5 deletions

View File

@ -592,9 +592,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
/* Start acqusition. */
regval = WMR_TRGRES | WMR_SDRAMWRITEEN;
#if ASIX_SIGMA_WITH_TRIGGER
regval |= WMR_TRGEN;
#endif
if (devc->use_triggers && ASIX_SIGMA_WITH_TRIGGER)
regval |= WMR_TRGEN;
ret = sigma_set_register(devc, WRITE_MODE, regval);
if (ret != SR_OK)
return ret;

View File

@ -1294,10 +1294,16 @@ SR_PRIV int sigma_convert_trigger(const struct sr_dev_inst *sdi)
devc = sdi->priv;
memset(&devc->trigger, 0, sizeof(devc->trigger));
devc->use_triggers = FALSE;
trigger = sr_session_trigger_get(sdi->session);
if (!trigger)
return SR_OK;
if (!ASIX_SIGMA_WITH_TRIGGER) {
sr_warn("Trigger support is not implemented. Ignoring the spec.");
return SR_OK;
}
trigger_set = 0;
for (l = trigger->stages; l; l = l->next) {
stage = l->data;
@ -1352,6 +1358,9 @@ SR_PRIV int sigma_convert_trigger(const struct sr_dev_inst *sdi)
}
}
/* Keep track whether triggers are involved during acquisition. */
devc->use_triggers = TRUE;
return SR_OK;
}
@ -1403,7 +1412,9 @@ static gboolean sample_matches_trigger(struct dev_context *devc, uint16_t sample
* See the previous get_trigger_offset() implementation. This
* code needs to get re-used here.
*/
(void)devc;
if (!devc->use_triggers)
return FALSE;
(void)sample;
(void)get_trigger_offset;
@ -1656,6 +1667,8 @@ static int download_capture(struct sr_dev_inst *sdi)
sr_err("Could not query capture positions/state.");
return FALSE;
}
if (!devc->use_triggers)
triggerpos = ~0;
trg_line = ~0UL;
trg_event = ~0UL;
if (modestatus & RMR_TRIGGERED) {
@ -1916,8 +1929,12 @@ SR_PRIV int sigma_build_basic_trigger(struct dev_context *devc,
size_t bitidx, condidx;
uint16_t value, mask;
/* Start assuming simple triggers. */
/* Setup something that "won't match" in the absence of a spec. */
memset(lut, 0, sizeof(*lut));
if (!devc->use_triggers)
return SR_OK;
/* Start assuming simple triggers. Edges are handled below. */
lut->m4 = 0xa000;
lut->m3q = 0xffff;