]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoders/lpc/pd.py
license: remove FSF postal address from boiler plate license text
[libsigrokdecode.git] / decoders / lpc / pd.py
index f097574b6bdbd6aa558fe0eb39ca3bd67a95d5b5..d0dadaa43a04b629c8f822e96b4d6d939a8a807f 100644 (file)
 ## 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/>.
 ##
 
-# LPC protocol decoder
-
 import sigrokdecode as srd
 
 # ...
@@ -98,7 +95,7 @@ fields = {
 }
 
 class Decoder(srd.Decoder):
-    api_version = 1
+    api_version = 2
     id = 'lpc'
     name = 'LPC'
     longname = 'Low-Pin-Count'
@@ -106,36 +103,39 @@ class Decoder(srd.Decoder):
     license = 'gplv2+'
     inputs = ['logic']
     outputs = ['lpc']
-    probes = [
-        {'id': 'lframe', 'name': 'LFRAME#', 'desc': 'TODO'},
-        {'id': 'lclk',   'name': 'LCLK',    'desc': 'TODO'},
-        {'id': 'lad0',   'name': 'LAD[0]',  'desc': 'TODO'},
-        {'id': 'lad1',   'name': 'LAD[1]',  'desc': 'TODO'},
-        {'id': 'lad2',   'name': 'LAD[2]',  'desc': 'TODO'},
-        {'id': 'lad3',   'name': 'LAD[3]',  'desc': 'TODO'},
-    ]
-    optional_probes = [
-        {'id': 'lreset', 'name': 'LRESET#', 'desc': 'TODO'},
-        {'id': 'ldrq',   'name': 'LDRQ#',   'desc': 'TODO'},
-        {'id': 'serirq', 'name': 'SERIRQ',  'desc': 'TODO'},
-        {'id': 'clkrun', 'name': 'CLKRUN#', 'desc': 'TODO'},
-        {'id': 'lpme',   'name': 'LPME#',   'desc': 'TODO'},
-        {'id': 'lpcpd',  'name': 'LPCPD#',  'desc': 'TODO'},
-        {'id': 'lsmi',   'name': 'LSMI#',   'desc': 'TODO'},
-    ]
-    options = {}
-    annotations = [
-        ['warnings', 'Warnings'],
-        ['start', 'Start'],
-        ['cycle_type', 'Cycle-type/direction'],
-        ['addr', 'Address'],
-        ['tar1', 'Turn-around cycle 1'],
-        ['sync', 'Sync'],
-        ['data', 'Data'],
-        ['tar2', 'Turn-around cycle 2'],
-    ]
-
-    def __init__(self, **kwargs):
+    channels = (
+        {'id': 'lframe', 'name': 'LFRAME#', 'desc': 'Frame'},
+        {'id': 'lclk',   'name': 'LCLK',    'desc': 'Clock'},
+        {'id': 'lad0',   'name': 'LAD[0]',  'desc': 'Addr/control/data 0'},
+        {'id': 'lad1',   'name': 'LAD[1]',  'desc': 'Addr/control/data 1'},
+        {'id': 'lad2',   'name': 'LAD[2]',  'desc': 'Addr/control/data 2'},
+        {'id': 'lad3',   'name': 'LAD[3]',  'desc': 'Addr/control/data 3'},
+    )
+    optional_channels = (
+        {'id': 'lreset', 'name': 'LRESET#', 'desc': 'Reset'},
+        {'id': 'ldrq',   'name': 'LDRQ#',   'desc': 'Encoded DMA / bus master request'},
+        {'id': 'serirq', 'name': 'SERIRQ',  'desc': 'Serialized IRQ'},
+        {'id': 'clkrun', 'name': 'CLKRUN#', 'desc': 'Clock run'},
+        {'id': 'lpme',   'name': 'LPME#',   'desc': 'LPC power management event'},
+        {'id': 'lpcpd',  'name': 'LPCPD#',  'desc': 'Power down'},
+        {'id': 'lsmi',   'name': 'LSMI#',   'desc': 'System Management Interrupt'},
+    )
+    annotations = (
+        ('warnings', 'Warnings'),
+        ('start', 'Start'),
+        ('cycle-type', 'Cycle-type/direction'),
+        ('addr', 'Address'),
+        ('tar1', 'Turn-around cycle 1'),
+        ('sync', 'Sync'),
+        ('data', 'Data'),
+        ('tar2', 'Turn-around cycle 2'),
+    )
+    annotation_rows = (
+        ('data', 'Data', (1, 2, 3, 4, 5, 6, 7)),
+        ('warnings', 'Warnings', (0,)),
+    )
+
+    def __init__(self):
         self.state = 'IDLE'
         self.oldlclk = -1
         self.samplenum = 0
@@ -151,7 +151,6 @@ class Decoder(srd.Decoder):
         self.ss_block = self.es_block = None
 
     def start(self):
-        # self.out_proto = self.register(srd.OUTPUT_PYTHON)
         self.out_ann = self.register(srd.OUTPUT_ANN)
 
     def putb(self, data):
@@ -346,7 +345,7 @@ class Decoder(srd.Decoder):
             if self.state == 'IDLE':
                 # A valid LPC cycle starts with LFRAME# being asserted (low).
                 if lframe != 0:
-                   continue
+                    continue
                 self.ss_block = self.samplenum
                 self.state = 'GET START'
                 self.lad = -1
@@ -365,6 +364,3 @@ class Decoder(srd.Decoder):
                 self.handle_get_data(lad, lad_bits)
             elif self.state == 'GET TAR2':
                 self.handle_get_tar2(lad, lad_bits)
-            else:
-                raise Exception('Invalid state: %s' % self.state)
-