]> sigrok.org Git - libsigrok.git/commitdiff
Demo: Add walking one/walking zero pattern
authorSoeren Apel <redacted>
Wed, 24 May 2017 09:20:04 +0000 (11:20 +0200)
committerUwe Hermann <redacted>
Sat, 27 May 2017 17:39:54 +0000 (19:39 +0200)
src/hardware/demo/api.c
src/hardware/demo/protocol.c
src/hardware/demo/protocol.h

index 8ffcfd93d08da939209ded164ca7a95dbdd34f53..29fadf5c601af393f02b540d032e6a32ded45276 100644 (file)
@@ -40,6 +40,8 @@ static const char *logic_pattern_str[] = {
        "sigrok",
        "random",
        "incremental",
+       "walking one",
+       "walking zero",
        "all-low",
        "all-high",
        "squid",
index 242d471ee26831fcf6f7240d0cc0f44fa1e1541c..7f5950b6b87188af6fa495eba402f69e8f37d8b7 100644 (file)
@@ -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. */
index 8eb841ce7d2e0b5fc61366a6cb9c4673670890e1..5d78c5e7ad3266ed89b3b5acc856de2f01865f88 100644 (file)
@@ -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,