ikalogic-scanalogic2: Use new trigger API.
This commit is contained in:
parent
9615eeb572
commit
02d5c0d8ea
|
@ -23,10 +23,16 @@ static const int hwcaps[] = {
|
||||||
SR_CONF_LOGIC_ANALYZER,
|
SR_CONF_LOGIC_ANALYZER,
|
||||||
SR_CONF_SAMPLERATE,
|
SR_CONF_SAMPLERATE,
|
||||||
SR_CONF_LIMIT_SAMPLES,
|
SR_CONF_LIMIT_SAMPLES,
|
||||||
SR_CONF_TRIGGER_TYPE,
|
SR_CONF_TRIGGER_MATCH,
|
||||||
SR_CONF_CAPTURE_RATIO,
|
SR_CONF_CAPTURE_RATIO,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const int32_t trigger_matches[] = {
|
||||||
|
SR_TRIGGER_RISING,
|
||||||
|
SR_TRIGGER_FALLING,
|
||||||
|
SR_TRIGGER_EDGE,
|
||||||
|
};
|
||||||
|
|
||||||
SR_PRIV const uint64_t sl2_samplerates[NUM_SAMPLERATES] = {
|
SR_PRIV const uint64_t sl2_samplerates[NUM_SAMPLERATES] = {
|
||||||
SR_KHZ(1.25),
|
SR_KHZ(1.25),
|
||||||
SR_KHZ(10),
|
SR_KHZ(10),
|
||||||
|
@ -390,8 +396,10 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
|
||||||
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
|
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
|
||||||
*data = g_variant_builder_end(&gvb);
|
*data = g_variant_builder_end(&gvb);
|
||||||
break;
|
break;
|
||||||
case SR_CONF_TRIGGER_TYPE:
|
case SR_CONF_TRIGGER_MATCH:
|
||||||
*data = g_variant_new_string(TRIGGER_TYPES);
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
||||||
|
trigger_matches, ARRAY_SIZE(trigger_matches),
|
||||||
|
sizeof(int32_t));
|
||||||
break;
|
break;
|
||||||
case SR_CONF_LIMIT_SAMPLES:
|
case SR_CONF_LIMIT_SAMPLES:
|
||||||
grange[0] = g_variant_new_uint64(0);
|
grange[0] = g_variant_new_uint64(0);
|
||||||
|
@ -431,7 +439,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
* The trigger must be configured first because the calculation of the
|
* The trigger must be configured first because the calculation of the
|
||||||
* pre and post trigger samples depends on a configured trigger.
|
* pre and post trigger samples depends on a configured trigger.
|
||||||
*/
|
*/
|
||||||
sl2_configure_trigger(sdi);
|
sl2_convert_trigger(sdi);
|
||||||
sl2_calculate_trigger_samples(sdi);
|
sl2_calculate_trigger_samples(sdi);
|
||||||
|
|
||||||
trigger_bytes = devc->pre_trigger_bytes + devc->post_trigger_bytes;
|
trigger_bytes = devc->pre_trigger_bytes + devc->post_trigger_bytes;
|
||||||
|
|
|
@ -479,14 +479,14 @@ SR_PRIV int sl2_set_limit_samples(const struct sr_dev_inst *sdi,
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SR_PRIV void sl2_configure_trigger(const struct sr_dev_inst *sdi)
|
SR_PRIV int sl2_convert_trigger(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct sr_channel *ch;
|
struct sr_trigger *trigger;
|
||||||
uint8_t trigger_type;
|
struct sr_trigger_stage *stage;
|
||||||
int channel_index, num_triggers_anyedge;
|
struct sr_trigger_match *match;
|
||||||
char *trigger;
|
const GSList *l, *m;
|
||||||
GSList *l;
|
int num_triggers_anyedge;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
|
@ -494,32 +494,36 @@ SR_PRIV void sl2_configure_trigger(const struct sr_dev_inst *sdi)
|
||||||
devc->trigger_channel = TRIGGER_CHANNEL_0;
|
devc->trigger_channel = TRIGGER_CHANNEL_0;
|
||||||
devc->trigger_type = TRIGGER_TYPE_NONE;
|
devc->trigger_type = TRIGGER_TYPE_NONE;
|
||||||
|
|
||||||
num_triggers_anyedge = 0;
|
if (!(trigger = sr_session_trigger_get()))
|
||||||
|
return SR_OK;
|
||||||
|
|
||||||
for (l = sdi->channels, channel_index = 0; l; l = l->next, channel_index++) {
|
if (g_slist_length(trigger->stages) > 1) {
|
||||||
ch = l->data;
|
sr_err("This device only supports 1 trigger stage.");
|
||||||
trigger = ch->trigger;
|
return SR_ERR;
|
||||||
|
|
||||||
if (!trigger || !ch->enabled)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
switch (*trigger) {
|
|
||||||
case 'r':
|
|
||||||
trigger_type = TRIGGER_TYPE_POSEDGE;
|
|
||||||
break;
|
|
||||||
case 'f':
|
|
||||||
trigger_type = TRIGGER_TYPE_NEGEDGE;
|
|
||||||
break;
|
|
||||||
case 'c':
|
|
||||||
trigger_type = TRIGGER_TYPE_ANYEDGE;
|
|
||||||
num_triggers_anyedge++;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
devc->trigger_channel = channel_index + 1;
|
num_triggers_anyedge = 0;
|
||||||
devc->trigger_type = trigger_type;
|
for (l = trigger->stages; l; l = l->next) {
|
||||||
|
stage = l->data;
|
||||||
|
for (m = stage->matches; m; m = m->next) {
|
||||||
|
match = m->data;
|
||||||
|
if (!match->channel->enabled)
|
||||||
|
/* Ignore disabled channels with a trigger. */
|
||||||
|
continue;
|
||||||
|
devc->trigger_channel = match->channel->index + 1;
|
||||||
|
switch (match->match) {
|
||||||
|
case SR_TRIGGER_RISING:
|
||||||
|
devc->trigger_type = TRIGGER_TYPE_POSEDGE;
|
||||||
|
break;
|
||||||
|
case SR_TRIGGER_FALLING:
|
||||||
|
devc->trigger_type = TRIGGER_TYPE_NEGEDGE;
|
||||||
|
break;
|
||||||
|
case SR_TRIGGER_EDGE:
|
||||||
|
devc->trigger_type = TRIGGER_TYPE_ANYEDGE;
|
||||||
|
num_triggers_anyedge++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -533,6 +537,8 @@ SR_PRIV void sl2_configure_trigger(const struct sr_dev_inst *sdi)
|
||||||
|
|
||||||
sr_dbg("Trigger set to channel 0x%02x and type 0x%02x.",
|
sr_dbg("Trigger set to channel 0x%02x and type 0x%02x.",
|
||||||
devc->trigger_channel, devc->trigger_type);
|
devc->trigger_channel, devc->trigger_type);
|
||||||
|
|
||||||
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SR_PRIV int sl2_set_capture_ratio(const struct sr_dev_inst *sdi,
|
SR_PRIV int sl2_set_capture_ratio(const struct sr_dev_inst *sdi,
|
||||||
|
|
|
@ -49,8 +49,6 @@
|
||||||
#define NUM_SAMPLERATES 11
|
#define NUM_SAMPLERATES 11
|
||||||
#define NUM_CHANNELS 4
|
#define NUM_CHANNELS 4
|
||||||
|
|
||||||
#define TRIGGER_TYPES "rfc"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Number of sample bytes and samples the device can acquire. Note that the
|
* Number of sample bytes and samples the device can acquire. Note that the
|
||||||
* vendor software can acquire 32736 sample bytes only but the device is capable
|
* vendor software can acquire 32736 sample bytes only but the device is capable
|
||||||
|
@ -225,7 +223,7 @@ SR_PRIV int sl2_set_samplerate(const struct sr_dev_inst *sdi,
|
||||||
uint64_t samplerate);
|
uint64_t samplerate);
|
||||||
SR_PRIV int sl2_set_limit_samples(const struct sr_dev_inst *sdi,
|
SR_PRIV int sl2_set_limit_samples(const struct sr_dev_inst *sdi,
|
||||||
uint64_t limit_samples);
|
uint64_t limit_samples);
|
||||||
SR_PRIV void sl2_configure_trigger(const struct sr_dev_inst *sdi);
|
SR_PRIV int sl2_convert_trigger(const struct sr_dev_inst *sdi);
|
||||||
SR_PRIV int sl2_set_capture_ratio(const struct sr_dev_inst *sdi,
|
SR_PRIV int sl2_set_capture_ratio(const struct sr_dev_inst *sdi,
|
||||||
uint64_t capture_ratio);
|
uint64_t capture_ratio);
|
||||||
SR_PRIV int sl2_set_after_trigger_delay(const struct sr_dev_inst *sdi,
|
SR_PRIV int sl2_set_after_trigger_delay(const struct sr_dev_inst *sdi,
|
||||||
|
|
Loading…
Reference in New Issue