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.
37 //Begin a new transaction.
42 //! Read and write an NRF byte.
43 u8 nrftrans8(u8 byte){
44 register unsigned int bit;
45 //This function came from the NRF Wikipedia article.
48 for (bit = 0; bit < 8; bit++) {
49 /* write MOSI on trailing edge of previous clock */
58 /* read MISO on trailing edge */
68 u8 nrf_regwrite(u8 reg, const u8 *buf, int len){
78 u8 nrf_regread(u8 reg, u8 *buf, int len){
88 //! Handles a Nordic RF command.
89 void nrfhandle(unsigned char app,
94 //Raise !SS to end transaction, just in case we forgot.
99 //PEEK and POKE might come later.
102 P5OUT&=~SS; //Drop !SS to begin transaction.
104 cmddata[i]=nrftrans8(cmddata[i]);
105 P5OUT|=SS; //Raise !SS to end transaction.
106 txdata(app,verb,len);
109 case PEEK://Grab NRF Register
110 P5OUT&=~SS; //Drop !SS to begin transaction.
111 nrftrans8(NRF_R_REGISTER | cmddata[0]); //000A AAAA
113 cmddata[i]=nrftrans8(cmddata[i]);
114 P5OUT|=SS; //Raise !SS to end transaction.
115 txdata(app,verb,len);
118 case POKE://Poke NRF Register
119 P5OUT&=~SS; //Drop !SS to begin transaction.
120 nrftrans8(NRF_W_REGISTER | cmddata[0]); //001A AAAA
122 cmddata[i]=nrftrans8(cmddata[i]);
123 P5OUT|=SS; //Raise !SS to end transaction.
124 txdata(app,verb,len);