Erase waits for competion to return.
[goodfet] / firmware / apps / spi / spi.c
index f4c6560..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.
 unsigned char spitrans8(unsigned char byte){
   unsigned int bit;
   //This function came from the SPI Wikipedia article.
@@ -187,6 +187,7 @@ void spihandle(unsigned char app,
       spitrans8(cmddata[i]);
     P5OUT|=SS;  //Raise !SS to end transaction.
     
       spitrans8(cmddata[i]);
     P5OUT|=SS;  //Raise !SS to end transaction.
     
+    
     while(spiflash_status()&0x01)//while busy
       P1OUT^=1;
     P1OUT&=~1;
     while(spiflash_status()&0x01)//while busy
       P1OUT^=1;
     P1OUT&=~1;
@@ -200,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.
     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;
 
     txdata(app,verb,0);
     break;
 
-
   case SETUP:
     spisetup();
     txdata(app,verb,0);
   case SETUP:
     spisetup();
     txdata(app,verb,0);