]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/asix-sigma/api.c
asix-sigma: unconditionally re-enable trigger support code
[libsigrok.git] / src / hardware / asix-sigma / api.c
index b8d68e9a0118c433184ab7a68f0c4ae3277bcb5b..f56bdd45bc2c4589a2bf560d5baa2c01653c5035 100644 (file)
@@ -49,10 +49,8 @@ static const uint32_t devopts[] = {
        SR_CONF_EXTERNAL_CLOCK | SR_CONF_GET | SR_CONF_SET,
        SR_CONF_EXTERNAL_CLOCK_SOURCE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
        SR_CONF_CLOCK_EDGE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
-#if ASIX_SIGMA_WITH_TRIGGER
        SR_CONF_TRIGGER_MATCH | SR_CONF_LIST,
        SR_CONF_CAPTURE_RATIO | SR_CONF_GET | SR_CONF_SET,
-#endif
 };
 
 static const char *ext_clock_edges[] = {
@@ -61,14 +59,12 @@ static const char *ext_clock_edges[] = {
        [SIGMA_CLOCK_EDGE_EITHER] = "either",
 };
 
-#if ASIX_SIGMA_WITH_TRIGGER
 static const int32_t trigger_matches[] = {
        SR_TRIGGER_ZERO,
        SR_TRIGGER_ONE,
        SR_TRIGGER_RISING,
        SR_TRIGGER_FALLING,
 };
-#endif
 
 static void clear_helper(struct dev_context *devc)
 {
@@ -317,11 +313,9 @@ static int config_get(uint32_t key, GVariant **data,
        case SR_CONF_LIMIT_MSEC:
        case SR_CONF_LIMIT_SAMPLES:
                return sr_sw_limits_config_get(&devc->limit.config, key, data);
-#if ASIX_SIGMA_WITH_TRIGGER
        case SR_CONF_CAPTURE_RATIO:
                *data = g_variant_new_uint64(devc->capture_ratio);
                break;
-#endif
        default:
                return SR_ERR_NA;
        }
@@ -376,11 +370,9 @@ static int config_set(uint32_t key, GVariant *data,
        case SR_CONF_LIMIT_MSEC:
        case SR_CONF_LIMIT_SAMPLES:
                return sr_sw_limits_config_set(&devc->limit.config, key, data);
-#if ASIX_SIGMA_WITH_TRIGGER
        case SR_CONF_CAPTURE_RATIO:
                devc->capture_ratio = g_variant_get_uint64(data);
                break;
-#endif
        default:
                return SR_ERR_NA;
        }
@@ -407,11 +399,9 @@ static int config_list(uint32_t key, GVariant **data,
        case SR_CONF_CLOCK_EDGE:
                *data = g_variant_new_strv(ARRAY_AND_SIZE(ext_clock_edges));
                break;
-#if ASIX_SIGMA_WITH_TRIGGER
        case SR_CONF_TRIGGER_MATCH:
                *data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches));
                break;
-#endif
        default:
                return SR_ERR_NA;
        }
@@ -433,6 +423,13 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 
        devc = sdi->priv;
 
+       /* Convert caller's trigger spec to driver's internal format. */
+       ret = sigma_convert_trigger(sdi);
+       if (ret != SR_OK) {
+               sr_err("Could not configure triggers.");
+               return ret;
+       }
+
        /*
         * Setup the device's samplerate from the value which up to now
         * just got checked and stored. As a byproduct this can pick and
@@ -455,12 +452,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        if (ret != SR_OK)
                return ret;
 
-       ret = sigma_convert_trigger(sdi);
-       if (ret != SR_OK) {
-               sr_err("Could not configure triggers.");
-               return ret;
-       }
-
        /* Enter trigger programming mode. */
        trigsel2 = TRGSEL2_RESET;
        ret = sigma_set_register(devc, WRITE_TRIGGER_SELECT2, trigsel2);
@@ -550,7 +541,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
         * Derive a mask where bits are set for unavailable channels.
         * Either send the single byte, or the full byte sequence.
         */
-       pindis_mask = ~BITS_MASK(devc->num_channels);
+       pindis_mask = ~BITS_MASK(devc->interp.num_channels);
        if (devc->clock.samplerate > SR_MHZ(50)) {
                ret = sigma_set_register(devc, WRITE_CLOCK_SELECT,
                        pindis_mask & 0xff);
@@ -592,7 +583,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 
        /* Start acqusition. */
        regval = WMR_TRGRES | WMR_SDRAMWRITEEN;
-       if (devc->use_triggers && ASIX_SIGMA_WITH_TRIGGER)
+       if (devc->use_triggers)
                regval |= WMR_TRGEN;
        ret = sigma_set_register(devc, WRITE_MODE, regval);
        if (ret != SR_OK)
@@ -608,7 +599,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        if (ret != SR_OK)
                return ret;
 
-       devc->state.state = SIGMA_CAPTURE;
+       devc->state = SIGMA_CAPTURE;
 
        return SR_OK;
 }
@@ -626,10 +617,10 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
         * already. The detour is required to have sample data retrieved
         * for forced acquisition stops.
         */
-       if (devc->state.state == SIGMA_CAPTURE) {
-               devc->state.state = SIGMA_STOPPING;
+       if (devc->state == SIGMA_CAPTURE) {
+               devc->state = SIGMA_STOPPING;
        } else {
-               devc->state.state = SIGMA_IDLE;
+               devc->state = SIGMA_IDLE;
                (void)sr_session_source_remove(sdi->session, -1);
        }