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

index 3414c35f7cf3a17eff4548522f32e5a1fa57d406..9b318d281a5cc008b9aa41e550dc48e0a0bb8ac3 100644 (file)
@@ -65,7 +65,7 @@ BIT_CTRLSTAT_ORUNDETECT = 1
 ANNOTATIONS = ['reset', 'enable', 'read', 'write', 'ack', 'data', 'parity']
 
 class Decoder(srd.Decoder):
 ANNOTATIONS = ['reset', 'enable', 'read', 'write', 'ack', 'data', 'parity']
 
 class Decoder(srd.Decoder):
-    api_version = 2
+    api_version = 3
     id = 'swd'
     name = 'SWD'
     longname = 'Serial Wire Debug'
     id = 'swd'
     name = 'SWD'
     longname = 'Serial Wire Debug'
@@ -95,7 +95,6 @@ class Decoder(srd.Decoder):
     def __init__(self):
         # SWD data/clock state
         self.state = 'UNKNOWN'
     def __init__(self):
         # SWD data/clock state
         self.state = 'UNKNOWN'
-        self.oldclk = -1
         self.sample_edge = RISING
         self.ack = None # Ack state of the current phase
         self.ss_req = 0 # Start sample of current req
         self.sample_edge = RISING
         self.ack = None # Ack state of the current phase
         self.ss_req = 0 # Start sample of current req
@@ -142,11 +141,10 @@ class Decoder(srd.Decoder):
         }[(self.apdp, self.rw)]
         self.putp(ptype, (self.addr, self.data, self.ack))
 
         }[(self.apdp, self.rw)]
         self.putp(ptype, (self.addr, self.data, self.ack))
 
-    def decode(self, ss, es, data):
-        for (self.samplenum, (clk, dio)) in data:
-            if clk == self.oldclk:
-                continue # Not a clock edge.
-            self.oldclk = clk
+    def decode(self):
+        while True:
+            # Wait for any clock edge.
+            clk, dio = self.wait({0: 'e'})
 
             # Count rising edges with DIO held high,
             # as a line reset (50+ high edges) can happen from any state.
 
             # Count rising edges with DIO held high,
             # as a line reset (50+ high edges) can happen from any state.