X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Ffx2lafw%2Fapi.c;h=49236511f2735576b3c005a71a3e88a0c6e5dd7c;hb=9740d9bf8c257e714d937602a10b8d81a7762d4e;hp=c2dc2e0c2772d465c7b28763fee78b8297e1d1b6;hpb=f66d45806fb6f9757343db72664ab2b058c75985;p=libsigrok.git diff --git a/hardware/fx2lafw/api.c b/hardware/fx2lafw/api.c index c2dc2e0c..49236511 100644 --- a/hardware/fx2lafw/api.c +++ b/hardware/fx2lafw/api.c @@ -79,7 +79,7 @@ static const int32_t hwopts[] = { static const int32_t hwcaps[] = { SR_CONF_LOGIC_ANALYZER, - SR_CONF_TRIGGER_TYPE, + SR_CONF_TRIGGER_MATCH, SR_CONF_SAMPLERATE, /* These are really implemented in the driver, not the hardware. */ @@ -93,6 +93,14 @@ static const char *channel_names[] = { NULL, }; +static const int32_t soft_trigger_matches[] = { + SR_TRIGGER_ZERO, + SR_TRIGGER_ONE, + SR_TRIGGER_RISING, + SR_TRIGGER_FALLING, + SR_TRIGGER_EDGE, +}; + static const uint64_t samplerates[] = { SR_KHZ(20), SR_KHZ(25), @@ -369,7 +377,6 @@ static int cleanup(void) if (!(drvc = di->priv)) return SR_OK; - ret = std_dev_clear(di, NULL); g_free(drvc); @@ -475,8 +482,10 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, 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(SOFT_TRIGGER_TYPES); + 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; @@ -507,6 +516,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) 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; @@ -520,17 +530,17 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc = sdi->priv; usb = sdi->conn; - /* Configures devc->trigger_* and devc->sample_wide */ - if (fx2lafw_configure_channels(sdi) != SR_OK) { - sr_err("Failed to configure channels."); - return SR_ERR; - } - devc->cb_data = cb_data; devc->sent_samples = 0; devc->acq_aborted = FALSE; devc->empty_transfer_count = 0; + if ((trigger = sr_session_trigger_get())) { + devc->stl = soft_trigger_logic_new(sdi, trigger); + devc->trigger_fired = FALSE; + } else + devc->trigger_fired = TRUE; + timeout = fx2lafw_get_timeout(devc); num_transfers = fx2lafw_get_number_of_transfers(devc); size = fx2lafw_get_buffer_size(devc); @@ -551,7 +561,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) transfer = libusb_alloc_transfer(0); libusb_fill_bulk_transfer(transfer, usb->devhdl, 2 | LIBUSB_ENDPOINT_IN, buf, size, - fx2lafw_receive_transfer, devc, timeout); + fx2lafw_receive_transfer, (void *)sdi, timeout); if ((ret = libusb_submit_transfer(transfer)) != 0) { sr_err("Failed to submit transfer: %s.", libusb_error_name(ret));