demo: Port trigger configuration from fx2lafw.

This commit is contained in:
luftek 2018-10-09 12:04:54 +02:00 committed by Uwe Hermann
parent 07182332f0
commit 31f69b096f
2 changed files with 21 additions and 0 deletions

View 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;
}

View 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[] = {