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

button interrupt not trigger

I want to use the push of a button, so I added the following code, but when the button is pressed, nothing happens.

/**@brief Function for handling bsp events.
 */
void bsp_evt_handler(bsp_event_t evt)
{
    uint32_t err_code;
    NRF_LOG_INFO("button is pressed");
    switch (evt)
    {
        case BSP_EVENT_KEY_0:
            NRF_LOG_INFO("BSP_EVENT_KEY_0");
            nus_c_send_status(m_status);
            break;

        case BSP_EVENT_KEY_1:

            break;

        default:
            return; // no implementation needed
    }
}


static void buttons_leds_init(void)
{
    ret_code_t err_code;
    bsp_event_t startup_event;

    err_code = bsp_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS, bsp_evt_handler);
    APP_ERROR_CHECK(err_code);

//    err_code = bsp_btn_ble_init(NULL, &startup_event);
//    APP_ERROR_CHECK(err_code);

//    *p_erase_bonds = (startup_event == BSP_EVENT_CLEAR_BONDING_DATA);
}

int main(void)
{
//    bool erase_bonds;

    // Initialize.
    uart_init();
    log_init();

    fds_init_data();
    fds_read_data();
        
    clock_initialization();
    timer_init();
    buttons_leds_init();
    ...
}

Related