From: Gerhard Sittig Date: Sun, 17 May 2020 14:15:54 +0000 (+0200) Subject: asix-sigma: track whether triggers were specified when acquisition started X-Git-Url: http://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=fb65ca09b79aa93e34f5d71b2611046c2414694c 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. --- diff --git a/src/hardware/asix-sigma/api.c b/src/hardware/asix-sigma/api.c index 41c4f644..db148076 100644 --- a/src/hardware/asix-sigma/api.c +++ b/src/hardware/asix-sigma/api.c @@ -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; diff --git a/src/hardware/asix-sigma/protocol.c b/src/hardware/asix-sigma/protocol.c index 3a653939..37bd9bab 100644 --- a/src/hardware/asix-sigma/protocol.c +++ b/src/hardware/asix-sigma/protocol.c @@ -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;