X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=decoders%2Fi2s%2Fpd.py;h=b0b177f1f007f0687e460db06e49361121af18a3;hb=4539e9ca58966ce3c9cad4801b16c315e86ace01;hp=6b94c1052ed031a223d42a9ec33ce5068ebcfa8a;hpb=2f37032807e19bc93b7f3223e1568db46318790c;p=libsigrokdecode.git diff --git a/decoders/i2s/pd.py b/decoders/i2s/pd.py index 6b94c10..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' @@ -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