Demo: Add walking one/walking zero pattern

This commit is contained in:
Soeren Apel 2017-05-24 11:20:04 +02:00 committed by Uwe Hermann
parent eac48b3491
commit 845060fa9d
3 changed files with 41 additions and 0 deletions

View File

@ -40,6 +40,8 @@ static const char *logic_pattern_str[] = {
"sigrok", "sigrok",
"random", "random",
"incremental", "incremental",
"walking one",
"walking zero",
"all-low", "all-low",
"all-high", "all-high",
"squid", "squid",

View File

@ -279,6 +279,35 @@ static void logic_generator(struct sr_dev_inst *sdi, uint64_t size)
devc->step++; devc->step++;
} }
break; break;
case PATTERN_WALKING_ONE:
/* j contains the value of the highest bit */
j = 1 << (devc->num_logic_channels - 1);
for (i = 0; i < size; i++) {
devc->logic_data[i] = devc->step;
if (devc->step == 0)
devc->step = 1;
else
if (devc->step == j)
devc->step = 0;
else
devc->step <<= 1;
}
break;
case PATTERN_WALKING_ZERO:
/* Same as walking one, only with inverted output */
/* j contains the value of the highest bit */
j = 1 << (devc->num_logic_channels - 1);
for (i = 0; i < size; i++) {
devc->logic_data[i] = ~devc->step;
if (devc->step == 0)
devc->step = 1;
else
if (devc->step == j)
devc->step = 0;
else
devc->step <<= 1;
}
break;
case PATTERN_ALL_LOW: case PATTERN_ALL_LOW:
case PATTERN_ALL_HIGH: case PATTERN_ALL_HIGH:
/* These were set when the pattern mode was selected. */ /* These were set when the pattern mode was selected. */

View File

@ -75,6 +75,16 @@ enum {
*/ */
PATTERN_INC, PATTERN_INC,
/**
* Single bit "walking" across all logic channels by being
* shifted across data lines, restarting after the last line
* was used. An all-zero (all-one) state is inserted to prevent
* repetitive patterns (e.g. with 8 data lines, every 8th state
* would show the same line state)
*/
PATTERN_WALKING_ONE,
PATTERN_WALKING_ZERO,
/** All channels have a low logic state. */ /** All channels have a low logic state. */
PATTERN_ALL_LOW, PATTERN_ALL_LOW,