Small Update to Mirf Library

One of my readers asked ( in the forums too ) for some help on reading register values from the Nordic chip, so I put together a quick example and added it to the library. This example reads the RF_SETUP register and prints the value in binary to the Serial output:

/**
 * Pins:
 * Hardware SPI:
 * MISO -> 12
 * MOSI -> 11
 * SCK -> 13
 *
 * Configurable:
 * CE -> 8
 * CSN -> 7
 */

#include 
#include 
#include 

void setup() {
  Serial.begin(9600);
  Serial.println( "Starting wireless..." );

  // Setup
  Mirf.init();
  Mirf.setRADDR((byte *)"clie1");
  Mirf.payload = sizeof(unsigned long);
  Mirf.config();

  // Read and print RF_SETUP
  byte rf_setup = 0;
  Mirf.readRegister( RF_SETUP, &rf_setup, sizeof(rf_setup) );
  Serial.print( "rf_setup = " );
  Serial.println( rf_setup, BIN );

  Serial.println( "Wireless initialized!" );
}

void loop() {}

When I ran this code on my board, it printed:

Starting wireless...
rf_setup = 1111
Wireless initialized!

So that’s 00001111 for the value of RF_SETUP. Breaking it down, high bit to low bit, using the datasheet:

0 – No continuous carrier wave
0 – Reserved – must be 0
0 – RF_DR_LOW is 0
0 – No PLL lock signal
1 – RF_DR_HIGH is 1, and according to chart, 01 = 2 Mbps
1 – High bit RF_PWR is 1
1 – Low bit RF_PWR is 1, according to chart, 11 = 0 dBm output power
1 – Not used/obsolete

You can download the library and bundled examples ( including this one ) from the Software page. Cheers!

Leave a Reply