2 # GoodFET EM260 Radio Client
4 # (C) 2010 Travis Goodspeed <travis at radiantmachines.com>
6 # This code is being rewritten and refactored. You've been warned!
8 # The EM260 is almost textbook SPI, except that the response cannot be
9 # read until after the nHOST_INT pin of the EM260 drops low and a dummy
10 # byte is read. That is, the sequence will look like the following:
12 # Transmit Host->Slave Data
13 # while(nHOST_INT); //Sleep until ready.
15 # Recv Slave->Host Data
17 # The delay is mandatory.
19 import sys, time, string, cStringIO, struct, glob, serial, os;
21 from GoodFETSPI import GoodFETSPI;
23 class GoodFETEM260(GoodFETSPI):
26 def EM260trans(self,data):
27 """Exchange data by EM260 SPI. (Slightly nonstandard.)"""
29 self.writecmd(0x01,0x82,len(data),data);
34 """Read a byte from the given address."""
35 data=self.EM260trans([0xfe,0x01,self.seq,0x00,
40 s=s+"%02x " % ord(foo);
45 """Read the info bytes."""
46 #data=self.EM260trans([0x0A,0xA7]);
47 #data=self.EM260trans([0xFE,0x04,
48 # 0x00,0x00,0x00,0x02,
50 data=self.EM260trans([0x0B,0xA7]);
52 #data=self.EM260trans([]);
54 #data=self.EM260trans([0x0B,0x0B,0x0B,0x0B,0xA7]);
58 s=s+"%02x " % ord(foo);