2 ## This file is part of the libsigrokdecode project.
4 ## Copyright (C) 2020 Analog Devices Inc.
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 3 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, see <http://www.gnu.org/licenses/>.
20 import sigrokdecode as srd
22 class Decoder(srd.Decoder):
26 longname = 'Analog Devices AD5626'
27 desc = 'Analog Devices AD5626 12-bit nanoDAC.'
31 tags = ['IC', 'Analog/digital']
33 ('voltage', 'Voltage'),
44 self.out_ann = self.register(srd.OUTPUT_ANN)
46 def decode(self, ss, es, data):
49 if ptype == 'CS-CHANGE':
50 cs_old, cs_new = data[1:]
51 if cs_old is not None and cs_old == 0 and cs_new == 1:
54 self.put(self.ss, es, self.out_ann, [0, ['%.3fV' % self.data]])
56 elif cs_old is not None and cs_old == 1 and cs_new == 0:
60 for bit in reversed(mosi):
61 self.data = self.data | bit[0]