SPI Flash Erase command.
authortravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Sat, 18 Jul 2009 15:35:30 +0000 (15:35 +0000)
committertravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Sat, 18 Jul 2009 15:35:30 +0000 (15:35 +0000)
Still need native POKE.

git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@66 12e2690d-a6be-4b82-a7b7-67c4a43b65c8

firmware/apps/spi/spi.c
firmware/include/command.h

index 93a41b9..785c476 100644 (file)
@@ -66,6 +66,13 @@ unsigned char spitrans8(unsigned char byte){
   return byte;
 }
 
   return byte;
 }
 
+//! Enable SPI writing
+void spiflash_wrten(){
+    P5OUT&=~SS; //Drop !SS to begin transaction.
+    spitrans8(0x06);//Chip Erase
+    P5OUT|=SS;  //Raise !SS to end transaction.
+}
+
 //! Handles a monitor command.
 void spihandle(unsigned char app,
               unsigned char verb,
 //! Handles a monitor command.
 void spihandle(unsigned char app,
               unsigned char verb,
@@ -102,6 +109,16 @@ void spihandle(unsigned char app,
     txdata(app,verb,len);
     P5OUT|=SS;  //Raise !SS to end transaction.
     break;
     txdata(app,verb,len);
     P5OUT|=SS;  //Raise !SS to end transaction.
     break;
+  case POKE://Poke up bytes from an SPI Flash ROM.
+    
+    break;
+  case SPI_ERASE://Erase the SPI Flash ROM.
+    spiflash_wrten();
+    P5OUT&=~SS; //Drop !SS to begin transaction.
+    spitrans8(0xC7);//Chip Erase
+    P5OUT|=SS;  //Raise !SS to end transaction.
+    txdata(app,verb,0);
+    break;
   case SETUP:
     spisetup();
     txdata(app,verb,0);
   case SETUP:
     spisetup();
     txdata(app,verb,0);
index 7eb1f61..ece0ad1 100644 (file)
@@ -52,7 +52,6 @@ extern unsigned char cmddata[256];
 //SPI commands
 #define SPI_JEDEC 0x80
 #define SPI_ERASE 0x81
 //SPI commands
 #define SPI_JEDEC 0x80
 #define SPI_ERASE 0x81
-#define SPI_WRITE 0x82
 
 //JTAG430 commands
 #define JTAG430_HALTCPU 0xA0
 
 //JTAG430 commands
 #define JTAG430_HALTCPU 0xA0