X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decoders%2Fmxc6225xu%2Fpd.py;h=7eac07e74940889b5424973ca59c25b002c0abdf;hp=46c6c09dc95e5e1871c00c254734d450f15c6248;hb=d6d8a8a440ea2a81e6ddde33d16bc84d01cdb432;hpb=c515eed7ef7a04a42b5b34abd308e08d6942835e diff --git a/decoders/mxc6225xu/pd.py b/decoders/mxc6225xu/pd.py index 46c6c09..7eac07e 100644 --- a/decoders/mxc6225xu/pd.py +++ b/decoders/mxc6225xu/pd.py @@ -14,8 +14,7 @@ ## 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 . ## import sigrokdecode as srd @@ -60,7 +59,7 @@ status = { } class Decoder(srd.Decoder): - api_version = 1 + api_version = 3 id = 'mxc6225xu' name = 'MXC6225XU' longname = 'MEMSIC MXC6225XU' @@ -68,20 +67,18 @@ 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): + tags = ['IC', 'Sensor'] + annotations = ( + ('text', 'Human-readable text'), + ) + + def __init__(self): + self.reset() + + def reset(self): self.state = 'IDLE' def start(self): - # self.out_python = self.register(srd.OUTPUT_PYTHON) self.out_ann = self.register(srd.OUTPUT_ANN) def putx(self, data): @@ -103,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) @@ -171,7 +168,6 @@ class Decoder(srd.Decoder): 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(?) @@ -219,6 +215,3 @@ class Decoder(srd.Decoder): self.state = 'IDLE' else: pass # TODO? - else: - raise Exception('Invalid state: %s' % self.state) -