static const struct device *button_dev = DEVICE_DT_GET(BUTTON0_DEV); int err = gpio_pin_configure(button_dev, BUTTON0_PIN, BUTTON0_FLAGS | GPIO_INPUT); if (err) { UART_INFO("[%s] %d %02x\r\n", __func__, __LINE__, err); return; } err = gpio_pin_interrupt_configure(button_dev, BUTTON0_PIN, GPIO_INT_EDGE_BOTH); if (err) { UART_INFO("[%s] %d %02x\r\n", __func__, __LINE__, err); return; } static struct gpio_callback gpio_cb; gpio_init_callback(&gpio_cb, BUTTON_PinInHandler, BIT(BUTTON0_PIN)); gpio_add_callback(button_dev, &gpio_cb);
It works when button0 is the pin of gpio0.
&button0 { gpios = <&gpio0 12 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; };
When it is the pin of gpio1, it does not work.
&button0 { gpios = <&gpio1 13 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; };