-
-
Save Lncn/49174feb32c2d96dc4e82924b6163c8f to your computer and use it in GitHub Desktop.
Zephyr GPIO IRQ callback init sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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