2 # GoodFET SPI and SPIFlash Client Library
4 # (C) 2009 Travis Goodspeed <travis at radiantmachines.com>
6 # This code is being rewritten and refactored. You've been warned!
8 import sys, time, string, cStringIO, struct, glob, serial, os;
10 from GoodFET import GoodFET;
12 class GoodFETAVR(GoodFET):
14 AVRVendors={0x1E: "Atmel",
18 #List from avr910.asm and other sources.
19 #More devices at http://avr.fenceline.de/device_data.html
49 """Move the FET into the SPI application."""
50 self.writecmd(self.AVRAPP,0x10,0,self.data); #SPI/SETUP
53 """Exchange data by AVR.
54 Input should probably be 4 bytes."""
56 self.writecmd(self.AVRAPP,0x00,len(data),data);
60 """Start the connection."""
61 self.writecmd(self.AVRAPP,0x20,0,None);
64 """Return an identifying string."""
65 self.writecmd(self.AVRAPP,0x83,0,None);
66 vendor=self.AVRVendors.get(ord(self.data[0]));
67 deviceid=(ord(self.data[1])<<8)+ord(self.data[2]);
68 device=self.AVRDevices.get(deviceid);
70 #Return hex if device is unknown.
71 #They are similar enough that it needn't be known.
73 device=("0x%04x" % deviceid);