From ad98889d2b5cd81f39e5f2690472d243345b8902 Mon Sep 17 00:00:00 2001 From: Andrew Scheller Date: Tue, 18 Feb 2025 18:58:09 +0000 Subject: [PATCH] Add a define for the pin number to hello_gpio_irq.c (#612) ...which hopefully makes the code slightly more comprehensible --- gpio/hello_gpio_irq/hello_gpio_irq.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gpio/hello_gpio_irq/hello_gpio_irq.c b/gpio/hello_gpio_irq/hello_gpio_irq.c index 8620b835a..e26952679 100644 --- a/gpio/hello_gpio_irq/hello_gpio_irq.c +++ b/gpio/hello_gpio_irq/hello_gpio_irq.c @@ -8,6 +8,8 @@ #include "pico/stdlib.h" #include "hardware/gpio.h" +#define GPIO_WATCH_PIN 2 + static char event_str[128]; void gpio_event_string(char *buf, uint32_t events); @@ -23,8 +25,8 @@ int main() { stdio_init_all(); printf("Hello GPIO IRQ\n"); - gpio_init(2); - gpio_set_irq_enabled_with_callback(2, GPIO_IRQ_EDGE_RISE | GPIO_IRQ_EDGE_FALL, true, &gpio_callback); + gpio_init(GPIO_WATCH_PIN); + gpio_set_irq_enabled_with_callback(GPIO_WATCH_PIN, GPIO_IRQ_EDGE_RISE | GPIO_IRQ_EDGE_FALL, true, &gpio_callback); // Wait forever while (1); @@ -57,4 +59,4 @@ void gpio_event_string(char *buf, uint32_t events) { } } *buf++ = '\0'; -} \ No newline at end of file +}