]> sigrok.org Git - libsigrokdecode.git/commitdiff
srd: SPI: Add support for arbitrary word sizes.
authorUwe Hermann <redacted>
Sat, 14 Jan 2012 17:09:11 +0000 (18:09 +0100)
committerUwe Hermann <redacted>
Sat, 14 Jan 2012 17:09:11 +0000 (18:09 +0100)
decoders/spi.py

index 0c98c1dea4e40b91b02912e62bece9624cb9736f..7c56aed6fb3a2aa60a62e9327a9a242e8bb49105 100644 (file)
@@ -114,20 +114,20 @@ class Decoder(srd.Decoder):
 
             # Receive MOSI bit into our shift register.
             if self.bit_order == MSB_FIRST:
-                self.mosidata |= mosi << (7 - self.bitcount)
+                self.mosidata |= mosi << (self.wordsize - 1 - self.bitcount)
             else:
                 self.mosidata |= mosi << self.bitcount
 
             # Receive MISO bit into our shift register.
             if self.bit_order == MSB_FIRST:
-                self.misodata |= miso << (7 - self.bitcount)
+                self.misodata |= miso << (self.wordsize - 1 - self.bitcount)
             else:
                 self.misodata |= miso << self.bitcount
 
             self.bitcount += 1
 
             # Continue to receive if not a byte yet.
-            if self.bitcount != 8:
+            if self.bitcount != self.wordsize:
                 continue
 
             self.put(self.start_sample, self.samplenum, self.out_proto,