SR_CONF_LOGIC_ANALYZER,
SR_CONF_SAMPLERATE,
SR_CONF_VOLTAGE_THRESHOLD,
+ SR_CONF_TRIGGER_MATCH,
/* These are really implemented in the driver, not the hardware. */
SR_CONF_LIMIT_SAMPLES,
SR_CONF_CONTINUOUS,
};
+static const int32_t soft_trigger_matches[] = {
+ SR_TRIGGER_ZERO,
+ SR_TRIGGER_ONE,
+ SR_TRIGGER_RISING,
+ SR_TRIGGER_FALLING,
+ SR_TRIGGER_EDGE,
+};
+
static const char *channel_names[] = {
"0", "1", "2", "3", "4", "5", "6", "7", "8",
"9", "10", "11", "12", "13", "14", "15",
}
*data = g_variant_builder_end(&gvb);
break;
+ case SR_CONF_TRIGGER_MATCH:
+ *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
+ soft_trigger_matches, ARRAY_SIZE(soft_trigger_matches),
+ sizeof(int32_t));
+ break;
default:
return SR_ERR_NA;
}
{
int i;
- devc->num_samples = -1;
+ devc->sent_samples = -1;
for (i = devc->num_transfers - 1; i >= 0; i--) {
if (devc->transfers[i])
tv.tv_sec = tv.tv_usec = 0;
libusb_handle_events_timeout(drvc->sr_ctx->libusb_ctx, &tv);
- if (devc->num_samples == -2) {
+ if (devc->sent_samples == -2) {
logic16_abort_acquisition(sdi);
abort_acquisition(devc);
}
struct dev_context *devc;
struct drv_context *drvc;
struct sr_usb_dev_inst *usb;
+ struct sr_trigger *trigger;
struct libusb_transfer *transfer;
unsigned int i, timeout, num_transfers;
int ret;
}
devc->cb_data = cb_data;
- devc->num_samples = 0;
+ devc->sent_samples = 0;
devc->empty_transfer_count = 0;
devc->cur_channel = 0;
memset(devc->channel_data, 0, sizeof(devc->channel_data));
+ if ((trigger = sr_session_trigger_get())) {
+ devc->stl = soft_trigger_logic_new(sdi, trigger);
+ devc->trigger_fired = FALSE;
+ } else
+ devc->trigger_fired = TRUE;
+
timeout = get_timeout(devc);
num_transfers = get_number_of_transfers(devc);
size = get_buffer_size(devc);
devc->num_transfers = 0;
g_free(devc->transfers);
g_free(devc->convbuffer);
+ if (devc->stl) {
+ soft_trigger_logic_free(devc->stl);
+ devc->stl = NULL;
+ }
}
static void free_transfer(struct libusb_transfer *transfer)
struct sr_datafeed_packet packet;
struct sr_datafeed_logic logic;
struct dev_context *devc;
- size_t converted_length;
+ size_t new_samples, num_samples;
+ int trigger_offset;
devc = transfer->user_data;
* If acquisition has already ended, just free any queued up
* transfer that come in.
*/
- if (devc->num_samples < 0) {
+ if (devc->sent_samples < 0) {
free_transfer(transfer);
return;
}
switch (transfer->status) {
case LIBUSB_TRANSFER_NO_DEVICE:
- devc->num_samples = -2;
+ devc->sent_samples = -2;
free_transfer(transfer);
return;
case LIBUSB_TRANSFER_COMPLETED:
* The FX2 gave up. End the acquisition, the frontend
* will work out that the samplecount is short.
*/
- devc->num_samples = -2;
+ devc->sent_samples = -2;
free_transfer(transfer);
} else {
resubmit_transfer(transfer);
devc->empty_transfer_count = 0;
}
- converted_length = convert_sample_data(devc, devc->convbuffer,
- devc->convbuffer_size, transfer->buffer,
- transfer->actual_length, devc->unitsize);
-
- if (converted_length > 0) {
- /* Cap sample count if needed. */
- if (devc->limit_samples &&
- (uint64_t)devc->num_samples + converted_length
- > devc->limit_samples) {
- converted_length =
- devc->limit_samples - devc->num_samples;
+ new_samples = convert_sample_data(devc, devc->convbuffer,
+ devc->convbuffer_size, transfer->buffer,
+ transfer->actual_length, devc->unitsize);
+
+ if (new_samples > 0) {
+ if (devc->trigger_fired) {
+ /* Send the incoming transfer to the session bus. */
+ packet.type = SR_DF_LOGIC;
+ packet.payload = &logic;
+ if (devc->limit_samples &&
+ new_samples > devc->limit_samples - devc->sent_samples)
+ new_samples = devc->limit_samples - devc->sent_samples;
+ logic.length = new_samples * devc->unitsize;
+ logic.unitsize = devc->unitsize;
+ logic.data = devc->convbuffer;
+ sr_session_send(devc->cb_data, &packet);
+ devc->sent_samples += new_samples;
+ } else {
+ trigger_offset = soft_trigger_logic_check(devc->stl,
+ devc->convbuffer, new_samples * devc->unitsize);
+ if (trigger_offset > -1) {
+ packet.type = SR_DF_LOGIC;
+ packet.payload = &logic;
+ num_samples = new_samples - trigger_offset;
+ if (devc->limit_samples &&
+ num_samples > devc->limit_samples - devc->sent_samples)
+ num_samples = devc->limit_samples - devc->sent_samples;
+ logic.length = num_samples * devc->unitsize;
+ logic.unitsize = devc->unitsize;
+ logic.data = devc->convbuffer + trigger_offset * devc->unitsize;
+ sr_session_send(devc->cb_data, &packet);
+ devc->sent_samples += num_samples;
+
+ devc->trigger_fired = TRUE;
+ }
}
- /* Send the incoming transfer to the session bus. */
- packet.type = SR_DF_LOGIC;
- packet.payload = &logic;
- logic.length = converted_length * devc->unitsize;
- logic.unitsize = devc->unitsize;
- logic.data = devc->convbuffer;
- sr_session_send(devc->cb_data, &packet);
-
- devc->num_samples += converted_length;
if (devc->limit_samples &&
- (uint64_t)devc->num_samples >= devc->limit_samples) {
- devc->num_samples = -2;
+ (uint64_t)devc->sent_samples >= devc->limit_samples) {
+ devc->sent_samples = -2;
free_transfer(transfer);
return;
}