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

Data Structures

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

Macros

#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
 
#define UART_TX_BUF_SIZE   128u
 
#define UART_RX_BUF_SIZE   1u
 

Enumerations

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

Functions

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. 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...
 
int main ()
 Function for main application entry. Does not return.
 

Detailed Description

The bicycle power-only sensor implementation.

Macro Definition Documentation

#define BP_CID_170   0xAAu

Calibration ID 0xAA = generic calibration request.

#define BP_PAGE_1   0x01u

Calibration message main data page.

#define BP_PAGE_16   0x10u

Standard Power only main data page.

#define BP_PAGE_RESERVE_BYTE   0xFFu

Page reserved value.

#define BP_TX_ANT_CHANNEL   0

Default ANT Channel used.

#define COMMON_PAGE_80   0x50u

Manufacturer's identification common data page.

#define COMMON_PAGE_81   0x51u

Product information common data page.

#define UART_RX_BUF_SIZE   1u

UART Rx buffer size.

#define UART_TX_BUF_SIZE   128u

UART Tx buffer size.

Enumeration Type Documentation

Bicycle Power profile application events.

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.

Function Documentation

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.

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_calib_resp_transmit ( bool  calibration_success,
uint32_t  calibration_data 
)

Function for preparing and queueing calibration response message ready for transmission.

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.

< Index of the calibration ID field in the calibration response main data page.

< Calibration response success status code in the calibration response main data page.

< Calibration response failure status code in the calibration response main data page.

< Index of the calibration data LSB field in the calibration response main data page.

< Get low byte of a uint16_t.

< Index of the calibration data MSB field in the calibration response main data page.

< Get high byte of a uint16_t.

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.

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_initialize ( void  )

Function for initializing the module.

Transmits the first broadcast message.

Returns
ant_broadcast_message_tx API return code, NRF_SUCCESS for success.

< Index of the data page number field.

< Index of the auto zero status field in the calibration response main data page.

< Auto zero is not a supported value in the calibration response main data page.

< Index of the data page number field.

< Index of the event count field in the power-only main data page.

< Index of the pedal power field in the power-only main data page.

< Index of the instantaneous cadence field in the power-only main data page.

< Index of the accumulated power LSB field in the power-only main data page.

< Get low byte of a uint16_t.

< Index of the accumulated power MSB field in the power-only main data page.

< Get high byte of a uint16_t.

< Index of the instantaneous power LSB field in the power-only main data page.

< Get low byte of a uint16_t.

< Index of the instantaneous power MSB field in the power-only main data page.

< Get high byte of a uint16_t.

void bp_only_tx_main_loop_run ( void  )

Function for running the bicycle power-only TX main processing loop. Does not return.

< Value of the RTC1 PRESCALER register.

< Maximum number of simultaneously created timers.

< Size of timer operation queues.

< Maximum number of users of the GPIOTE handler.

< Value of the RTC1 PRESCALER register.

< Delay from a GPIOTE event until a button is reported as pushed (in number of timer ticks).

< Minimum size of ANT event message buffer.

< Event for: ANT stack interrupt received.

< Event for: ANT stack interrupt received.

< Event for: button 0 pressed.

< Event for: button 0 pressed.

< Event for: button 1 pressed.

< Event for: button 1 pressed.

uint32_t bp_only_tx_power_decrement ( void  )

Function for decrementing the power-only message instantaneous power field by 2.

Returns
NRF_SUCCESS.

< Amount to be subtracted from current instantaneous power field as a response to user input.

uint32_t bp_only_tx_power_increment ( void  )

Function for incrementing the power-only message instantaneous power field by 2.

Returns
NRF_SUCCESS.

< Amount to be added to current instantaneous power field as a response to user input.