nRF51 SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

The Stride and Distance Monitor minimal example RX (Slave). More...

Macros

#define CHANNEL_0   0x00
 
#define CHANNEL_0_RX_CHANNEL_PERIOD   8134u
 
#define CHANNEL_0_ANT_EXT_ASSIGN   0x00
 
#define CHANNEL_0_FREQUENCY   57u
 
#define NETWORK_0   0x00
 
#define NETWORK_0_KEY   {0, 0, 0, 0, 0, 0, 0, 0}
 
#define CHANNEL_0_CHAN_ID_DEV_TYPE   0x7Cu
 
#define CHANNEL_0_CHAN_ID_DEV_NUM   0x00
 
#define CHANNEL_0_CHAN_ID_TRANS_TYPE   0x00
 
#define ANT_EVENT_MSG_BUFFER_MIN_SIZE   32u
 
#define BROADCAST_DATA_BUFFER_SIZE   8u
 

Functions

void PROTOCOL_EVENT_IRQHandler (void)
 Function for Stack Interrupt handling.
 
void softdevice_assert_callback (uint32_t pc, uint16_t line_num, const uint8_t *p_file_name)
 Function for handling softdevice asserts. More...
 
void app_error_handler (uint32_t error_code, uint32_t line_num, const uint8_t *p_file_name)
 Function for handling an error. More...
 
static void ant_channel_sdm_rx_setup (void)
 Function for setting up ANT module to be ready for SDM RX broadcast. More...
 
void sdm_main_loop (void)
 Function for Stride and Distance Monitor RX example main loop. More...
 
int main (void)
 Function for application main entry, does not return. More...
 

Variables

static uint8_t m_network_0_key [] = NETWORK_0_KEY
 

Detailed Description

The Stride and Distance Monitor (SDM) slave implements all of the features, which are required for the receiver to be compliant with the ANT+ SDM profile, as defined by the ANT+ SDM specification:

The process flow of the SDM RX example is illustrated below:

sdm_rx_flowchart.png
SDM RX flowchart
Logging

For logging UART will be the primary display. Data will be printed after broadcast data is received. Depending on the page received, the following data will be logged:

The logging with UART will be enabled by default in the project file. This can be deactivated by removing TRACE_UART from the compiler flags. When deactivated the data processing function will not be included in the compilation, as there are no need to interpret the data received, when we can not display the information.

As UART will use some extra current, a low power alternative is also available, using GPIO. By default the GPIO pins are connected to LEDs when using the PCA10003 ev-kit board or with nRF6310 with setup A. Also GPIO logging is enabled by default by the project file. This can be deactivated by removing TRACE_GPIO from the compiler flags. The GPIO pins to be used can be changed by editing the GPIO defines.

When GPIO logging is enabled the following GPIO will toggle:

When using PCA10003 board this board only have two leds. SDM_GPIO_2 will not be connected to any LED, but could be monitored by a logic analyzer or such.

Note
The ANT+ Network Key is available for ANT+ Adopters. Please refer to http://thisisant.com to become an ANT+ Adopter and access the key.

Macro Definition Documentation

#define CHANNEL_0   0x00

ANT Channel 0.

#define CHANNEL_0_RX_CHANNEL_PERIOD   8134u

Channel period 4.03 Hz.

#define CHANNEL_0_ANT_EXT_ASSIGN   0x00

ANT Ext Assign.

#define CHANNEL_0_FREQUENCY   57u

Channel Frequency.

#define NETWORK_0   0x00

ANT Network 0.

#define NETWORK_0_KEY   {0, 0, 0, 0, 0, 0, 0, 0}

Public ANT network.

#define CHANNEL_0_CHAN_ID_DEV_TYPE   0x7Cu

Device type 124.

#define CHANNEL_0_CHAN_ID_DEV_NUM   0x00

Device number.

#define CHANNEL_0_CHAN_ID_TRANS_TYPE   0x00

Transmission type.

#define ANT_EVENT_MSG_BUFFER_MIN_SIZE   32u

Minimum size of ANT event message buffer.

#define BROADCAST_DATA_BUFFER_SIZE   8u

Size of the broadcast data buffer.

Function Documentation

void softdevice_assert_callback ( uint32_t  pc,
uint16_t  line_num,
const uint8_t *  p_file_name 
)
Parameters
[in]pcThe value of the program counter.
[in]line_numLine number where the error occurred.
[in]p_file_namePointer to the file name.
void app_error_handler ( uint32_t  error_code,
uint32_t  line_num,
const uint8_t *  p_file_name 
)

Function for error handling, which is called when an error has occurred.

Parameters
[in]error_codeError code supplied to the handler.
[in]line_numLine number where the handler is called.
[in]p_file_namePointer to the file name.
static void ant_channel_sdm_rx_setup ( void  )
static

Issues the following commands:

  • set network key
  • assign channel
  • set channel ID
  • set channel frequency
  • set channel period
  • open channel
void sdm_main_loop ( void  )

The main loop will try to sleep as much as possible. Every time a protocol event occours, the application will be woken up, polling the ANT stack event queue. When finished processing all events, the application will go back to sleep.

int main ( void  )

The main function will do all necessary initalization. This includes sdm rx module and softdevice.

Variable Documentation

uint8_t m_network_0_key[] = NETWORK_0_KEY
static

ANT network key for SDM example.