Skip to content

Commit

Permalink
Add a define for the pin number to hello_gpio_irq.c (#612)
Browse files Browse the repository at this point in the history
...which hopefully makes the code slightly more comprehensible
  • Loading branch information
lurch authored Feb 18, 2025
1 parent 7207593 commit ad98889
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions gpio/hello_gpio_irq/hello_gpio_irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -57,4 +59,4 @@ void gpio_event_string(char *buf, uint32_t events) {
}
}
*buf++ = '\0';
}
}

0 comments on commit ad98889

Please sign in to comment.