X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=decoders%2Fspi%2Fpd.py;h=8579258d33d70de95ebc90c1e296cd035d6e33a5;hb=0c7d5a56449babeb84013118935c0dacecdadd70;hp=5c7df196370f2643378697199a63a3490dae1375;hpb=34929ee00c976842196ca95240b6cb1a7f5d8c75;p=libsigrokdecode.git diff --git a/decoders/spi/pd.py b/decoders/spi/pd.py index 5c7df19..8579258 100644 --- a/decoders/spi/pd.py +++ b/decoders/spi/pd.py @@ -63,7 +63,7 @@ spi_mode = { class SamplerateError(Exception): pass -class MissingDataError(Exception): +class ChannelError(Exception): pass class Decoder(srd.Decoder): @@ -116,7 +116,7 @@ class Decoder(srd.Decoder): self.misodata = self.mosidata = 0 self.misobits = [] self.mosibits = [] - self.startsample = -1 + self.ss_block = -1 self.samplenum = -1 self.cs_was_deasserted = False self.oldcs = -1 @@ -134,7 +134,7 @@ class Decoder(srd.Decoder): meta=(int, 'Bitrate', 'Bitrate during transfers')) def putw(self, data): - self.put(self.startsample, self.samplenum, self.out_ann, data) + self.put(self.ss_block, self.samplenum, self.out_ann, data) def putdata(self): # Pass MISO and MOSI bits and then data to the next PD up the stack. @@ -175,7 +175,7 @@ class Decoder(srd.Decoder): def handle_bit(self, miso, mosi, clk, cs): # If this is the first bit of a dataword, save its sample number. if self.bitcount == 0: - self.startsample = self.samplenum + self.ss_block = self.samplenum self.cs_was_deasserted = False if self.have_cs: active_low = (self.options['cs_polarity'] == 'active-low') @@ -225,9 +225,9 @@ class Decoder(srd.Decoder): # Meta bitrate. elapsed = 1 / float(self.samplerate) - elapsed *= (self.samplenum - self.startsample + 1) + elapsed *= (self.samplenum - self.ss_block + 1) bitrate = int(1 / elapsed * self.options['wordsize']) - self.put(self.startsample, self.samplenum, self.out_bitrate, bitrate) + self.put(self.ss_block, self.samplenum, self.out_bitrate, bitrate) if self.have_cs and self.cs_was_deasserted: self.putw([4, ['CS# was deasserted during this data word!']]) @@ -265,7 +265,7 @@ class Decoder(srd.Decoder): def decode(self, ss, es, data): if not self.samplerate: - raise SamplerateError("Cannot decode without samplerate.") + raise SamplerateError('Cannot decode without samplerate.') # Either MISO or MOSI can be omitted (but not both). CS# is optional. for (self.samplenum, pins) in data: @@ -279,7 +279,6 @@ class Decoder(srd.Decoder): # Either MISO or MOSI (but not both) can be omitted. if not (self.have_miso or self.have_mosi): - raise MissingDataError('Either MISO or MOSI (or both) pins required.') + raise ChannelError('Either MISO or MOSI (or both) pins required.') self.find_clk_edge(miso, mosi, clk, cs) -