Set GPIO input for interrupt on custom board

Hi all

I'm working on custom board build with an nrf9161. Right now I'd like to use a gpio as input with interrupt for i2c captor icm20948. So for I've searched and I think I have 2 solutions but which one is better

First solution : in my common dtsi file add section like gpio-keys like a button. Is there a another solution because use button is not fine I think...

Second solution: I see in nrf9161dk board file something like this

arduino_i2c: &i2c2 {
	compatible = "nordic,nrf-twim";
	status = "okay";
	pinctrl-0 = <&i2c2_default>;
	pinctrl-1 = <&i2c2_sleep>;
	pinctrl-names = "default", "sleep";
	clock-frequency = <I2C_BITRATE_FAST>;

	pcal6408a: pcal6408a@21 {
		compatible = "nxp,pcal6408a";
		status = "disabled";
		reg = <0x21>;
		gpio-controller;
		#gpio-cells = <2>;
		ngpios = <8>;
		int-gpios = <&gpio0 19 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
	};
};

It's look like there is an i2c captor on i2c2 and use interupt on gpio 19, so for me icm20948 I have to develop the library to comunicate with it so this is a better solution or not ?

Parents
  • Hello,

    I believe the second solution you mentioned is more reliable, and I feel this is the proper method for integrating a sensor. I haven’t worked with the specific sensor you mentioned, but in the second solution you provided, you referenced a GPIO line that generates an interrupt event for an I2C device. This is a more correct and specific way of handling sensor interrupts compared to using the gpio-keys mechanism. However, as you mentioned, you would need to develop the driver yourselves. Perhaps you can refer to the Device Driver Model lesson from the Nordic Developer Academy, which explains custom driver development.

    Kind regards,
    Abhijith

Reply
  • Hello,

    I believe the second solution you mentioned is more reliable, and I feel this is the proper method for integrating a sensor. I haven’t worked with the specific sensor you mentioned, but in the second solution you provided, you referenced a GPIO line that generates an interrupt event for an I2C device. This is a more correct and specific way of handling sensor interrupts compared to using the gpio-keys mechanism. However, as you mentioned, you would need to develop the driver yourselves. Perhaps you can refer to the Device Driver Model lesson from the Nordic Developer Academy, which explains custom driver development.

    Kind regards,
    Abhijith

Children
No Data
Related