GPIO low to high and high to low

Hi,

I am configuring a button and an ISR to handle the events, but the interrupt is not  called  only when there is a  transition.

Is there any other configuration needed?

static void button_isr_callback(const struct device *port,
                                struct gpio_callback *cb, uint32_t pins) {
  // k_sem_give(&update);
  static int i = 0;
  printk("%d button_isr_callback pino=%d pin=%d \n", i++, pins,
         gpio_pin_get_raw(port, 14));
}


void config_buttons(gpio_callback_handler_t *pcbButton) {
  // #ifdef SW1_PORT
  const struct device *dev;
  int err;


  dev = device_get_binding(SW1_PORT);
  if (!dev) {
    printk("failed to get button device");
    return;
  }

  err = gpio_pin_configure(dev, SW1_PIN,
                           GPIO_INPUT  | SW1_FLAGS);

  gpio_init_callback(&button_callback, pcbButton, BIT(SW1_PIN));

  err = gpio_add_callback(dev, &button_callback);
  if (err) {
    printk("failed to add button callback");
    return;
  }


  err = gpio_pin_interrupt_configure(dev, SW1_PIN,   GPIO_INT_EDGE_BOTH);
  if (err) {
    printk("failed to enable button callback");
    return;
  }
  LOG_WRN("OK - Button cnfigured");

}

 

Thanks

Parents Reply Children
Related