0

For some reason this simple configuration of NRF52 sdk 15.3.0 doesn't work. I was trying to edit my code from gpio to gpiote and I cannot initialize even the event to recognize that the button has been pressed.

The NRF52832 is Active-low as I understand and also from running some tests.

I made sure that both: #define GPIOTE_ENABLED 1 and #define NRFX_GPIOTE_ENABLED 1 are defined.

What might be wrong?

#include "nrfx_gpiote.h"
#include "app_error.h"
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"

#define BUTTON_PIN_NUMBER 13

void button_event_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    NRF_LOG_INFO("Button event detected");
}

int main(void)
{
    NRF_LOG_INIT(NULL);
    NRF_LOG_DEFAULT_BACKENDS_INIT();

    nrfx_err_t err;

    // Initialize nrfx_gpiote
    err = nrfx_gpiote_init();
    APP_ERROR_CHECK(err);

    // Set up button as GPIOTE input with pull-up resistor
    nrfx_gpiote_in_config_t btn_config = NRFX_GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);
    btn_config.pull = NRF_GPIO_PIN_PULLUP;

    err = nrfx_gpiote_in_init(BUTTON_PIN_NUMBER, &btn_config, button_event_handler);
    APP_ERROR_CHECK(err);
    nrfx_gpiote_in_event_enable(BUTTON_PIN_NUMBER, true);

    while (true)
    {
        NRF_LOG_FLUSH();
    }

    return 0;
}

1 Answer 1

1

The app_gpiote.c file was missing inside the drivers.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.