This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Question about bsp event handler

Hi, all

I am studying the bsp part while looking at the example of 'ble_app_uart'. (pca10056)

The difference between 'bsp_event_handler' and 'bsp_button_event_handler' is confusing.

Does the 'bsp_button_event_handler' become callback due to 'nrf_drv_gpiote_in_event_enable()' ?

Please explain how the two event handlers work.

add)

Also, is the app_timer created by 'app_button_init' continuously recognizing the press status of the button?

if (type & BSP_INIT_BUTTONS)
    {
        uint32_t num;

        for (num = 0; ((num < BUTTONS_NUMBER) && (err_code == NRF_SUCCESS)); num++)
        {
            err_code = bsp_event_to_button_action_assign(num, BSP_BUTTON_ACTION_PUSH, BSP_EVENT_DEFAULT);
        }

        if (err_code == NRF_SUCCESS)
        {
            err_code = app_button_init((app_button_cfg_t *)app_buttons,
                                       BUTTONS_NUMBER,
                                       APP_TIMER_TICKS(50));
        }

        if (err_code == NRF_SUCCESS)
        {
            err_code = app_button_enable();
        }

        if (err_code == NRF_SUCCESS)
        {
            err_code = app_timer_create(&m_bsp_button_tmr,
                                        APP_TIMER_MODE_SINGLE_SHOT,
                                        button_timer_handler);
        }
    }

/* Create polling timer. */
    return app_timer_create(&m_detection_delay_timer_id,
                            APP_TIMER_MODE_SINGLE_SHOT,
                            detection_delay_timeout_handler);

  • Hi Iyrics, 

    bsp_event_handler is the function for handling events from the  BSP BLE Button Module

    bsp_button_event_handler is the function for handling button events. If you look at the function bsp_button_event_handler() in bsp.c, this is actually the app_button callback. 

    is the app_timer created by 'app_button_init' continuously recognizing the press status of the button?

    yes. app_button_init() in bsp.c uses the value calculated by APP_TIMER_TICKS to calculate the delay from a GPIOTE event until a button is reported as pushed (detection_delay). 

    -Amanda H. 

Related