X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Ffx2lafw%2Fapi.c;h=213be9cf2d72488a9a5d3a216e086829c3dfc2b6;hb=787ec9dbd9613d34e0afed6ec145f24917e450c5;hp=64d3bfea574fc4a40129a2866acdd211f0b81565;hpb=aac29cc192ccf82b64e77b5e6b11b411da32deed;p=libsigrok.git diff --git a/src/hardware/fx2lafw/api.c b/src/hardware/fx2lafw/api.c index 64d3bfea..213be9cf 100644 --- a/src/hardware/fx2lafw/api.c +++ b/src/hardware/fx2lafw/api.c @@ -87,6 +87,7 @@ static const uint32_t devopts[] = { SR_CONF_CONN | SR_CONF_GET, SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, SR_CONF_TRIGGER_MATCH | SR_CONF_LIST, + SR_CONF_CAPTURE_RATIO | SR_CONF_GET | SR_CONF_SET, }; static const char *channel_names[] = { @@ -253,9 +254,8 @@ static GSList *scan(GSList *options) /* Fill in channellist according to this device's profile. */ num_logic_channels = prof->dev_caps & DEV_CAPS_16BIT ? 16 : 8; for (j = 0; j < num_logic_channels; j++) { - if (!(ch = sr_channel_new(j, SR_CHANNEL_LOGIC, TRUE, - channel_names[j]))) - return NULL; + ch = sr_channel_new(j, SR_CHANNEL_LOGIC, TRUE, + channel_names[j]); sdi->channels = g_slist_append(sdi->channels, ch); } @@ -436,6 +436,9 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s case SR_CONF_SAMPLERATE: *data = g_variant_new_uint64(devc->cur_samplerate); break; + case SR_CONF_CAPTURE_RATIO: + *data = g_variant_new_uint64(devc->capture_ratio); + break; default: return SR_ERR_NA; } @@ -478,6 +481,14 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd case SR_CONF_LIMIT_SAMPLES: devc->limit_samples = g_variant_get_uint64(data); break; + case SR_CONF_CAPTURE_RATIO: + devc->capture_ratio = g_variant_get_uint64(data); + if (devc->capture_ratio > 100) { + devc->capture_ratio = 0; + ret = SR_ERR; + } else + ret = SR_OK; + break; default: ret = SR_ERR_NA; } @@ -568,7 +579,12 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc->empty_transfer_count = 0; if ((trigger = sr_session_trigger_get(sdi->session))) { - devc->stl = soft_trigger_logic_new(sdi, trigger); + int pre_trigger_samples = 0; + if (devc->limit_samples > 0) + pre_trigger_samples = devc->capture_ratio * devc->limit_samples/100; + devc->stl = soft_trigger_logic_new(sdi, trigger, pre_trigger_samples); + if (devc->stl == NULL) + return SR_ERR_MALLOC; devc->trigger_fired = FALSE; } else devc->trigger_fired = TRUE;