Skip to content

Commit ad98889

Browse files
authored
Add a define for the pin number to hello_gpio_irq.c (#612)
...which hopefully makes the code slightly more comprehensible
1 parent 7207593 commit ad98889

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

gpio/hello_gpio_irq/hello_gpio_irq.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include "pico/stdlib.h"
99
#include "hardware/gpio.h"
1010

11+
#define GPIO_WATCH_PIN 2
12+
1113
static char event_str[128];
1214

1315
void gpio_event_string(char *buf, uint32_t events);
@@ -23,8 +25,8 @@ int main() {
2325
stdio_init_all();
2426

2527
printf("Hello GPIO IRQ\n");
26-
gpio_init(2);
27-
gpio_set_irq_enabled_with_callback(2, GPIO_IRQ_EDGE_RISE | GPIO_IRQ_EDGE_FALL, true, &gpio_callback);
28+
gpio_init(GPIO_WATCH_PIN);
29+
gpio_set_irq_enabled_with_callback(GPIO_WATCH_PIN, GPIO_IRQ_EDGE_RISE | GPIO_IRQ_EDGE_FALL, true, &gpio_callback);
2830

2931
// Wait forever
3032
while (1);
@@ -57,4 +59,4 @@ void gpio_event_string(char *buf, uint32_t events) {
5759
}
5860
}
5961
*buf++ = '\0';
60-
}
62+
}

0 commit comments

Comments
 (0)