Ejemplo n.º 1
0
uint32_t ant_hrm_init(ant_hrm_profile_t * p_profile, ant_channel_config_t const * p_channel_config,
                      ant_hrm_tx_config_t const * p_tx_config)
{
    ASSERT(p_profile != NULL);
    ASSERT(p_channel_config != NULL);

    p_profile->channel_number = p_channel_config->channel_number;

    if (p_tx_config != NULL)
    {
        p_profile->p_cb           = p_tx_config->p_cb_buffer;
        ant_hrm_tx_cb_t * p_hrm_cb   = (ant_hrm_tx_cb_t *)p_profile->p_cb;

        p_hrm_cb->page_1_present = p_tx_config->page_1_present;

        ASSERT((p_tx_config->main_page_number == ANT_HRM_PAGE_0) || (p_tx_config->main_page_number == ANT_HRM_PAGE_4));
        p_hrm_cb->main_page_number  = p_tx_config->main_page_number;

        p_hrm_cb->ext_page_number = p_hrm_cb->page_1_present ? ANT_HRM_PAGE_1 : ANT_HRM_PAGE_2;
        p_hrm_cb->message_counter = 0;
        p_hrm_cb->toggle_bit      = true;
    }

    p_profile->page_0 = (ant_hrm_page0_data_t)DEFAULT_ANT_HRM_PAGE0();
    p_profile->page_1 = (ant_hrm_page1_data_t)DEFAULT_ANT_HRM_PAGE1();
    p_profile->page_2 = (ant_hrm_page2_data_t)DEFAULT_ANT_HRM_PAGE2();
    p_profile->page_3 = (ant_hrm_page3_data_t)DEFAULT_ANT_HRM_PAGE3();
    p_profile->page_4 = (ant_hrm_page4_data_t)DEFAULT_ANT_HRM_PAGE4();

    LOG_ANT("ANT HRM channel %u init\n\r", p_profile->channel_number);
    return ant_channel_init(p_channel_config);
}
Ejemplo n.º 2
0
/**@brief Function for initializing the ANT HRM profile instance.
 *
 * @param[in]  p_profile        Pointer to the profile instance.
 * @param[in]  p_channel_config Pointer to the ANT channel configuration structure.
 *
 * @retval     NRF_SUCCESS      If initialization was successful. Otherwise, an error code is returned.
 */
static ret_code_t ant_hrm_init(ant_hrm_profile_t          * p_profile,
                             ant_channel_config_t const * p_channel_config)
{
    p_profile->channel_number = p_channel_config->channel_number;

    p_profile->page_0 = DEFAULT_ANT_HRM_PAGE0();
    p_profile->page_1 = DEFAULT_ANT_HRM_PAGE1();
    p_profile->page_2 = DEFAULT_ANT_HRM_PAGE2();
    p_profile->page_3 = DEFAULT_ANT_HRM_PAGE3();
    p_profile->page_4 = DEFAULT_ANT_HRM_PAGE4();

    NRF_LOG_INFO("ANT HRM channel %u init\r\n", p_profile->channel_number);
    return ant_channel_init(p_channel_config);
}