]> sigrok.org Git - libsigrok.git/commitdiff
demo: Port trigger configuration from fx2lafw.
authorluftek <redacted>
Tue, 9 Oct 2018 10:04:54 +0000 (12:04 +0200)
committerUwe Hermann <redacted>
Sun, 14 Oct 2018 19:37:30 +0000 (21:37 +0200)
src/hardware/demo/api.c
src/hardware/demo/protocol.h

index a44aa0985141bf11a13d15005f29790f94247c61..32ca88dd106d55da14ac7f5e03b58ddb90214e0c 100644 (file)
@@ -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;
                }
index d21d0d6a359c9a26f2cd92d42e7a63650afdd94b..cf1cca60e4207c6a18c8f82b186719bf496e7a53 100644 (file)
@@ -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[] = {