From: Uwe Hermann Date: Thu, 12 Sep 2013 18:45:02 +0000 (+0200) Subject: spi: Make data format a PD option, add annotation types. X-Git-Tag: libsigrokdecode-0.3.0~318 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=3eda7779a7db58d76f0512940da7f6d7e4339731;p=libsigrokdecode.git spi: Make data format a PD option, add annotation types. The data format can be specified via the PD's "format" option now, it is no longer an annotation type. Also, add and use two annotation types: "Data" and "Warnings". --- diff --git a/decoders/spi/pd.py b/decoders/spi/pd.py index 3816659..c15c882 100644 --- a/decoders/spi/pd.py +++ b/decoders/spi/pd.py @@ -2,7 +2,7 @@ ## This file is part of the libsigrokdecode project. ## ## Copyright (C) 2011 Gareth McMullin -## Copyright (C) 2012 Uwe Hermann +## Copyright (C) 2012-2013 Uwe Hermann ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -33,9 +33,6 @@ spi_mode = { (1, 1): 3, # Mode 3 } -# Annotation formats -ANN_HEX = 0 - class Decoder(srd.Decoder): api_version = 1 id = 'spi' @@ -60,9 +57,11 @@ class Decoder(srd.Decoder): 'cpha': ['Clock phase', 0], 'bitorder': ['Bit order within the SPI data', 'msb-first'], 'wordsize': ['Word size of SPI data', 8], # 1-64? + 'format': ['Data format', 'hex'], } annotations = [ - ['Hex', 'SPI data bytes in hex format'], + ['Data', 'SPI data'], + ['Warnings', 'Human-readable warnings'], ] def __init__(self): @@ -148,12 +147,12 @@ class Decoder(srd.Decoder): self.put(self.start_sample, self.samplenum, self.out_proto, ['DATA', self.mosidata, self.misodata]) self.put(self.start_sample, self.samplenum, self.out_ann, - [ANN_HEX, ['MOSI: 0x%02x, MISO: 0x%02x' % (self.mosidata, + [0, ['MOSI: 0x%02x, MISO: 0x%02x' % (self.mosidata, self.misodata)]]) if self.cs_was_deasserted_during_data_word: self.put(self.start_sample, self.samplenum, self.out_ann, - [ANN_HEX, ['WARNING: CS# was deasserted during this ' + [1, ['CS# was deasserted during this ' 'SPI data byte!']]) # Reset decoder state.