20 def __init__(self, chip, channelCount, resolution, vref, name):
21 SPI.__init__(self,
toint(chip), 0, 8, 10000)
22 ADC.__init__(self, channelCount, resolution, float(vref))
27 return "%s(chip=%d)" % (self.
name, self.
chip)
30 data = self.__command__(channel, diff)
32 return ((r[1] & self.
MSB_MASK) << 8) | r[2]
35 def __init__(self, chip, channelCount, vref, name):
36 MCP3X0X.__init__(self, chip, channelCount, 10, vref, name)
39 d = [0x00, 0x00, 0x00]
41 d[1] |= (
not diff) << 7
42 d[1] |= ((channel >> 2) & 0x01) << 6
43 d[1] |= ((channel >> 1) & 0x01) << 5
44 d[1] |= ((channel >> 0) & 0x01) << 4
49 MCP300X.__init__(self, chip, 2, vref,
"MCP3002")
62 d = [0x00, 0x00, 0x00]
64 d[1] |= (
not diff) << 7
70 MCP300X.__init__(self, chip, 4, vref,
"MCP3004")
74 MCP300X.__init__(self, chip, 8, vref,
"MCP3008")
77 def __init__(self, chip, channelCount, vref, name):
78 MCP3X0X.__init__(self, chip, channelCount, 12, vref, name)
81 d = [0x00, 0x00, 0x00]
83 d[0] |= (
not diff) << 1
84 d[0] |= (channel >> 2) & 0x01
85 d[1] |= ((channel >> 1) & 0x01) << 7
86 d[1] |= ((channel >> 0) & 0x01) << 6
91 MCP320X.__init__(self, chip, 4, vref,
"MCP3204")
95 MCP320X.__init__(self, chip, 8, vref,
"MCP3208")