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

The Stride and Distance Monitor minimal example TX (Master). More...

Modules

 SDM data update timer
 SDM TX timer interface.
 

Macros

#define CHANNEL_0   0x00
 
#define CHANNEL_0_TX_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   0xAAAAu
 
#define CHANNEL_0_CHAN_ID_TRANS_TYPE   0x05u
 
#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_tx_setup (void)
 Function for setting up ANT module to be ready for TX broadcast. More...
 
void sdm_main_loop (void)
 Function for Stride and Distance Monitor TX example main loop. More...
 
void sdm_data_timer_callback (void)
 Function for callback for timer to invoke. More...
 
int main (void)
 

Variables

static uint8_t m_broadcast_data [BROADCAST_DATA_BUFFER_SIZE]
 
static uint8_t m_network_0_key [] = NETWORK_0_KEY
 

Detailed Description

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

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

sdm_tx_flowchart.png
SDM TX flowchart
Logging

For logging UART will be the primary display. Data will be printed after broadcast data is set. Depending on the page transmitted, 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.

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:

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_TX_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   0xAAAAu

Device number.

#define CHANNEL_0_CHAN_ID_TRANS_TYPE   0x05u

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_tx_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.

void sdm_data_timer_callback ( void  )

This function will call sdm module to update its stride and distance data according to what features SDM TX module has implemented.

int main ( void  )

for application main entry, does not return.

The main function will do all necessary initalization. This includes sdm tx module, timer and softdevice.

Variable Documentation

uint8_t m_broadcast_data[BROADCAST_DATA_BUFFER_SIZE]
static

Primary data transmit buffer.

uint8_t m_network_0_key[] = NETWORK_0_KEY
static

ANT network key for SDM example.