nRF51 SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
ANT bicycle power-only sensor example

The bicycle power-only sensor implementation. More...

Macros

#define UART_TX_BUF_SIZE   128u
 
#define UART_RX_BUF_SIZE   1u
 
#define BP_TX_ANT_CHANNEL   0
 
#define BP_PAGE_1   0x01u
 
#define BP_PAGE_16   0x10u
 
#define COMMON_PAGE_80   0x50u
 
#define COMMON_PAGE_81   0x51u
 
#define BP_PAGE_RESERVE_BYTE   0xFFu
 
#define BP_CID_170   0xAAu
 

Enumerations

enum  antplus_event_t {
  ANTPLUS_EVENT_PAGE,
  ANTPLUS_EVENT_MAX,
  ANTPLUS_EVENT_NONE,
  ANTPLUS_EVENT_CALIBRATION_REQUEST,
  ANTPLUS_EVENT_PAGE,
  ANTPLUS_EVENT_MAX,
  ANTPLUS_EVENT_NONE,
  ANTPLUS_EVENT_CALIBRATION_REQUEST
}
 Bicycle Power profile application events. More...
 

Functions

static void softdevice_assert_callback (uint32_t pc, uint16_t line_num, const uint8_t *p_file_name)
 Function for handling SoftDevice asserts. Does not return. More...
 
void app_error_handler (uint32_t error_code, uint32_t line_num, const uint8_t *p_file_name)
 Function for handling errors, which is called when an error has occurred. More...
 
static __INLINE void softdevice_setup (void)
 Function for configuring and setting up the SoftDevice.
 
int main ()
 Function for main application entry. Does not return.
 
uint32_t bp_only_tx_initialize (void)
 Function for initializing the module. More...
 
uint32_t bp_only_tx_channel_event_handle (uint32_t event, uint8_t const *p_event_message_buffer, antplus_event_return_t *p_event_return)
 Function for processing received ANT channel event message. More...
 
uint32_t bp_only_tx_power_increment (void)
 Function for incrementing the power-only message instantaneous power field by 2. More...
 
uint32_t bp_only_tx_power_decrement (void)
 Function for decrementing the power-only message instantaneous power field by 2. More...
 
uint32_t bp_only_tx_calib_resp_transmit (bool calibration_success, uint32_t calibration_data)
 Function for preparing and queueing calibration response message ready for transmission. More...
 
void bp_only_tx_main_loop_run (void)
 Function for running the bicycle power-only TX main processing loop. Does not return.
 

Data Structures

struct  antplus_event_return_t
 Bicycle Power profile to application communication object. More...
 

Detailed Description

The bicycle power-only sensor implementation implements all the features, which are required for the sensor to be compliant with the ANT+ Bike Power profile, as defined by the ANT+ Bicycle Power Profile specification:

The general architecture of the power-only sensor is illustrated in the picture below.

bicycle_power_only_tx_design.png
Architecture overview
User interface

A simple user interface exists consisting of 2 keypad buttons, which allow the user to decrease or increase the instantaneous power value.

Bicycle power-only sensor configuration options

The following compile time configuration options are available to suite various bicycle power-only sensor implementations:

Development phase configuration options

The bicycle power-only sensor will trace ASSERT macro specific information to UART depending on the selected compile time configuration options.

The following compile time configuration options are available, and enabled by default, to assist in the development phase of the power-only sensor implementation:

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 UART_TX_BUF_SIZE   128u

UART Tx buffer size.

#define UART_RX_BUF_SIZE   1u

UART Rx buffer size.

#define BP_TX_ANT_CHANNEL   0

Default ANT Channel used.

#define BP_PAGE_1   0x01u

Calibration message main data page.

#define BP_PAGE_16   0x10u

Standard Power only main data page.

#define COMMON_PAGE_80   0x50u

Manufacturer's identification common data page.

#define COMMON_PAGE_81   0x51u

Product information common data page.

#define BP_PAGE_RESERVE_BYTE   0xFFu

Page reserved value.

#define BP_CID_170   0xAAu

Calibration ID 0xAA = generic calibration request.

Enumeration Type Documentation

Enumerator
ANTPLUS_EVENT_PAGE 

Received a data page.

ANTPLUS_EVENT_MAX 

Upper limit.

ANTPLUS_EVENT_NONE 

No event.

ANTPLUS_EVENT_CALIBRATION_REQUEST 

Calibration request received event.

ANTPLUS_EVENT_PAGE 

Received a data page.

ANTPLUS_EVENT_MAX 

Upper limit.

ANTPLUS_EVENT_NONE 

No event.

ANTPLUS_EVENT_CALIBRATION_REQUEST 

Calibration request received event.

Function Documentation

static void softdevice_assert_callback ( uint32_t  pc,
uint16_t  line_num,
const uint8_t *  p_file_name 
)
static

Traces out the user supplied parameters and busy loops.

Parameters
[in]pcThe value of the program counter.
[in]line_numThe line number where the assert occurred.
[in]p_file_nameFile name where asserted.
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.
uint32_t bp_only_tx_initialize ( void  )

Transmits the first broadcast message.

Returns
ant_broadcast_message_tx API return code, NRF_SUCCESS for success.
uint32_t bp_only_tx_channel_event_handle ( uint32_t  event,
uint8_t const *  p_event_message_buffer,
antplus_event_return_t p_event_return 
)
Parameters
[in]eventANT event received.
[in]p_event_message_bufferANT event message buffer.
[out]p_event_returnOutput data from the profile.
Returns
ant_broadcast_message_tx API return code, NRF_SUCCESS for success.
uint32_t bp_only_tx_power_increment ( void  )
Returns
NRF_SUCCESS.
uint32_t bp_only_tx_power_decrement ( void  )
Returns
NRF_SUCCESS.
uint32_t bp_only_tx_calib_resp_transmit ( bool  calibration_success,
uint32_t  calibration_data 
)

Response message is delivered to the ANT stack for transmission upon receiving EVENT_TX.

Parameters
[in]calibration_successTrue for calibration response success.
[in]calibration_dataSigned 16-bit calibration data for the response message.
Returns
NRF_SUCCESS.