Skip to content

Instantly share code, notes, and snippets.

@Lncn

Lncn/.c

Created Nov 13, 2018
Embed
What would you like to do?
Zephyr GPIO IRQ callback init sample
struct gpio_callback x_irq_cb;
struct device *x_irq;
void x_disable_irq(void)
{
gpio_pin_disable_callback(x_irq, CONFIG_x_IRQ_GPIO_PIN);
}
void x_enable_irq(void(*handler)(void))
{
gpio_pin_configure(x_irq, CONFIG_x_IRQ_GPIO_PIN, GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE | GPIO_INT_ACTIVE_HIGH);
gpio_init_callback(&x_irq_cb, x_irq_handler, BIT(CONFIG_x_IRQ_GPIO_PIN));
gpio_add_callback(x_irq, &x_irq_cb);
gpio_pin_enable_callback(x_irq, CONFIG_x_IRQ_GPIO_PIN);
}
void x_irq_handler(struct device *gpio, struct gpio_callback *cb, uint32_t pins)
{
/* Does something */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment