Datasheet

Table Of Contents
18 gpio_event_string(event_str, events);
19 printf("GPIO %d %s\n", gpio, event_str);
20 }
21
22 int main() {
23 stdio_init_all();
24
25 printf("Hello GPIO IRQ\n");
26 gpio_set_irq_enabled_with_callback(2, GPIO_IRQ_EDGE_RISE | GPIO_IRQ_EDGE_FALL, true,
Ê &gpio_callback);
27
28 // Wait forever
29 while (1);
30
31 return 0;
32 }
33
34
35 static const char *gpio_irq_str[] = {
36 "LEVEL_LOW", // 0x1
37 "LEVEL_HIGH", // 0x2
38 "EDGE_FALL", // 0x4
39 "EDGE_RISE" // 0x8
40 };
41
42 void gpio_event_string(char *buf, uint32_t events) {
43 for (uint i = 0; i < 4; i++) {
44 uint mask = (1 << i);
45 if (events & mask) {
46 // Copy this event string into the user string
47 const char *event_str = gpio_irq_str[i];
48 while (*event_str != '\0') {
49 *buf++ = *event_str++;
50 }
51 events &= ~mask;
52
53 // If more events add ", "
54 if (events) {
55 *buf++ = ',';
56 *buf++ = ' ';
57 }
58 }
59 }
60 *buf++ = '\0';
61 }
2.19.6. List of Registers
2.19.6.1. IO - User Bank
The User Bank IO registers start at a base address of 0x40014000 (defined as IO_BANK0_BASE in SDK).
Table 293. List of
IO_BANK0 registers
Offset Name Info
0x000 GPIO0_STATUS GPIO status
0x004 GPIO0_CTRL GPIO control including function select and overrides.
0x008 GPIO1_STATUS GPIO status
RP2040 Datasheet
2.19. GPIO 264