devc = sdi->priv;
- if (devc->probes[devc->channel]->enabled) {
+ if (devc->channels[devc->channel]->enabled) {
offset = devc->sample_packet * PACKET_NUM_SAMPLE_BYTES;
/*
struct dev_context *devc;
struct sr_datafeed_packet packet;
struct sr_datafeed_logic logic;
- uint8_t i, j, tmp, buffer[PACKET_NUM_SAMPLES], *ptr[NUM_PROBES];
+ uint8_t i, j, tmp, buffer[PACKET_NUM_SAMPLES], *ptr[NUM_CHANNELS];
uint16_t offset, n = 0;
int8_t k;
* enabled one for an uniform access to them. Note that the currently
* received samples always belong to the last enabled channel.
*/
- for (i = 0; i < devc->num_enabled_probes - 1; i++)
- ptr[i] = devc->sample_buffer[devc->probe_map[i]] + offset;
+ for (i = 0; i < devc->num_enabled_channels - 1; i++)
+ ptr[i] = devc->sample_buffer[devc->channel_map[i]] + offset;
/*
* Skip the first 4 bytes of the buffer because they contain channel
* Extract the current sample for each enabled channel
* and store them in the buffer.
*/
- for (j = 0; j < devc->num_enabled_probes; j++) {
+ for (j = 0; j < devc->num_enabled_channels; j++) {
tmp = (ptr[j][i] & (1 << k)) >> k;
- buffer[n] |= tmp << devc->probe_map[j];
+ buffer[n] |= tmp << devc->channel_map[j];
}
n++;
devc->wait_data_ready_time = g_get_monotonic_time();
}
} else if (devc->state == STATE_RECEIVE_DATA) {
- last_channel = devc->probe_map[devc->num_enabled_probes - 1];
+ last_channel = devc->channel_map[devc->num_enabled_channels - 1];
if (devc->channel < last_channel) {
buffer_sample_data(sdi);
} else {
/*
* Stop acquisition because all samples of enabled
- * probes are processed.
+ * channels are processed.
*/
devc->next_state = STATE_RESET_AND_IDLE;
}
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_probe *probe;
- uint8_t trigger_type;
- int probe_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->probes, probe_index = 0; l; l = l->next, probe_index++) {
- probe = l->data;
- trigger = probe->trigger;
+ if (!(trigger = sr_session_trigger_get()))
+ return SR_OK;
- if (!trigger || !probe->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 = probe_index + 1;
- devc->trigger_type = trigger_type;
}
/*
* Set trigger to any edge on all channels if the trigger for each
* channel is set to any edge.
*/
- if (num_triggers_anyedge == NUM_PROBES) {
+ if (num_triggers_anyedge == NUM_CHANNELS) {
devc->trigger_channel = TRIGGER_CHANNEL_ALL;
devc->trigger_type = TRIGGER_TYPE_ANYEDGE;
}
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,