Hi,
I'm stuck with setting up device tree section about the TCA6416 and the associated C code.
the TCA6416 is connected to nrf9160 gpio P0.28 as interrupt active low.
I want to set up pin 2 as output and pin 3 as input (specifically as an interrupt) I would have other pins as interrupt also.
1- would there be a callback per pin or a single callback for all interupt pins (with a switch case) ?
here where I am, and got errors when building
device tree:
&i2c2 { compatible = "nordic,nrf-twim"; status = "okay"; clock-frequency = <I2C_BITRATE_FAST>; pinctrl-0 = <&i2c2_default>; pinctrl-1 = <&i2c2_sleep>; pinctrl-names = "default", "sleep"; tca6416: tca6416@20 { compatible = "ti,tca6416"; reg = <0x20>; // I2C address of the TCA6416 #gpio-cells = <2>; // Number of cells for GPIO gpio-controller; label = "TCA6416"; reg = <0x20>; #address-cells = <1>; #size-cells = <0>; signal_enable: signal-enable { gpio-controller; #gpio-cells = <2>; gpio-pin = <2 0>; /* Output */ }; signal_detect: signal-detect { gpio-controller; #gpio-cells = <2>; gpio-pin = <3 1>; /* Input */ }; }; };
C code:
/* Define the device tree node for the TCA6416 */ #define TCA6416_NAME "TCA6416" // Define the pin numbers for TAMPER_REARM and TAMPER_DETECT // #define SIGNAL_ENABLE_PIN 2 // #define SIGNAL_DETECT_PIN 3 #define TCA6416_NODE DT_NODELABEL(tca6416) #define SIGNAL_ENABLE_PIN DT_GPIO_PIN(TCA6416_NODE, signal_rearm_gpios) #define SIGNAL_DETECT_PIN DT_GPIO_PIN(TCA6416_NODE, signal_detect_gpios) void tca6416_init(void) { /* Get the GPIO device for the TCA6416 */ struct device *gpio_expander_dev = device_get_binding(TCA6416_NAME); if (!gpio_expander_dev) { printk("Failed to get GPIO device\n"); return; } gpio_pin_configure(gpio_expander_dev, SIGNAL_ENABLE_PIN , GPIO_OUTPUT_ACTIVE); gpio_pin_configure(gpio_expander_dev, SIGNAL_DETECT_PIN , GPIO_INPUT); }
much appreciate any help.