Beispiel #1
0
uint32_t nrf_drv_ppi_channels_include_in_group(uint32_t channel_mask,
                                               nrf_ppi_channel_group_t group)
{
    ret_code_t err_code = NRF_SUCCESS;
    
    if (!is_app_group(group))
    {
        err_code = NRF_ERROR_INVALID_PARAM;
    }
    else if (!is_allocated_group(group))
    {
        err_code = NRF_ERROR_INVALID_STATE;
    }
    else if (!are_app_channels(channel_mask))
    {
        err_code = NRF_ERROR_INVALID_PARAM;
    }
    else
    {   
        CRITICAL_REGION_ENTER();
        nrf_ppi_channels_include_in_group(channel_mask, group);
        CRITICAL_REGION_EXIT();
    }
    NRF_LOG_INFO("Function: %s, error code: %s.\r\n", (uint32_t)__func__, (uint32_t)ERR_TO_STR(err_code));
    return err_code;
}
Beispiel #2
0
uint32_t nrf_drv_ppi_group_alloc(nrf_ppi_channel_group_t * p_group)
{
    uint32_t err_code;
    uint32_t mask = 0;
    nrf_ppi_channel_group_t group;

    err_code = NRF_ERROR_NO_MEM;

    mask = NRF_PPI_ALL_APP_GROUPS_MASK;
    for (group = NRF_PPI_CHANNEL_GROUP0; mask != 0; mask &= ~group_to_mask(group), group++)
    {
        CRITICAL_REGION_ENTER();
        if ((mask & group_to_mask(group)) && (!is_allocated_group(group)))
        {
            group_allocated_set(group);
            *p_group = group;
            err_code = NRF_SUCCESS;
        }
        CRITICAL_REGION_EXIT();
        if (err_code == NRF_SUCCESS)
        {
            break;
        }
    }

    return err_code;
}
Beispiel #3
0
uint32_t nrf_drv_ppi_group_alloc(nrf_ppi_channel_group_t * p_group)
{
    uint32_t err_code;
    uint32_t mask = 0;
    nrf_ppi_channel_group_t group;

    err_code = NRF_ERROR_NO_MEM;

    mask = NRF_PPI_ALL_APP_GROUPS_MASK;
    for (group = NRF_PPI_CHANNEL_GROUP0; mask != 0; mask &= ~group_to_mask(group), group++)
    {
        CRITICAL_REGION_ENTER();
        if ((mask & group_to_mask(group)) && (!is_allocated_group(group)))
        {
            group_allocated_set(group);
            *p_group = group;
            err_code = NRF_SUCCESS;
        }
        CRITICAL_REGION_EXIT();
        if (err_code == NRF_SUCCESS)
        {
            NRF_LOG_INFO("Allocated group: %d.\r\n", group);
            break;
        }
    }

    NRF_LOG_INFO("Function: %s, error code: %s.\r\n", (uint32_t)__func__, (uint32_t)ERR_TO_STR(err_code));
    return err_code;
}
uint32_t nrf_drv_ppi_group_free(nrf_ppi_channel_group_t group)
{
    uint32_t err_code;

    if (!is_app_group(group))
    {
        err_code = NRF_ERROR_INVALID_PARAM;
    }
    else if (!is_allocated_group(group))
    {
        err_code = NRF_ERROR_INVALID_STATE;
    }
    else
    {
#if (NRF_PPI_RESTRICTED > 0)
        err_code = sd_ppi_group_task_disable((uint8_t) group);
#else
        nrf_ppi_group_disable(group);
        err_code = NRF_SUCCESS;
#endif
        CRITICAL_REGION_ENTER();
        group_allocated_clr(group);
        CRITICAL_REGION_EXIT();
    }

    return err_code;
}
uint32_t nrf_drv_ppi_channel_include_in_group(nrf_ppi_channel_t       channel,
                                              nrf_ppi_channel_group_t group)
{
    uint32_t err_code;

#if (NRF_PPI_RESTRICTED > 0)
    uint32_t ch_mask;
#endif

    if (!is_app_group(group))
    {
        err_code = NRF_ERROR_INVALID_PARAM;
    }
    else if (!is_allocated_group(group))
    {
        err_code = NRF_ERROR_INVALID_STATE;
    }
    else if (!is_app_channel(channel))
    {
        err_code = NRF_ERROR_INVALID_PARAM;
    }
    else
    {
#if (NRF_PPI_RESTRICTED > 0)

        CRITICAL_REGION_ENTER();
        err_code = sd_ppi_group_get((uint8_t) group, &ch_mask);
        if (err_code != NRF_SUCCESS)
        {
            err_code = NRF_ERROR_INVALID_PARAM;
        }
        else
        {
            ch_mask |= channel_to_mask(channel);
            err_code = sd_ppi_group_assign((uint8_t) group, ch_mask);
            if (err_code != NRF_SUCCESS)
            {
                err_code = NRF_ERROR_INVALID_PARAM;
            }
        }
        CRITICAL_REGION_EXIT();
#else

        CRITICAL_REGION_ENTER();
        nrf_ppi_channel_include_in_group(channel, group);
        CRITICAL_REGION_EXIT();
        err_code = NRF_SUCCESS;

#endif
    }

    return err_code;
}
Beispiel #6
0
uint32_t nrf_drv_ppi_group_enable(nrf_ppi_channel_group_t group)
{
    if (!is_app_group(group))
    {
        return NRF_ERROR_INVALID_PARAM;
    }
    if (!is_allocated_group(group))
    {
        return NRF_ERROR_INVALID_STATE;
    }
    nrf_ppi_group_enable(group);
    return NRF_SUCCESS;
}
Beispiel #7
0
uint32_t nrf_drv_ppi_channels_remove_from_group(uint32_t channel_mask,
                                                nrf_ppi_channel_group_t group)
{
    uint32_t err_code;

    if (!is_app_group(group))
    {
        err_code = NRF_ERROR_INVALID_PARAM;
    }
    else if (!is_allocated_group(group))
    {
        err_code = NRF_ERROR_INVALID_STATE;
    }
    else if (!are_app_channels(channel_mask))
    {
        err_code = NRF_ERROR_INVALID_PARAM;
    }
    else
    {
#if (NRF_PPI_RESTRICTED > 0)
        uint32_t channels_in_group = 0;

        CRITICAL_REGION_ENTER();
        err_code = sd_ppi_group_get((uint8_t) group, &channels_in_group);

        if (err_code != NRF_SUCCESS)
        {
            err_code = NRF_ERROR_INVALID_PARAM;
        }
        else
        {
            channels_in_group &= ~channel_mask;
            err_code = sd_ppi_group_assign((uint8_t) group, channels_in_group);

            if (err_code != NRF_SUCCESS)
            {
                err_code = NRF_ERROR_INVALID_PARAM;
            }
        }
        CRITICAL_REGION_EXIT();

#else
        CRITICAL_REGION_ENTER();
        nrf_ppi_channels_remove_from_group(channel_mask, group);
        CRITICAL_REGION_EXIT();
        err_code = NRF_SUCCESS;
#endif

    }
    return err_code;
}
Beispiel #8
0
uint32_t nrf_drv_ppi_group_free(nrf_ppi_channel_group_t group)
{
    if (!is_app_group(group))
    {
        return NRF_ERROR_INVALID_PARAM;
    }
    if (!is_allocated_group(group))
    {
        return NRF_ERROR_INVALID_STATE;
    }
    else
    nrf_ppi_group_disable(group);
    CRITICAL_REGION_ENTER();
    group_allocated_clr(group);
    CRITICAL_REGION_EXIT();
    return NRF_SUCCESS;
}
Beispiel #9
0
uint32_t nrf_drv_ppi_group_enable(nrf_ppi_channel_group_t group)
{
    ret_code_t err_code = NRF_SUCCESS;

    if (!is_app_group(group))
    {
        err_code = NRF_ERROR_INVALID_PARAM;
    }
    else if (!is_allocated_group(group))
    {
        err_code = NRF_ERROR_INVALID_STATE;
    }
    else
    {
        nrf_ppi_group_enable(group);
    }
    NRF_LOG_INFO("Function: %s, error code: %s.\r\n", (uint32_t)__func__, (uint32_t)ERR_TO_STR(err_code));
    return err_code;
}
Beispiel #10
0
uint32_t nrf_drv_ppi_channels_include_in_group(uint32_t channel_mask,
                                               nrf_ppi_channel_group_t group)
{
    if (!is_app_group(group))
    {
        return NRF_ERROR_INVALID_PARAM;
    }
    if (!is_allocated_group(group))
    {
        return NRF_ERROR_INVALID_STATE;
    }
    if (!are_app_channels(channel_mask))
    {
        return NRF_ERROR_INVALID_PARAM;
    }
    CRITICAL_REGION_ENTER();
    nrf_ppi_channels_include_in_group(channel_mask, group);
    CRITICAL_REGION_EXIT();
    return NRF_SUCCESS;
}
Beispiel #11
0
uint32_t nrf_drv_ppi_group_free(nrf_ppi_channel_group_t group)
{
    ret_code_t err_code = NRF_SUCCESS;

    if (!is_app_group(group))
    {
        err_code = NRF_ERROR_INVALID_PARAM;
    }
    if (!is_allocated_group(group))
    {
        err_code = NRF_ERROR_INVALID_STATE;
    }
    else
    {
        nrf_ppi_group_disable(group);
        CRITICAL_REGION_ENTER();
        group_allocated_clr(group);
        CRITICAL_REGION_EXIT();
    }
    NRF_LOG_INFO("Function: %s, error code: %s.\r\n", (uint32_t)__func__, (uint32_t)ERR_TO_STR(err_code));
    return err_code;
}
Beispiel #12
0
uint32_t nrf_drv_ppi_group_enable(nrf_ppi_channel_group_t group)
{
    uint32_t err_code;

    if (!is_app_group(group))
    {
        err_code = NRF_ERROR_INVALID_PARAM;
    }
    else if (!is_allocated_group(group))
    {
        err_code = NRF_ERROR_INVALID_STATE;
    }
    else
    {
#if (NRF_PPI_RESTRICTED > 0)
        err_code = sd_ppi_group_task_enable((uint8_t) group);
#else
        nrf_ppi_group_enable(group);
        err_code = NRF_SUCCESS;
#endif
    }

    return err_code;
}