X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=firmware%2Fapps%2Fradios%2Fccspi.c;h=ff4661694f2020cc670101b097e20e77d1c1e7b2;hp=6fdea296507834198874d34ee64a7b8ae2ab947a;hb=022d9128fe8a5783e3b804581fe7996d17095ef6;hpb=4359af022eff64cec047af0bd3b738d2f34993e1 diff --git a/firmware/apps/radios/ccspi.c b/firmware/apps/radios/ccspi.c index 6fdea29..ff46616 100644 --- a/firmware/apps/radios/ccspi.c +++ b/firmware/apps/radios/ccspi.c @@ -20,18 +20,42 @@ #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, -#define RADIOACTIVE SETCE -#define RADIOPASSIVE CLRCE + /* 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" +}; //! Set up the pins for CCSPI mode. void ccspisetup(){ - SETSS; - P5DIR&=~MISO; - P5DIR|=MOSI+SCK; + SPIDIR&=~MISO; + SPIDIR|=MOSI+SCK; DIRSS; DIRCE; + P4OUT|=BIT5; //activate CC2420 voltage regulator + P4OUT|=BIT6; //bring CC2420 out of reset + //Begin a new transaction. CLRSS; SETSS; @@ -86,20 +110,15 @@ 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. - RADIOPASSIVE; - //Raise !SS to end transaction, just in case we forgot. - SETSS; - ccspisetup(); + //debugstr("Chipcon SPI handler."); switch(verb){ - //PEEK and POKE might come later. - case READ: + case READ: case WRITE: CLRSS; //Drop !SS to begin transaction. for(i=0;i