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']
36 ('data', 'Data', (0,)),
47 self.out_ann = self.register(srd.OUTPUT_ANN)
49 def put_data(self, pos, data):
50 self.put(pos[0], pos[1], self.out_ann, [0, [str(data) + 'V']])
52 def decode(self, ss, es, data):
55 if ptype == 'CS-CHANGE':
56 cs_old, cs_new = data[1:]
57 if cs_old is not None and cs_old == 0 and cs_new == 1:
60 self.put_data([self.ss, es], self.data)
62 elif cs_old is not None and cs_old == 1 and cs_new == 0:
66 for bit in reversed(mosi):
67 self.data = self.data | bit[0]