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

how do I generate a GPIO interrupt

I have a nRF9160DK board and a want to generate a simple interrupt when I press button 1 (pin 6) on the DK board. When this works I will move to a different GPIO and hook a real signal on the pin to cause a real interrupt. I just want to get this simple example working so I can understand the concepts. I tried the following code shown below but I never received an interrupt. I am sure I am missing something very simple. any help would be appreciated. 

const struct device *buttonPtr = device_get_binding("GPIO_0");
struct gpio_callback gpio_button_cb;
gpio_pin_configure(buttonPtr, 6,GPIO_INPUT | GPIO_ACTIVE_LOW);
gpio_init_callback(&gpio_button_cb, (gpio_callback_handler_t)ButtonCallback, BIT(6));
gpio_add_callback(buttonPtr, &gpio_button_cb);
gpio_pin_interrupt_configure(buttonPtr, 6, GPIO_INT_EDGE_BOTH);

void ButtonCallback(struct device *dev, struct gpio_callback *cb, uint32_t pins)
{
inputPeriod = 1;
inputPulseWidth = 2;
}

Related