This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

PCAL6408a IO Expander INT-Debounce

Hi,

Working with a nRF9160dk here.

Documentation states, that the GPIO_INT_DEBOUNCE flag should just be ignored when configuring a pin, if it is not available in the driver.
https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.8.0/zephyr/reference/peripherals/gpio.html

But in the PCAL6408 driver you can find the following:

static int pcal6408a_pin_configure(const struct device *dev,
				   gpio_pin_t pin,
				   gpio_flags_t flags)
{
	struct pcal6408a_drv_data *drv_data = dev->data;
	struct pcal6408a_pins_cfg pins_cfg;
	gpio_flags_t flags_io;
	int rc;

	/* This device does not support open-source outputs, and open-drain
	 * outputs can be only configured port-wise. It also does not support
	 * debouncing.
	 */
	if ((flags & GPIO_SINGLE_ENDED) != 0 ||
	    (flags & GPIO_INT_DEBOUNCE) != 0) {
		return -ENOTSUP;
	}
// ...
}

When the debounce flag is given, it aborts with -ENOTSUP.

Since this C-Module has the Nordic Copyright on it, I thought to post this here, so either the documentation or the driver can get updated, or I will get told that I am misunderstanding something, which is also very possible :)

  • Update:

    I realise that pin configure() might not have been the right function to look at, sorry.
    In the pin Interrupt configure functions is essentially the same problem though.

    The Flag gets an assert before even getting to a driver level functionat gpio_pin_interrupt_configure():

    static inline int z_impl_gpio_pin_interrupt_configure(const struct device *port,
    						      gpio_pin_t pin,
    						      gpio_flags_t flags)
    {
    	const struct gpio_driver_api *api =
    		(const struct gpio_driver_api *)port->api;
    	const struct gpio_driver_config *const cfg =
    		(const struct gpio_driver_config *)port->config;
    	const struct gpio_driver_data *const data =
    		(const struct gpio_driver_data *)port->data;
    	enum gpio_int_trig trig;
    	enum gpio_int_mode mode;
    
    	__ASSERT_NO_MSG((flags & GPIO_INT_DEBOUNCE) == 0);
    // ...
    }

  • Hi Mattias,

    Thank you for reporting this. I will forward this to the relevant developers and keep you updated.

    Best regards,

    Håkon

  • Hi Matthias,

    This is addressed here: https://github.com/zephyrproject-rtos/zephyr/pull/43436

    Feedback from the developer:

    "Regarding the assertion in gpio_pin_interrupt_configure(), it is correct. Although the documentation does not state it in the best way, the GPIO_INT_DEBOUNCE flag, despite its name, is supposed to be used in a call to gpio_pin_configure(), not gpio_pin_interrupt_configure(). See this description."

    Thanks again for reporting this :)

    Best regards,

    Håkon

  • Hi,

    Thank you very much for looking into this and for the notification!

Related