#Define extra modules here.
moreapps?=
-apps= $(moreapps) apps/monitor/monitor.o apps/spi/spi.o apps/i2c/i2c.o apps/chipcon/chipcon.o apps/jtag/jtag.o apps/jtag/jtag430.o apps/jtag/jtag430x2.o
+apps= $(moreapps) apps/monitor/monitor.o apps/spi/spi.o apps/i2c/i2c.o apps/chipcon/chipcon.o apps/jtag/jtag.o apps/jtag/jtag430.o apps/jtag/jtag430x2.o apps/avr/avr.o
libs= lib/$(mcu).o lib/command.o apps/jtag/jtag430asm.o
app= goodfet
unsigned int bitcount){
unsigned int bit;
//0x8000
- unsigned long high;
+ unsigned long high=0x8000;
if(bitcount==20)
high=0x80000;
void jtag430handle(unsigned char app,
unsigned char verb,
unsigned long len){
- register char blocks;
unsigned long at;
unsigned int i, val;
#include <io.h>
#include <iomacros.h>
-#include <spi.h>
+#include "spi.h"
//This could be more accurate.
//Does it ever need to be?
SETSS; //Raise !SS to end transaction.
}
-//! Write many blocks to the SPI Flash.
-void spiflash_pokeblocks(unsigned long adr,
- unsigned char *buf,
- unsigned int len){
- long off=0;//offset of this block
- int blen;//length of this block
- SETSS;
- spiflash_setstatus(0x02);
- spiflash_wrten();
-
- while(off<len){
- //calculate block length
- blen=(len-off>0x100?0x100:len-off);
- //write the block
- spiflash_pokeblock(adr+off,
- buf+off,
- blen);
- //add offset
- off+=blen;
- }
-}
-
//! Read a block to a buffer.
void spiflash_pokeblock(unsigned long adr,
unsigned char *buf,
}
+//! Write many blocks to the SPI Flash.
+void spiflash_pokeblocks(unsigned long adr,
+ unsigned char *buf,
+ unsigned int len){
+ long off=0;//offset of this block
+ int blen;//length of this block
+ SETSS;
+ spiflash_setstatus(0x02);
+ spiflash_wrten();
+
+ while(off<len){
+ //calculate block length
+ blen=(len-off>0x100?0x100:len-off);
+ //write the block
+ spiflash_pokeblock(adr+off,
+ buf+off,
+ blen);
+ //add offset
+ off+=blen;
+ }
+}
+
+
+
//! Peek some blocks.
void spiflash_peek(unsigned char app,
unsigned char verb,
case SPI:\r
spihandle(app,verb,len);\r
break;\r
+ case AVR:\r
+ avrhandle(app,verb,len);\r
+ break;\r
case I2CAPP:\r
i2chandle(app,verb,len);\r
break;\r
#define JTAG430 0x11
#define CHIPCON 0x30
#define SIF 0x31
+#define AVR 0x32
#define OCT 0x70
//! Step an instruction
void cc_step_instr();
+
+//CHIPCON commands
+#define CC_CHIP_ERASE 0x80
+#define CC_WR_CONFIG 0x81
+#define CC_RD_CONFIG 0x82
+#define CC_GET_PC 0x83
+#define CC_READ_STATUS 0x84
+#define CC_SET_HW_BRKPNT 0x85
+#define CC_HALT 0x86
+#define CC_RESUME 0x87
+#define CC_DEBUG_INSTR 0x88
+#define CC_STEP_INSTR 0x89
+#define CC_STEP_REPLACE 0x8a
+#define CC_GET_CHIP_ID 0x8b
+//CHIPCON macros
+#define CC_READ_CODE_MEMORY 0x90
+#define CC_READ_XDATA_MEMORY 0x91
+#define CC_WRITE_XDATA_MEMORY 0x92
+#define CC_SET_PC 0x93
+#define CC_CLOCK_INIT 0x94
+#define CC_WRITE_FLASH_PAGE 0x95
+#define CC_READ_FLASH_PAGE 0x96
+#define CC_MASS_ERASE_FLASH 0x97
+#define CC_PROGRAM_FLASH 0x98
#define MONITOR_SIZEBUF 0xC2
-//CHIPCON commands
-#define CC_CHIP_ERASE 0x80
-#define CC_WR_CONFIG 0x81
-#define CC_RD_CONFIG 0x82
-#define CC_GET_PC 0x83
-#define CC_READ_STATUS 0x84
-#define CC_SET_HW_BRKPNT 0x85
-#define CC_HALT 0x86
-#define CC_RESUME 0x87
-#define CC_DEBUG_INSTR 0x88
-#define CC_STEP_INSTR 0x89
-#define CC_STEP_REPLACE 0x8a
-#define CC_GET_CHIP_ID 0x8b
-//CHIPCON macros
-#define CC_READ_CODE_MEMORY 0x90
-#define CC_READ_XDATA_MEMORY 0x91
-#define CC_WRITE_XDATA_MEMORY 0x92
-#define CC_SET_PC 0x93
-#define CC_CLOCK_INIT 0x94
-#define CC_WRITE_FLASH_PAGE 0x95
-#define CC_READ_FLASH_PAGE 0x96
-#define CC_MASS_ERASE_FLASH 0x97
-#define CC_PROGRAM_FLASH 0x98
-
-//JTAG commands
-#define JTAG_IR_SHIFT 0x80
-#define JTAG_DR_SHIFT 0x81
-#define JTAG_DR_SHIFT20 0x91
+
//SPI commands
#define SPI_JEDEC 0x80
#define OCT_CMP 0x90
#define OCT_RES 0x91
-//JTAG430 commands
-#define JTAG430_HALTCPU 0xA0
-#define JTAG430_RELEASECPU 0xA1
-#define JTAG430_SETINSTRFETCH 0xC1
-#define JTAG430_SETPC 0xC2
-#define JTAG430_WRITEMEM 0xE0
-#define JTAG430_WRITEFLASH 0xE1
-#define JTAG430_READMEM 0xE2
-#define JTAG430_ERASEFLASH 0xE3
-#define JTAG430_ERASECHECK 0xE4
-#define JTAG430_VERIFYMEM 0xE5
-#define JTAG430_BLOWFUSE 0xE6
-#define JTAG430_ISFUSEBLOWN 0xE7
-#define JTAG430_COREIP_ID 0xF0
-#define JTAG430_DEVICE_ID 0xF1
//! Handle a plugin, weak-linked to error.
extern int pluginhandle(unsigned char app,
void jtag430handle(unsigned char, unsigned char, unsigned long);
void jtag430x2handle(unsigned char app, unsigned char verb,
unsigned long len);
-
+void avrhandle(unsigned char app,
+ unsigned char verb,
+ unsigned long len);
unsigned int jtag430x2_syncpor();
//! Executes an MSP430X2 POR
unsigned int jtag430x2_por();
+
+
+//JTAG commands
+#define JTAG_IR_SHIFT 0x80
+#define JTAG_DR_SHIFT 0x81
+#define JTAG_DR_SHIFT20 0x91
+
+
+//JTAG430 commands
+#define JTAG430_HALTCPU 0xA0
+#define JTAG430_RELEASECPU 0xA1
+#define JTAG430_SETINSTRFETCH 0xC1
+#define JTAG430_SETPC 0xC2
+#define JTAG430_WRITEMEM 0xE0
+#define JTAG430_WRITEFLASH 0xE1
+#define JTAG430_READMEM 0xE2
+#define JTAG430_ERASEFLASH 0xE3
+#define JTAG430_ERASECHECK 0xE4
+#define JTAG430_VERIFYMEM 0xE5
+#define JTAG430_BLOWFUSE 0xE6
+#define JTAG430_ISFUSEBLOWN 0xE7
+#define JTAG430_COREIP_ID 0xF0
+#define JTAG430_DEVICE_ID 0xF1
#define SETCLK P5OUT|=SCK
#define CLRCLK P5OUT&=~SCK
#define READMISO (P5IN&MISO?1:0)
+
+//! Set up the pins for SPI mode.
+void spisetup();
+
+//! Read and write an SPI byte.
+unsigned char spitrans8(unsigned char byte);
+
+//! Read a block to a buffer.
+void spiflash_peekblock(unsigned long adr,
+ unsigned char *buf,
+ unsigned int len);
+
+
+//! Write many blocks to the SPI Flash.
+void spiflash_pokeblocks(unsigned long adr,
+ unsigned char *buf,
+ unsigned int len);