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

nRF52840 DK, implementing Board Button event handler, but no response on button press.

Hi, 

I am trying to do some tasks based on a particular button press, below attached is the buttons_init() function and the button_evt_handler() function. Code compiles and runs successfully, but nothing happens on button press. Please let me know if I am missing out on something. 

Thanks in advance.

static void buttons_init(void)
{
    uint32_t err_code;

    static app_button_cfg_t buttons[] = 
    { 
        {BSP_BUTTON_0, false, BUTTON_PULL, button_evt_handler},
        {BSP_BUTTON_1, false, BUTTON_PULL, button_evt_handler}
    };

    err_code = app_button_init(buttons, ARRAY_SIZE(buttons), BUTTON_DEBOUNCE_DELAY);
    APP_ERROR_CHECK(err_code);

    err_code = app_button_enable();
    APP_ERROR_CHECK(err_code);
}    

static void button_evt_handler(uint8_t pin_no, uint8_t button_action)
{
    if(button_action == APP_BUTTON_PUSH)
    {
        switch(pin_no)
        {
            case BSP_BUTTON_0:
                NRF_LOG_INFO("Sending blood pressure data\r\n");
                break;
            case BSP_BUTTON_1:
                NRF_LOG_INFO("Sending temperature data\r\n");
                break;
            default:
                NRF_LOG_INFO("Default case\r\n");
                break;
        }
        
    }
}

Parents Reply Children
No Data
Related