Please find below my config for handling Interrupt calls.
I've tested on another sensor dev board that the sensor I use is properly set up and is sending INT1 and INT2.
I also tried switching the outputs of the sensor and when I did so I got a response on INT2 (that should have been triggered on INT1) and vice versa.
I also tried switching the INT pins in the device tree and that worked.
I cant seem to get INT1 to work while int@ works as desired. The configuration is the same, there are no conflicts in any error messages or device tree.
buttons { compatible = "gpio-keys"; button1: button_1 { gpios = <&gpio1 13 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; label = "Push button 2"; }; int1: int_1 { status = "okay"; gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>; label = "interrupt 1"; }; int2: int_2 { status = "okay"; gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>; label = "interrupt 2"; }; }; #define INT1_NODE DT_ALIAS(int1) #define INT1_GPIO_CONTROLLER DEVICE_DT_GET(DT_GPIO_CTLR(INT1_NODE, gpios)) #define INT1_GPIO_PIN DT_GPIO_PIN(INT1_NODE, gpios) #define INT1_GPIO_FLAGS (DT_GPIO_FLAGS(INT1_NODE, gpios) | GPIO_INPUT) #define INT2_NODE DT_ALIAS(int2) #define INT2_GPIO_CONTROLLER DEVICE_DT_GET(DT_GPIO_CTLR(INT2_NODE, gpios)) #define INT2_GPIO_PIN DT_GPIO_PIN(INT2_NODE, gpios) #define INT2_GPIO_FLAGS (DT_GPIO_FLAGS(INT2_NODE, gpios) | GPIO_INPUT) struct k_work idleDetected_work; struct k_work int1_work; void idleDetected_work_handler(struct k_work* item) { printk("Idle detected\n"); } void int1_work_handler(struct k_work* item) { printk("INT2\n"); } void int1_callback(const struct device* dev, struct gpio_callback* cb, uint32_t pins) { k_work_submit(&idleDetected_work); } void int2_callback(const struct device* dev, struct gpio_callback* cb, uint32_t pins) { k_work_submit(&int1_work); } int configure_gpio(const struct device* gpio_dev, gpio_pin_t pin, gpio_flags_t flags) { int ret; /* Ensure the GPIO device is ready */ if (!device_is_ready(gpio_dev)) { printk("Error: %s device not ready\n", gpio_dev->name); return -1; } /* Configure the GPIO pin */ ret = gpio_pin_configure(gpio_dev, pin, flags); if (ret != 0) { printk("Failed to configure GPIO pin %d: %d\n", pin, ret); return ret; } /* Configure the GPIO pin interrupt */ ret = gpio_pin_interrupt_configure(gpio_dev, pin, GPIO_INT_EDGE_TO_ACTIVE); if (ret != 0) { printk("Failed to configure GPIO pin interrupt %d: %d\n", pin, ret); return ret; } return 0; } int setup_gpio_callback(const struct device* gpio_dev, gpio_pin_t pin, struct gpio_callback* cb, gpio_callback_handler_t handler) { int ret; /* Initialize and add the GPIO callback */ gpio_init_callback(cb, handler, BIT(pin)); ret = gpio_add_callback(gpio_dev, cb); if (ret != 0) { printk("Failed to add GPIO callback for pin %d: %d\n", pin, ret); return ret; } return 0; } int setup_irq_init(const struct i2c_dt_spec* dev) { int status; status = configure_gpio(INT1_GPIO_CONTROLLER, INT1_GPIO_PIN, INT1_GPIO_FLAGS); check_error(status, "configure_gpio1"); status = setup_gpio_callback(INT1_GPIO_CONTROLLER, INT1_GPIO_PIN, &int1_cb_data, int1_callback); check_error(status, "setup_gpio_callback1"); status = configure_gpio(INT2_GPIO_CONTROLLER, INT2_GPIO_PIN, INT2_GPIO_FLAGS); check_error(status, "configure_gpio2"); status = setup_gpio_callback(INT2_GPIO_CONTROLLER, INT2_GPIO_PIN, &int2_cb_data, int2_callback); check_error(status, "setup_gpio_callback2"); k_work_init(&int1_work, int1_work_handler); k_work_init(&idleDetected_work, idleDetected_work_handler); return 0; // Success }
What am I doing wrong?