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.
24 #define RADIOACTIVE SETCE
25 #define RADIOPASSIVE CLRCE
27 //! Set up the pins for CCSPI mode.
35 //Begin a new transaction.
40 //! Read and write an CCSPI byte.
41 u8 ccspitrans8(u8 byte){
42 register unsigned int bit;
43 //This function came from the CCSPI Wikipedia article.
46 for (bit = 0; bit < 8; bit++) {
47 /* write MOSI on trailing edge of previous clock */
56 /* read MISO on trailing edge */
66 u8 ccspi_regwrite(u8 reg, const u8 *buf, int len){
77 u8 ccspi_regread(u8 reg, u8 *buf, int len){
82 *buf++=ccspitrans8(0);
88 //! Handles a Chipcon SPI command.
89 void ccspihandle(unsigned char app,
94 //Drop CE to passify radio.
96 //Raise !SS to end transaction, just in case we forgot.
101 //PEEK and POKE might come later.
104 CLRSS; //Drop !SS to begin transaction.
106 cmddata[i]=ccspitrans8(cmddata[i]);
107 SETSS; //Raise !SS to end transaction.
108 txdata(app,verb,len);
111 case PEEK://Grab CCSPI Register
112 CLRSS; //Drop !SS to begin transaction.
113 ccspitrans8(CCSPI_R_REGISTER | cmddata[0]); //000A AAAA
115 cmddata[i]=ccspitrans8(cmddata[i]);
116 SETSS; //Raise !SS to end transaction.
117 txdata(app,verb,len);
120 case POKE://Poke CCSPI Register
121 CLRSS; //Drop !SS to begin transaction.
122 ccspitrans8(CCSPI_W_REGISTER | cmddata[0]); //001A AAAA
124 cmddata[i]=ccspitrans8(cmddata[i]);
125 SETSS; //Raise !SS to end transaction.
126 txdata(app,verb,len);
136 ccspitrans8(CCSPI_RXFIFO);
138 cmddata[i]=ccspitrans8(0xde);
146 ccspitrans8(CCSPI_SFLUSHRX);
155 debugstr("Not yet supported.");