nRF51 SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
ANT bicycle power minimum receiver example

The bicycle power minimum receiver implementation. More...

Data Structures

struct  bp_page16_data_t
 Bicycle Power page 16 data structure. More...
 
struct  bp_page17_data_t
 Bicycle Power page 17 data structure. More...
 
struct  bp_page18_data_t
 Bicycle Power page 18 data structure. More...
 
struct  bp_page32_data_t
 Bicycle Power page 32 data structure. More...
 
struct  bp_page1_response_data_t
 Bicycle Power page 1 general calibration response data structure. More...
 
struct  page80_data_t
 Common page 80 data structure. More...
 
struct  page81_data_t
 Common page 81 data structure. More...
 
struct  antplus_event_return_t
 Bicycle Power profile to application communication object. More...
 

Macros

#define BP_RX_ANT_CHANNEL   0
 
#define BP_PAGE_1   0x01u
 
#define BP_PAGE_16   0x10u
 
#define BP_PAGE_17   0x11u
 
#define BP_PAGE_18   0x12u
 
#define BP_PAGE_32   0x20u
 
#define BP_CID_170   0xAAu
 
#define BP_CID_172   0xACu
 
#define BP_CID_175   0xAFu
 
#define BP_PAGE_RESERVE_BYTE   0xFFu
 
#define COMMON_PAGE_80   0x50u
 
#define COMMON_PAGE_81   0x51u
 
#define APP_TIMER_PRESCALER   0
 
#define UART_TX_BUF_SIZE   256u
 
#define UART_RX_BUF_SIZE   1u
 
#define ANTPLUS_NETWORK_NUMBER   0
 
#define ANT_EVENT_MSG_BUFFER_MIN_SIZE   32u
 
#define BP_RX_CHANNEL_TYPE   CHANNEL_TYPE_SLAVE
 
#define BP_RX_TRANS_TYPE   0
 
#define BP_RX_DEVICE_NUMBER   0
 
#define BP_EXT_ASSIGN   0
 
#define BP_DEVICE_TYPE   0x0Bu
 
#define BP_RF_FREQ   0x39u
 
#define BP_MSG_PERIOD   0x1FF6u
 
#define BP_NETWORK_KEY   {0,0,0,0,0,0,0,0}
 
#define APP_TIMER_MAX_TIMERS   2u
 
#define APP_TIMER_OP_QUEUE_SIZE   2u
 
#define APP_GPIOTE_MAX_USERS   1u
 
#define BUTTON_DETECTION_DELAY   APP_TIMER_TICKS(50u, APP_TIMER_PRESCALER)
 
#define EVT_BUTTON_0   (1u << 0)
 
#define EVT_CALIBRATION_RESPONSE_TIMEOUT   (1u << 1u)
 
#define EVT_ANT_STACK   (1u << 2u)
 

Typedefs

typedef void(* calibration_process_callback_t )(calibration_notif_event_t event)
 

Enumerations

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

Functions

void bicycle_power_rx_init (void)
 Function for initializing the module.
 
void bp_rx_calibration_cb_register (calibration_process_callback_t callback)
 Function for registering a calibration process statemachine callback client. More...
 
bool bp_rx_channel_event_handle (uint32_t event, uint8_t const *const p_event_message_buffer, antplus_event_return_t *p_event_return)
 Function for processing received ANT channel event message. More...
 
void bp_rx_calibration_start (void)
 Function for starting manual zero-offset calibration procedure. More...
 
void bp_rx_calibration_tout_handle (void)
 Function for handling a calibration response timeout event.
 
bp_page16_data_tbp_rx_data_page16_get (void)
 Function for getting the reference to data page 16, which is the standard power-only main data page. More...
 
bp_page17_data_tbp_rx_data_page17_get (void)
 Function for getting the reference to data page 17, which is the standard wheel torque main data page. More...
 
bp_page18_data_tbp_rx_data_page18_get (void)
 Function for getting the reference to data page 18, which is the standard crank torque main data page. More...
 
bp_page32_data_tbp_rx_data_page32_get (void)
 Function for getting the reference to data page 32, which is the crank torque frequency (CTF) main data page. More...
 
bp_page1_response_data_tbp_rx_data_page1_response_get (void)
 Function for getting the reference to data page 1, which is the general calibration response main data page. More...
 
page80_data_tbp_rx_data_page80_get (void)
 Function for getting the reference to data page 80, which is the manufacturer's identification common page. More...
 
page81_data_tbp_rx_data_page81_get (void)
 Function for getting the reference to data page 81, which is the product information common page. More...
 
void bicycle_power_rx_main_loop_run (void)
 Function for running the bicycle power RX main processing loop. Does not return. More...
 
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 error handling, which is called when an error has occurred. More...
 
int main ()
 Function for main application entry. Does not return.
 
void button_event_handler (uint8_t pin_no, uint8_t button_action)
 Function for handling button events. More...
 
void SD_EVT_IRQHandler (void)
 Function for handling stack interrupts. More...
 

Detailed Description

The bicycle power minimum receiver implementation.

Macro Definition Documentation

#define ANT_EVENT_MSG_BUFFER_MIN_SIZE   32u

Minimum size of ANT event message buffer.

#define ANTPLUS_NETWORK_NUMBER   0

Network number.

#define APP_GPIOTE_MAX_USERS   1u

Maximum number of users of the GPIOTE handler.

#define APP_TIMER_MAX_TIMERS   2u

Maximum number of simultaneously created timers.

#define APP_TIMER_OP_QUEUE_SIZE   2u

Size of timer operation queues.

#define APP_TIMER_PRESCALER   0

Value of the RTC1 PRESCALER register.

#define BP_CID_170   0xAAu

Calibration ID 0xAA = generic calibration request.

#define BP_CID_172   0xACu

Calibration ID 0xAC = calibration response manual zero success.

#define BP_CID_175   0xAFu

Calibration ID 0xAF = calibration response failure.

#define BP_DEVICE_TYPE   0x0Bu

Bike Power Device Type.

#define BP_EXT_ASSIGN   0

ANT Ext Assign.

#define BP_MSG_PERIOD   0x1FF6u

Decimal 8182 (~4.00Hz).

#define BP_NETWORK_KEY   {0,0,0,0,0,0,0,0}

The network key used.

#define BP_PAGE_1   0x01u

Calibration message main data page.

#define BP_PAGE_16   0x10u

Standard Power only main data page.

#define BP_PAGE_17   0x11u

Wheel Torque (WT) main data page.

#define BP_PAGE_18   0x12u

Standard Crank Torque (CT) main data page.

#define BP_PAGE_32   0x20u

Standard Crank Torque Frequency (CTF) main data page.

#define BP_PAGE_RESERVE_BYTE   0xFFu

Page reserved value.

#define BP_RF_FREQ   0x39u

RF Channel 57 (2457 MHz).

#define BP_RX_ANT_CHANNEL   0

Default ANT Channel used.

#define BP_RX_CHANNEL_TYPE   CHANNEL_TYPE_SLAVE

Slave.

#define BP_RX_DEVICE_NUMBER   0

Device Number.

#define BP_RX_TRANS_TYPE   0

Transmission Type.

#define BUTTON_DETECTION_DELAY   APP_TIMER_TICKS(50u, APP_TIMER_PRESCALER)

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

#define COMMON_PAGE_80   0x50u

Manufacturer's identification common data page.

#define COMMON_PAGE_81   0x51u

Product information common data page.

#define EVT_ANT_STACK   (1u << 2u)

Event for: ANT stack interrupt received.

#define EVT_BUTTON_0   (1u << 0)

Event for: button 0 pressed.

#define EVT_CALIBRATION_RESPONSE_TIMEOUT   (1u << 1u)

Event for: calibration response timeout.

#define UART_RX_BUF_SIZE   1u

UART RX buffer size.

#define UART_TX_BUF_SIZE   256u

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.

Enumerator
CALIBRATION_NOT_ACTIVE_STATE_ENTER 

Calibration process not running state entry event.

CALIBRATION_RESPONSE_TIMEOUT 

Calibration process response timeout event.

Function Documentation

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.
void bicycle_power_rx_main_loop_run ( void  )

Function for running the bicycle power RX main processing loop. Does not return.

< Maximum number of simultaneously created timers.

< Size of timer operation queues.

< Maximum number of users of the GPIOTE handler.

< 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: button 0 pressed.

< Event for: button 0 pressed.

< Event for: ANT stack interrupt received.

< Event for: ANT stack interrupt received.

< Event for: calibration response timeout.

< Event for: calibration response timeout.

void bp_rx_calibration_cb_register ( calibration_process_callback_t  callback)

Function for registering a calibration process statemachine callback client.

Parameters
[in]callbackThe callback, which is called when various calibration process statemachine events occur.
void bp_rx_calibration_start ( void  )

Function for starting manual zero-offset calibration procedure.

Note
If this method is called when the calibration process is running, the end result is undefined.

< Calibration response timeout value in units of timer ticks.

bool bp_rx_channel_event_handle ( uint32_t  event,
uint8_t const *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
true if p_event_return contains valid data, false otherwise.
bp_page16_data_t* bp_rx_data_page16_get ( void  )

Function for getting the reference to data page 16, which is the standard power-only main data page.

Returns
Reference to data page 16.
bp_page17_data_t* bp_rx_data_page17_get ( void  )

Function for getting the reference to data page 17, which is the standard wheel torque main data page.

Returns
Reference to data page 17.
bp_page18_data_t* bp_rx_data_page18_get ( void  )

Function for getting the reference to data page 18, which is the standard crank torque main data page.

Returns
Reference to data page 18.
bp_page1_response_data_t* bp_rx_data_page1_response_get ( void  )

Function for getting the reference to data page 1, which is the general calibration response main data page.

Returns
Reference to data page 1 general response.
bp_page32_data_t* bp_rx_data_page32_get ( void  )

Function for getting the reference to data page 32, which is the crank torque frequency (CTF) main data page.

Returns
Reference to data page 32.
page80_data_t* bp_rx_data_page80_get ( void  )

Function for getting the reference to data page 80, which is the manufacturer's identification common page.

Returns
Reference to data page 80.
page81_data_t* bp_rx_data_page81_get ( void  )

Function for getting the reference to data page 81, which is the product information common page.

Returns
Reference to data page 81.
void button_event_handler ( uint8_t  pin_no,
uint8_t  button_action 
)

Function for handling button events.

Parameters
[in]pin_noThe pin number of the button pressed.

< Event for: button 0 pressed.

void SD_EVT_IRQHandler ( void  )

Function for handling stack interrupts.

< Event for: ANT stack interrupt received.

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.

Traces out the user supplied parameters and busy loops.

Parameters
[in]pcValue of the program counter.
[in]line_numLine number where the assert occured.
[in]p_file_namePointer to the file name.