You are here: Forum Home → ANT Developers Forums → ANT General Questions → Thread
// initialize logging
ret_code_t err_code = NRF_LOG_INIT(NULL);
APP_ERROR_CHECK(err_code);
NRF_LOG_DEFAULT_BACKENDS_INIT();
NRF_LOG_INFO("Hello world")
// sanity check, this prints 15
NRF_LOG_INFO("ANT_CONFIG_TOTAL_CHANNELS_ALLOCATED = %d",
ANT_CONFIG_TOTAL_CHANNELS_ALLOCATED);
// initialize app timer
err_code = app_timer_init();
APP_ERROR_CHECK(err_code);
// enable ANT softdevice
err_code = nrf_sdh_enable_request();
APP_ERROR_CHECK(err_code);
ASSERT(nrf_sdh_is_enabled());
err_code = nrf_sdh_ant_enable();
APP_ERROR_CHECK(err_code);
// configure ANT to report device ID and RSSI
err_code = sd_ant_lib_config_set(
ANT_LIB_CONFIG_MESG_OUT_INC_DEVICE_ID |
ANT_LIB_CONFIG_MESG_OUT_INC_RSSI);
APP_ERROR_CHECK(err_code);
// channel config for continuous scanning slave
ant_channel_config_t channel_config = {
.channel_number = ANT_SCAN_CHANNEL_NUMBER, // = 0
.channel_type = CHANNEL_TYPE_SLAVE,
.ext_assign = 0x00,
.rf_freq = RF_FREQ,
.transmission_type = CHAN_ID_SLAVE_TRANS_TYPE, // = 0
.device_type = CHAN_ID_SLAVE_DEV_TYPE, // = 0
.device_number = 0x00,
.channel_period = 0x00,
.network_number = ANT_NETWORK_NUM, // = 0
};
err_code = ant_channel_init(&channel;_config);
APP_ERROR_CHECK(err_code);
// assign response channel 1
err_code = sd_ant_channel_assign(1,
CHANNEL_TYPE_SLAVE,
ANT_NETWORK_NUM,
0x00);
APP_ERROR_CHECK(err_code); // <--- success
// assign response channel 2
err_code = sd_ant_channel_assign(2,
CHANNEL_TYPE_SLAVE,
ANT_NETWORK_NUM,
0x00);
APP_ERROR_CHECK(err_code); // <--- returns with 0x4033
// ANT Channels
//==========================================================
// NRF_SDH_ANT_TOTAL_CHANNELS_ALLOCATED - Allocated ANT channels.
#ifndef NRF_SDH_ANT_TOTAL_CHANNELS_ALLOCATED
#define NRF_SDH_ANT_TOTAL_CHANNELS_ALLOCATED 2
#endif