class GoodFETAVR(GoodFET):
AVRAPP=0x32;
+ AVRVendors={0x1E: "Atmel",
+ 0x00: "Locked",
+ };
+
+ #List from avr910.asm and other sources.
+ #More devices at http://avr.fenceline.de/device_data.html
+ AVRDevices={
+ 0x9003: "tiny10",
+ 0x9004: "tiny11",
+ 0x9005: "tiny12",
+ 0x9006: "tiny15",
+ 0x9007: "tiny13",
+ 0x930B: "tiny85",
+
+ 0x9001: "S1200",
+
+ 0x9101: "S1213",
+ 0x9102: "S2323",
+ 0x9105: "S2333",
+ 0x9103: "S2343",
+
+ 0x9201: "S4414",
+ 0x9203: "S4433",
+ 0x9202: "S4434",
+
+ 0x9301: "S8515",
+ 0x9303: "S8535",
+
+ 0x9305: "mega83",
+ 0x9701: "mega103",
+ 0x9401: "mega161",
+ 0x9402: "mega163",
+ };
def setup(self):
"""Move the FET into the SPI application."""
def identstr(self):
"""Return an identifying string."""
self.writecmd(self.AVRAPP,0x83,0,None);
- return "AVR(%02x)" % ord(self.data[0]);
+ vendor=self.AVRVendors.get(ord(self.data[0]));
+ deviceid=(ord(self.data[1])<<8)+ord(self.data[2]);
+ device=self.AVRDevices.get(deviceid);
+
+ #Return hex if device is unknown.
+ #They are similar enough that it needn't be known.
+ if device==None:
+ device=("0x%04x" % deviceid);
+
+ return device;
//! Initialized an attached AVR.
void avrconnect(){
- register int i;
- avrsetup();//set I/O pins
+ //set I/O pins
+ avrsetup();
//Pulse !RST (SS) at least twice while CLK is low.
CLRCLK;
avr_prgen();
}
-//! Read and write an SPI byte.
+//! Read and write an SPI byte with delays.
unsigned char avrtrans8(unsigned char byte){
register unsigned int bit;
//This function came from the SPI Wikipedia article.
avrtrans8(b);
if(avrtrans8(c)!=b){
debugstr("AVR sync error, b not returned as c.");
- }else{
- debugstr("Synced properly.");
+ //Reconnect here?
}
return avrtrans8(d);
}
}
//! Read AVR device code.
-u8 avr_devicecode(){
+u8 avr_sig(u8 i){
return avrexchange(0x30, //Read signature byte
0x00,
- 0x00, //&0x03 is sig adr
- 0x00 //don't care.
+ i&0x03, //sig adr
+ 0x00 //don't care.
);
}
avrconnect();
//no break here
case AVR_PEEKSIG:
- cmddata[0]=avr_devicecode();
- txdata(app,verb,1);
+ for(i=0;i<4;i++)
+ cmddata[i]=avr_sig(i);
+ txdata(app,verb,4);
break;
case PEEK:
case POKE:
//! Enable AVR programming mode.
void avr_prgen();
//! Read AVR device code.
-u8 avr_devicecode();
+u8 avr_sig(u8 i);
//Command codes.