wrote a method to try and fake the vin
[goodfet] / client / GoodFETI2C.py
1 #!/usr/bin/env python
2 # GoodFET I2C and I2Ceeprom Client Library
3
4 # Pre-alpha.  You've been warned!
5
6 #import sys, time, string, cStringIO, struct, glob, serial, os
7
8 from GoodFET import GoodFET
9
10 class GoodFETI2C(GoodFET):
11     def I2Csetup(self):
12         """Move the FET into the I2C application."""
13         self.writecmd(0x02,0x10)
14         
15     def I2Cstart(self):
16         """Produce Start condition on I2C bus"""
17         self.writecmd(0x02,0x20)
18     def I2Cstop(self):
19         """Produce Stop condition on I2C bus"""
20         self.writecmd(0x02,0x21)
21     def I2Cread(self,count=1):
22         """Read data from I2C."""
23         self.writecmd(0x02,0x00,1,[count])
24     def I2Cwritebytes(self,data):
25         """Write multiple bytes to I2C."""
26         self.writecmd(0x02,0x01,len(data),data)
27     def I2Cwritebyte(self,val):
28         """Write a single byte to I2C."""
29         self.I2Cwritebytes([val])
30     def I2Ctrans(self,readcount,data):
31         """Use PEEK to do a multi-start transaction"""
32         return self.writecmd(0x02,0x02,len(data)+1,[readcount]+data)