From: Uwe Hermann Date: Sat, 14 Jan 2012 17:09:11 +0000 (+0100) Subject: srd: SPI: Add support for arbitrary word sizes. X-Git-Tag: libsigrokdecode-0.1.0~154 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=cc2047464a6b01474721557f32acafd9f1f00cb9;p=libsigrokdecode.git srd: SPI: Add support for arbitrary word sizes. --- diff --git a/decoders/spi.py b/decoders/spi.py index 0c98c1d..7c56aed 100644 --- a/decoders/spi.py +++ b/decoders/spi.py @@ -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,