- devc->pretrig_entries =
- (devc->capture_ratio * devc->limit_samples) / 100;
- devc->stl =
- soft_trigger_logic_new(sdi, trigger,
- devc->pretrig_entries);
+ if (g_slist_length(trigger->stages) > 1)
+ return SR_ERR_NA;
+
+ struct sr_trigger_stage *stage;
+ struct sr_trigger_match *match;
+ GSList *l;
+ stage = g_slist_nth_data(trigger->stages, 0);
+ if (!stage)
+ return SR_ERR_ARG;
+ for (l = stage->matches; l; l = l->next) {
+ match = l->data;
+ if (!match->match)
+ continue;
+ if (!match->channel->enabled)
+ continue;
+ int idx = match->channel->index;
+ int8_t val;
+ switch(match->match) {
+ case SR_TRIGGER_ZERO:
+ val = 0; break;
+ case SR_TRIGGER_ONE:
+ val = 1; break;
+ case SR_TRIGGER_RISING:
+ val = 2; break;
+ case SR_TRIGGER_FALLING:
+ val = 3; break;
+ case SR_TRIGGER_EDGE:
+ val = 4; break;
+ default:
+ val = -1;
+ }
+ sr_info("Trigger value idx %d match %d", idx, match->match);
+ /* Only set trigger on enabled channels */
+ if ((val >= 0) && ((devc->d_chan_mask >> idx) & 1)) {
+ sprintf(&tmpstr[0], "t%d%02d\n", val, idx+2);
+ if (send_serial_w_ack(serial, tmpstr) != SR_OK) {
+ sr_err("Trigger cfg to device failed");
+ return SR_ERR;
+ }
+ }
+ }
+
+ sprintf(&tmpstr[0], "p%d\n", devc->pretrig_entries);
+ if (send_serial_w_ack(serial, tmpstr) != SR_OK) {
+ sr_err("Pretrig to device failed");
+ return SR_ERR;
+ }
+
+ devc->stl = soft_trigger_logic_new(sdi, trigger, devc->pretrig_entries);