]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoders/i2c.py
srd: change output_new() API call to add()
[libsigrokdecode.git] / decoders / i2c.py
index 0f554f78f5fefce887fdc612eed5edbb2d2c2b1c..f098affcbbe966af5d208c85d4fc99c92ca51eaf 100644 (file)
@@ -180,8 +180,8 @@ class Decoder(sigrokdecode.Decoder):
         self.oldsda = None
 
     def start(self, metadata):
-        self.output_protocol = self.output_new(1)
-        self.output_annotation = self.output_new(0)
+        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: