2 \author Travis Goodspeed
3 \brief NordicRF Register Interface
6 //Higher level left to client application.
18 //Weird HOPE badge wiring. This was a fuckup.
19 //BIT0 should be SS, but in point of fact it is IRQ.
20 //BIT4 is actually SS, BIT5 is CE.
23 //This could be more accurate.
24 //Does it ever need to be?
30 //! Set up the pins for NRF mode.
38 //Begin a new transaction.
45 //! Read and write an NRF byte.
46 unsigned char nrftrans8(unsigned char byte){
47 register unsigned int bit;
48 //This function came from the NRF Wikipedia article.
51 for (bit = 0; bit < 8; bit++) {
52 /* write MOSI on trailing edge of previous clock */
61 /* read MISO on trailing edge */
70 //! Handles a Nordic RF command.
71 void nrfhandle(unsigned char app,
76 //Raise !SS to end transaction, just in case we forgot.
81 //PEEK and POKE might come later.
84 P5OUT&=~SS; //Drop !SS to begin transaction.
86 cmddata[i]=nrftrans8(cmddata[i]);
87 P5OUT|=SS; //Raise !SS to end transaction.
91 case PEEK://Grab NRF Register
92 P5OUT&=~SS; //Drop !SS to begin transaction.
93 nrftrans8(0|(NRF_R_REGISTER & cmddata[0])); //000A AAAA
95 cmddata[i]=nrftrans8(cmddata[i]);
96 P5OUT|=SS; //Raise !SS to end transaction.
100 case POKE://Poke NRF Register
101 P5OUT&=~SS; //Drop !SS to begin transaction.
102 nrftrans8(0|(NRF_W_REGISTER & cmddata[0])); //001A AAAA
104 cmddata[i]=nrftrans8(cmddata[i]);
105 P5OUT|=SS; //Raise !SS to end transaction.
106 txdata(app,verb,len);