X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=decoders%2Fmxc6225xu%2Fpd.py;h=7eac07e74940889b5424973ca59c25b002c0abdf;hb=d6d8a8a440ea2a81e6ddde33d16bc84d01cdb432;hp=39564a957f1e4d0ea4557c9316f82060d2eae704;hpb=24c74fd30fb161837c5f8b01baf3c0fe2dfa4ed5;p=libsigrokdecode.git diff --git a/decoders/mxc6225xu/pd.py b/decoders/mxc6225xu/pd.py index 39564a9..7eac07e 100644 --- a/decoders/mxc6225xu/pd.py +++ b/decoders/mxc6225xu/pd.py @@ -1,5 +1,5 @@ ## -## This file is part of the sigrok project. +## This file is part of the libsigrokdecode project. ## ## Copyright (C) 2012 Uwe Hermann ## @@ -14,12 +14,9 @@ ## 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 . ## -# MEMSIC MXC6225XU protocol decoder - import sigrokdecode as srd # Definitions of various bits in MXC6225XU registers. @@ -62,7 +59,7 @@ status = { } class Decoder(srd.Decoder): - api_version = 1 + api_version = 3 id = 'mxc6225xu' name = 'MXC6225XU' longname = 'MEMSIC MXC6225XU' @@ -70,24 +67,19 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['i2c'] outputs = ['mxc6225xu'] - probes = [] - optional_probes = [ - {'id': 'int', 'name': 'INT', 'desc': 'DTOS interrupt output pin'}, - ] - options = {} - annotations = [ - ['Text', 'Human-readable text'], - ] - - def __init__(self, **kwargs): - self.state = 'IDLE' + tags = ['IC', 'Sensor'] + annotations = ( + ('text', 'Human-readable text'), + ) - def start(self, metadata): - # self.out_proto = self.add(srd.OUTPUT_PROTO, 'mxc6225xu') - self.out_ann = self.add(srd.OUTPUT_ANN, 'mxc6225xu') + def __init__(self): + self.reset() - def report(self): - pass + def reset(self): + self.state = 'IDLE' + + def start(self): + self.out_ann = self.register(srd.OUTPUT_ANN) def putx(self, data): self.put(self.ss, self.es, self.out_ann, data) @@ -108,7 +100,7 @@ class Decoder(srd.Decoder): # Bits[7:7]: INT int_val = (b >> 7) & 1 s = 'unchanged and no' if (int_val == 0) else 'changed or' - ann = 'INT = %d: Orientation %s shake event occured\n' % (int_val, s) + ann = 'INT = %d: Orientation %s shake event occurred\n' % (int_val, s) # Bits[6:5]: SH[1:0] sh = (((b >> 6) & 1) << 1) | ((b >> 5) & 1) @@ -167,16 +159,15 @@ class Decoder(srd.Decoder): def decode(self, ss, es, data): cmd, databyte = data - # Store the start/end samples of this I2C packet. + # Store the start/end samples of this I²C packet. self.ss, self.es = ss, es # State machine. if self.state == 'IDLE': - # Wait for an I2C START condition. + # Wait for an I²C START condition. if cmd != 'START': return self.state = 'GET SLAVE ADDR' - self.block_start_sample = ss elif self.state == 'GET SLAVE ADDR': # Wait for an address write operation. # TODO: We should only handle packets to the slave(?) @@ -224,6 +215,3 @@ class Decoder(srd.Decoder): self.state = 'IDLE' else: pass # TODO? - else: - raise Exception('Invalid state: %d' % self.state) -