| nRF5 SDK v12.0.0 |

Choose documentation: | nRF5 SDK | S130 SoftDevice API | S132 SoftDevice API | S212 SoftDevice API | S332 SoftDevice API

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Bicycle Speed and Cadence
This information applies to the following SoftDevices: S212, S332

This module implements the Bicycle Speed and Cadence ANT+ device profile. The API for this module is available here: Bicycle Speed and Cadence profile

During initialization, the module configures the selected channel and resets the profile data.

# Compile time configuration options

The module traces profile-specific information to UART using the logger.

The following configuration options are available at compile time to assist in the development phase of the BSC Receiver implementation:

- TRACE_BSC_GENERAL_ENABLE: Output page number of the current page.
- TRACE_BSC_PAGE_0_ENABLE: Output page 0 data.
- TRACE_BSC_PAGE_1_ENABLE: Output page 1 data.
- TRACE_BSC_PAGE_2_ENABLE: Output page 2 data.
- TRACE_BSC_PAGE_3_ENABLE: Output page 3 data.
- TRACE_BSC_PAGE_4_ENABLE: Output page 4 data.
- TRACE_BSC_PAGE_5_ENABLE: Output page 5 data.
- TRACE_BSC_COMB_PAGE_0_ENABLE: Output combined speed and cadence page 0 data.

The above macros must be defined on the project settings level.

# BSC Receiver

The following code snippets show how to initialize the BSC Receiver:

void ant_bsc_evt_handler(ant_bsc_profile_t * p_profile, ant_bsc_evt_t event);
BSC_DISP_CHANNEL_CONFIG_DEF(m_ant_bsc,
BSC_CHANNEL_NUMBER,
WILDCARD_TRANSMISSION_TYPE,
DISPLAY_TYPE,
WILDCARD_DEVICE_NUMBER,
ANTPLUS_NETWORK_NUMBER,
BSC_MSG_PERIOD_4Hz);
BSC_DISP_PROFILE_CONFIG_DEF(m_ant_bsc,
ant_bsc_evt_handler);
ant_bsc_profile_t m_ant_bsc;
uint32_t err_code;
err_code = ant_bsc_disp_init(&m_ant_bsc,
BSC_DISP_CHANNEL_CONFIG(m_ant_bsc),
BSC_DISP_PROFILE_CONFIG(m_ant_bsc));
APP_ERROR_CHECK(err_code);
err_code = ant_bsc_disp_open(&m_ant_bsc);
APP_ERROR_CHECK(err_code);
err_code = ant_state_indicator_channel_opened();
APP_ERROR_CHECK(err_code);

After opening the profile instance channel, the module keeps the profile structure updated.

Three different message periods are supported:

- BSC_MSG_PERIOD_4Hz
- BSC_MSG_PERIOD_2Hz
- BSC_MSG_PERIOD_1Hz

The sample application that uses the Bicycle Speed and Cadence Profile is available here: Receiver

# BSC Transmitter

The following code snippets show how to initialize the BSC Transmitter:

void ant_bsc_evt_handler(ant_bsc_profile_t * p_profile, ant_bsc_evt_t event);
BSC_SENS_CHANNEL_CONFIG_DEF(m_ant_bsc,
BSC_CHANNEL_NUMBER,
CHAN_ID_TRANS_TYPE,
SENSOR_TYPE,
CHAN_ID_DEV_NUM,
ANTPLUS_NETWORK_NUMBER);
BSC_SENS_PROFILE_CONFIG_DEF(m_ant_bsc,
true,
true,
ANT_BSC_PAGE_5,
ant_bsc_evt_handler);
static ant_bsc_profile_t m_ant_bsc;
uint32_t err_code;
err_code = ant_bsc_sens_init(&m_ant_bsc,
BSC_SENS_CHANNEL_CONFIG(m_ant_bsc),
BSC_SENS_PROFILE_CONFIG(m_ant_bsc));
APP_ERROR_CHECK(err_code);
m_ant_bsc.BSC_PROFILE_manuf_id = BSC_MF_ID;
m_ant_bsc.BSC_PROFILE_serial_num = BSC_SERIAL_NUMBER;
m_ant_bsc.BSC_PROFILE_hw_version = BSC_HW_VERSION;
m_ant_bsc.BSC_PROFILE_sw_version = BSC_SW_VERSION;
m_ant_bsc.BSC_PROFILE_model_num = BSC_MODEL_NUMBER;
err_code = ant_bsc_sens_open(&m_ant_bsc);
APP_ERROR_CHECK(err_code);
err_code = ant_state_indicator_channel_opened();
APP_ERROR_CHECK(err_code);

After opening the profile instance channel, the module broadcasts the data from the profile structure. The user application should keep this structure updated. Users can configure which main data page is used (page 0 or 5) and whether page 1 and/or page 4 are present.

The sample application that uses the Bicycle Speed and Cadence Profile is available here: Transmitter

Note
  The application must propagate ANT stack events to the ANT Bicycle Speed and Cadence module by calling ant_bsc_tx_evt_handle() or ant_bsc_rx_evt_handle() from the ant_event_handler callback.

Warning
  The ant_event_handler is called from an interrupt. Therefore, the profile structure is changed asynchronously.