]> sigrok.org Git - libsigrok.git/commitdiff
asix-sigma: track whether triggers were specified when acquisition started
authorGerhard Sittig <redacted>
Sun, 17 May 2020 14:15:54 +0000 (16:15 +0200)
committerGerhard Sittig <redacted>
Sun, 31 May 2020 21:41:40 +0000 (23:41 +0200)
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.

src/hardware/asix-sigma/api.c
src/hardware/asix-sigma/protocol.c

index 41c4f6448d65d67c05301d4c593622e7c88cfb6b..db148076bf279fe4b272f07203fc9de7e3413b68 100644 (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;
index 3a653939f7a11c4f44a2ccee951933e341a88c9f..37bd9babb5259ace10889eec329adc3f0dc6eef4 100644 (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;