2 # GoodFET I2C and I2Ceeprom Client Library
4 # Pre-alpha. You've been warned!
6 #import sys, time, string, cStringIO, struct, glob, serial, os
8 from GoodFET import GoodFET
10 class GoodFETI2C(GoodFET):
12 """Move the FET into the I2C application."""
13 self.writecmd(0x02,0x10)
16 """Produce Start condition on I2C bus"""
17 self.writecmd(0x02,0x20)
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)