X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decoders%2Fparallel%2Fpd.py;h=094b12a3595dff6e2cb83867145827bee22e2901;hp=c31718fb4efc371fadfe17d056425a40d805e988;hb=6a15597a7b3f901b566b7bfc8c484a14e0fb6a11;hpb=8eafa2613d2541e934a04874cd35cbc944c3168b diff --git a/decoders/parallel/pd.py b/decoders/parallel/pd.py index c31718f..094b12a 100644 --- a/decoders/parallel/pd.py +++ b/decoders/parallel/pd.py @@ -18,12 +18,10 @@ ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ## -# Parallel (sync) bus protocol decoder - import sigrokdecode as srd ''' -Protocol output format: +OUTPUT_PYTHON format: Packet: [, ] @@ -56,12 +54,12 @@ Packet: word is 7, and so on. ''' -def probe_list(num_probes): +def channel_list(num_channels): l = [{'id': 'clk', 'name': 'CLK', 'desc': 'Clock line'}] - for i in range(num_probes): + for i in range(num_channels): d = {'id': 'd%d' % i, 'name': 'D%d' % i, 'desc': 'Data line %d' % i} l.append(d) - return l + return tuple(l) class Decoder(srd.Decoder): api_version = 1 @@ -72,18 +70,18 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['parallel'] - probes = [] - optional_probes = probe_list(8) - options = { - 'clock_edge': ['Clock edge to sample on', 'rising'], - 'wordsize': ['Word size of the data', 1], - 'endianness': ['Endianness of the data', 'little'], - 'format': ['Data format', 'hex'], - } - annotations = [ - ['items', 'Items'], - ['words', 'Words'], - ] + optional_channels = channel_list(8) + options = ( + {'id': 'clock_edge', 'desc': 'Clock edge to sample on', + 'default': 'rising', 'values': ('rising', 'falling')}, + {'id': 'wordsize', 'desc': 'Data wordsize', 'default': 1}, + {'id': 'endianness', 'desc': 'Data endianness', + 'default': 'little', 'values': ('little', 'big')}, + ) + annotations = ( + ('items', 'Items'), + ('words', 'Words'), + ) def __init__(self): self.oldclk = None @@ -97,17 +95,17 @@ class Decoder(srd.Decoder): self.state = 'IDLE' def start(self): - self.out_proto = self.register(srd.OUTPUT_PYTHON) + self.out_python = self.register(srd.OUTPUT_PYTHON) self.out_ann = self.register(srd.OUTPUT_ANN) def putpb(self, data): - self.put(self.ss_item, self.es_item, self.out_proto, data) + self.put(self.ss_item, self.es_item, self.out_python, data) def putb(self, data): self.put(self.ss_item, self.es_item, self.out_ann, data) def putpw(self, data): - self.put(self.ss_word, self.es_word, self.out_proto, data) + self.put(self.ss_word, self.es_word, self.out_python, data) def putw(self, data): self.put(self.ss_word, self.es_word, self.out_ann, data) @@ -144,7 +142,7 @@ class Decoder(srd.Decoder): if self.itemcount < ws: return - # Output annotations/proto for a word (a collection of items). + # Output annotations/python for a word (a collection of items). word = 0 for i in range(ws): if endian == 'little':