]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoders/aud/pd.py
decoders: Fix incorrect 'outputs' fields.
[libsigrokdecode.git] / decoders / aud / pd.py
index 6be1f8385270e3284a5bebe8ed0d0dffb2fc3d8e..ea19a100d3eec30e8ce3716b0a75c534a3b2d58a 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/>.
 ##
 
 # TODO:
 import sigrokdecode as srd
 
 class Decoder(srd.Decoder):
-    api_version = 2
+    api_version = 3
     id = 'aud'
     name = 'AUD'
     longname = 'Advanced User Debugger'
     desc = 'Renesas/Hitachi Advanced User Debugger (AUD) protocol.'
     license = 'gplv2+'
     inputs = ['logic']
-    outputs = ['aud']
+    outputs = []
+    tags = ['Debug/trace']
     channels = (
         {'id': 'audck', 'name': 'AUDCK', 'desc': 'AUD clock'},
         {'id': 'naudsync', 'name': 'nAUDSYNC', 'desc': 'AUD sync'},
@@ -46,13 +46,14 @@ class Decoder(srd.Decoder):
         ('dest', 'Destination address'),
     )
 
-    def __init__(self, **kwargs):
+    def __init__(self):
+        self.reset()
+
+    def reset(self):
         self.ncnt = 0
         self.nmax = 0
         self.addr = 0
         self.lastaddr = 0
-        self.samplenum = 0
-        self.oldclk = 0
         self.ss = 0
 
     def start(self):
@@ -61,15 +62,7 @@ class Decoder(srd.Decoder):
     def putx(self, data):
         self.put(self.ss, self.samplenum, self.out_ann, data)
 
-    def find_clk_edge(self, clk, sync, datapins):
-        # Ignore sample if there's no edge.
-        if clk == self.oldclk:
-            return
-        self.oldclk = clk
-        # Ignore falling edges.
-        if clk == 0:
-            return
-
+    def handle_clk_edge(self, clk, sync, datapins):
         # Reconstruct nibble.
         nib = 0
         for i in range(4):
@@ -106,9 +99,10 @@ class Decoder(srd.Decoder):
                 self.addr |= nib << (self.ncnt * 4)
                 self.ncnt += 1
 
-    def decode(self, ss, es, data):
-        for (self.samplenum, pins) in data:
+    def decode(self):
+        while True:
+            pins = self.wait({0: 'r'})
             clk = pins[0]
             sync = pins[1]
             d = pins[2:]
-            self.find_clk_edge(clk, sync, d)
+            self.handle_clk_edge(clk, sync, d)