From: Uwe Hermann Date: Tue, 4 Feb 2014 21:47:43 +0000 (+0100) Subject: spi: Fix warnings about CS# being de-asserted. X-Git-Tag: libsigrokdecode-0.3.0~94 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=bb08f4b3608b7ed4c932ed2041b1f41a5c9a7fed;p=libsigrokdecode.git spi: Fix warnings about CS# being de-asserted. --- diff --git a/decoders/spi/pd.py b/decoders/spi/pd.py index 3bebc7d..78b167a 100644 --- a/decoders/spi/pd.py +++ b/decoders/spi/pd.py @@ -109,7 +109,7 @@ class Decoder(srd.Decoder): self.mosibits = [] self.startsample = -1 self.samplenum = -1 - self.cs_was_deasserted_during_data_word = 0 + self.cs_was_deasserted = False self.oldcs = -1 self.oldpins = None self.have_cs = self.have_miso = self.have_mosi = None @@ -167,11 +167,12 @@ class Decoder(srd.Decoder): # If this is the first bit of a dataword, save its sample number. if self.bitcount == 0: self.startsample = self.samplenum + self.cs_was_deasserted = False if self.have_cs: active_low = (self.options['cs_polarity'] == 'active-low') - deasserted = cs if active_low else not cs + deasserted = (cs == 1) if active_low else (cs == 0) if deasserted: - self.cs_was_deasserted_during_data_word = 1 + self.cs_was_deasserted = True ws = self.options['wordsize'] @@ -218,7 +219,7 @@ class Decoder(srd.Decoder): bitrate = int(1 / elapsed * self.options['wordsize']) self.put(self.startsample, self.samplenum, self.out_bitrate, bitrate) - if self.have_cs and self.cs_was_deasserted_during_data_word: + if self.have_cs and self.cs_was_deasserted: self.putw([4, ['CS# was deasserted during this data word!']]) self.reset_decoder_state()