Exemplo n.º 1
0
Arquivo: main.c Projeto: IOIOI/nRF51
/**@brief Function for setting up the ANT module to be ready for TX broadcast.
 */
static void ant_channel_tx_broadcast_setup(void)
{
    uint32_t err_code;

    ant_channel_config_t broadcast_channel_config =
    {
        .channel_number    = ANT_BROADCAST_CHANNEL_NUMBER,
        .channel_type      = CHANNEL_TYPE_MASTER_TX_ONLY,
        .ext_assign        = EXT_ASSIGN_NONE,
        .rf_freq           = ANT_FREQUENCY,
        .transmission_type = ANT_BROADCAST_TRANSMISSION_TYPE,
        .device_type       = ANT_BROADCAST_DEVICE_TYPE,
        .device_number     = ANT_BROADCAST_DEVICE_NUMBER,
        .channel_period    = ANT_CHANNEL_PERIOD,
        .network_number    = ANT_NETWORK_NUMBER,
    };

    err_code = ant_channel_init(&broadcast_channel_config);
    APP_ERROR_CHECK(err_code);

    // Fill tx buffer for the first frame.
    ant_message_send();

    // Open channel.
    err_code = sd_ant_channel_open(ANT_BROADCAST_CHANNEL_NUMBER);
    APP_ERROR_CHECK(err_code);
}
Exemplo n.º 2
0
void ant_bpwr_sens_evt_handler(ant_bpwr_profile_t * p_profile, ant_evt_t * p_ant_event)
{
    if (p_ant_event->channel == p_profile->channel_number)
    {
        ANT_MESSAGE * p_message;

        switch (p_ant_event->event)
        {
            case EVENT_TX:
                ant_message_send(p_profile);
                break;

            case EVENT_RX:
                p_message = (ANT_MESSAGE *)p_ant_event->msg.evt_buffer;

                if (p_message->ANT_MESSAGE_ucMesgID == MESG_ACKNOWLEDGED_DATA_ID)
                {
                    sens_message_decode(p_profile, p_message->ANT_MESSAGE_aucPayload);
                }
                break;

            default:
                // No implementation needed
                break;
        }
    }
}
Exemplo n.º 3
0
ret_code_t ant_bpwr_sens_open(ant_bpwr_profile_t * p_profile)
{
    // Fill tx buffer for the first frame
    ant_message_send(p_profile);

    LOG_BPWR("ANT B-PWR %u open\n\r", p_profile->channel_number);
    return sd_ant_channel_open(p_profile->channel_number);
}
Exemplo n.º 4
0
ret_code_t ant_hrm_sens_open(ant_hrm_profile_t * p_profile)
{
    ASSERT(p_profile != NULL);

    // Fill tx buffer for the first frame
    ant_message_send(p_profile);

    NRF_LOG_INFO("ANT HRM channel %u open\r\n", p_profile->channel_number);
    return sd_ant_channel_open(p_profile->channel_number);
}
Exemplo n.º 5
0
ret_code_t ant_bsc_sens_open(ant_bsc_profile_t * p_profile)
{
    ASSERT(p_profile != NULL);

    // Fill tx buffer for the first frame
    ant_message_send(p_profile);

    LOG_BSC("ANT BSC channel %u open\n\r", p_profile->channel_number);
    return sd_ant_channel_open(p_profile->channel_number);
}
Exemplo n.º 6
0
void ant_hrm_sens_evt_handler(ant_hrm_profile_t * p_profile, ant_evt_t * p_ant_event)
{
    if (p_ant_event->channel == p_profile->channel_number)
    {
        switch (p_ant_event->event)
        {
            case EVENT_TX:
                ant_message_send(p_profile);
                break;

            default:
                break;
        }
    }
}
Exemplo n.º 7
0
Arquivo: main.c Projeto: IOIOI/nRF51
/**@brief Function for dispatching a ANT stack event to all modules with a ANT stack event handler.
 *
 * @details This function is called from the ANT Stack event interrupt handler after a ANT stack
 *          event has been received.
 *
 * @param[in] p_ant_evt  ANT stack event.
 */
void ant_evt_dispatch(ant_evt_t * p_ant_evt)
{
    uint32_t err_code;

    if (p_ant_evt->channel == ANT_BROADCAST_CHANNEL_NUMBER)
    {
        switch (p_ant_evt->event)
        {
            case EVENT_TX:
                ant_message_send();

                err_code = bsp_indication_set(BSP_INDICATE_SENT_OK);
                APP_ERROR_CHECK(err_code);
                break;

            default:
                break;
        }
    }
}