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"
49 //! Set up the pins for CCSPI mode.
56 P4OUT|=BIT5; //activate CC2420 voltage regulator
57 P4OUT|=BIT6; //bring CC2420 out of reset
59 //Begin a new transaction.
64 //! Read and write an CCSPI byte.
65 u8 ccspitrans8(u8 byte){
66 register unsigned int bit;
67 //This function came from the CCSPI Wikipedia article.
70 for (bit = 0; bit < 8; bit++) {
71 /* write MOSI on trailing edge of previous clock */
80 /* read MISO on trailing edge */
90 u8 ccspi_regwrite(u8 reg, const u8 *buf, int len){
101 u8 ccspi_regread(u8 reg, u8 *buf, int len){
104 reg=ccspitrans8(reg);
106 *buf++=ccspitrans8(0);
112 //! Handles a Chipcon SPI command.
113 void ccspi_handle_fn( uint8_t const app,
118 //debugstr("Chipcon SPI handler.");
123 CLRSS; //Drop !SS to begin transaction.
125 cmddata[i]=ccspitrans8(cmddata[i]);
126 SETSS; //Raise !SS to end transaction.
127 txdata(app,verb,len);
130 case PEEK://Grab CCSPI Register
131 CLRSS; //Drop !SS to begin transaction.
132 cmddata[0]=ccspitrans8(/*CCSPI_R_REGISTER |*/ cmddata[0]); //000A AAAA
134 cmddata[i]=ccspitrans8(cmddata[i]);
135 SETSS; //Raise !SS to end transaction.
136 txdata(app,verb,len);
139 case POKE://Poke CCSPI Register
140 CLRSS; //Drop !SS to begin transaction.
141 cmddata[0]=ccspitrans8(/* CCSPI_W_REGISTER |*/ 0x40 | cmddata[0]); //02AA AAAA
143 cmddata[i]=ccspitrans8(cmddata[i]);
144 SETSS; //Raise !SS to end transaction.
145 txdata(app,verb,len);
154 ccspitrans8(CCSPI_RXFIFO);
156 cmddata[i]=ccspitrans8(0xde);
164 ccspitrans8(CCSPI_SFLUSHRX);
173 debugstr("Not yet supported.");