From: Soeren Apel Date: Wed, 24 May 2017 09:20:04 +0000 (+0200) Subject: Demo: Add walking one/walking zero pattern X-Git-Tag: libsigrok-0.5.0~29 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=845060fa9ddbfae9441aa67fab4934f46f4baa05;p=libsigrok.git Demo: Add walking one/walking zero pattern --- diff --git a/src/hardware/demo/api.c b/src/hardware/demo/api.c index 8ffcfd93..29fadf5c 100644 --- a/src/hardware/demo/api.c +++ b/src/hardware/demo/api.c @@ -40,6 +40,8 @@ static const char *logic_pattern_str[] = { "sigrok", "random", "incremental", + "walking one", + "walking zero", "all-low", "all-high", "squid", diff --git a/src/hardware/demo/protocol.c b/src/hardware/demo/protocol.c index 242d471e..7f5950b6 100644 --- a/src/hardware/demo/protocol.c +++ b/src/hardware/demo/protocol.c @@ -279,6 +279,35 @@ static void logic_generator(struct sr_dev_inst *sdi, uint64_t size) devc->step++; } 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_HIGH: /* These were set when the pattern mode was selected. */ diff --git a/src/hardware/demo/protocol.h b/src/hardware/demo/protocol.h index 8eb841ce..5d78c5e7 100644 --- a/src/hardware/demo/protocol.h +++ b/src/hardware/demo/protocol.h @@ -75,6 +75,16 @@ enum { */ 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. */ PATTERN_ALL_LOW,