GPIO Interrupt example for NCS1.9.1

Hello,

NCS1.9.1, nRF52840DK,  Windows10 X64,  VS Code, 

i want to use P0.31 as gpio interrupt pin,

anyone know how to do it ?

void device_irq_callback(const struct device *port,struct gpio_callback *cb,gpio_port_pins_t pins)
{
}
void init_gpio_interrupt(void)
{
	#define GPIO(id) DT_NODELABEL(gpio##id)
	const struct device *gpio_31 = device_get_binding(DT_LABEL(GPIO(31)));
	// const struct device *gpio_31 = device_get_binding(DT_LABEL(DT_NODELABEL(gpio31)));

	gpio_pin_configure(gpio_31, 31, GPIO_INPUT | GPIO_PULL_UP);//IRQ_GPIO_FLAGS
	gpio_pin_interrupt_configure(gpio_31, 31, GPIO_INT_EDGE_BOTH);
	struct gpio_callback callback;
	gpio_init_callback(&callback, device_irq_callback, BIT(31));    
	gpio_add_callback(gpio_31, &callback);
}

if config to overlay file like follow,it show unkonw label.

thanks 

Best Regards

Parents Reply Children
Related