A major refactor of the GoodFET firmware build system and apps to give better
[goodfet] / firmware / apps / radios / ccspi.c
index e1cb9bb..ab1051f 100644 (file)
@@ -1,6 +1,11 @@
 /*! \file ccspi.c
   \author Travis Goodspeed
   \brief Chipcon SPI Register Interface
+  
+  Unfortunately, there is very little similarity between the CC2420
+  and the CC2500, to name just two of the myriad of Chipcon SPI
+  radios.  Auto-detection will be a bit difficult, but more to the
+  point, all high level functionality must be moved into the client.
 */
 
 //Higher level left to client application.
 #include "ccspi.h"
 #include "spi.h"
 
+//! Handles a Chipcon SPI command.
+void ccspi_handle_fn( uint8_t const app,
+                                         uint8_t const verb,
+                                         uint32_t const len);
+
+// define the ccspi app's app_t
+app_t const ccspi_app = {
+
+       /* app number */
+       CCSPI,
+
+       /* handle fn */
+       ccspi_handle_fn,
+
+       /* name */
+       "CCSPI",
+
+       /* desc */
+       "\tThe CCSPI app adds support for the Chipcon SPI register\n"
+       "\tinterface. Unfortunately, there is very little similarity\n"
+       "\tbetween the CC2420 and the CC2500, to name just two of the\n"
+       "\tmyriad of Chipcon SPI radios.  Auto-detection will be a bit\n"
+       "\tdifficult, but more to the point, all high level functionality\n"
+       "\tmust be moved into the client.\n"
+};
+
 
 #define RADIOACTIVE SETCE
 #define RADIOPASSIVE CLRCE
@@ -81,9 +112,10 @@ u8 ccspi_regread(u8 reg, u8 *buf, int len){
 }
 
 //! Handles a Chipcon SPI command.
-void ccspihandle(unsigned char app,
-              unsigned char verb,
-              unsigned long len){
+void ccspi_handle_fn( uint8_t const app,
+                                         uint8_t const verb,
+                                         uint32_t const len)
+{
   unsigned long i;
   
   //Drop CE to passify radio.
@@ -128,7 +160,7 @@ void ccspihandle(unsigned char app,
     RADIOPASSIVE;
     //Get the packet.
     CLRSS;
-    ccspitrans8(CCSPI_R_RX_PAYLOAD);
+    ccspitrans8(CCSPI_RXFIFO);
     for(i=0;i<32;i++)
       cmddata[i]=ccspitrans8(0xde);
     SETSS;
@@ -138,7 +170,7 @@ void ccspihandle(unsigned char app,
   case CCSPI_RX_FLUSH:
     //Flush the buffer.
     CLRSS;
-    ccspitrans8(CCSPI_FLUSH_RX);
+    ccspitrans8(CCSPI_SFLUSHRX);
     SETSS;
     
     //Return the packet.