2 \author Travis Goodspeed
3 \brief NordicRF Register Interface
6 //Higher level left to client application.
19 #define RADIOACTIVE SETCE
20 #define RADIOPASSIVE CLRCE
22 //! Set up the pins for NRF mode.
30 //Begin a new transaction.
35 //! Read and write an NRF byte.
36 u8 nrftrans8(u8 byte){
37 register unsigned int bit;
38 //This function came from the NRF Wikipedia article.
41 for (bit = 0; bit < 8; bit++) {
42 /* write MOSI on trailing edge of previous clock */
51 /* read MISO on trailing edge */
61 u8 nrf_regwrite(u8 reg, const u8 *buf, int len){
72 u8 nrf_regread(u8 reg, u8 *buf, int len){
83 //! Handles a Nordic RF command.
84 void nrfhandle(unsigned char app,
89 //Drop CE to passify radio.
91 //Raise !SS to end transaction, just in case we forgot.
96 //PEEK and POKE might come later.
99 CLRSS; //Drop !SS to begin transaction.
101 cmddata[i]=nrftrans8(cmddata[i]);
102 SETSS; //Raise !SS to end transaction.
103 txdata(app,verb,len);
106 case PEEK://Grab NRF Register
107 CLRSS; //Drop !SS to begin transaction.
108 nrftrans8(NRF_R_REGISTER | cmddata[0]); //000A AAAA
110 cmddata[i]=nrftrans8(cmddata[i]);
111 SETSS; //Raise !SS to end transaction.
112 txdata(app,verb,len);
115 case POKE://Poke NRF Register
116 CLRSS; //Drop !SS to begin transaction.
117 nrftrans8(NRF_W_REGISTER | cmddata[0]); //001A AAAA
119 cmddata[i]=nrftrans8(cmddata[i]);
120 SETSS; //Raise !SS to end transaction.
121 txdata(app,verb,len);
131 nrftrans8(NRF_R_RX_PAYLOAD);
133 cmddata[i]=nrftrans8(0xde);
141 nrftrans8(NRF_FLUSH_RX);
150 debugstr("Not yet supported.");