Patched CCSPI PEEK to restore the address before returning data. 0x40 bit is cleared.
[goodfet] / firmware / apps / radios / ccspi.c
index eb7417a..cca3305 100644 (file)
@@ -115,6 +115,7 @@ void ccspi_handle_fn( uint8_t const app,
                      uint8_t const verb,
                      uint32_t const len){
   unsigned long i;
+  u8 j;
 
   //debugstr("Chipcon SPI handler.");
 
@@ -126,9 +127,11 @@ void ccspi_handle_fn( uint8_t const app,
   case WRITE:
   case POKE:
     CLRSS; //Drop !SS to begin transaction.
+    j=cmddata[0];//Backup address.
     for(i=0;i<len;i++)
       cmddata[i]=ccspitrans8(cmddata[i]);
     SETSS;  //Raise !SS to end transaction.
+    cmddata[0]=j&~0x40;//Restore address.
     txdata(app,verb,len);
     break;
   case SETUP:
@@ -139,7 +142,7 @@ void ccspi_handle_fn( uint8_t const app,
 #ifdef FIFOP
     //Has there been an overflow?
     if((!FIFO)&&FIFOP){
-      debugstr("Clearing overflow");
+      //debugstr("Clearing overflow");
       CLRSS;
       ccspitrans8(0x08); //SFLUSHRX
       SETSS;
@@ -149,7 +152,7 @@ void ccspi_handle_fn( uint8_t const app,
     if(FIFOP&&FIFO){
       //Wait for completion.
       while(SFD);
-
+      
       //Get the packet.
       CLRSS;
       ccspitrans8(CCSPI_RXFIFO | 0x40);
@@ -160,9 +163,11 @@ void ccspi_handle_fn( uint8_t const app,
       SETSS;
 
       //Flush buffer.
-      CLRSS;
-      ccspitrans8(0x08); //SFLUSHRX
-      SETSS;
+      //CLRSS;
+      //ccspitrans8(0x08); //SFLUSHRX
+      //SETSS;
+      
+      
       //Only should transmit length of one more than the reported
       // length of the frame, which holds the length byte:
       txdata(app,verb,cmddata[0]+1);
@@ -355,6 +360,12 @@ void ccspi_handle_fn( uint8_t const app,
 
     //Wait for last packet to TX.
     //while(ccspi_status()&BIT3);
+    
+    //Flush TX buffer.
+    CLRSS;
+    ccspitrans8(0x09); //SFLUSHTX
+    SETSS;
+    
 
     //Load the packet.
     CLRSS;
@@ -371,12 +382,7 @@ void ccspi_handle_fn( uint8_t const app,
     //Wait for the pulse on SFD, after which the packet has been sent.
     while(!SFD);
     while(SFD);
-
-    //Flush TX buffer.
-    CLRSS;
-    ccspitrans8(0x09); //SFLUSHTX
-    SETSS;
-
+    
     txdata(app,verb,0);
 #else
     debugstr("Can't TX a packet with SFD and FIFOP definitions.");