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 """Read a byte from the given address."""
27 data=self.SPItrans([0xfe,0x01,0x00,
29 0xA7,0,0,0,0,0,0,0,0]);
31 def poke8(self,adr, byte):
32 """Poke a byte to the given address."""
34 """Read the info bytes."""
35 data=self.SPItrans([0x0B,0xA7,
37 0xFF,0xFF,0xFF, #00 02 A7
38 0,0,0,0,0,0,0,0,0,0,
39 0,0,0,0,0,0,0,0,0,0,
40 0,0,0,0,0,0,0,0,0,0,
41 0,0,0,0,0,0,0,0,0,0,
42 0,0,0,0,0,0,0,0,0,0,
46 print "%02x" % ord(foo);