| 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
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions
Bicycle Speed and Cadence profile
ANT+ profiles

This module implements the Bicycle Speed and Cadence profile. More...

## Modules
| Bicycle Speed and Cadence Profile configuration
| Bicycle Speed and Cadence profile pages
| This module implements functions for the BSC data pages.
| Bicycle Speed and Cadence profile utilities
| This module implements utilities for the Bicycle Speed and Cadence profile.

## Data Structures
struct | ant_bsc_disp_config_t
| BSC Display configuration structure. More...
struct | ant_bsc_sens_config_t
| BSC Sensor configuration structure. More...
struct | ant_bsc_profile_s
| BSC profile structure. More...
struct | ant_bsc_sens_cb_t
| BSC Sensor control block. More...
struct | ant_bsc_disp_cb_t
| BSC Display control block. More...

## Macros
#define | BSC_ANTPLUS_RF_FREQ 0x39u
| Frequency, decimal 57 (2457 MHz).
#define | BSC_SPEED_DEVICE_TYPE 0x7B
| Device type reserved for ANT+ bike speed sensor.
#define | BSC_CADENCE_DEVICE_TYPE 0x7A
| Device type reserved for ANT+ bike cadence sensor.
#define | BSC_COMBINED_DEVICE_TYPE 0x79
| Device type reserved for ANT+ bike combined speed and cadence sensor.
#define | BSC_MSG_PERIOD_4Hz 1u
| Message period, 4 Hz (in basic period counts, where basic period time = 0.25 s).
#define | BSC_MSG_PERIOD_2Hz 2u
| Message period, 2 Hz (in basic period counts).
#define | BSC_MSG_PERIOD_1Hz 4u
| Message period, 1 Hz (in basic period counts).
#define | BSC_MSG_PERIOD_SPEED 0x1FB6u
| Message period in ticks, decimal 8118 (4.04 Hz).
#define | BSC_MSG_PERIOD_CADENCE 0x1FA6u
| Message period in ticks, decimal 8102 (4.04 Hz).
#define | BSC_MSG_PERIOD_COMBINED 0x1F96u
| Message period in ticks, decimal 8086 (4.05 Hz).
#define | BSC_EXT_ASSIGN 0x00
| ANT ext assign (see Ext. Assign Channel Parameters in ant_parameters.h: ANT Stack Parameters).
#define | BSC_DISP_CHANNEL_TYPE CHANNEL_TYPE_SLAVE_RX_ONLY
| Display BSC channel type.
#define | BSC_SENS_CHANNEL_TYPE CHANNEL_TYPE_MASTER
| Sensor BSC channel type.
#define | BSC_DEVICE_TICKS(DEVICE_TYPE)
| Select the basic ANT channel period (in ticks) for the BSC profile depending on the device type. More...
#define | BSC_PERIOD_TICKS(DEVICE_TYPE, BSC_MSG_PERIOD) ((BSC_DEVICE_TICKS(DEVICE_TYPE)) * (BSC_MSG_PERIOD))
| Calculate the channel period (in ticks) depending on the device type and the chosen message frequency. More...
#define | BSC_DISP_CHANNEL_CONFIG_DEF(NAME,CHANNEL_NUMBER,TRANSMISSION_TYPE,DEVICE_TYPE,DEVICE_NUMBER,NETWORK_NUMBER,BSC_MSG_PERIOD)
| Initialize an ANT channel configuration structure for the BSC profile (Display). More...
#define | BSC_DISP_CHANNEL_CONFIG(NAME) &NAME##_channel_bsc_disp_config
#define | BSC_SENS_CHANNEL_CONFIG_DEF(NAME,CHANNEL_NUMBER,TRANSMISSION_TYPE,DEVICE_TYPE,DEVICE_NUMBER,NETWORK_NUMBER)
| Initialize an ANT channel configuration structure for the BSC profile (Transmitter). More...
#define | BSC_SENS_CHANNEL_CONFIG(NAME) &NAME##_channel_bsc_sens_config
#define | BSC_DISP_PROFILE_CONFIG_DEF(NAME,EVT_HANDLER)
| Initialize an ANT profile configuration structure for the BSC profile (Display). More...
#define | BSC_DISP_PROFILE_CONFIG(NAME) &NAME##_profile_bsc_disp_config
#define | BSC_SENS_PROFILE_CONFIG_DEF(NAME,PAGE_1_PRESENT,PAGE_4_PRESENT,MAIN_PAGE_NUMBER,EVT_HANDLER)
| Initialize an ANT profile configuration structure for the BSC profile (Sensor). More...
#define | BSC_SENS_PROFILE_CONFIG(NAME) &NAME##_profile_bsc_sens_config

## Typedefs
typedef struct ant_bsc_profile_s | ant_bsc_profile_t
typedef void(* | ant_bsc_evt_handler_t )(ant_bsc_profile_t *, ant_bsc_evt_t)
| BSC event handler type.

## Enumerations
enum | ant_bsc_page_t { ANT_BSC_PAGE_0, ANT_BSC_PAGE_1, ANT_BSC_PAGE_2, ANT_BSC_PAGE_3, ANT_BSC_PAGE_4, ANT_BSC_PAGE_5, ANT_BSC_COMB_PAGE_0 }
| BSC page number type. More...
enum | ant_bsc_evt_t { ANT_BSC_PAGE_0_UPDATED = ANT_BSC_PAGE_0, ANT_BSC_PAGE_1_UPDATED = ANT_BSC_PAGE_1, ANT_BSC_PAGE_2_UPDATED = ANT_BSC_PAGE_2, ANT_BSC_PAGE_3_UPDATED = ANT_BSC_PAGE_3, ANT_BSC_PAGE_4_UPDATED = ANT_BSC_PAGE_4, ANT_BSC_PAGE_5_UPDATED = ANT_BSC_PAGE_5, ANT_BSC_COMB_PAGE_0_UPDATED = ANT_BSC_COMB_PAGE_0 }
| BSC profile event type. More...

## Functions
ret_code_t | ant_bsc_disp_init (ant_bsc_profile_t *p_profile, ant_channel_config_t const *p_channel_config, ant_bsc_disp_config_t const *p_disp_config)
| Function for initializing the ANT BSC profile instance. More...
ret_code_t | ant_bsc_sens_init (ant_bsc_profile_t *p_profile, ant_channel_config_t const *p_channel_config, ant_bsc_sens_config_t const *p_sens_config)
| Function for initializing the ANT BSC profile instance. More...
ret_code_t | ant_bsc_disp_open (ant_bsc_profile_t *p_profile)
| Function for opening the profile instance channel for the ANT BSC Display. More...
ret_code_t | ant_bsc_sens_open (ant_bsc_profile_t *p_profile)
| Function for opening the profile instance channel for the ANT BSC Sensor. More...
void | ant_bsc_sens_evt_handler (ant_bsc_profile_t *p_profile, ant_evt_t *p_ant_event)
| Function for handling the Sensor ANT events. More...
void | ant_bsc_disp_evt_handler (ant_bsc_profile_t *p_profile, ant_evt_t *p_ant_event)
| Function for handling the Display ANT events. More...

## Defines for accessing ant_bsc_profile_t member variables
#define | BSC_PROFILE_event_time page_0.event_time
#define | BSC_PROFILE_rev_count page_0.rev_count
#define | BSC_PROFILE_operating_time page_1.operating_time
#define | BSC_PROFILE_manuf_id page_2.manuf_id
#define | BSC_PROFILE_serial_num page_2.serial_num
#define | BSC_PROFILE_hw_version page_3.hw_version
#define | BSC_PROFILE_sw_version page_3.sw_version
#define | BSC_PROFILE_model_num page_3.model_num
#define | BSC_PROFILE_fract_bat_volt page_4.fract_bat_volt
#define | BSC_PROFILE_coarse_bat_volt page_4.coarse_bat_volt
#define | BSC_PROFILE_bat_status page_4.bat_status
#define | BSC_PROFILE_stop_indicator page_5.stop_indicator
#define | BSC_PROFILE_cadence_event_time page_comb_0.cadence_event_time
#define | BSC_PROFILE_cadence_rev_count page_comb_0.cadence_rev_count
#define | BSC_PROFILE_speed_event_time page_comb_0.speed_event_time
#define | BSC_PROFILE_speed_rev_count page_comb_0.speed_rev_count

## Detailed Description

This module implements the Bicycle Speed and Cadence profile.

## Macro Definition Documentation

#define BSC_DEVICE_TICKS | ( |  | DEVICE_TYPE | ) |

Value:
((DEVICE_TYPE) == (BSC_SPEED_DEVICE_TYPE) ? (BSC_MSG_PERIOD_SPEED) : \
((DEVICE_TYPE) == (BSC_CADENCE_DEVICE_TYPE) ? (BSC_MSG_PERIOD_CADENCE) : \
((DEVICE_TYPE) == (BSC_COMBINED_DEVICE_TYPE) ? (BSC_MSG_PERIOD_COMBINED) : 0u)))

Select the basic ANT channel period (in ticks) for the BSC profile depending on the device type.

Parameters

  [in] | DEVICE_TYPE | Type of device. Supported types: BSC_SPEED_DEVICE_TYPE, BSC_CADENCE_DEVICE_TYPE, BSC_COMBINED_DEVICE_TYPE.

#define BSC_DISP_CHANNEL_CONFIG_DEF | ( |  | NAME,
|  |  | CHANNEL_NUMBER,
|  |  | TRANSMISSION_TYPE,
|  |  | DEVICE_TYPE,
|  |  | DEVICE_NUMBER,
|  |  | NETWORK_NUMBER,
|  |  | BSC_MSG_PERIOD
| ) |  |

Value:
static const ant_channel_config_t NAME##_channel_bsc_disp_config = \
{ \
.channel_number = (CHANNEL_NUMBER), \
.channel_type = BSC_DISP_CHANNEL_TYPE, \
.ext_assign = BSC_EXT_ASSIGN, \
.rf_freq = BSC_ANTPLUS_RF_FREQ, \
.transmission_type = (TRANSMISSION_TYPE), \
.device_type = (DEVICE_TYPE), \
.device_number = (DEVICE_NUMBER), \
.channel_period = BSC_PERIOD_TICKS(DEVICE_TYPE, BSC_MSG_PERIOD), \
.network_number = (NETWORK_NUMBER), \
}

Initialize an ANT channel configuration structure for the BSC profile (Display).

Parameters

  [in] | NAME | Name of related instance.
  [in] | CHANNEL_NUMBER | Number of the channel assigned to the profile instance.
  [in] | TRANSMISSION_TYPE | Type of transmission assigned to the profile instance.
  [in] | DEVICE_TYPE | Type of device. Supported types: BSC_SPEED_DEVICE_TYPE, BSC_CADENCE_DEVICE_TYPE, BSC_COMBINED_DEVICE_TYPE.
  [in] | DEVICE_NUMBER | Number of the device assigned to the profile instance.
  [in] | NETWORK_NUMBER | Number of the network assigned to the profile instance.
  [in] | BSC_MSG_PERIOD | Channel data frequency in Hz. The BSC profile supports only the following frequencies: BSC_MSG_PERIOD_4Hz, BSC_MSG_PERIOD_2Hz, BSC_MSG_PERIOD_1Hz.

#define BSC_DISP_PROFILE_CONFIG_DEF | ( |  | NAME,
|  |  | EVT_HANDLER
| ) |  |

Value:
static ant_bsc_disp_cb_t NAME##_bsc_disp_cb; \
static const ant_bsc_disp_config_t NAME##_profile_bsc_disp_config = \
{ \
.p_cb = &NAME##_bsc_disp_cb, \
.evt_handler = (EVT_HANDLER), \
}

Initialize an ANT profile configuration structure for the BSC profile (Display).

Parameters

  [in] | NAME | Name of related instance.
  [in] | EVT_HANDLER | Event handler to be called for handling events in the BSC profile.

#define BSC_PERIOD_TICKS | ( |  | DEVICE_TYPE,
|  |  | BSC_MSG_PERIOD
| ) |  | ((BSC_DEVICE_TICKS(DEVICE_TYPE)) * (BSC_MSG_PERIOD))

Calculate the channel period (in ticks) depending on the device type and the chosen message frequency.

Parameters

  [in] | DEVICE_TYPE | Type of device. Supported types: BSC_SPEED_DEVICE_TYPE, BSC_CADENCE_DEVICE_TYPE, BSC_COMBINED_DEVICE_TYPE.
  [in] | BSC_MSG_PERIOD | Channel data period. The BSC profile supports only the following periods: BSC_MSG_PERIOD_4Hz, BSC_MSG_PERIOD_2Hz, BSC_MSG_PERIOD_1Hz.

#define BSC_SENS_CHANNEL_CONFIG_DEF | ( |  | NAME,
|  |  | CHANNEL_NUMBER,
|  |  | TRANSMISSION_TYPE,
|  |  | DEVICE_TYPE,
|  |  | DEVICE_NUMBER,
|  |  | NETWORK_NUMBER
| ) |  |

Value:
static const ant_channel_config_t NAME##_channel_bsc_sens_config = \
{ \
.channel_number = (CHANNEL_NUMBER), \
.channel_type = BSC_SENS_CHANNEL_TYPE, \
.ext_assign = BSC_EXT_ASSIGN, \
.rf_freq = BSC_ANTPLUS_RF_FREQ, \
.transmission_type = (TRANSMISSION_TYPE), \
.device_type = (DEVICE_TYPE), \
.device_number = (DEVICE_NUMBER), \
.channel_period = BSC_PERIOD_TICKS(DEVICE_TYPE, BSC_MSG_PERIOD_4Hz), \
.network_number = (NETWORK_NUMBER), \
}

Initialize an ANT channel configuration structure for the BSC profile (Transmitter).

Parameters

  [in] | NAME | Name of related instance.
  [in] | CHANNEL_NUMBER | Number of the channel assigned to the profile instance.
  [in] | TRANSMISSION_TYPE | Type of transmission assigned to the profile instance.
  [in] | DEVICE_TYPE | Type of device. Supported types: BSC_SPEED_DEVICE_TYPE, BSC_CADENCE_DEVICE_TYPE, BSC_COMBINED_DEVICE_TYPE.
  [in] | DEVICE_NUMBER | Number of the device assigned to the profile instance.
  [in] | NETWORK_NUMBER | Number of the network assigned to the profile instance.

#define BSC_SENS_PROFILE_CONFIG_DEF | ( |  | NAME,
|  |  | PAGE_1_PRESENT,
|  |  | PAGE_4_PRESENT,
|  |  | MAIN_PAGE_NUMBER,
|  |  | EVT_HANDLER
| ) |  |

Value:
static ant_bsc_sens_cb_t NAME##_bsc_sens_cb; \
static const ant_bsc_sens_config_t NAME##_profile_bsc_sens_config = \
{ \
.page_1_present = (PAGE_1_PRESENT), \
.page_4_present = (PAGE_4_PRESENT), \
.main_page_number = (MAIN_PAGE_NUMBER), \
.p_cb = &NAME##_bsc_sens_cb, \
.evt_handler = (EVT_HANDLER), \
}

Initialize an ANT profile configuration structure for the BSC profile (Sensor).

Parameters

  [in] | NAME | Name of related instance.
  [in] | PAGE_1_PRESENT | Determines whether page 1 is included.
  [in] | PAGE_4_PRESENT | Determines whether page 4 is included.
  [in] | MAIN_PAGE_NUMBER | Determines the main data page (ANT_BSC_PAGE_0 or ANT_BSC_PAGE_5 or ANT_BSC_COMB_PAGE_0).
  [in] | EVT_HANDLER | Event handler to be called for handling events in the BSC profile.

## Enumeration Type Documentation

enum ant_bsc_evt_t

BSC profile event type.

Enumerator
ANT_BSC_PAGE_0_UPDATED | Data page 0 has been updated (Display) or sent (Sensor).
ANT_BSC_PAGE_1_UPDATED | Data page 0 and page 1 have been updated (Display) or sent (Sensor).
ANT_BSC_PAGE_2_UPDATED | Data page 0 and page 2 have been updated (Display) or sent (Sensor).
ANT_BSC_PAGE_3_UPDATED | Data page 0 and page 3 have been updated (Display) or sent (Sensor).
ANT_BSC_PAGE_4_UPDATED | Data page 0 and page 4 have been updated (Display) or sent (Sensor).
ANT_BSC_PAGE_5_UPDATED | Data page 0 and page 5 have been updated (Display) or sent (Sensor).
ANT_BSC_COMB_PAGE_0_UPDATED | Combined Speed and cadence data page has been updated (Display) or sent (Sensor).

enum ant_bsc_page_t

BSC page number type.

Enumerator
ANT_BSC_PAGE_0 | Main data page number 0.
ANT_BSC_PAGE_1 | Background data page number 1. This page is optional.
ANT_BSC_PAGE_2 | Background data page number 2.
ANT_BSC_PAGE_3 | Background data page number 3.
ANT_BSC_PAGE_4 | Background data page number 4. This page is optional.
ANT_BSC_PAGE_5 | Main data page number 5. This page is optional.
ANT_BSC_COMB_PAGE_0 | Main data page number 0 for combined speed and cadence sensor.

## Function Documentation

void ant_bsc_disp_evt_handler | ( | ant_bsc_profile_t * | p_profile,
|  | ant_evt_t * | p_ant_event
| ) |  |

Function for handling the Display ANT events.

This function handles all events from the ANT stack that are of interest to the Bicycle Speed and Cadence Display profile.

Parameters

  [in] | p_profile | Pointer to the profile instance.
  [in] | p_ant_event | Event received from the ANT stack.

ret_code_t ant_bsc_disp_init | ( | ant_bsc_profile_t * | p_profile,
|  | ant_channel_config_t const * | p_channel_config,
|  | ant_bsc_disp_config_t const * | p_disp_config
| ) |  |

Function for initializing the ANT BSC profile instance.

Parameters

  [in] | p_profile | Pointer to the profile instance.
  [in] | p_channel_config | Pointer to the ANT channel configuration structure.
  [in] | p_disp_config | Pointer to the BSC display configuration structure.

Return values

  NRF_SUCCESS | If initialization was successful. Otherwise, an error code is returned.

ret_code_t ant_bsc_disp_open | ( | ant_bsc_profile_t * | p_profile | ) |

Function for opening the profile instance channel for the ANT BSC Display.

Before calling this function, pages should be configured.

Parameters

  [in] | p_profile | Pointer to the profile instance.

Return values

  NRF_SUCCESS | If the channel was successfully opened. Otherwise, an error code is returned.

void ant_bsc_sens_evt_handler | ( | ant_bsc_profile_t * | p_profile,
|  | ant_evt_t * | p_ant_event
| ) |  |

Function for handling the Sensor ANT events.

This function handles all events from the ANT stack that are of interest to the Bicycle Speed and Cadence Sensor profile.

Parameters

  [in] | p_profile | Pointer to the profile instance.
  [in] | p_ant_event | Event received from the ANT stack.

ret_code_t ant_bsc_sens_init | ( | ant_bsc_profile_t * | p_profile,
|  | ant_channel_config_t const * | p_channel_config,
|  | ant_bsc_sens_config_t const * | p_sens_config
| ) |  |

Function for initializing the ANT BSC profile instance.

Parameters

  [in] | p_profile | Pointer to the profile instance.
  [in] | p_channel_config | Pointer to the ANT channel configuration structure.
  [in] | p_sens_config | Pointer to the BSC sensor configuration structure.

Return values

  NRF_SUCCESS | If initialization was successful. Otherwise, an error code is returned.

ret_code_t ant_bsc_sens_open | ( | ant_bsc_profile_t * | p_profile | ) |

Function for opening the profile instance channel for the ANT BSC Sensor.

Before calling this function, pages should be configured.

Parameters

  [in] | p_profile | Pointer to the profile instance.

Return values

  NRF_SUCCESS | If the channel was successfully opened. Otherwise, an error code is returned.