X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFETMAXUSB.py;h=ede1026621b8e21160608f27521622d0d0ef9373;hp=d38bfa7d6f623c2881c3507d6b90cf78785492ec;hb=1bbe7c29a95d160725815184e8db10055de5c0f4;hpb=074e3d443c3d008cb9b1be3c30034b7e1774c574 diff --git a/client/GoodFETMAXUSB.py b/client/GoodFETMAXUSB.py index d38bfa7..ede1026 100644 --- a/client/GoodFETMAXUSB.py +++ b/client/GoodFETMAXUSB.py @@ -203,6 +203,7 @@ bmHXFRDNIRQ =0x80 class GoodFETMAXUSB(GoodFET): MAXUSBAPP=0x40; + usbverbose=True; def service_irqs(self): """Handle USB interrupt events.""" @@ -219,10 +220,10 @@ class GoodFETMAXUSB(GoodFET): self.wreg(rEPIRQ,bmOUT1DAVIRQ); #Clear the bit *AFTER* servicing. if(epirq&bmIN3BAVIRQ): #IN3-IN packet self.do_IN3(); - self.wreg(rEPIRQ,bmIN3BAVIRQ); #Clear the bit + #self.wreg(rEPIRQ,bmIN3BAVIRQ); #Clear the bit if(epirq&bmIN2BAVIRQ): #IN2 packet self.do_IN2(); - self.wreg(rEPIRQ,bmIN2BAVIRQ); #Clear the bit + #self.wreg(rEPIRQ,bmIN2BAVIRQ); #Clear the bit #else: # print "No idea how to service this IRQ: %02x" % epirq; def do_IN2(self): @@ -231,7 +232,7 @@ class GoodFETMAXUSB(GoodFET): """Overload this.""" def do_OUT1(self): """Overload this.""" - print "Ignoring an OUT1 interrupt."; + if self.usbverbose: print "Ignoring an OUT1 interrupt."; def setup2str(self,SUD): """Converts the header of a setup packet to a string.""" return "bmRequestType=0x%02x, bRequest=0x%02x, wValue=0x%04x, wIndex=0x%04x, wLength=0x%04x" % ( @@ -286,7 +287,7 @@ class GoodFETMAXUSB(GoodFET): ashex=""; for foo in toret: ashex=ashex+(" %02x"%ord(foo)); - print "GET %02x==%s" % (reg,ashex); + if self.usbverbose: print "GET %02x==%s" % (reg,ashex); return toret; def readbytesAS(self,reg,length): """Peek some bytes from a register, acking prior transfer.""" @@ -296,8 +297,29 @@ class GoodFETMAXUSB(GoodFET): ashex=""; for foo in toret: ashex=ashex+(" %02x"%ord(foo)); - print "GETAS %02x==%s" % (reg,ashex); + if self.usbverbose: print "GETAS %02x==%s" % (reg,ashex); return toret; + def fifo_ep3in_tx(self,data): + """Sends the data out of EP3 in 64-byte chunks.""" + #Wait for the buffer to be free before starting. + while not(self.rreg(rEPIRQ)&bmIN3BAVIRQ): pass; + + count=len(data); + pos=0; + while count>0: + #Send 64-byte chunks or the remainder. + c=min(count,64); + self.writebytes(rEP3INFIFO, + data[pos:pos+c]); + self.wregAS(rEP3INBC,c); + count=count-c; + pos=pos+c; + + #Wait for the buffer to be free before continuing. + while not(self.rreg(rEPIRQ)&bmIN3BAVIRQ): pass; + + return; + def ctl_write_nd(self,request): """Control Write with no data stage. Assumes PERADDR is set and the SUDFIFO contains the 8 setup bytes. Returns with @@ -413,13 +435,13 @@ class GoodFETMAXUSB(GoodFET): data=""; if type(tosend)==str: data=chr((reg<<3)|3)+tosend; - print "PUT %02x:=%s (0x%02x bytes)" % (reg,tosend,len(data)) + if self.usbverbose: print "PUT %02x:=%s (0x%02x bytes)" % (reg,tosend,len(data)) else: data=[(reg<<3)|3]+tosend; ashex=""; for foo in tosend: ashex=ashex+(" %02x"%foo); - print "PUT %02x:=%s (0x%02x bytes)" % (reg,ashex,len(data)) + if self.usbverbose: print "PUT %02x:=%s (0x%02x bytes)" % (reg,ashex,len(data)) self.writecmd(self.MAXUSBAPP,0x00,len(data),data); def usb_connect(self): """Connect the USB port."""