saleae-logic16: Add SR_CONF_CAPTURE_RATIO support.
This commit is contained in:
parent
7bfcb25cf1
commit
5a971f66a3
|
@ -53,6 +53,7 @@ static const uint32_t devopts[] = {
|
||||||
SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
|
SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
|
||||||
SR_CONF_VOLTAGE_THRESHOLD | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
|
SR_CONF_VOLTAGE_THRESHOLD | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
|
||||||
SR_CONF_TRIGGER_MATCH | SR_CONF_LIST,
|
SR_CONF_TRIGGER_MATCH | SR_CONF_LIST,
|
||||||
|
SR_CONF_CAPTURE_RATIO | SR_CONF_GET | SR_CONF_SET,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int32_t soft_trigger_matches[] = {
|
static const int32_t soft_trigger_matches[] = {
|
||||||
|
@ -459,6 +460,12 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
*data = g_variant_new_uint64(devc->cur_samplerate);
|
*data = g_variant_new_uint64(devc->cur_samplerate);
|
||||||
break;
|
break;
|
||||||
|
case SR_CONF_CAPTURE_RATIO:
|
||||||
|
if (!sdi)
|
||||||
|
return SR_ERR;
|
||||||
|
devc = sdi->priv;
|
||||||
|
*data = g_variant_new_uint64(devc->capture_ratio);
|
||||||
|
break;
|
||||||
case SR_CONF_VOLTAGE_THRESHOLD:
|
case SR_CONF_VOLTAGE_THRESHOLD:
|
||||||
if (!sdi)
|
if (!sdi)
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
@ -505,6 +512,14 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
case SR_CONF_LIMIT_SAMPLES:
|
case SR_CONF_LIMIT_SAMPLES:
|
||||||
devc->limit_samples = g_variant_get_uint64(data);
|
devc->limit_samples = g_variant_get_uint64(data);
|
||||||
break;
|
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;
|
||||||
case SR_CONF_VOLTAGE_THRESHOLD:
|
case SR_CONF_VOLTAGE_THRESHOLD:
|
||||||
g_variant_get(data, "(dd)", &low, &high);
|
g_variant_get(data, "(dd)", &low, &high);
|
||||||
ret = SR_ERR_ARG;
|
ret = SR_ERR_ARG;
|
||||||
|
@ -719,7 +734,12 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
memset(devc->channel_data, 0, sizeof(devc->channel_data));
|
memset(devc->channel_data, 0, sizeof(devc->channel_data));
|
||||||
|
|
||||||
if ((trigger = sr_session_trigger_get(sdi->session))) {
|
if ((trigger = sr_session_trigger_get(sdi->session))) {
|
||||||
devc->stl = soft_trigger_logic_new(sdi, trigger, 0);
|
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;
|
devc->trigger_fired = FALSE;
|
||||||
} else
|
} else
|
||||||
devc->trigger_fired = TRUE;
|
devc->trigger_fired = TRUE;
|
||||||
|
|
|
@ -713,6 +713,7 @@ SR_PRIV void logic16_receive_transfer(struct libusb_transfer *transfer)
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
size_t new_samples, num_samples;
|
size_t new_samples, num_samples;
|
||||||
int trigger_offset;
|
int trigger_offset;
|
||||||
|
int pre_trigger_samples;
|
||||||
|
|
||||||
sdi = transfer->user_data;
|
sdi = transfer->user_data;
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
@ -785,8 +786,9 @@ SR_PRIV void logic16_receive_transfer(struct libusb_transfer *transfer)
|
||||||
devc->sent_samples += new_samples;
|
devc->sent_samples += new_samples;
|
||||||
} else {
|
} else {
|
||||||
trigger_offset = soft_trigger_logic_check(devc->stl,
|
trigger_offset = soft_trigger_logic_check(devc->stl,
|
||||||
devc->convbuffer, new_samples * 2, NULL);
|
devc->convbuffer, new_samples * 2, &pre_trigger_samples);
|
||||||
if (trigger_offset > -1) {
|
if (trigger_offset > -1) {
|
||||||
|
devc->sent_samples += pre_trigger_samples;
|
||||||
packet.type = SR_DF_LOGIC;
|
packet.type = SR_DF_LOGIC;
|
||||||
packet.payload = &logic;
|
packet.payload = &logic;
|
||||||
num_samples = new_samples - trigger_offset;
|
num_samples = new_samples - trigger_offset;
|
||||||
|
|
|
@ -59,6 +59,9 @@ struct dev_context {
|
||||||
/** Maximum number of samples to capture, if nonzero. */
|
/** Maximum number of samples to capture, if nonzero. */
|
||||||
uint64_t limit_samples;
|
uint64_t limit_samples;
|
||||||
|
|
||||||
|
/** Percent of the samples that should be captured before the trigger. */
|
||||||
|
uint64_t capture_ratio;
|
||||||
|
|
||||||
/** The currently configured input voltage of the device. */
|
/** The currently configured input voltage of the device. */
|
||||||
enum voltage_range cur_voltage_range;
|
enum voltage_range cur_voltage_range;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue