linguini1 commented on PR #16281:
URL: https://github.com/apache/nuttx/pull/16281#issuecomment-2842016830

   > @linguini1 I'm not able to get this to trigger an interrupt. Is this code 
correct? Is it possible that you can give me a testing code / snippet to run 
that also worked for you? This way we can make sure nothing breaks.
   
   Sorry for the late response, here is the full snippet I used for enabling 
the interrupts; it was done as part of the standard RP2040 GPIO driver.
   
   ```c
   /* Attaching interrupts */
   
   static int gpint_attach(struct gpio_dev_s *dev,
                           pin_interrupt_t callback)
   {
     struct rp2040gpint_dev_s *rp2040gpint =
       (struct rp2040gpint_dev_s *)dev;
     int irq = g_gpiointinputs[rp2040gpint->rp2040gpio.id];
     int ret;
   
     gpioinfo("Attaching the callback\n");
   
     /* Make sure the interrupt is disabled */
   
     rp2040_gpio_disable_irq(irq);
     ret = rp2040_gpio_irq_attach(irq,
                                  RP2040_GPIO_INTR_EDGE_LOW |
                                  RP2040_GPIO_INTR_EDGE_HIGH,
                                  rp2040gpio_interrupt,
                                  &g_gpint[rp2040gpint->rp2040gpio.id]);
     if (ret < 0)
       {
         syslog(LOG_ERR, "ERROR: gpint_attach() failed: %d\n", ret);
         return ret;
       }
   
     gpioinfo("Attach %p\n", callback);
     rp2040gpint->callback = callback;
     return OK;
   }
   
   /* Inside rp2040_dev_gpio_init() */
   
     for (i = 0; i < BOARD_NGPIOINT; i++)
       {
         /* Setup and register the GPIO pin */
   
         g_gpint[i].rp2040gpio.gpio.gp_pintype = GPIO_INTERRUPT_PIN;
         g_gpint[i].rp2040gpio.gpio.gp_ops     = &gpint_ops;
         g_gpint[i].rp2040gpio.id              = i;
         gpio_pin_register(&g_gpint[i].rp2040gpio.gpio, g_gpiointinputs[i]);
   
         /* Configure the pins that will be used as interrupt input */
   
         rp2040_gpio_init(g_gpiointinputs[i]);
   
         /* pull-up = false : pull-down = true */
   
         rp2040_gpio_set_pulls(g_gpiointinputs[i], false, true);
   
         pincount++;
       }
   ```
   
   I tested using the `gpio` example which uses `sigwait`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to