SR_CONF_LOGIC_ANALYZER,
SR_CONF_SAMPLERATE,
SR_CONF_LIMIT_SAMPLES,
- SR_CONF_TRIGGER_TYPE,
+ SR_CONF_TRIGGER_MATCH,
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_KHZ(1.25),
SR_KHZ(10),
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
*data = g_variant_builder_end(&gvb);
break;
- case SR_CONF_TRIGGER_TYPE:
- *data = g_variant_new_string(TRIGGER_TYPES);
+ case SR_CONF_TRIGGER_MATCH:
+ *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
+ trigger_matches, ARRAY_SIZE(trigger_matches),
+ sizeof(int32_t));
break;
case SR_CONF_LIMIT_SAMPLES:
grange[0] = g_variant_new_uint64(0);
* The trigger must be configured first because the calculation of the
* pre and post trigger samples depends on a configured trigger.
*/
- sl2_configure_trigger(sdi);
+ sl2_convert_trigger(sdi);
sl2_calculate_trigger_samples(sdi);
trigger_bytes = devc->pre_trigger_bytes + devc->post_trigger_bytes;
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 sr_channel *ch;
- uint8_t trigger_type;
- int channel_index, num_triggers_anyedge;
- char *trigger;
- GSList *l;
+ struct sr_trigger *trigger;
+ struct sr_trigger_stage *stage;
+ struct sr_trigger_match *match;
+ const GSList *l, *m;
+ int num_triggers_anyedge;
devc = sdi->priv;
devc->trigger_channel = TRIGGER_CHANNEL_0;
devc->trigger_type = TRIGGER_TYPE_NONE;
- num_triggers_anyedge = 0;
-
- for (l = sdi->channels, channel_index = 0; l; l = l->next, channel_index++) {
- ch = l->data;
- trigger = ch->trigger;
+ if (!(trigger = sr_session_trigger_get()))
+ return SR_OK;
- if (!trigger || !ch->enabled)
- continue;
+ if (g_slist_length(trigger->stages) > 1) {
+ sr_err("This device only supports 1 trigger stage.");
+ return SR_ERR;
+ }
- 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;
+ num_triggers_anyedge = 0;
+ 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;
+ }
}
-
- devc->trigger_channel = channel_index + 1;
- devc->trigger_type = trigger_type;
}
/*
sr_dbg("Trigger set to channel 0x%02x and type 0x%02x.",
devc->trigger_channel, devc->trigger_type);
+
+ return SR_OK;
}
SR_PRIV int sl2_set_capture_ratio(const struct sr_dev_inst *sdi,
#define NUM_SAMPLERATES 11
#define NUM_CHANNELS 4
-#define TRIGGER_TYPES "rfc"
-
/*
* 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
uint64_t samplerate);
SR_PRIV int sl2_set_limit_samples(const struct sr_dev_inst *sdi,
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,
uint64_t capture_ratio);
SR_PRIV int sl2_set_after_trigger_delay(const struct sr_dev_inst *sdi,