]> sigrok.org Git - libsigrokdecode.git/commitdiff
i2s: Convert to PD API version 3.
authorUwe Hermann <redacted>
Fri, 26 Aug 2016 13:14:07 +0000 (15:14 +0200)
committerUwe Hermann <redacted>
Wed, 7 Dec 2016 21:45:46 +0000 (22:45 +0100)
decoders/i2s/pd.py

index 3287a7258ced6181b2c25aeaab21d1751a50e7b5..e14e5a4b4d369a079ce9e62c9fda4daf12caea6b 100644 (file)
@@ -37,7 +37,7 @@ class SamplerateError(Exception):
     pass
 
 class Decoder(srd.Decoder):
-    api_version = 2
+    api_version = 3
     id = 'i2s'
     name = 'I²S'
     longname = 'Integrated Interchip Sound'
@@ -61,7 +61,6 @@ class Decoder(srd.Decoder):
 
     def __init__(self):
         self.samplerate = None
-        self.oldsck = 1
         self.oldws = 1
         self.bitcount = 0
         self.data = 0
@@ -130,18 +129,12 @@ class Decoder(srd.Decoder):
         lo, hi = s & 0xff, (s >> 8) & 0xff
         return bytes([lo, hi])
 
-    def decode(self, ss, es, data):
+    def decode(self):
         if not self.samplerate:
             raise SamplerateError('Cannot decode without samplerate.')
-        for self.samplenum, (sck, ws, sd) in data:
-
-            # Ignore sample if the bit clock hasn't changed.
-            if sck == self.oldsck:
-                continue
-
-            self.oldsck = sck
-            if sck == 0:   # Ignore the falling clock edge.
-                continue
+        while True:
+            # Wait for a rising edge on the SCK pin.
+            sck, ws, sd = self.wait({0: 'r'})
 
             self.data = (self.data << 1) | sd
             self.bitcount += 1