2 \author Travis Goodspeed
3 \brief NordicRF Register Interface
6 //Higher level left to client application.
18 //! Handles a Nordic RF command.
19 void nrf_handle_fn( uint8_t const app,
23 // define the nrf app's app_t
24 app_t const nrf_app = {
36 "\tThe NRF app adds support for the NordicRF register\n"
40 #define RADIOACTIVE SETCE
41 #define RADIOPASSIVE CLRCE
43 //! Set up the pins for NRF mode.
51 //Begin a new transaction.
56 //! Read and write an NRF byte.
57 u8 nrftrans8(u8 byte){
58 register unsigned int bit;
59 //This function came from the NRF Wikipedia article.
62 for (bit = 0; bit < 8; bit++) {
63 /* write MOSI on trailing edge of previous clock */
72 /* read MISO on trailing edge */
82 u8 nrf_regwrite(u8 reg, const u8 *buf, int len){
93 u8 nrf_regread(u8 reg, u8 *buf, int len){
104 //! Handles a Nordic RF command.
105 void nrf_handle_fn( uint8_t const app,
111 //Drop CE to passify radio.
113 //Raise !SS to end transaction, just in case we forgot.
118 //PEEK and POKE might come later.
121 CLRSS; //Drop !SS to begin transaction.
123 cmddata[i]=nrftrans8(cmddata[i]);
124 SETSS; //Raise !SS to end transaction.
125 txdata(app,verb,len);
128 case PEEK://Grab NRF Register
129 CLRSS; //Drop !SS to begin transaction.
130 nrftrans8(NRF_R_REGISTER | cmddata[0]); //000A AAAA
132 cmddata[i]=nrftrans8(cmddata[i]);
133 SETSS; //Raise !SS to end transaction.
134 txdata(app,verb,len);
137 case POKE://Poke NRF Register
138 CLRSS; //Drop !SS to begin transaction.
139 nrftrans8(NRF_W_REGISTER | cmddata[0]); //001A AAAA
141 cmddata[i]=nrftrans8(cmddata[i]);
142 SETSS; //Raise !SS to end transaction.
143 txdata(app,verb,len);
153 nrftrans8(NRF_R_RX_PAYLOAD);
155 cmddata[i]=nrftrans8(0xde);
163 nrftrans8(NRF_FLUSH_RX);
172 debugstr("Not yet supported.");