X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fopenbench-logic-sniffer%2Fapi.c;h=8a83abc711447843bf432964edf26ca3cd391fae;hb=8f996b89481670219c7576e2c68b128a0a2ce026;hp=0000b42dd9e9983a8c1d98da4ef8ba7daf2e7c8a;hpb=967760a8937e997ba9d7b729442f882947be154e;p=libsigrok.git diff --git a/hardware/openbench-logic-sniffer/api.c b/hardware/openbench-logic-sniffer/api.c index 0000b42d..8a83abc7 100644 --- a/hardware/openbench-logic-sniffer/api.c +++ b/hardware/openbench-logic-sniffer/api.c @@ -32,7 +32,9 @@ static const int32_t hwcaps[] = { SR_CONF_TRIGGER_TYPE, SR_CONF_CAPTURE_RATIO, SR_CONF_LIMIT_SAMPLES, + SR_CONF_EXTERNAL_CLOCK, SR_CONF_PATTERN_MODE, + SR_CONF_SWAP, SR_CONF_RLE, }; @@ -233,10 +235,13 @@ static int cleanup(void) return dev_clear(); } -static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi) +static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, + const struct sr_probe_group *probe_group) { struct dev_context *devc; + (void)probe_group; + if (!sdi) return SR_ERR_ARG; @@ -267,13 +272,16 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi) return SR_OK; } -static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) +static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi, + const struct sr_probe_group *probe_group) { struct dev_context *devc; int ret; uint64_t tmp_u64; const char *stropt; + (void)probe_group; + if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; @@ -301,6 +309,16 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) } else ret = SR_OK; break; + case SR_CONF_EXTERNAL_CLOCK: + if (g_variant_get_boolean(data)) { + sr_info("Enabling external clock."); + devc->flag_reg |= FLAG_CLOCK_EXTERNAL; + } else { + sr_info("Disabled external clock."); + devc->flag_reg &= ~FLAG_CLOCK_EXTERNAL; + } + ret = SR_OK; + break; case SR_CONF_PATTERN_MODE: stropt = g_variant_get_string(data, NULL); ret = SR_OK; @@ -314,6 +332,17 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) ret = SR_ERR; } break; + case SR_CONF_SWAP: + if (g_variant_get_boolean(data)) { + sr_info("Enabling channel swapping."); + devc->flag_reg |= FLAG_SWAP_PROBES; + } else { + sr_info("Disabling channel swapping."); + devc->flag_reg &= ~FLAG_SWAP_PROBES; + } + ret = SR_OK; + break; + case SR_CONF_RLE: if (g_variant_get_boolean(data)) { sr_info("Enabling RLE."); @@ -331,12 +360,14 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) return ret; } -static int config_list(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) { GVariant *gvar; GVariantBuilder gvb; (void)sdi; + (void)probe_group; switch (key) { case SR_CONF_SCAN_OPTIONS: @@ -466,8 +497,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, } sr_info("Setting samplerate to %" PRIu64 "Hz (divider %u, " - "demux %s)", devc->cur_samplerate, devc->cur_samplerate_divider, - devc->flag_reg & FLAG_DEMUX ? "on" : "off"); + "demux %s, noise_filter %s)", devc->cur_samplerate, + devc->cur_samplerate_divider, + devc->flag_reg & FLAG_DEMUX ? "on" : "off", + devc->flag_reg & FLAG_FILTER ? "on": "off"); if (send_longcommand(serial, CMD_SET_DIVIDER, reverse32(devc->cur_samplerate_divider)) != SR_OK) return SR_ERR; @@ -480,7 +513,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, /* The flag register wants them here, and 1 means "disable channel". */ devc->flag_reg |= ~(changrp_mask << 2) & 0x3c; - devc->flag_reg |= FLAG_FILTER; devc->rle_count = 0; data = (devc->flag_reg << 24) | ((devc->flag_reg << 8) & 0xff0000); if (send_longcommand(serial, CMD_SET_FLAGS, data) != SR_OK) @@ -492,6 +524,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, /* Reset all operational states. */ devc->num_transfers = devc->num_samples = devc->num_bytes = 0; + memset(devc->sample, 0, 4); /* Send header packet to the session bus. */ std_session_send_df_header(cb_data, LOG_PREFIX);