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

Struggeling combining ble_app_gatts and gpiote

I’m in the process of learning the nRF52, and tries to combine the ble_app_gatts and the  pin_change_int examples (using nRF52 DK, SDK 15.3 SES projects on a Win7 machine).
In the SDK 15.3 ble_app_gatts project I have included the "nrf_drv_gpiote.h" and the following code for the init and the pin_handler:

#define PIN_OUT   LED_4
#define PIN_IN    BUTTON_4

void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    nrf_drv_gpiote_out_toggle(PIN_OUT);
    NRF_LOG_INFO("IRQ received.");
}
/**
 * @brief Function for configuring: PIN_IN pin for input, PIN_OUT pin for output,
 * and configures GPIOTE to give an interrupt on pin change.
 */
static void gpio_init(void)
{
    ret_code_t err_code;
    if(!nrf_drv_gpiote_is_init())
    {
      err_code = nrf_drv_gpiote_init();
      APP_ERROR_CHECK(err_code);
    }

    nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);

    err_code = nrf_drv_gpiote_out_init(PIN_OUT, &out_config);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
    in_config.pull = NRF_GPIO_PIN_PULLUP;

    err_code = nrf_drv_gpiote_in_init(PIN_IN, &in_config, in_pin_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_event_enable(PIN_IN, true);
}

The gpio_init() is called at the end of the modules_init():

static void modules_init(void)
{
    log_init();
    leds_init();
    timers_init();
    buttons_leds_init(&m_erase_bonds);
    power_management_init();
    ble_stack_init();
    gap_params_init();
    gatt_init();
    db_discovery_init();
    services_init();
    advertising_init();
    peer_manager_init();
    gpio_init();
}

However, when running the program, it terminates in the nrf_drv_gpiote_in_init(PIN_IN, &in_config, in_pin_handler);, telling that the pin is in use by gpiote.

I have also tried using pin 43, with the same result.

What am I missing/doing wrong?

Thanks.

Parents Reply
  • The suggestions are appreciated, but I'm in the process of learning and need to understand the basics of the example projects before I dig into the special cases and start to change the underlying sw. The nrfx_gpio_... seems to be called further down the stack. I do still not understand how to combine the ble_app_gatts and the  pin_change_int examples without changing the BSP_INIT_BUTTONS.

Children
No Data
Related