X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=decoders%2Fi2c%2Fi2c.py;h=816fd790baa33fb4ca0d2091390911ad4b91596a;hb=ad022d94ef9a32428fe44710e7eff311991fd9e6;hp=270e0f3a9f3faeaf1bb041630dbe1a5a32907f97;hpb=c49750787d045582dc08419b1312770a57fb845f;p=libsigrokdecode.git diff --git a/decoders/i2c/i2c.py b/decoders/i2c/i2c.py index 270e0f3..816fd79 100644 --- a/decoders/i2c/i2c.py +++ b/decoders/i2c/i2c.py @@ -129,6 +129,7 @@ class Decoder(srd.Decoder): {'id': 'scl', 'name': 'SCL', 'desc': 'Serial clock line'}, {'id': 'sda', 'name': 'SDA', 'desc': 'Serial data line'}, ] + extra_probes = [] options = { 'addressing': ['Slave addressing (in bits)', 7], # 7 or 10 } @@ -154,13 +155,13 @@ class Decoder(srd.Decoder): self.oldscl = None self.oldsda = None - # Set protocol decoder option defaults. - self.addressing = Decoder.options['addressing'][1] - def start(self, metadata): self.out_proto = self.add(srd.OUTPUT_PROTO, 'i2c') self.out_ann = self.add(srd.OUTPUT_ANN, 'i2c') + def report(self): + pass + def is_start_condition(self, scl, sda): # START condition (S): SDA = falling, SCL = high if (self.oldsda == 1 and sda == 0) and scl == 1: @@ -293,8 +294,7 @@ class Decoder(srd.Decoder): elif self.is_stop_condition(scl, sda): self.found_stop(scl, sda) else: - # Shouldn't happen. - raise Exception("unknown state %d" % self.STATE) + raise Exception('Invalid state %d' % self.STATE) # Save current SDA/SCL values for the next round. self.oldscl = scl