hantek-dso: support for SR_HWCAP_FILTER
This commit is contained in:
parent
3c4976c9c4
commit
ebb781a69f
|
@ -48,6 +48,7 @@ static int capabilities[] = {
|
|||
SR_HWCAP_TRIGGER_SOURCE,
|
||||
SR_HWCAP_TRIGGER_SLOPE,
|
||||
SR_HWCAP_HORIZ_TRIGGERPOS,
|
||||
SR_HWCAP_FILTER,
|
||||
0,
|
||||
};
|
||||
|
||||
|
@ -101,6 +102,13 @@ static char *trigger_sources[] = {
|
|||
NULL
|
||||
};
|
||||
|
||||
static char *filter_targets[] = {
|
||||
"CH1",
|
||||
"CH2",
|
||||
/* TODO: "TRIGGER", */
|
||||
NULL
|
||||
};
|
||||
|
||||
SR_PRIV libusb_context *usb_context = NULL;
|
||||
SR_PRIV GSList *dev_insts = NULL;
|
||||
|
||||
|
@ -354,6 +362,9 @@ static void *hw_get_device_info(int dev_index, int dev_info_id)
|
|||
case SR_DI_TRIGGER_SOURCES:
|
||||
info = trigger_sources;
|
||||
break;
|
||||
case SR_DI_FILTERS:
|
||||
info = filter_targets;
|
||||
break;
|
||||
/* TODO remove this */
|
||||
case SR_DI_CUR_SAMPLERATE:
|
||||
info = &tmp;
|
||||
|
@ -387,7 +398,7 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value)
|
|||
float tmp_float;
|
||||
uint64_t tmp_u64;
|
||||
int ret, i;
|
||||
char *tmp_str;
|
||||
char *tmp_str, **targets;
|
||||
|
||||
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
|
||||
return SR_ERR;
|
||||
|
@ -452,6 +463,26 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value)
|
|||
if (trigger_sources[i] == 0)
|
||||
ret = SR_ERR_ARG;
|
||||
break;
|
||||
case SR_HWCAP_FILTER:
|
||||
ctx->filter_ch1 = ctx->filter_ch2 = ctx->filter_trigger = 0;
|
||||
targets = g_strsplit(value, ",", 0);
|
||||
for (i = 0; targets[i]; i++) {
|
||||
if (targets[i] == '\0')
|
||||
/* Empty filter string can be used to clear them all. */
|
||||
;
|
||||
else if (!strcmp(targets[i], "CH1"))
|
||||
ctx->filter_ch1 = TRUE;
|
||||
else if (!strcmp(targets[i], "CH2"))
|
||||
ctx->filter_ch2 = TRUE;
|
||||
else if (!strcmp(targets[i], "TRIGGER"))
|
||||
ctx->filter_trigger = TRUE;
|
||||
else {
|
||||
sr_err("invalid filter target %s", targets[i]);
|
||||
ret = SR_ERR_ARG;
|
||||
}
|
||||
}
|
||||
g_strfreev(targets);
|
||||
break;
|
||||
default:
|
||||
ret = SR_ERR_ARG;
|
||||
}
|
||||
|
|
|
@ -338,17 +338,24 @@ SR_PRIV int dso_set_filters(struct context *ctx)
|
|||
int ret, tmp;
|
||||
uint8_t cmdstring[8];
|
||||
|
||||
sr_dbg("hantek-dso: sending CMD_SET_FILTERS");
|
||||
sr_dbg("hantek-dso: preparing CMD_SET_FILTERS");
|
||||
|
||||
memset(cmdstring, 0, sizeof(cmdstring));
|
||||
cmdstring[0] = CMD_SET_FILTERS;
|
||||
cmdstring[1] = 0x0f;
|
||||
if (ctx->filter_ch1)
|
||||
if (ctx->filter_ch1) {
|
||||
sr_dbg("hantek-dso: turning on CH1 filter");
|
||||
cmdstring[2] |= 0x80;
|
||||
if (ctx->filter_ch2)
|
||||
}
|
||||
if (ctx->filter_ch2) {
|
||||
sr_dbg("hantek-dso: turning on CH2 filter");
|
||||
cmdstring[2] |= 0x40;
|
||||
if (ctx->filter_trigger)
|
||||
}
|
||||
if (ctx->filter_trigger) {
|
||||
/* TODO: supported on the DSO-2090? */
|
||||
sr_dbg("hantek-dso: turning on trigger filter");
|
||||
cmdstring[2] |= 0x20;
|
||||
}
|
||||
|
||||
if (send_begin(ctx) != SR_OK)
|
||||
return SR_ERR;
|
||||
|
@ -360,6 +367,7 @@ SR_PRIV int dso_set_filters(struct context *ctx)
|
|||
sr_err("Failed to set filters: %d", ret);
|
||||
return SR_ERR;
|
||||
}
|
||||
sr_dbg("hantek-dso: sent CMD_SET_FILTERS");
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue