Exemple #1
0
uint32_t nrf_drv_ppi_channel_fork_assign(nrf_ppi_channel_t channel, uint32_t fork_tep)
{
    ret_code_t err_code = NRF_SUCCESS;
#ifdef PPI_FEATURE_FORKS_PRESENT
    if (!is_programmable_app_channel(channel))
    {
        err_code = NRF_ERROR_INVALID_PARAM;
    }
    else if (!is_allocated_channel(channel))
    {
        err_code = NRF_ERROR_INVALID_STATE;
    }
    else
    {
        nrf_ppi_fork_endpoint_setup(channel, fork_tep);
        NRF_LOG_INFO("Fork assigned channel: %d, task end point: %d.\r\n", channel, fork_tep);
    }
    NRF_LOG_INFO("Function: %s, error code: %s.\r\n", (uint32_t)__func__, (uint32_t)ERR_TO_STR(err_code));
    return err_code;
#else   
    err_code = NRF_ERROR_NOT_SUPPORTED;
    NRF_LOG_WARNING("Function: %s, error code: %s.\r\n", (uint32_t)__func__, (uint32_t)ERR_TO_STR(err_code));
    return err_code;
#endif
}
Exemple #2
0
uint32_t nrf_drv_ppi_channel_alloc(nrf_ppi_channel_t * p_channel)
{
    uint32_t err_code = NRF_SUCCESS;
    nrf_ppi_channel_t channel;
    uint32_t mask = 0;

    err_code = NRF_ERROR_NO_MEM;

    mask = NRF_PPI_PROG_APP_CHANNELS_MASK;
    for (channel = NRF_PPI_CHANNEL0; mask != 0; mask &= ~nrf_drv_ppi_channel_to_mask(channel), channel++)
    {
        CRITICAL_REGION_ENTER();
        if ((mask & nrf_drv_ppi_channel_to_mask(channel)) && (!is_allocated_channel(channel)))
        {
            channel_allocated_set(channel);
            *p_channel = channel;
            err_code   = NRF_SUCCESS;
        }
        CRITICAL_REGION_EXIT();
        if (err_code == NRF_SUCCESS)
        {
            NRF_LOG_INFO("Allocated channel: %d.\r\n", channel);
            break;
        }
    }

    NRF_LOG_INFO("Function: %s, error code: %s.\r\n", (uint32_t)__func__, (uint32_t)ERR_TO_STR(err_code));
    return err_code;
}
Exemple #3
0
uint32_t nrf_drv_ppi_channel_alloc(nrf_ppi_channel_t * p_channel)
{
    uint32_t err_code;
    nrf_ppi_channel_t channel;
    uint32_t mask = 0;

    err_code = NRF_ERROR_NO_MEM;

    mask = NRF_PPI_PROG_APP_CHANNELS_MASK;
    for (channel = NRF_PPI_CHANNEL0; mask != 0; mask &= ~nrf_drv_ppi_channel_to_mask(channel), channel++)
    {
        CRITICAL_REGION_ENTER();
        if ((mask & nrf_drv_ppi_channel_to_mask(channel)) && (!is_allocated_channel(channel)))
        {
            channel_allocated_set(channel);
            *p_channel = channel;
            err_code   = NRF_SUCCESS;
        }
        CRITICAL_REGION_EXIT();
        if (err_code == NRF_SUCCESS)
        {
            break;
        }
    }

    return err_code;
}
uint32_t nrf_drv_ppi_channel_assign(nrf_ppi_channel_t channel, uint32_t eep, uint32_t tep)
{
    uint32_t err_code;

    if (((uint32_t *)eep == NULL) || ((uint32_t *)tep == NULL))
    {
        err_code = NRF_ERROR_NULL;
    }
    else if (!is_programmable_app_channel(channel))
    {
        err_code = NRF_ERROR_INVALID_PARAM;
    }
    else if (!is_allocated_channel(channel))
    {
        err_code = NRF_ERROR_INVALID_STATE;
    }
    else
    {
#if (NRF_PPI_RESTRICTED > 0)
        err_code = sd_ppi_channel_assign((uint8_t) channel, (const volatile void *) eep, (const volatile void *) tep);
        if (err_code != NRF_SUCCESS)
        {
            err_code = NRF_ERROR_INVALID_PARAM;
        }
#else
        nrf_ppi_channel_endpoint_setup(channel, eep, tep);
        err_code = NRF_SUCCESS;
#endif
    }

    return err_code;
}
Exemple #5
0
uint32_t nrf_drv_ppi_channel_disable(nrf_ppi_channel_t channel)
{
    if (!is_app_channel(channel))
    {
        return NRF_ERROR_INVALID_PARAM;
    }
    if (is_programmable_app_channel(channel) && !is_allocated_channel(channel))
    {
        return NRF_ERROR_INVALID_STATE;
    }
    nrf_ppi_channel_disable(channel);
    return NRF_SUCCESS;
}
Exemple #6
0
uint32_t nrf_drv_ppi_channel_assign(nrf_ppi_channel_t channel, uint32_t eep, uint32_t tep)
{
    if (((uint32_t *)eep == NULL) || ((uint32_t *)tep == NULL))
    {
        return NRF_ERROR_NULL;
    }
    if (!is_programmable_app_channel(channel))
    {
        return NRF_ERROR_INVALID_PARAM;
    }
    if (!is_allocated_channel(channel))
    {
        return NRF_ERROR_INVALID_STATE;
    }
    
    nrf_ppi_channel_endpoint_setup(channel, eep, tep);
    return NRF_SUCCESS;
}
Exemple #7
0
uint32_t nrf_drv_ppi_channel_enable(nrf_ppi_channel_t channel)
{
    ret_code_t err_code = NRF_SUCCESS;

    if (!is_app_channel(channel))
    {
        err_code = NRF_ERROR_INVALID_PARAM;
    }
    else if (is_programmable_app_channel(channel) && !is_allocated_channel(channel))
    {
        err_code = NRF_ERROR_INVALID_STATE;
    }
    else
    {
        nrf_ppi_channel_enable(channel);
    }
    NRF_LOG_INFO("Function: %s, error code: %s.\r\n", (uint32_t)__func__, (uint32_t)ERR_TO_STR(err_code));
    return err_code;
}
Exemple #8
0
uint32_t nrf_drv_ppi_channel_assign(nrf_ppi_channel_t channel, uint32_t eep, uint32_t tep)
{
    VERIFY_PARAM_NOT_NULL((uint32_t *)eep);
    VERIFY_PARAM_NOT_NULL((uint32_t *)tep);

    ret_code_t err_code = NRF_SUCCESS;

    if (!is_programmable_app_channel(channel))
    {
        err_code = NRF_ERROR_INVALID_PARAM;
    }
    else if (!is_allocated_channel(channel))
    {
        err_code = NRF_ERROR_INVALID_STATE;
    }
    else
    {
        nrf_ppi_channel_endpoint_setup(channel, eep, tep);
        NRF_LOG_INFO("Assigned channel: %d, event end point: %x, task end point: %x.\r\n", channel, eep, tep);
    }
    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_channel_disable(nrf_ppi_channel_t channel)
{
    uint32_t err_code;

    if (!is_app_channel(channel))
    {
        err_code = NRF_ERROR_INVALID_PARAM;
    }
    else if (is_programmable_app_channel(channel) && !is_allocated_channel(channel))
    {
        err_code = NRF_ERROR_INVALID_STATE;
    }
    else
    {
#if (NRF_PPI_RESTRICTED > 0)
        err_code = sd_ppi_channel_enable_clr(channel_to_mask(channel));
#else
        nrf_ppi_channel_disable(channel);
        err_code = NRF_SUCCESS;
#endif
    }

    return err_code;
}