Skip to content

Commit 5696a4d

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 6af1de2 commit 5696a4d

File tree

3 files changed

+631
-37
lines changed

3 files changed

+631
-37
lines changed

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

Lines changed: 21 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 */
@@ -343,7 +351,7 @@ static int config_list(uint32_t key, GVariant **data,
343351
const struct sr_dev_inst *sdi,
344352
const struct sr_channel_group *cg)
345353
{
346-
struct dev_context *devc;
354+
struct dev_context *devc = sdi ? sdi->priv : NULL;
347355
int num_ols_changrp, i;
348356

349357
switch (key) {
@@ -355,7 +363,12 @@ static int config_list(uint32_t key, GVariant **data,
355363
*data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates));
356364
break;
357365
case SR_CONF_TRIGGER_MATCH:
358-
*data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches));
366+
if (!devc)
367+
return SR_ERR_ARG;
368+
/* Advanced Triggering is only available on the Demon Core. */
369+
*data = devc->device_flags & DEVICE_FLAG_IS_DEMON_CORE
370+
? std_gvar_array_i32(ARRAY_AND_SIZE(advanced_trigger_matches))
371+
: std_gvar_array_i32(ARRAY_AND_SIZE(basic_trigger_matches));
359372
break;
360373
case SR_CONF_CLOCK_EDGE:
361374
*data = std_gvar_array_str(ARRAY_AND_SIZE(external_clock_edges));
@@ -364,9 +377,8 @@ static int config_list(uint32_t key, GVariant **data,
364377
*data = g_variant_new_strv(ARRAY_AND_SIZE(patterns));
365378
break;
366379
case SR_CONF_LIMIT_SAMPLES:
367-
if (!sdi)
380+
if (!devc)
368381
return SR_ERR_ARG;
369-
devc = sdi->priv;
370382
if (devc->max_samples == 0)
371383
/* Device didn't specify sample memory size in metadata. */
372384
return SR_ERR_NA;
@@ -405,7 +417,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
405417
return ret;
406418

407419
/* Start acquisition on the device. */
408-
if (send_shortcommand(serial, CMD_ARM_BASIC_TRIGGER) != SR_OK)
420+
if (send_shortcommand(serial,
421+
devc->device_flags & DEVICE_FLAG_IS_DEMON_CORE ?
422+
CMD_ARM_ADVANCED_TRIGGER :
423+
CMD_ARM_BASIC_TRIGGER) != SR_OK)
409424
return SR_ERR;
410425

411426
/* Reset all operational states. */

0 commit comments

Comments
 (0)