2 \author Travis Goodspeed
3 \brief Chipcon SPI Register Interface
5 Unfortunately, there is very little similarity between the CC2420
6 and the CC2500, to name just two of the myriad of Chipcon SPI
7 radios. Auto-detection will be a bit difficult, but more to the
8 point, all high level functionality must be moved into the client.
11 //Higher level left to client application.
23 //! Handles a Chipcon SPI command.
24 void ccspi_handle_fn( uint8_t const app,
28 // define the ccspi app's app_t
29 app_t const ccspi_app = {
41 "\tThe CCSPI app adds support for the Chipcon SPI register\n"
42 "\tinterface. Unfortunately, there is very little similarity\n"
43 "\tbetween the CC2420 and the CC2500, to name just two of the\n"
44 "\tmyriad of Chipcon SPI radios. Auto-detection will be a bit\n"
45 "\tdifficult, but more to the point, all high level functionality\n"
46 "\tmust be moved into the client.\n"
50 #define RADIOACTIVE CLRCE
51 #define RADIOPASSIVE SETCE
53 //! Set up the pins for CCSPI mode.
60 //Telos B Radio VReg Enable
61 P4DIR|=BIT5+BIT2+BIT6+BIT7;
65 //Begin a new transaction.
70 //! Read and write an CCSPI byte.
71 u8 ccspitrans8(u8 byte){
72 register unsigned int bit;
73 //This function came from the CCSPI Wikipedia article.
76 for (bit = 0; bit < 8; bit++) {
77 /* write MOSI on trailing edge of previous clock */
86 /* read MISO on trailing edge */
96 u8 ccspi_regwrite(u8 reg, const u8 *buf, int len){
107 u8 ccspi_regread(u8 reg, u8 *buf, int len){
110 reg=ccspitrans8(reg);
112 *buf++=ccspitrans8(0);
118 //! Handles a Chipcon SPI command.
119 void ccspi_handle_fn( uint8_t const app,
124 //debugstr("Chipcon SPI handler.");
129 CLRSS; //Drop !SS to begin transaction.
131 cmddata[i]=ccspitrans8(cmddata[i]);
132 SETSS; //Raise !SS to end transaction.
133 txdata(app,verb,len);
136 case PEEK://Grab CCSPI Register
137 CLRSS; //Drop !SS to begin transaction.
138 cmddata[0]=ccspitrans8(/*CCSPI_R_REGISTER |*/ cmddata[0]); //000A AAAA
140 cmddata[i]=ccspitrans8(cmddata[i]);
141 SETSS; //Raise !SS to end transaction.
142 txdata(app,verb,len);
145 case POKE://Poke CCSPI Register
146 CLRSS; //Drop !SS to begin transaction.
147 cmddata[0]=ccspitrans8(/* CCSPI_W_REGISTER |*/ 0x40 | cmddata[0]); //02AA AAAA
149 cmddata[i]=ccspitrans8(cmddata[i]);
150 SETSS; //Raise !SS to end transaction.
151 txdata(app,verb,len);
160 ccspitrans8(CCSPI_RXFIFO);
162 cmddata[i]=ccspitrans8(0xde);
170 ccspitrans8(CCSPI_SFLUSHRX);
179 debugstr("Not yet supported.");