2 \author Travis Goodspeed
3 \brief NordicRF Register Interface
6 //Higher level left to client application.
20 //! Handles a Nordic RF command.
21 void nrf_handle_fn( uint8_t const app,
25 // define the nrf app's app_t
26 app_t const nrf_app = {
38 "\tThe NRF app adds support for the NordicRF register\n"
42 #define RADIOACTIVE SETCE
43 #define RADIOPASSIVE CLRCE
45 //! Set up the pins for NRF mode.
53 //Begin a new transaction.
58 //! Read and write an NRF byte.
59 u8 nrftrans8(u8 byte){
60 register unsigned int bit;
61 //This function came from the NRF Wikipedia article.
64 for (bit = 0; bit < 8; bit++) {
65 /* write MOSI on trailing edge of previous clock */
74 /* read MISO on trailing edge */
84 u8 nrf_regwrite(u8 reg, const u8 *buf, int len){
95 u8 nrf_regread(u8 reg, u8 *buf, int len){
106 //! Handles a Nordic RF command.
107 void nrf_handle_fn( uint8_t const app,
113 //Drop CE to passify radio.
115 //Raise !SS to end transaction, just in case we forgot.
120 //PEEK and POKE might come later.
123 CLRSS; //Drop !SS to begin transaction.
125 cmddata[i]=nrftrans8(cmddata[i]);
126 SETSS; //Raise !SS to end transaction.
127 txdata(app,verb,len);
130 case PEEK://Grab NRF Register
131 CLRSS; //Drop !SS to begin transaction.
132 nrftrans8(NRF_R_REGISTER | cmddata[0]); //000A AAAA
134 cmddata[i]=nrftrans8(cmddata[i]);
135 SETSS; //Raise !SS to end transaction.
136 txdata(app,verb,len);
139 case POKE://Poke NRF Register
140 CLRSS; //Drop !SS to begin transaction.
141 nrftrans8(NRF_W_REGISTER | cmddata[0]); //001A AAAA
143 cmddata[i]=nrftrans8(cmddata[i]);
144 SETSS; //Raise !SS to end transaction.
145 txdata(app,verb,len);
155 nrftrans8(NRF_R_RX_PAYLOAD);
157 cmddata[i]=nrftrans8(0xde);
165 nrftrans8(NRF_FLUSH_RX);
174 debugstr("Not yet supported.");