RNet Stack as Component, nRF24L01+ with Software SPI

The great thing with Processor Expert is: it writes the code for me :-). I’m using now the RNet wireless stack in more than 10 different projects, and keeping the projects up-to-date with the RNet stack sources in a traditional way gets harder and harder: I  need to make sure the paths are pointing to the right place, and if I pass the project to somebody else, I have to make sure all the sources are packaged with that project. Processor Expert makes things simpler: it can generate the source files into my project, and I can easily configure it.

So instead to copy and support files by hand, I decided to package the RNet stack files into a Processor Expert component: all still normal C files, but easier to configure and distribute.

RNet Component

RNet Component

RNet Component

The component has several properties: to select the transceiver and to configure the Shell with or without the standard I/O redirection:

RNet Component Properties

RNet Component Properties

Based on the settings, the source files are copied/generated and properly configured. If you still want to have the ‘normal’ C sources, they are on GitHub here: https://github.com/ErichStyger/mcuoneclipse/tree/master/Drivers/RNet

Simple Demo Application

I have contributed a simple demo application for the nRF24L01+ transceiver with the Freesale FRDM-KL25Z board: it remaps the reset button as normal push buttons: depending on how long the button is pressed, it sends a ‘1’ or a ‘2’ to the network as broadcast message which toggles a LED on the receiver side (Application.c):

static void CheckKey(void) {
  uint16_t cnt;
  uint8_t data;

  if (SW1_GetVal()==0) { /* low active */
    WAIT1_WaitOSms(50); /* simple debounce */
    if (SW1_GetVal()==0) { /* still pressed? */
      cnt = 0;
while(SW1_GetVal()==0) { /* wait until released */
        cnt += 10;
      if (cnt>1000) { /* long press */
        data = 2; /* toggle LED2 */
      } else {
        data = 1; /* toggle LED1 */
      (void)RAPP_SendPayloadDataBlock(&data, sizeof(data), RAPP_MSG_TYPE_DATA, RNWK_ADDR_BROADCAST, RPHY_PACKET_FLAGS_NONE);

On the receiver side (RNet_App.c), it checks the data transmitted, and toggles a LED:

static uint8_t RNETA_HandleRxMessage(RAPP_MSG_Type type, uint8_t size, uint8_t *data, RNWK_ShortAddrType srcAddr, bool *handled, RPHY_PacketDesc *packet) {
  uint8_t val;

  switch(type) {
    case RAPP_MSG_TYPE_DATA: /* <type><size><data */
      *handled = TRUE;
      val = *data; /* get data from packet */
      if (val==1) {
      } else if (val==2) {
      } else if (val==3) {
      return ERR_OK;
  } /* switch */
  return ERR_OK;

nRF24L01+ Component

Not directly related to the RNet stack, but worthwhile to mention: the properties of the nRF24L01+ component have been extended:

  1. I can now use a Software SPI (bit-banging with normal General Purpose I/O pins)
  2. To switch and share the SPI bus with other devices, it is needed to have hooks. For this an option enables this, along with the possibility to change the SPI clock frequency.
nRF24L01+ Component Properties

nRF24L01+ Component Properties

With this, there are two additional event hooks which can be used e.g. with a Semaphore/Mutex to guard access to the SPI bus.

nRF24L01+ Methods and Events

nRF24L01+ Methods and Events

Additionally, the method ConstantCarrierWave() has been added: I needed that transceiver functionality for EMI and wireless communication band compliance testing with the authorities at the TÜV.

Spectrum Analyzer showing Constant Carrier Wave

Spectrum Analyzer showing Constant Carrier Wave


The RNet component for sure can be extended even more. Right now it includes the Nordic Semicondcutor nRF24L01+ transceiver, and I will add the Freescale MC13201 transceiver shortly, along with more configuration settings. The new files are available on GitHub:

  1. Updated component(s): https://github.com/ErichStyger/mcuoneclipse/tree/master/PEupd
  2. Example project with Shell and Std I/O redirection: https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/FRDM-KL25Z/FRDM-KL25Z_RNet_Component
  3. Simple example, pressing a push button sends a message with data: https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/FRDM-KL25Z/FRDM-KL25Z_RNet_Simple

Happy RNeting 🙂


8 thoughts on “RNet Stack as Component, nRF24L01+ with Software SPI

  1. Erich,

    I downloaded your Rnet stack for the radios and I found several files corrupted
    from the GitHub account.

    See for your self.

    Look inside the Radio.c file.

    There are more corrupted.

    Just to let you know.

    By the way nice work on the stacks.


  2. Pingback: FTF: FRDM-K64F, Kinetis Design Studio and Kinetis SDK | MCU on Eclipse

  3. Pingback: JoyStick Shield with the FRDM Board | MCU on Eclipse

  4. Pingback: Enhanced RNet Wireless Components and Communication Stack | MCU on Eclipse

  5. Pingback: New Zumo Robot PCB’s Arrived! | MCU on Eclipse

  6. Pingback: nRF24L01+ 2.4 GHz Wireless Connectivity with the tinyK20 Board | MCU on Eclipse

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.