Skip to content

Commit 789e911

Browse files
committed
ols: Add support for advanced triggers
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.
1 parent fb32bf1 commit 789e911

File tree

3 files changed

+489
-38
lines changed

3 files changed

+489
-38
lines changed

src/hardware/openbench-logic-sniffer/api.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,19 @@ static const uint32_t devopts[] = {
4343
SR_CONF_RLE | SR_CONF_GET | SR_CONF_SET,
4444
};
4545

46-
static const int32_t trigger_matches[] = {
46+
static const int32_t basic_trigger_matches[] = {
4747
SR_TRIGGER_ZERO,
4848
SR_TRIGGER_ONE,
4949
};
5050

51+
static const int32_t advanced_trigger_matches[] = {
52+
SR_TRIGGER_ZERO,
53+
SR_TRIGGER_ONE,
54+
SR_TRIGGER_RISING,
55+
SR_TRIGGER_FALLING,
56+
SR_TRIGGER_EDGE,
57+
};
58+
5159
static const char* external_clock_edges[] = {
5260
"rising", // positive edge
5361
"falling" // negative edge
@@ -336,7 +344,7 @@ static int config_set(uint32_t key, GVariant *data,
336344
static int config_list(uint32_t key, GVariant **data,
337345
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
338346
{
339-
struct dev_context *devc;
347+
struct dev_context *devc = sdi ? sdi->priv : NULL;
340348
int num_ols_changrp, i;
341349

342350
switch (key) {
@@ -347,7 +355,12 @@ static int config_list(uint32_t key, GVariant **data,
347355
*data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates));
348356
break;
349357
case SR_CONF_TRIGGER_MATCH:
350-
*data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches));
358+
if (!devc)
359+
return SR_ERR_ARG;
360+
/* Advanced Triggering is only available on the Demon Core. */
361+
*data = devc->device_flags & DEVICE_FLAG_IS_DEMON_CORE
362+
? std_gvar_array_i32(ARRAY_AND_SIZE(advanced_trigger_matches))
363+
: std_gvar_array_i32(ARRAY_AND_SIZE(basic_trigger_matches));
351364
break;
352365
case SR_CONF_CLOCK_EDGE:
353366
*data = std_gvar_array_str(ARRAY_AND_SIZE(external_clock_edges));
@@ -356,9 +369,8 @@ static int config_list(uint32_t key, GVariant **data,
356369
*data = g_variant_new_strv(ARRAY_AND_SIZE(patterns));
357370
break;
358371
case SR_CONF_LIMIT_SAMPLES:
359-
if (!sdi)
372+
if (!devc)
360373
return SR_ERR_ARG;
361-
devc = sdi->priv;
362374
if (devc->max_samples == 0)
363375
/* Device didn't specify sample memory size in metadata. */
364376
return SR_ERR_NA;
@@ -397,7 +409,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
397409
return ret;
398410

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

403416
/* Reset all operational states. */

0 commit comments

Comments
 (0)