summaryrefslogtreecommitdiff
path: root/decoders
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2016-08-26 15:14:07 +0200
committerUwe Hermann <uwe@hermann-uwe.de>2016-12-07 22:45:46 +0100
commit07e40f346ac1ed5ca98f636f2dd0ba5a7fe0011e (patch)
treeb376d7e2eb3ccbad2f0f5e0a4ff1fe5b8f7eb447 /decoders
parent592f355b7fcf1cfb9e38d5d52373b6559ac26ecc (diff)
downloadlibsigrokdecode-07e40f346ac1ed5ca98f636f2dd0ba5a7fe0011e.tar.gz
libsigrokdecode-07e40f346ac1ed5ca98f636f2dd0ba5a7fe0011e.zip
i2s: Convert to PD API version 3.
Diffstat (limited to 'decoders')
-rw-r--r--decoders/i2s/pd.py17
1 files changed, 5 insertions, 12 deletions
diff --git a/decoders/i2s/pd.py b/decoders/i2s/pd.py
index 3287a72..e14e5a4 100644
--- a/decoders/i2s/pd.py
+++ b/decoders/i2s/pd.py
@@ -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