X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=blobdiff_plain;f=hardware%2Fikalogic-scanalogic2%2Fapi.c;h=b4c697f91a8e7b715825465bbb4c00e82c0acd78;hp=93a9ca87ce692bb384dfe98c8a01d005c9e96875;hb=43cd4637285833706f8a404ca027bcf0ee75b9ae;hpb=0b9b3c41c2768c5fda73b3e38b3483278bcab202 diff --git a/hardware/ikalogic-scanalogic2/api.c b/hardware/ikalogic-scanalogic2/api.c index 93a9ca87..b4c697f9 100644 --- a/hardware/ikalogic-scanalogic2/api.c +++ b/hardware/ikalogic-scanalogic2/api.c @@ -23,9 +23,14 @@ static const int hwcaps[] = { SR_CONF_LOGIC_ANALYZER, SR_CONF_SAMPLERATE, SR_CONF_LIMIT_SAMPLES, - SR_CONF_TRIGGER_TYPE, + SR_CONF_TRIGGER_MATCH, SR_CONF_CAPTURE_RATIO, - SR_CONF_MAX_UNCOMPRESSED_SAMPLES, +}; + +static const int32_t trigger_matches[] = { + SR_TRIGGER_RISING, + SR_TRIGGER_FALLING, + SR_TRIGGER_EDGE, }; SR_PRIV const uint64_t sl2_samplerates[NUM_SAMPLERATES] = { @@ -42,7 +47,7 @@ SR_PRIV const uint64_t sl2_samplerates[NUM_SAMPLERATES] = { SR_MHZ(20), }; -static const char *probe_names[NUM_PROBES + 1] = { +static const char *channel_names[NUM_CHANNELS + 1] = { "0", "1", "2", "3", NULL, }; @@ -60,7 +65,7 @@ static GSList *scan(GSList *options) GSList *usb_devices, *devices, *l; struct drv_context *drvc; struct sr_dev_inst *sdi; - struct sr_probe *probe; + struct sr_channel *ch; struct dev_context *devc; struct sr_usb_dev_inst *usb; struct device_info dev_info; @@ -137,11 +142,11 @@ static GSList *scan(GSList *options) sdi->inst_type = SR_INST_USB; sdi->conn = usb; - for (i = 0; probe_names[i]; i++) { - probe = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, - probe_names[i]); - sdi->probes = g_slist_append(sdi->probes, probe); - devc->probes[i] = probe; + for (i = 0; channel_names[i]; i++) { + ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, + channel_names[i]); + sdi->channels = g_slist_append(sdi->channels, ch); + devc->channels[i] = ch; } devc->state = STATE_IDLE; @@ -309,12 +314,12 @@ static int cleanup(void) } static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi, - const struct sr_probe_group *probe_group) + const struct sr_channel_group *cg) { struct dev_context *devc; int ret; - (void)probe_group; + (void)cg; ret = SR_OK; devc = sdi->priv; @@ -326,9 +331,6 @@ static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi, case SR_CONF_CAPTURE_RATIO: *data = g_variant_new_uint64(devc->capture_ratio); break; - case SR_CONF_MAX_UNCOMPRESSED_SAMPLES: - *data = g_variant_new_uint64(MAX_SAMPLES); - break; default: return SR_ERR_NA; } @@ -337,12 +339,12 @@ static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi, } static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi, - const struct sr_probe_group *probe_group) + const struct sr_channel_group *cg) { uint64_t samplerate, limit_samples, capture_ratio; int ret; - (void)probe_group; + (void)cg; if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; @@ -370,14 +372,14 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi, } static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, - const struct sr_probe_group *probe_group) + const struct sr_channel_group *cg) { - GVariant *gvar; + GVariant *gvar, *grange[2]; GVariantBuilder gvb; int ret; (void)sdi; - (void)probe_group; + (void)cg; ret = SR_OK; @@ -394,8 +396,15 @@ 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(TRIGGER_TYPES); + case SR_CONF_TRIGGER_MATCH: + *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, + trigger_matches, ARRAY_SIZE(trigger_matches), + sizeof(int32_t)); + break; + case SR_CONF_LIMIT_SAMPLES: + grange[0] = g_variant_new_uint64(0); + grange[1] = g_variant_new_uint64(MAX_SAMPLES); + *data = g_variant_new_tuple(grange, 2); break; default: return SR_ERR_NA; @@ -430,7 +439,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) * The trigger must be configured first because the calculation of the * pre and post trigger samples depends on a configured trigger. */ - sl2_configure_trigger(sdi); + sl2_convert_trigger(sdi); sl2_calculate_trigger_samples(sdi); trigger_bytes = devc->pre_trigger_bytes + devc->post_trigger_bytes; @@ -442,21 +451,21 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) if (trigger_bytes % PACKET_NUM_SAMPLE_BYTES != 0) devc->num_sample_packets++; - devc->num_enabled_probes = 0; + devc->num_enabled_channels = 0; /* - * Count the number of enabled probes and number them for a sequential + * Count the number of enabled channels and number them for a sequential * access. */ - for (i = 0, j = 0; i < NUM_PROBES; i++) { - if (devc->probes[i]->enabled) { - devc->num_enabled_probes++; - devc->probe_map[j] = i; + for (i = 0, j = 0; i < NUM_CHANNELS; i++) { + if (devc->channels[i]->enabled) { + devc->num_enabled_channels++; + devc->channel_map[j] = i; j++; } } - sr_dbg("Number of enabled probes: %i.", devc->num_enabled_probes); + sr_dbg("Number of enabled channels: %i.", devc->num_enabled_channels); /* Set up the transfer buffer for the acquisition. */ devc->xfer_data_out[0] = CMD_SAMPLE; @@ -481,7 +490,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_ERR; } - usb_source_add(drvc->sr_ctx, 100, ikalogic_scanalogic2_receive_data, (void *)sdi); + usb_source_add(sdi->session, drvc->sr_ctx, 100, + ikalogic_scanalogic2_receive_data, (void *)sdi); sr_dbg("Acquisition started successfully.");