embedded-software
reusable software modules for embedded systems
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nrf_network_example.c File Reference
#include <msp430.h>
#include <stdint.h>
#include "project_settings.h"
#include "nrf24.h"
#include "nrf24network.h"
#include "timing.h"
#include "task.h"
#include "uart.h"
#include "spi.h"
#include "hal_general.h"
Include dependency graph for nrf_network_example.c:

Macros

#define RF_SPI_CH   SPI_B0
 

Functions

void SetClk24MHz (void)
 
void SetVcoreUp (unsigned int level)
 
void RF1_CE (uint8_t out)
 
void RF1_CSN (uint8_t out)
 
void RF1_PollIRQ (void)
 
void RF2_CE (uint8_t out)
 
void RF2_CSN (uint8_t out)
 
void RF2_PollIRQ (void)
 
void RF1_Init (void)
 
void RF2_Init (void)
 
void RF1_RxPayloadHandler (uint8_t *data, uint8_t length)
 
void RF1_AckPayloadHandler (uint8_t *data, uint8_t length)
 
void RF1_AckReceivedHandler (void)
 
void RF1_MaxRetriesHandler (void)
 
void RF2_RxPayloadHandler (uint8_t *data, uint8_t length)
 
void RF2_AckPayloadHandler (uint8_t *data, uint8_t length)
 
void RF2_AckReceivedHandler (void)
 
void RF2_MaxRetriesHandler (void)
 
void SendTest (void)
 
void ThisNode_TestMsgHandler (uint8_t *data, uint8_t length, uint8_t from)
 
void ThisNode2_TestMsgHandler (uint8_t *data, uint8_t length, uint8_t from)
 
int main (void)
 

Variables

nrfnet_t RF2_Net
 
char test_msg [16] = {"Test Message!\r\n"}
 
char reply_msg [25] = {"Test Message Response!\r\n"}
 

Macro Definition Documentation

#define RF_SPI_CH   SPI_B0

NRF24 Network Example

This example demonstrates very basic use of the NRF Network on the MSP430. The example uses two radios both connected to a single MSP430. Due to the size of the nrf24_network layer, the required program space will exceed the code-size limited license of most Code Composer Studio installations. To use this project, you must either:

1) Have a full featured license 2) Acquire a 90-day full featured evaluation license 3) Switch compilers to use the GCC compiler

Likely the best option for most users is to switch to the GCC compiler due to the expensive full license and time-limit on the evaluation license. For information on switching to the GCC compiler, refer to the other documentation in this library

In this example, the network is configured and some simple messages are sent between the two nodes. The first node is configured using the default network built into the network layer. The second node requires that the user interface with the extended functionality of the network layer. For most use cases, there will only be one node on a single uC and therefore, the extended functionality is not needed. See documentation for the nrf network layer and inline comments below for more information about the extended functionality.

The first node, using the default network built into the network layer, is configured using the THIS_NODE macro found in system.h You must always define this macro in the system.h file to use the network layer. In this example, we want the first node to be a branch (Meaning it has a parent (the THIS_NODE2) and children). Most users on a network will be configured as either a leaf or a branch, since only one user can be configured as a THIS_NODE2.

The second node, using the extended functionality, is setup to be the THIS_NODE2 of the network.

The first node (the branch) sets up a message handler to listen for TEST_MSG's, while the second node (the THIS_NODE2) sets up a message handler to listen for TEST_MSG's. (TEST_MSG and TEST_MSG were arbitrarily chosen and do not implement any of the functionality of those application layers)

A periodic task is setup to send a TEST_MSG to THIS_NODE from the THIS_NODE2. The THIS_NODE node has a listener configured to handle reception of TEST_MSG. In the handler, the received message is simply printed over UART1. In addition, the THIS_NODE node, in turn, writes a TEST_MSG back to the THIS_NODE2. Remember this is for demonstration purposes only. Typically the THIS_NODE2 and branch nodes would both have message handlers for the same type of system and the THIS_NODE node would just respond with the same message type.

When the THIS_NODE2 receives the TEST_MSG, the handler is called and the received message is simply printed to the terminal over UART1.

Be sure to read the inline comments below to get a better understanding of how to implement applications using the network layer.

To test this example, simply run the program with a terminal setup on UART1 and look for

Test Message! Test Message Response!

Function Documentation

int main ( void  )

Here is the call graph for this function:

void RF1_AckPayloadHandler ( uint8_t *  data,
uint8_t  length 
)
void RF1_AckReceivedHandler ( void  )
void RF1_CE ( uint8_t  out)

Here is the caller graph for this function:

void RF1_CSN ( uint8_t  out)

Here is the call graph for this function:

Here is the caller graph for this function:

void RF1_Init ( void  )
void RF1_MaxRetriesHandler ( void  )
void RF1_PollIRQ ( void  )

Here is the call graph for this function:

Here is the caller graph for this function:

void RF1_RxPayloadHandler ( uint8_t *  data,
uint8_t  length 
)
void RF2_AckPayloadHandler ( uint8_t *  data,
uint8_t  length 
)
void RF2_AckReceivedHandler ( void  )
void RF2_CE ( uint8_t  out)

Here is the caller graph for this function:

void RF2_CSN ( uint8_t  out)

Here is the call graph for this function:

Here is the caller graph for this function:

void RF2_Init ( void  )
void RF2_MaxRetriesHandler ( void  )
void RF2_PollIRQ ( void  )

Here is the caller graph for this function:

void RF2_RxPayloadHandler ( uint8_t *  data,
uint8_t  length 
)
void SendTest ( void  )

Here is the call graph for this function:

Here is the caller graph for this function:

void SetClk24MHz ( void  )

Here is the call graph for this function:

Here is the caller graph for this function:

void SetVcoreUp ( unsigned int  level)

Here is the caller graph for this function:

void ThisNode2_TestMsgHandler ( uint8_t *  data,
uint8_t  length,
uint8_t  from 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void ThisNode_TestMsgHandler ( uint8_t *  data,
uint8_t  length,
uint8_t  from 
)

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

char reply_msg[25] = {"Test Message Response!\r\n"}
nrfnet_t RF2_Net
char test_msg[16] = {"Test Message!\r\n"}