rp2040 setting gpio interrupt on raise low-high, high-low

399 Views Asked by At

I want to setup level change interrupt on a gpio pin(GPIO2) solely through registers to understand innerworkings of the rp2040, but I have failed to do so. From what I understand I need to enable it in IO_BANK0 PROC0_INTE0, but I don't understand how to actually set a callback function for the interrupt.

I have tried navigating pico-sdk but it is a bit stretchy in a way it's written so I couldn't really make it work.

1

There are 1 best solutions below

4
On

To enable an interrupt and set its handler function, you could use irq_set_enabled and irq_set_exclusive_handler from the Pico SDK, as documented here:

https://www.raspberrypi.com/documentation/pico-sdk/hardware.html#hardware_irq

If you want to write to registers yourself then you should look at the source code of those functions to see how they work.