]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoders/i2s/pd.py
license: remove FSF postal address from boiler plate license text
[libsigrokdecode.git] / decoders / i2s / pd.py
index 6b94c1052ed031a223d42a9ec33ce5068ebcfa8a..b0b177f1f007f0687e460db06e49361121af18a3 100644 (file)
@@ -14,8 +14,7 @@
 ## GNU General Public License for more details.
 ##
 ## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+## along with this program; if not, see <http://www.gnu.org/licenses/>.
 ##
 
 import sigrokdecode as srd
@@ -37,7 +36,7 @@ class SamplerateError(Exception):
     pass
 
 class Decoder(srd.Decoder):
-    api_version = 2
+    api_version = 3
     id = 'i2s'
     name = 'I²S'
     longname = 'Integrated Interchip Sound'
@@ -59,9 +58,8 @@ class Decoder(srd.Decoder):
         ('wav', 'WAV file'),
     )
 
-    def __init__(self, **kwargs):
+    def __init__(self):
         self.samplerate = None
-        self.oldsck = 1
         self.oldws = 1
         self.bitcount = 0
         self.data = 0
@@ -130,18 +128,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