X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=decoders%2Fi2s%2Fpd.py;h=b0b177f1f007f0687e460db06e49361121af18a3;hb=4539e9ca58966ce3c9cad4801b16c315e86ace01;hp=3287a7258ced6181b2c25aeaab21d1751a50e7b5;hpb=92b7b49f6964f57a7d6fc4473645c993cfa4ba52;p=libsigrokdecode.git diff --git a/decoders/i2s/pd.py b/decoders/i2s/pd.py index 3287a72..b0b177f 100644 --- a/decoders/i2s/pd.py +++ b/decoders/i2s/pd.py @@ -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 . ## 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' @@ -61,7 +60,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 +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