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

how to set high priority to push button

I'm using nrf51822. I have a program which shut down the system when the button is clicked. however, not every time I click the button, the system respond. my system is full of other events (interrupts). the BUTTON_DETECTION_DELAY is set to 1 second. I want a long press before going down.

void buttons_init(void)
{
    static app_button_cfg_t buttons[] = {
        {ON_OFF_BUTTON_PIN_NO, false, NRF_GPIO_PIN_PULLUP, button_event_handler},
    };

    uint32_t err_code = app_button_init(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY);
    APP_ERROR_CHECK(err_code);

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

void button_event_handler(uint8_t pin_no, uint8_t button_action)
{
      // set turn off flag, and turn off from main loop
}

how can I set the button handler the rightest priority

Related