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

GPIOTE INPUT simple use with SDK 11.0.0

Hi, everyone.

I have read the nRF5 SDK --> GPIOTE part in the infocenter. However, I have not get anything useful.

I just want to recieve a interrupt from an external sensor and do something in a handler function. So I tried some code like this:

static void event(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    i = 1;
}


int main(void)
{
    uint32_t err_code;
    bool erase_bonds;
    
    const nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);

    timers_init();
    buttons_leds_init(&erase_bonds);
    twi_init();
    nrf_drv_gpiote_init();
    
    nrf_drv_gpiote_in_init(13, &config, event);
    
    ble_stack_init();
    device_manager_init(erase_bonds);
    gap_params_init();
    advertising_init();
    services_init();
    conn_params_init();

    
    application_timers_start();
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);

    
    for (;;)
    {
        power_manage();
    }
}

But when I run it on PCA10028 and press the Button 1, event function will never be executed. So I just want to ask why I'm wrong and how to use the GPIOTE input event?

Related