Erase waits for competion to return.
[goodfet] / firmware / apps / spi / spi.c
index a5f72b8..594e04f 100644 (file)
@@ -43,7 +43,7 @@ void spisetup(){
 }
 
 
-//! Read and write an SPI bit.
+//! Read and write an SPI byte.
 unsigned char spitrans8(unsigned char byte){
   unsigned int bit;
   //This function came from the SPI Wikipedia article.
@@ -186,7 +186,12 @@ void spihandle(unsigned char app,
     for(i=0;i<len;i++)
       spitrans8(cmddata[i]);
     P5OUT|=SS;  //Raise !SS to end transaction.
-    while(spiflash_status()&0x01);//while busy
+    
+    
+    while(spiflash_status()&0x01)//while busy
+      P1OUT^=1;
+    P1OUT&=~1;
+    
     txdata(app,verb,len);
     break;
 
@@ -196,10 +201,15 @@ void spihandle(unsigned char app,
     P5OUT&=~SS; //Drop !SS to begin transaction.
     spitrans8(0xC7);//Chip Erase
     P5OUT|=SS;  //Raise !SS to end transaction.
+    
+        
+    while(spiflash_status()&0x01)//while busy
+      P1OUT^=1;
+    P1OUT&=~1;
+    
     txdata(app,verb,0);
     break;
 
-
   case SETUP:
     spisetup();
     txdata(app,verb,0);