2 ## This file is part of the libsigrokdecode project.
4 ## Copyright (C) 2012 Iztok Jeras <iztok.jeras@gmail.com>
6 ## This program is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation; either version 2 of the License, or
9 ## (at your option) any later version.
11 ## This program is distributed in the hope that it will be useful,
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ## GNU General Public License for more details.
16 ## You should have received a copy of the GNU General Public License
17 ## along with this program; if not, write to the Free Software
18 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 import sigrokdecode as srd
23 # Dictionary of FUNCTION commands and their names.
26 0x4e: 'Write scratchpad',
27 0xbe: 'Read scratchpad',
28 0x48: 'Copy scratchpad',
30 0x44: 'Convert temperature',
31 0xb4: 'Read power mode',
32 0xb8: 'Recall EEPROM',
33 0xf5: 'PIO access read',
34 0xA5: 'PIO access write',
38 class Decoder(srd.Decoder):
42 longname = 'Maxim DS28EA00 1-Wire digital thermometer'
43 desc = '1-Wire digital thermometer with Sequence Detect and PIO.'
45 inputs = ['onewire_network']
46 outputs = ['maxim_ds28ea00']
48 ('text', 'Human-readable text'),
55 self.rom = 0x0000000000000000
58 self.out_ann = self.register(srd.OUTPUT_ANN)
61 self.put(self.ss, self.es, self.out_ann, data)
63 def decode(self, ss, es, data):
66 self.ss, self.es = ss, es
69 if code == 'RESET/PRESENCE':
70 self.putx([0, ['Reset/presence: %s'
71 % ('true' if val else 'false')]])
75 self.putx([0, ['ROM: 0x%016x' % (val)]])
76 self.state = 'COMMAND'
78 if self.state == 'COMMAND':
79 if val not in command:
80 self.putx([0, ['Unrecognized command: 0x%02x' % val]])
82 self.putx([0, ['Function command: 0x%02x \'%s\''
83 % (val, command[val])]])
84 self.state = command[val].upper()
85 elif self.state == 'READ SCRATCHPAD':
86 self.putx([0, ['Scratchpad data: 0x%02x' % val]])
87 elif self.state == 'CONVERT TEMPERATURE':
88 self.putx([0, ['Temperature conversion status: 0x%02x' % val]])
89 elif self.state in [s.upper() for s in command.values()]:
90 self.putx([0, ['TODO \'%s\': 0x%02x' % (self.state, val)]])