X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fpipistrello-ols%2Fapi.c;h=5006380b6374a418a9f18621d0c95d1610365f0c;hb=105df67463b84683a35f3474eccc871e5aa4ed0e;hp=a9a137beafdfb345dd423250ae3e8133eb7a06a5;hpb=e66d1892d0dd16ed166fc8f13493f95de0607362;p=libsigrok.git diff --git a/src/hardware/pipistrello-ols/api.c b/src/hardware/pipistrello-ols/api.c index a9a137be..5006380b 100644 --- a/src/hardware/pipistrello-ols/api.c +++ b/src/hardware/pipistrello-ols/api.c @@ -20,8 +20,11 @@ #include #include "protocol.h" -static const uint32_t devopts[] = { +static const uint32_t drvopts[] = { SR_CONF_LOGIC_ANALYZER, +}; + +static const uint32_t devopts[] = { SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, SR_CONF_TRIGGER_MATCH | SR_CONF_LIST, @@ -88,31 +91,24 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) devices = NULL; - /* Allocate memory for our private device context. */ devc = g_malloc0(sizeof(struct dev_context)); - /* Device-specific settings */ devc->max_samplebytes = devc->max_samplerate = devc->protocol_version = 0; - /* Acquisition settings */ devc->limit_samples = devc->capture_ratio = 0; devc->trigger_at = -1; devc->channel_mask = 0xffffffff; devc->flag_reg = 0; - /* Allocate memory for the incoming ftdi data. */ devc->ftdi_buf = g_malloc0(FTDI_BUF_SIZE); - /* Allocate memory for the FTDI context (ftdic) and initialize it. */ if (!(devc->ftdic = ftdi_new())) { sr_err("Failed to initialize libftdi."); goto err_free_ftdi_buf;; } - /* Try to open the FTDI device */ - if (p_ols_open(devc) != SR_OK) { + if (p_ols_open(devc) != SR_OK) goto err_free_ftdic; - } /* The discovery procedure is like this: first send the Reset * command (0x00) 5 times, since the device could be anywhere @@ -163,7 +159,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) goto err_close_ftdic; } - /* Close device. We'll reopen it again when we need it. */ p_ols_close(devc); /* Parse the metadata. */ @@ -181,7 +176,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) err_close_ftdic: p_ols_close(devc); err_free_ftdic: - ftdi_free(devc->ftdic); /* NOT free() or g_free()! */ + ftdi_free(devc->ftdic); err_free_ftdi_buf: g_free(devc->ftdi_buf); g_free(devc); @@ -339,24 +334,17 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * const struct sr_channel_group *cg) { struct dev_context *devc; - GVariant *gvar, *grange[2]; - GVariantBuilder gvb; + GVariant *grange[2]; int num_pols_changrp, i; switch (key) { case SR_CONF_DEVICE_OPTIONS: - return STD_CONFIG_LIST(key, data, sdi, cg, NULL, NULL, devopts); + return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts); case SR_CONF_SAMPLERATE: - g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}")); - gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), samplerates, - ARRAY_SIZE(samplerates), sizeof(uint64_t)); - g_variant_builder_add(&gvb, "{sv}", "samplerate-steps", gvar); - *data = g_variant_builder_end(&gvb); + *data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates)); break; case SR_CONF_TRIGGER_MATCH: - *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, - trigger_matches, ARRAY_SIZE(trigger_matches), - sizeof(int32_t)); + *data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches)); break; case SR_CONF_PATTERN_MODE: *data = g_variant_new_strv(patterns, ARRAY_SIZE(patterns));