Skip to content

Commit

Permalink
OLS: Add support for advanced triggers
Browse files Browse the repository at this point in the history
This adds code from http://web.archive.org/web/20190317154112/
http://mygizmos.org/ols/Logic-Sniffer-FPGA-Spec.pdf (GPL2 with the option
to relicense it to any later version of that license) with reformatting
and without typos to set up the LUT bits.

The trigger setup starts with a delay to collect the required number of
pre-trigger samples. Afterwards, the remaining samples are captured or
further trigger stages follow.

Each of these extra stages mirrors what the user has defined as trigger
pattern: Level and edge triggers are combined and the state machine only
advances to the next stage if all levels and at least one edge meets the
conditions. Contrary to level triggers, edge triggers are ORed together.
This is an undocumented property of the Demon Core.
  • Loading branch information
v1ne committed Apr 2, 2020
1 parent a865b6c commit e89d03a
Show file tree
Hide file tree
Showing 3 changed files with 490 additions and 38 deletions.
25 changes: 19 additions & 6 deletions src/hardware/openbench-logic-sniffer/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,19 @@ static const uint32_t devopts[] = {
SR_CONF_RLE | SR_CONF_GET | SR_CONF_SET,
};

static const int32_t trigger_matches[] = {
static const int32_t basic_trigger_matches[] = {
SR_TRIGGER_ZERO,
SR_TRIGGER_ONE,
};

static const int32_t advanced_trigger_matches[] = {
SR_TRIGGER_ZERO,
SR_TRIGGER_ONE,
SR_TRIGGER_RISING,
SR_TRIGGER_FALLING,
SR_TRIGGER_EDGE,
};

static const char* external_clock_edges[] = {
"r", // positive edge
"f" // negative edge
Expand Down Expand Up @@ -334,7 +342,7 @@ static int config_set(uint32_t key, GVariant *data,
static int config_list(uint32_t key, GVariant **data,
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
struct dev_context *devc;
struct dev_context *devc = sdi ? sdi->priv : NULL;
int num_ols_changrp, i;

switch (key) {
Expand All @@ -345,7 +353,12 @@ static int config_list(uint32_t key, GVariant **data,
*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));
if (!devc)
return SR_ERR_ARG;
/* Advanced Triggering is only available on the Demon Core. */
*data = devc->device_flags & DEVICE_FLAG_IS_DEMON_CORE
? std_gvar_array_i32(ARRAY_AND_SIZE(advanced_trigger_matches))
: std_gvar_array_i32(ARRAY_AND_SIZE(basic_trigger_matches));
break;
case SR_CONF_CLOCK_EDGE:
*data = std_gvar_array_str(ARRAY_AND_SIZE(external_clock_edges));
Expand All @@ -354,9 +367,8 @@ static int config_list(uint32_t key, GVariant **data,
*data = g_variant_new_strv(ARRAY_AND_SIZE(patterns));
break;
case SR_CONF_LIMIT_SAMPLES:
if (!sdi)
if (!devc)
return SR_ERR_ARG;
devc = sdi->priv;
if (devc->max_samples == 0)
/* Device didn't specify sample memory size in metadata. */
return SR_ERR_NA;
Expand Down Expand Up @@ -394,7 +406,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
return ret;

/* Start acquisition on the device. */
if (send_shortcommand(serial, CMD_ARM_BASIC_TRIGGER) != SR_OK)
if (send_shortcommand(serial, devc->device_flags & DEVICE_FLAG_IS_DEMON_CORE
? CMD_ARM_ADVANCED_TRIGGER : CMD_ARM_BASIC_TRIGGER) != SR_OK)
return SR_ERR;

/* Reset all operational states. */
Expand Down
Loading

0 comments on commit e89d03a

Please sign in to comment.