]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoders/mx25lxx05d.py
srd: decoders: Rename obsolete timeoffset/duration.
[libsigrokdecode.git] / decoders / mx25lxx05d.py
index 973e0659cb9de765f5ddffca09c7e7d414202b50..8055c638668413f29c73d3aced9b563f16af8284 100644 (file)
@@ -30,7 +30,7 @@
 # http://www.macronix.com/QuickPlace/hq/PageLibrary4825740B00298A3B.nsf/h_Index/3F21BAC2E121E17848257639003A3146/$File/MX25L1605D-3205D-6405D-1.5.pdf
 #
 
-import sigrok
+import sigrokdecode as srd
 
 # States
 IDLE = -1
@@ -157,20 +157,9 @@ miso_packets = [
     {'type': 'D',  'range': (10, 11), 'data': 0xff, 'ann': ''},
 ]
 
-class Sample():
-    def __init__(self, data):
-        self.data = data
-    def probe(self, probe):
-        s = ord(self.data[int(probe / 8)]) & (1 << (probe % 8))
-        return True if s else False
-
-def sampleiter(data, unitsize):
-    for i in range(0, len(data), unitsize):
-        yield(Sample(data[i:i+unitsize]))
-
-class Decoder(sigrok.Decoder):
+class Decoder(srd.Decoder):
     id = 'mx25lxx05d'
-    name = 'Macronix MX25Lxx05D'
+    name = 'MX25Lxx05D'
     longname = 'Macronix MX25Lxx05D SPI flash chip decoder'
     desc = 'Macronix MX25Lxx05D SPI flash chip decoder'
     longdesc = 'TODO'
@@ -179,21 +168,18 @@ class Decoder(sigrok.Decoder):
     license = 'gplv2+'
     inputs = ['spi', 'spi', 'logic']
     outputs = ['mx25lxx05d']
-    probes = {} # TODO: HOLD#, WP#/ACC
+    probes = [] # TODO: HOLD#, WP#/ACC
     options = {} # TODO
+    annotations = []
 
     def __init__(self, **kwargs):
-        self.probes = Decoder.probes.copy()
-        self.output_protocol = None
-        self.output_annotation = None
         self.state = IDLE
         self.cmdstate = 1 # TODO
         self.out = []
 
     def start(self, metadata):
-        self.unitsize = metadata['unitsize']
-        # self.output_protocol = self.output_new(2)
-        self.output_annotation = self.output_new(1)
+        # self.out_proto = self.add(srd.OUTPUT_PROTO, 'mx25lxx05d')
+        self.out_ann = self.add(srd.OUTPUT_ANN, 'mx25lxx05d')
 
     def report(self):
         pass
@@ -324,7 +310,7 @@ class Decoder(sigrok.Decoder):
 
         self.out += o
 
-    def decode(self, timeoffset, duration, data):
+    def decode(self, ss, es, data):
         self.out = []
 
         # Iterate over all SPI MISO/MOSI packets. TODO: HOLD#, WP#/ACC?
@@ -364,6 +350,6 @@ class Decoder(sigrok.Decoder):
                 pass
 
         if self.out != []:
-            # self.put(self.output_protocol, 0, 0, out_proto)
-            self.put(self.output_annotation, 0, 0, self.out)
+            # self.put(0, 0, self.out_proto, out_proto)
+            self.put(0, 0, self.out_ann, self.out)