How to setup GPIO Level interrupts correctly

If i setup GPIO level interrupt as follows,

ret = gpio_pin_interrupt_configure_dt(&spiInterrupt, GPIO_INT_TRIG_LOW |GPIO_INT_MODE_LEVEL);


My gpio interrupt callback keeps on getting executed. My ISR only releases a semaphore, the SPI read operation is in main thread.
Until i read, the peripheral will keep the GPIO pin active. If i setup the pin as follows


ret
= gpio_pin_interrupt_configure_dt(&spiInterrupt, GPIO_INT_TRIG_LOW);


then everything works correctly, I get only one interrupt call. But this call is wrong (or is it?) and if compiled with CONFIG_ASSERT
it will fail with assertion "Must either enable or disable interrupts"

Whats the right way to setup GPIO interrupts for my case where an interrupt should release a semaphore and the main thread can then
read from SPI.I cannot use edge triggers because of Errata 153.
Parents
  • Hi,

     

    The function requires that you either enable or disable interrupt via the GPIO_INT_* flag.

    If you are using an external pin that is active low, you can pass the flag "GPIO_INT_LEVEL_INACTIVE"

     

    Do you have a pull resistor on this line?

    You can configure that like this:

    ret = gpio_pin_configure_dt(&spiInterrupt, GPIO_INPUT | GPIO_PULL_UP);

     

    Kind regards,

    Håkon

Reply
  • Hi,

     

    The function requires that you either enable or disable interrupt via the GPIO_INT_* flag.

    If you are using an external pin that is active low, you can pass the flag "GPIO_INT_LEVEL_INACTIVE"

     

    Do you have a pull resistor on this line?

    You can configure that like this:

    ret = gpio_pin_configure_dt(&spiInterrupt, GPIO_INPUT | GPIO_PULL_UP);

     

    Kind regards,

    Håkon

Children
Related