Esempio n. 1
0
void setup_example(void)
{
    uint32_t event;
    nrf_ppi_channel_t ppi_channel;
    uint32_t err_code;

    nrf_gpio_cfg_output(BSP_LED_0);

    err_code = nrf_drv_rtc_init(&rtc, NULL, rtc_evt_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_rtc_tick_enable(&rtc, false);
    event = nrf_drv_rtc_event_address_get(&rtc, NRF_RTC_EVENT_TICK);

    nrf_gpiote_task_config(0, BSP_LED_0, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);

    err_code = nrf_drv_ppi_init();
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_ppi_channel_alloc(&ppi_channel);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_ppi_channel_assign(ppi_channel,event,(uint32_t)&NRF_GPIOTE->TASKS_OUT[0]);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_ppi_channel_enable(ppi_channel);
    APP_ERROR_CHECK(err_code);

    nrf_drv_rtc_enable(&rtc);
}
Esempio n. 2
0
File: main.c Progetto: IOIOI/nRF51
void setup_example(void)
{
    uint32_t event;
    nrf_ppi_channel_t ppi_channel;
    uint32_t err_code;

    nrf_gpio_cfg_output(BSP_LED_0);

    err_code = nrf_drv_rtc_init(&rtc, NULL, rtc_evt_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_rtc_tick_enable(&rtc, false);
    event = nrf_drv_rtc_event_address_get(&rtc, NRF_RTC_EVENT_TICK);

    if (!nrf_drv_gpiote_is_init())
    {
        err_code = nrf_drv_gpiote_init();
        APP_ERROR_CHECK(err_code);
    }
    
    nrf_drv_gpiote_out_config_t pin_out_config = GPIOTE_CONFIG_OUT_TASK_TOGGLE(false);
    err_code = nrf_drv_gpiote_out_init(BSP_LED_0,&pin_out_config);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_out_task_enable(BSP_LED_0);

    uint32_t gpiote_task_addr = nrf_drv_gpiote_out_task_addr_get(BSP_LED_0);

    err_code = nrf_drv_ppi_init();
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_ppi_channel_alloc(&ppi_channel);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_ppi_channel_assign(ppi_channel,event,gpiote_task_addr);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_ppi_channel_enable(ppi_channel);
    APP_ERROR_CHECK(err_code);

    nrf_drv_rtc_enable(&rtc);
}