Skip to content

Commit 5579c62

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 f15a469 commit 5579c62

File tree

3 files changed

+540
-38
lines changed

3 files changed

+540
-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 */
@@ -337,7 +345,7 @@ static int config_set(uint32_t key, GVariant *data,
337345
static int config_list(uint32_t key, GVariant **data,
338346
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
339347
{
340-
struct dev_context *devc;
348+
struct dev_context *devc = sdi ? sdi->priv : NULL;
341349
int num_ols_changrp, i;
342350

343351
switch (key) {
@@ -348,7 +356,12 @@ static int config_list(uint32_t key, GVariant **data,
348356
*data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates));
349357
break;
350358
case SR_CONF_TRIGGER_MATCH:
351-
*data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches));
359+
if (!devc)
360+
return SR_ERR_ARG;
361+
/* Advanced Triggering is only available on the Demon Core. */
362+
*data = devc->device_flags & DEVICE_FLAG_IS_DEMON_CORE
363+
? std_gvar_array_i32(ARRAY_AND_SIZE(advanced_trigger_matches))
364+
: std_gvar_array_i32(ARRAY_AND_SIZE(basic_trigger_matches));
352365
break;
353366
case SR_CONF_CLOCK_EDGE:
354367
*data = std_gvar_array_str(ARRAY_AND_SIZE(external_clock_edges));
@@ -357,9 +370,8 @@ static int config_list(uint32_t key, GVariant **data,
357370
*data = g_variant_new_strv(ARRAY_AND_SIZE(patterns));
358371
break;
359372
case SR_CONF_LIMIT_SAMPLES:
360-
if (!sdi)
373+
if (!devc)
361374
return SR_ERR_ARG;
362-
devc = sdi->priv;
363375
if (devc->max_samples == 0)
364376
/* Device didn't specify sample memory size in metadata. */
365377
return SR_ERR_NA;
@@ -398,7 +410,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
398410
return ret;
399411

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

404417
/* Reset all operational states. */

0 commit comments

Comments
 (0)