X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=decoders%2Fi2c.py;h=f098affcbbe966af5d208c85d4fc99c92ca51eaf;hb=f9a3947a7a8d884de6c55693b216f89b1d27d979;hp=2a10ab7408eb4c8950f27a46ff549a065c2a373a;hpb=3e2a9de2adfc73a640fa352fdc1ebc804fc98a69;p=libsigrokdecode.git diff --git a/decoders/i2c.py b/decoders/i2c.py index 2a10ab7..f098aff 100644 --- a/decoders/i2c.py +++ b/decoders/i2c.py @@ -180,8 +180,8 @@ class Decoder(sigrokdecode.Decoder): self.oldsda = None def start(self, metadata): - self.output_protocol = self.output_new(sigrokdecode.SRD_OUTPUT_PROTOCOL, 'i2c') - self.output_annotation = self.output_new(sigrokdecode.SRD_OUTPUT_ANNOTATION, 'i2c') + self.output_protocol = self.add(sigrokdecode.SRD_OUTPUT_PROTOCOL, 'i2c') + self.output_annotation = self.add(sigrokdecode.SRD_OUTPUT_ANNOTATION, 'i2c') def report(self): pass @@ -242,9 +242,12 @@ class Decoder(sigrokdecode.Decoder): self.databyte >>= 1 # Shift out unwanted ACK/NACK bit here. if self.state == FIND_ADDRESS: - d = self.databyte & 0xfe # The READ/WRITE bit is only in address bytes, not data bytes. - self.wr = 1 if (self.databyte & 1) else 0 + if self.databyte & 1: + self.wr = 0 + else: + self.wr = 1 + d = self.databyte >> 1 elif self.state == FIND_DATA: d = self.databyte else: