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
63 //Begin a new transaction.
68 //! Read and write an CCSPI byte.
69 u8 ccspitrans8(u8 byte){
70 register unsigned int bit;
71 //This function came from the CCSPI Wikipedia article.
74 for (bit = 0; bit < 8; bit++) {
75 /* write MOSI on trailing edge of previous clock */
84 /* read MISO on trailing edge */
94 u8 ccspi_regwrite(u8 reg, const u8 *buf, int len){
105 u8 ccspi_regread(u8 reg, u8 *buf, int len){
108 reg=ccspitrans8(reg);
110 *buf++=ccspitrans8(0);
116 //! Handles a Chipcon SPI command.
117 void ccspi_handle_fn( uint8_t const app,
122 //debugstr("Chipcon SPI handler.");
126 cmddata[0]|=0x40; //Set the read bit.
131 CLRSS; //Drop !SS to begin transaction.
133 cmddata[i]=ccspitrans8(cmddata[i]);
134 SETSS; //Raise !SS to end transaction.
135 txdata(app,verb,len);
144 ccspitrans8(CCSPI_RXFIFO);
146 cmddata[i]=ccspitrans8(0xde);
154 ccspitrans8(CCSPI_SFLUSHRX);
163 debugstr("Not yet supported.");