From: luftek Date: Tue, 9 Oct 2018 10:04:54 +0000 (+0200) Subject: demo: Port trigger configuration from fx2lafw. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=31f69b096f8020d817ff26800231cb549f5ce11e;p=libsigrok.git demo: Port trigger configuration from fx2lafw. --- diff --git a/src/hardware/demo/api.c b/src/hardware/demo/api.c index a44aa098..32ca88dd 100644 --- a/src/hardware/demo/api.c +++ b/src/hardware/demo/api.c @@ -67,6 +67,8 @@ static const uint32_t devopts[] = { SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, SR_CONF_AVERAGING | SR_CONF_GET | SR_CONF_SET, SR_CONF_AVG_SAMPLES | SR_CONF_GET | SR_CONF_SET, + SR_CONF_TRIGGER_MATCH | SR_CONF_LIST, + SR_CONF_CAPTURE_RATIO | SR_CONF_GET | SR_CONF_SET, }; static const uint32_t devopts_cg_logic[] = { @@ -82,6 +84,14 @@ static const uint32_t devopts_cg_analog_channel[] = { SR_CONF_AMPLITUDE | SR_CONF_GET | SR_CONF_SET, }; +static const int32_t trigger_matches[] = { + SR_TRIGGER_ZERO, + SR_TRIGGER_ONE, + SR_TRIGGER_RISING, + SR_TRIGGER_FALLING, + SR_TRIGGER_EDGE, +}; + static const uint64_t samplerates[] = { SR_HZ(1), SR_GHZ(1), @@ -265,6 +275,9 @@ static int config_get(uint32_t key, GVariant **data, ag = g_hash_table_lookup(devc->ch_ag, ch); *data = g_variant_new_double(ag->amplitude); break; + case SR_CONF_CAPTURE_RATIO: + *data = g_variant_new_uint64(devc->capture_ratio); + break; default: return SR_ERR_NA; } @@ -348,6 +361,9 @@ static int config_set(uint32_t key, GVariant *data, ag->amplitude = g_variant_get_double(data); } break; + case SR_CONF_CAPTURE_RATIO: + devc->capture_ratio = g_variant_get_uint64(data); + break; default: return SR_ERR_NA; } @@ -368,6 +384,9 @@ static int config_list(uint32_t key, GVariant **data, case SR_CONF_SAMPLERATE: *data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates)); break; + case SR_CONF_TRIGGER_MATCH: + *data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches)); + break; default: return SR_ERR_NA; } diff --git a/src/hardware/demo/protocol.h b/src/hardware/demo/protocol.h index d21d0d6a..cf1cca60 100644 --- a/src/hardware/demo/protocol.h +++ b/src/hardware/demo/protocol.h @@ -117,6 +117,8 @@ struct dev_context { size_t enabled_analog_channels; size_t first_partial_logic_index; uint8_t first_partial_logic_mask; + /* Triggers */ + uint64_t capture_ratio; }; static const char *analog_pattern_str[] = {