This project is read-only.

Getting Started

  • Download source code
  • Open and build
  • Add assembly reference to .\mfNordic\bin\release\mfnordic.dll

Using the class

The source code contains a simple example application that demonstrates how to use the class.

First step is to create an instance of the class.

_radio = new Nrf24L01P(SPI_Devices.SPI1, Pins.GPIO_PIN_D0, Pins.GPIO_PIN_D1, Pins.GPIO_PIN_D2); 


Next we can hook up the event handlers for the callbacks that are generated by the internal interrupt handler of the Nrf24L01P device.

_radio.OnDataReceived += RadioOnDataReceived;
_radio.OnTransmitFailed += RadioOnTransmitFailed;
_radio.OnTransmitSuccess += RadioOnTransmitSucess;
_radio.OnDataReceiveFailure += RadioDataReceivedFailure;


For the purpose of the demo we leave the radio module with the default settings, butt enable the following features for the demo code:

// Allow a dynamically sized payload to be sent.
_radio.DynamicPayloadEnabled = true;
// Allow the radio to send packets with dynamic acknowledgement see Table 28 page 28 of the NRF24L01P specification
_radio.DynamicAckEnabled = true;


Next the device is enabled and powered on

_radio.Enable = true;
_radio.PowerUp = true;


Next we set the radio to transmitter mode:

_radio.Mode = Mode.Transmitter;


We can queue a packet in the transmit FIFO without an expected packet acknowledge, pulsing the enable will make the radio send the packet and invoke the RadioOnTransmitSucess event handler.

RadioSend(false);

private static void RadioSend(Boolean ack)
{
	_radio.WriteTransmitPayload(new Byte[] {0,1,2,3,4,5}, ack);
	
	_radio.Enable = false;
	WaitMicroseconds(10);
	_radio.Enable = true;
	
	Debug.Print("Waiting for transmit");
	TransmitSignal.WaitOne();
}


We can queue a packet in the transmit FIFO with an expected packet acknowledge. Note that for the demo if there is no receiving device configured to send an ACK back the RadioOnTransmitFailed event handle will be invoked.

RadioSend(true);


To receive packet data we switch the mode to receive and power up the device.

_radio.Mode = Mode.Receiver;
_radio.PowerUp = true; 


The demo waits for the ReceiveSignal to be signaled by the RadioOnDataReceived event handler. Note without a transmitter configured to send some data the demo will wait indefinitely for the event handling callback.

do
{
	ReceiveSignal.WaitOne();
	
	Debug.Print("Received: " + _dataReceivedEventArgs.Payload.Length + " bytes on Pipe: " + _dataReceivedEventArgs.Pipe);
} while(true);

Last edited Nov 18, 2014 at 9:43 PM by dgoslin, version 15