61 def __init__(self, chip, vref, channelCount, resolution, name):
62 SPI.__init__(self,
toint(chip), 0, 8, 10000000)
63 DAC.__init__(self,
toint(channelCount),
toint(resolution), float(vref))
65 self.values = [0
for i
in range(
toint(channelCount))]
70 return "%s(chip=%d)(chips=%d)(slice=%d)" % (self.name, self.chip, self.chips, self.slice)
75 return self.values[channel]
82 def __init__(self, chip, vref, channelCount, resolution, name, chipsCount):
83 ADVRSPIDC.__init__(self, chip, vref, channelCount*chipsCount, resolution, name)
84 self.chips = chipsCount
85 self.slice = channelCount
92 self.values[channel] = value & 0xFF
95 chipAddr = channel%self.slice
96 addressString = (bin(chipAddr)[2:]).rjust(self.ADDRESS_BITS,
'0')
97 debug(
"Address=%s" % addressString)
99 slotValues = self.values[chipAddr::self.slice]
104 unpaddedNumberBits = (self.ADDRESS_BITS + 8) * self.chips
105 debug(
"Unpadlength=%s" % unpaddedNumberBits)
107 lastBit = (unpaddedNumberBits % 8)
109 padLength = 8 - lastBit
112 debug(
"Padlength=%s" % padLength)
114 padString =
"".rjust(padLength,
'0')
115 debug(
"Padding=%s" % padString)
117 for i
in range(len(slotValues)):
118 slotValues[i] = (bin(slotValues[i])[2:]).rjust(8,
'0')
120 for valueString
in slotValues:
121 bitSequence = bitSequence + addressString + valueString
122 bitSequence = padString + bitSequence
123 debug(
"Bitsequence=%s" % bitSequence)
126 for s
in range (0, len(bitSequence), 8):
127 data.append(int(bitSequence[s:s+8], 2))
130 self.writeBytes(bytearray(data))
142 ADVRSPIDCMULTI.__init__(self, chip, vref, 4, 8,
"AD5204DC",
toint(chips))
153 def __init__(self, chip=0, vref=5.0, chips=1):
154 ADVRSPIDCMULTI.__init__(self, chip, vref, 4, 8,
"AD5263DC",
toint(chips))
165 def __init__(self, chip=0, vref=5.0, chips=1):
166 ADVRSPIDCMULTI.__init__(self, chip, vref, 4, 8,
"AD8403DC",
toint(chips))
173 def __init__(self, chip, vref, chips, resolution, name):
174 ADVRSPIDC.__init__(self, chip, vref, chips, resolution, name)
181 self.values[channel] = value & 0xFF
182 data = bytearray(self.values)
193 def __init__(self, chip=0, vref=5.0, chips=1):
194 ADVRSPIDCSINGLE.__init__(self, chip, vref,
toint(chips), 8,
"AD5161DC")
201 def __init__(self, chip=0, vref=5.0, chips=1):
202 ADVRSPIDCSINGLE.__init__(self, chip, vref,
toint(chips), 8,
"AD5290DC")